sa.axform = atTransform; if (projectionHandler != null) { sa.rxform = projectionHandler.getRenderingTransform(sa.crsxform); } else { sa.rxform = sa.crsxform;
@Test public void testWrapGeometryLatLonMultipleTimes() throws Exception { ReferencedEnvelope renderingEnvelope = new ReferencedEnvelope(-90, 90, -580, 540, ED50_LATLON); // a geometry close to the dateline Geometry g = new WKTReader().read("POLYGON((-74 -33, -29 -33, -29 5, -74 5, -74 -33))"); // make sure the geometry is not wrapped, but it is preserved ProjectionHandler handler = ProjectionHandlerFinder.getHandler(renderingEnvelope, WGS84, true); assertTrue(handler.requiresProcessing(g)); Geometry preProcessed = handler.preProcess(g); MathTransform mt = handler.getRenderingTransform(CRS.findMathTransform(WGS84, ED50_LATLON)); Geometry transformed = JTS.transform(preProcessed, mt); // post process (provide identity transform to force wrap heuristic) Geometry postProcessed = handler.postProcess(mt, transformed); assertTrue(postProcessed.isValid()); // should have been replicated three times assertEquals(3, postProcessed.getNumGeometries()); }
@Test public void testWrapGeometryReprojectToED50() throws Exception { ReferencedEnvelope world = new ReferencedEnvelope(-80, 80, -180, 180, ED50); ProjectionHandler handler = ProjectionHandlerFinder.getHandler(world, WGS84, true); // a geometry that will cross the dateline and sitting in the same area as the // rendering envelope (with wgs84 lon/latcoordinates) String wkt = "POLYGON((178 -80, 178 80, 182 80, 182 80, 178 -80))"; Geometry g = new WKTReader().read(wkt); Geometry original = new WKTReader().read(wkt); MathTransform mt = CRS.findMathTransform(WGS84, ED50); mt = handler.getRenderingTransform(mt); Geometry reprojected = JTS.transform(original, mt); // make sure the geometry is not wrapped, but it is preserved assertTrue(handler.requiresProcessing(g)); Geometry preProcessed = handler.preProcess(g); // no cutting expected assertEquals(original, preProcessed); // post process, this should wrap the geometry and clone it Geometry postProcessed = handler.postProcess(mt, reprojected); assertTrue(postProcessed instanceof MultiPolygon); }
@Test public void testWrapAnctartica() throws Exception { ReferencedEnvelope world = new ReferencedEnvelope(-80, 80, -180, 180, ED50_LATLON); // make sure the geometry is not wrapped, but it is preserved ProjectionHandler handler = ProjectionHandlerFinder.getHandler(world, WGS84, true); // a geometry that will cross the dateline and sitting in the same area as the // rendering envelope (with wgs84 lon/latcoordinates) String wkt = "POLYGON((180 -90, 180 90, -180 90, -180 -90, 180 -90))"; Geometry g = new WKTReader().read(wkt); MathTransform mt = CRS.findMathTransform(WGS84, ED50_LATLON); MathTransform prepared = handler.getRenderingTransform(mt); assertTrue(handler.requiresProcessing(g)); Geometry preProcessed = handler.preProcess(g); Geometry reprojected = JTS.transform(preProcessed, prepared); assertTrue(reprojected.isValid()); reprojected.apply( new CoordinateFilter() { @Override public void filter(Coordinate coord) { assertEquals(90.0, Math.abs(coord.getOrdinate(0)), 0.1); assertEquals(180.0, Math.abs(coord.getOrdinate(1)), 5); } }); // post process, this should wrap the geometry, make sure it's valid, and avoid large jumps // in its border Geometry postProcessed = handler.postProcess(prepared, reprojected); assertThat(postProcessed, CoreMatchers.instanceOf(MultiPolygon.class)); assertEquals(2, postProcessed.getNumGeometries()); }
@Test public void testWrapGeometryReprojectToLatLonED50() throws Exception { ReferencedEnvelope world = new ReferencedEnvelope(-80, 80, -180, 180, ED50_LATLON); // make sure the geometry is not wrapped, but it is preserved ProjectionHandler handler = ProjectionHandlerFinder.getHandler(world, WGS84, true); // a geometry that will cross the dateline and sitting in the same area as the // rendering envelope (with wgs84 lon/latcoordinates) String wkt = "POLYGON((178 -80, 178 80, 182 80, 182 80, 178 -80))"; Geometry g = new WKTReader().read(wkt); Geometry original = new WKTReader().read(wkt); MathTransform mt = CRS.findMathTransform(WGS84, ED50_LATLON); MathTransform prepared = handler.getRenderingTransform(CRS.findMathTransform(WGS84, ED50_LATLON)); Geometry reprojected = JTS.transform(original, prepared); assertTrue(handler.requiresProcessing(g)); Geometry preProcessed = handler.preProcess(g); // no cutting expected assertEquals(original, preProcessed); // post process, this should wrap the geometry and clone it Geometry postProcessed = handler.postProcess(prepared, reprojected); assertTrue(postProcessed instanceof MultiPolygon); }