@Test public void testBuildGeometryFromInValidPolygonWithHoles() { String testfile = "invalid-polygon-2-inner-rings.wkt"; String expectedfile = "invalid-polygon-2-inner-rings-repaired.wkt"; List<TDWay> ways = MockingUtils.wktPolygonToWays(testfile); Geometry geometry = JTSUtils.toJtsGeometry(ways.get(0), ways.subList(1, ways.size())); Assert.isTrue(geometry instanceof Polygon); Assert.isTrue(geometry.isValid()); Geometry expected = MockingUtils.readWKTFile(expectedfile); Assert.equals(expected, geometry); }
public static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays) { if (way == null) { LOGGER.warning("way is null"); return null; } if (way.isForcePolygonLine()) { return buildMultiLineString(way, innerWays); } if (way.getShape() != TDWay.LINE || innerWays != null && innerWays.size() > 0) { Polygon polygon = buildPolygon(way, innerWays); if (polygon.isValid()) { return polygon; } return repairInvalidPolygon(polygon); } return buildLineString(way); }
JTSUtils { public static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays) { if (way == null) { LOGGER.warning("way is null"); return null; } if (way.isForcePolygonLine()) { return buildMultiLineString(way, innerWays); } if (way.getShape() != TDWay.LINE || innerWays != null && innerWays.size() > 0) { Polygon polygon = buildPolygon(way, innerWays); if (polygon.isValid()) { return polygon; } return repairInvalidPolygon(polygon); } return buildLineString(way); } }
JTSUtils { public static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays) { if (way == null) { LOGGER.warning("way is null"); return null; } if (way.isForcePolygonLine()) { return buildMultiLineString(way, innerWays); } if (way.getShape() != TDWay.LINE || innerWays != null && innerWays.size() > 0) { Polygon polygon = buildPolygon(way, innerWays); if (polygon.isValid()) { return polygon; } return repairInvalidPolygon(polygon); } return buildLineString(way); } private  JTSUtils(); }
JTSUtils { public static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays) { if (way == null) { LOGGER.warning("way is null"); return null; } if (way.isForcePolygonLine()) { return buildMultiLineString(way, innerWays); } if (way.getShape() != TDWay.LINE || innerWays != null && innerWays.size() > 0) { Polygon polygon = buildPolygon(way, innerWays); if (polygon.isValid()) { return polygon; } return repairInvalidPolygon(polygon); } return buildLineString(way); } private  JTSUtils(); static Coordinate toCoordinate(TDNode node); static Coordinate[] toCoordinates(TDWay way); static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays); }
JTSUtils { public static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays) { if (way == null) { LOGGER.warning("way is null"); return null; } if (way.isForcePolygonLine()) { return buildMultiLineString(way, innerWays); } if (way.getShape() != TDWay.LINE || innerWays != null && innerWays.size() > 0) { Polygon polygon = buildPolygon(way, innerWays); if (polygon.isValid()) { return polygon; } return repairInvalidPolygon(polygon); } return buildLineString(way); } private  JTSUtils(); static Coordinate toCoordinate(TDNode node); static Coordinate[] toCoordinates(TDWay way); static Geometry toJtsGeometry(TDWay way, List<TDWay> innerWays);  }