GeometryUtils { public static Geometry createGeometry(String geometryWkt) { Geometry geometry = parseWKT(geometryWkt); if (geometry != null && !isGlobalCoverageGeometry(geometry)) { int unwrapDateline = DateLineOps.unwrapDateline(geometry, -180, 180); if (unwrapDateline > 0) { geometry = DateLineOps.pageGeom(geometry, -180, 180); } } return geometry; }  static Geometry createGeometry(String geometryWkt); static boolean isGlobalCoverageGeometry(Geometry geometry); static Geometry parseWKT(String geometryWkt);  }
@Test public void testDateLineUnwrapping() throws Exception { String fiji = "POLYGON ((179.7 -15.9, 178.4 -16.4, 177.4 -16.6, 177.4 -16.8, 177.5 -17.1, 178.8 -17.1, -179.8 -16.5, 179.7 -15.9, 179.7 -15.9))"; Geometry geometry = GeometryUtils.createGeometry(fiji); assertNotNull(geometry); String fijiUnWrapped = "MULTIPOLYGON (((180 -16.260000000000012, 180 -16.585714285714282, 178.8 -17.1, 177.5 -17.1, 177.4 -16.8, 177.4 -16.6, 178.4 -16.4, 179.7 -15.9, 180 -16.260000000000012)), ((-180 -16.585714285714282, -180 -16.260000000000012, -179.8 -16.5, -180 -16.585714285714282)))"; assertEquals(fijiUnWrapped, geometry.toText()); }