@Test public void testDensification() throws Exception { CoordinateReferenceSystem utm32n = CRS.decode("EPSG:32632", true); ReferencedEnvelope wgs84Envelope = new ReferencedEnvelope(-190, 60, -90, 45, WGS84); ProjectionHandler handler = ProjectionHandlerFinder.getHandler(wgs84Envelope, WGS84, true); Geometry line = gf.createLineString( new Coordinate[] {new Coordinate(40, 45), new Coordinate(40, 88)}); LineString notDensified = (LineString) handler.preProcess(line); assertEquals(2, notDensified.getCoordinates().length); Map params = new HashMap(); params.put(ProjectionHandler.ADVANCED_PROJECTION_DENSIFY, 1.0); handler = ProjectionHandlerFinder.getHandler(wgs84Envelope, WGS84, true, params); LineString densified = (LineString) handler.preProcess(line); assertEquals(45, densified.getCoordinates().length); }
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; }