GeometryReverse { public static final Geometry check(Geometry geometry, String srsURI) { Boolean isAxisXY = SRSRegistry.getAxisXY(srsURI); return check(geometry, isAxisXY); }  static final Geometry check(Geometry geometry, String srsURI); static final Geometry check(Geometry geometry, SRSInfo srsInfo); static final Geometry check(Geometry geometry, Boolean isAxisXY); static Geometry reverseGeometry(Geometry geometry);  }
@Test public void testCheckPoint() throws FactoryException { WKTReader reader = new WKTReader(); try { Point geometry = (Point) reader.read("POINT(2 0)"); String srsURI = "http: Geometry expResult = reader.read("POINT(0 2)"); Geometry result = GeometryReverse.check(geometry, srsURI); assertEquals(expResult, result); } catch (ParseException ex) { System.err.println("ParseException: " + ex.getMessage()); } }
@Test public void testCheckLineString() throws FactoryException { WKTReader reader = new WKTReader(); try { LineString geometry = (LineString) reader.read("LINESTRING(0 0, 2 0, 5 0)"); String srsURI = "http: Geometry expResult = reader.read("LINESTRING(0 0, 0 2, 0 5)"); Geometry result = GeometryReverse.check(geometry, srsURI); assertEquals(expResult, result); } catch (ParseException ex) { System.err.println("ParseException: " + ex.getMessage()); } }
@Test public void testCheckPolygon() throws FactoryException { WKTReader reader = new WKTReader(); try { Polygon geometry = (Polygon) reader.read("POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))"); String srsURI = "http: Geometry expResult = reader.read("POLYGON ((10 30, 40 40, 40 20, 20 10, 10 30))"); Geometry result = GeometryReverse.check(geometry, srsURI); assertEquals(expResult, result); } catch (ParseException ex) { System.err.println("ParseException: " + ex.getMessage()); } }
@Test public void testCheckPolygonHoled() throws FactoryException { WKTReader reader = new WKTReader(); try { Polygon geometry = (Polygon) reader.read("POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))"); String srsURI = "http: Geometry expResult = reader.read("POLYGON ((10 35, 45 45, 40 15, 20 10, 10 35),(30 20, 35 35, 20 30, 30 20))"); Geometry result = GeometryReverse.check(geometry, srsURI); assertEquals(expResult, result); } catch (ParseException ex) { System.err.println("ParseException: " + ex.getMessage()); } }
@Test public void testCheckMultiPoint() throws FactoryException { WKTReader reader = new WKTReader(); try { MultiPoint geometry = (MultiPoint) reader.read("MULTIPOINT (10 40, 40 30, 20 20, 30 10)"); String srsURI = "http: Geometry expResult = reader.read("MULTIPOINT (40 10, 30 40, 20 20, 10 30)"); Geometry result = GeometryReverse.check(geometry, srsURI); assertEquals(expResult, result); } catch (ParseException ex) { System.err.println("ParseException: " + ex.getMessage()); } }
@Test public void testCheckMultiPolygon() throws FactoryException { WKTReader reader = new WKTReader(); try { MultiPolygon geometry = (MultiPolygon) reader.read("MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)),((15 5, 40 10, 10 20, 5 10, 15 5)))"); String srsURI = "http: Geometry expResult = reader.read("MULTIPOLYGON (((20 30, 40 45, 40 10, 20 30)),((5 15, 10 40, 20 10, 10 5, 5 15)))"); Geometry result = GeometryReverse.check(geometry, srsURI); assertEquals(expResult, result); } catch (ParseException ex) { System.err.println("ParseException: " + ex.getMessage()); } }
@Test public void testCheckMultiLineString() throws FactoryException { WKTReader reader = new WKTReader(); try { MultiLineString geometry = (MultiLineString) reader.read("MULTILINESTRING ((10 10, 20 30, 10 40),(40 45, 30 35, 40 20, 30 10))"); String srsURI = "http: Geometry expResult = reader.read("MULTILINESTRING ((10 10, 30 20, 40 10),(45 40, 35 30, 20 40, 10 30))"); Geometry result = GeometryReverse.check(geometry, srsURI); assertEquals(expResult, result); } catch (ParseException ex) { System.err.println("ParseException: " + ex.getMessage()); } }
@Test public void testCheckLineStringNotReversed() { WKTReader reader = new WKTReader(); try { LineString geometry = (LineString) reader.read("LINESTRING(0 0, 2 0, 5 0)"); String srsURI = SRS_URI.DEFAULT_WKT_CRS84; Geometry expResult = reader.read("LINESTRING(0 0, 2 0, 5 0)"); Geometry result = GeometryReverse.check(geometry, srsURI); assertEquals(expResult, result); } catch (ParseException ex) { System.err.println("ParseException: " + ex.getMessage()); } }
@Test public void testCheckMultiPolygonHoled() throws FactoryException { WKTReader reader = new WKTReader(); try { MultiPolygon geometry = (MultiPolygon) reader.read("MULTIPOLYGON (((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30)),((15 5, 40 10, 10 20, 5 10, 15 5)))"); String srsURI = "http: Geometry expResult = reader.read("MULTIPOLYGON (((10 35, 45 45, 40 15, 20 10, 10 35),(30 20, 35 35, 20 30, 30 20)),((5 15, 10 40, 20 10, 10 5, 5 15)))"); Geometry result = GeometryReverse.check(geometry, srsURI); assertEquals(expResult, result); } catch (ParseException ex) { System.err.println("ParseException: " + ex.getMessage()); } }