@Test public void testCutGeometryTouchingValidArea() throws Exception { String wkb = "AAAAAAMAAAACAAAAJsBX4dme0ZBrwBBHY3zBphTAV9wm/XQjVMAN5aZ25n+AwFfRnB4QLcDACkbY\n" + "u6mfgMBX0IDk68FEwAn9i4xuQADAV9LyxRH1/MAKtRmwO4KAwFfFCYjFNfzABzwNbZWeAMBXro+u\n" + "Q3TIwAMozHt2zADAV5nQ8kYDGMAABfJy8QWAwFdz2+lf1Xy/9dkUVMuzAMBXK24mVt9kv9u1veRJ\n" + "CADAVxApDvwLFD0wAAAAAAAAwFlKt6hdgbi+jC+LAAAAAMBZS9W86QecwAP6Pg0jSwDAWOUBPzQM\n" + "OMAD1MCXZ+6AwFiD2a7LN6jABO4o20CCgMBYcM4alj+AwAVxI3rh+4DAWGFB3LdZJMAGMd3VXb+A\n" + "wFhJc+py+vDACDw/gWQHAMBYO+vyzRGUwAnbp1i4wgDAWDEaWTENgMALgYeOOnuAwFgpGBGENtjA\n" + "DRepG9PXAMBYIP4dLlt8wA+klG+5IADAWBwX+BP4WMARKUKeEtiAwFgXoZhXNYDAExH5Zal0QMBY\n" + "GEP/ANogwBbbF0xESIDAWBN/U/McQMAYXuP5jyKAwFgKqiyQ+gTAGix578FUgMBYA1s+gKpwwBsT\n" + "o7wYhYDAV/qZDD5aYMAbwu+JuyoAwFfqj6KbhxTAHIrvGplNAMBX4hOw7Jx0wBy+1+x/XkDAV9vV\n" + "ZESR7MAca5H4ZYHAwFfWkK/y7sDAG3TJ1EFXgMBX1+eqod08wBrqABEuC8DAV+jS2XIy3MAYBQgf\n" + "RHnAwFfslYpsZkDAFphJ8XbhQMBX6mVp0arUwBOSV/ye1QDAV+HZntGQa8AQR2N8waYUAAAABMBX\n" + "4dme0ZBrwBBHY3zBphTAV+GPbx9YxMAQMbM4fB1AwFfivDEmxxzAEIAAI+c6wMBX4dme0ZBrwBBH\n" + "Y3zBphQ="; Geometry geometry = new WKBReader().read(Base64.decode(wkb)); CoordinateReferenceSystem lambertPolar = getLambertPolar(); ReferencedEnvelope renderingEnvelope = new ReferencedEnvelope( -14542204.652543461, 15480411.404320458, -18705497.11355389, 11278026.995319324, lambertPolar); ReferencedEnvelope validAreaBounds = new ReferencedEnvelope(-180, 180, 0, 90, DefaultGeographicCRS.WGS84); ProjectionHandler ph = new ProjectionHandler( DefaultGeographicCRS.WGS84, validAreaBounds, renderingEnvelope); assertNull(ph.preProcess(geometry)); }
public Geometry preProcess(Geometry geometry) throws TransformException, FactoryException { if (validAreaBounds == null) return densify(geometry); if (noReprojection) { return densify(geometry); } Geometry mask; ReferencedEnvelope ge = new ReferencedEnvelope(geometry.getEnvelopeInternal(), geometryCRS); ReferencedEnvelope geWGS84 = ge.transform(WGS84, true); geWGS84.expandBy(EPS); if (validArea == null) { if (validAreaBounds.contains((Envelope) geWGS84)) { return densify(geometry); } ReferencedEnvelope envIntWgs84 = new ReferencedEnvelope(validAreaBounds.intersection(geWGS84), WGS84); if (envIntWgs84.getHeight() <= 0 || envIntWgs84.getWidth() <= 0) { if (validAreaBounds.contains( 180, (validAreaBounds.getMinY() + validAreaBounds.getMaxY()) / 2)) { ReferencedEnvelope translated = new ReferencedEnvelope(validAreaBounds); translated.translate(-360, 0); if (translated.contains((Envelope) geWGS84)) { return densify(geometry); } envIntWgs84 = translated.intersection(geWGS84); } else if (validAreaBounds.contains( -180, (validAreaBounds.getMinY() + validAreaBounds.getMaxY()) / 2)) { ReferencedEnvelope translated = new ReferencedEnvelope(validAreaBounds); translated.translate(360, 0); if (translated.contains((Envelope) geWGS84)) { return densify(geometry); } envIntWgs84 = translated.intersection(geWGS84); } if (envIntWgs84.getHeight() <= 0 || envIntWgs84.getWidth() <= 0) { return null; } } ReferencedEnvelope envInt = envIntWgs84.transform(geometryCRS, true); mask = JTS.toGeometry((Envelope) envInt); } else { if (validaAreaTester.contains(JTS.toGeometry(geWGS84))) { return densify(geometry); } ReferencedEnvelope envIntWgs84 = new ReferencedEnvelope(validAreaBounds.intersection(geWGS84), WGS84); if (envIntWgs84.isEmpty()) { return null; } Polygon polyIntWgs84 = JTS.toGeometry(envIntWgs84); Geometry maskWgs84 = intersect(validArea, polyIntWgs84, geometryCRS); if (maskWgs84 == null || maskWgs84.isEmpty()) { return null; } mask = JTS.transform(maskWgs84, CRS.findMathTransform(WGS84, geometryCRS)); } return densify(intersect(geometry, mask, geometryCRS)); }
ProjectionHandler { public Geometry preProcess(Geometry geometry) throws TransformException, FactoryException { if (validAreaBounds == null) return densify(geometry); if (noReprojection) { return densify(geometry); } Geometry mask; ReferencedEnvelope ge = new ReferencedEnvelope(geometry.getEnvelopeInternal(), geometryCRS); ReferencedEnvelope geWGS84 = ge.transform(WGS84, true); geWGS84.expandBy(EPS); if (validArea == null) { if (validAreaBounds.contains((Envelope) geWGS84)) { return densify(geometry); } ReferencedEnvelope envIntWgs84 = new ReferencedEnvelope(validAreaBounds.intersection(geWGS84), WGS84); if (envIntWgs84.getHeight() <= 0 || envIntWgs84.getWidth() <= 0) { if (validAreaBounds.contains( 180, (validAreaBounds.getMinY() + validAreaBounds.getMaxY()) / 2)) { ReferencedEnvelope translated = new ReferencedEnvelope(validAreaBounds); translated.translate(-360, 0); if (translated.contains((Envelope) geWGS84)) { return densify(geometry); } envIntWgs84 = translated.intersection(geWGS84); } else if (validAreaBounds.contains( -180, (validAreaBounds.getMinY() + validAreaBounds.getMaxY()) / 2)) { ReferencedEnvelope translated = new ReferencedEnvelope(validAreaBounds); translated.translate(360, 0); if (translated.contains((Envelope) geWGS84)) { return densify(geometry); } envIntWgs84 = translated.intersection(geWGS84); } if (envIntWgs84.getHeight() <= 0 || envIntWgs84.getWidth() <= 0) { return null; } } ReferencedEnvelope envInt = envIntWgs84.transform(geometryCRS, true); mask = JTS.toGeometry((Envelope) envInt); } else { if (validaAreaTester.contains(JTS.toGeometry(geWGS84))) { return densify(geometry); } ReferencedEnvelope envIntWgs84 = new ReferencedEnvelope(validAreaBounds.intersection(geWGS84), WGS84); if (envIntWgs84.isEmpty()) { return null; } Polygon polyIntWgs84 = JTS.toGeometry(envIntWgs84); Geometry maskWgs84 = intersect(validArea, polyIntWgs84, geometryCRS); if (maskWgs84 == null || maskWgs84.isEmpty()) { return null; } mask = JTS.transform(maskWgs84, CRS.findMathTransform(WGS84, geometryCRS)); } return densify(intersect(geometry, mask, geometryCRS)); } }
ProjectionHandler { public Geometry preProcess(Geometry geometry) throws TransformException, FactoryException { if (validAreaBounds == null) return densify(geometry); if (noReprojection) { return densify(geometry); } Geometry mask; ReferencedEnvelope ge = new ReferencedEnvelope(geometry.getEnvelopeInternal(), geometryCRS); ReferencedEnvelope geWGS84 = ge.transform(WGS84, true); geWGS84.expandBy(EPS); if (validArea == null) { if (validAreaBounds.contains((Envelope) geWGS84)) { return densify(geometry); } ReferencedEnvelope envIntWgs84 = new ReferencedEnvelope(validAreaBounds.intersection(geWGS84), WGS84); if (envIntWgs84.getHeight() <= 0 || envIntWgs84.getWidth() <= 0) { if (validAreaBounds.contains( 180, (validAreaBounds.getMinY() + validAreaBounds.getMaxY()) / 2)) { ReferencedEnvelope translated = new ReferencedEnvelope(validAreaBounds); translated.translate(-360, 0); if (translated.contains((Envelope) geWGS84)) { return densify(geometry); } envIntWgs84 = translated.intersection(geWGS84); } else if (validAreaBounds.contains( -180, (validAreaBounds.getMinY() + validAreaBounds.getMaxY()) / 2)) { ReferencedEnvelope translated = new ReferencedEnvelope(validAreaBounds); translated.translate(360, 0); if (translated.contains((Envelope) geWGS84)) { return densify(geometry); } envIntWgs84 = translated.intersection(geWGS84); } if (envIntWgs84.getHeight() <= 0 || envIntWgs84.getWidth() <= 0) { return null; } } ReferencedEnvelope envInt = envIntWgs84.transform(geometryCRS, true); mask = JTS.toGeometry((Envelope) envInt); } else { if (validaAreaTester.contains(JTS.toGeometry(geWGS84))) { return densify(geometry); } ReferencedEnvelope envIntWgs84 = new ReferencedEnvelope(validAreaBounds.intersection(geWGS84), WGS84); if (envIntWgs84.isEmpty()) { return null; } Polygon polyIntWgs84 = JTS.toGeometry(envIntWgs84); Geometry maskWgs84 = intersect(validArea, polyIntWgs84, geometryCRS); if (maskWgs84 == null || maskWgs84.isEmpty()) { return null; } mask = JTS.transform(maskWgs84, CRS.findMathTransform(WGS84, geometryCRS)); } return densify(intersect(geometry, mask, geometryCRS)); } ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Envelope validAreaBounds,
            ReferencedEnvelope renderingEnvelope);  ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Geometry validArea,
            ReferencedEnvelope renderingEnvelope); }
ProjectionHandler { public Geometry preProcess(Geometry geometry) throws TransformException, FactoryException { if (validAreaBounds == null) return densify(geometry); if (noReprojection) { return densify(geometry); } Geometry mask; ReferencedEnvelope ge = new ReferencedEnvelope(geometry.getEnvelopeInternal(), geometryCRS); ReferencedEnvelope geWGS84 = ge.transform(WGS84, true); geWGS84.expandBy(EPS); if (validArea == null) { if (validAreaBounds.contains((Envelope) geWGS84)) { return densify(geometry); } ReferencedEnvelope envIntWgs84 = new ReferencedEnvelope(validAreaBounds.intersection(geWGS84), WGS84); if (envIntWgs84.getHeight() <= 0 || envIntWgs84.getWidth() <= 0) { if (validAreaBounds.contains( 180, (validAreaBounds.getMinY() + validAreaBounds.getMaxY()) / 2)) { ReferencedEnvelope translated = new ReferencedEnvelope(validAreaBounds); translated.translate(-360, 0); if (translated.contains((Envelope) geWGS84)) { return densify(geometry); } envIntWgs84 = translated.intersection(geWGS84); } else if (validAreaBounds.contains( -180, (validAreaBounds.getMinY() + validAreaBounds.getMaxY()) / 2)) { ReferencedEnvelope translated = new ReferencedEnvelope(validAreaBounds); translated.translate(360, 0); if (translated.contains((Envelope) geWGS84)) { return densify(geometry); } envIntWgs84 = translated.intersection(geWGS84); } if (envIntWgs84.getHeight() <= 0 || envIntWgs84.getWidth() <= 0) { return null; } } ReferencedEnvelope envInt = envIntWgs84.transform(geometryCRS, true); mask = JTS.toGeometry((Envelope) envInt); } else { if (validaAreaTester.contains(JTS.toGeometry(geWGS84))) { return densify(geometry); } ReferencedEnvelope envIntWgs84 = new ReferencedEnvelope(validAreaBounds.intersection(geWGS84), WGS84); if (envIntWgs84.isEmpty()) { return null; } Polygon polyIntWgs84 = JTS.toGeometry(envIntWgs84); Geometry maskWgs84 = intersect(validArea, polyIntWgs84, geometryCRS); if (maskWgs84 == null || maskWgs84.isEmpty()) { return null; } mask = JTS.transform(maskWgs84, CRS.findMathTransform(WGS84, geometryCRS)); } return densify(intersect(geometry, mask, geometryCRS)); } ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Envelope validAreaBounds,
            ReferencedEnvelope renderingEnvelope);  ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Geometry validArea,
            ReferencedEnvelope renderingEnvelope); void setProjectionParameters(Map projectionParameters); ReferencedEnvelope getRenderingEnvelope(); CoordinateReferenceSystem getSourceCRS(); List<ReferencedEnvelope> getQueryEnvelopes(); ReferencedEnvelope getProjectedEnvelope(
            ReferencedEnvelope envelope, CoordinateReferenceSystem targetCRS); boolean requiresProcessing(Geometry geometry); Geometry preProcess(Geometry geometry); MathTransform getRenderingTransform(MathTransform mt); Geometry postProcess(MathTransform mt, Geometry geometry); ReferencedEnvelope getValidAreaBounds(); }
ProjectionHandler { public Geometry preProcess(Geometry geometry) throws TransformException, FactoryException { if (validAreaBounds == null) return densify(geometry); if (noReprojection) { return densify(geometry); } Geometry mask; ReferencedEnvelope ge = new ReferencedEnvelope(geometry.getEnvelopeInternal(), geometryCRS); ReferencedEnvelope geWGS84 = ge.transform(WGS84, true); geWGS84.expandBy(EPS); if (validArea == null) { if (validAreaBounds.contains((Envelope) geWGS84)) { return densify(geometry); } ReferencedEnvelope envIntWgs84 = new ReferencedEnvelope(validAreaBounds.intersection(geWGS84), WGS84); if (envIntWgs84.getHeight() <= 0 || envIntWgs84.getWidth() <= 0) { if (validAreaBounds.contains( 180, (validAreaBounds.getMinY() + validAreaBounds.getMaxY()) / 2)) { ReferencedEnvelope translated = new ReferencedEnvelope(validAreaBounds); translated.translate(-360, 0); if (translated.contains((Envelope) geWGS84)) { return densify(geometry); } envIntWgs84 = translated.intersection(geWGS84); } else if (validAreaBounds.contains( -180, (validAreaBounds.getMinY() + validAreaBounds.getMaxY()) / 2)) { ReferencedEnvelope translated = new ReferencedEnvelope(validAreaBounds); translated.translate(360, 0); if (translated.contains((Envelope) geWGS84)) { return densify(geometry); } envIntWgs84 = translated.intersection(geWGS84); } if (envIntWgs84.getHeight() <= 0 || envIntWgs84.getWidth() <= 0) { return null; } } ReferencedEnvelope envInt = envIntWgs84.transform(geometryCRS, true); mask = JTS.toGeometry((Envelope) envInt); } else { if (validaAreaTester.contains(JTS.toGeometry(geWGS84))) { return densify(geometry); } ReferencedEnvelope envIntWgs84 = new ReferencedEnvelope(validAreaBounds.intersection(geWGS84), WGS84); if (envIntWgs84.isEmpty()) { return null; } Polygon polyIntWgs84 = JTS.toGeometry(envIntWgs84); Geometry maskWgs84 = intersect(validArea, polyIntWgs84, geometryCRS); if (maskWgs84 == null || maskWgs84.isEmpty()) { return null; } mask = JTS.transform(maskWgs84, CRS.findMathTransform(WGS84, geometryCRS)); } return densify(intersect(geometry, mask, geometryCRS)); } ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Envelope validAreaBounds,
            ReferencedEnvelope renderingEnvelope);  ProjectionHandler(
            CoordinateReferenceSystem sourceCRS,
            Geometry validArea,
            ReferencedEnvelope renderingEnvelope); void setProjectionParameters(Map projectionParameters); ReferencedEnvelope getRenderingEnvelope(); CoordinateReferenceSystem getSourceCRS(); List<ReferencedEnvelope> getQueryEnvelopes(); ReferencedEnvelope getProjectedEnvelope(
            ReferencedEnvelope envelope, CoordinateReferenceSystem targetCRS); boolean requiresProcessing(Geometry geometry); Geometry preProcess(Geometry geometry); MathTransform getRenderingTransform(MathTransform mt); Geometry postProcess(MathTransform mt, Geometry geometry); ReferencedEnvelope getValidAreaBounds(); static final String ADVANCED_PROJECTION_DENSIFY; }