public static Geometry toJtsGeometry ( TDWay way , List < TDWay > innerWays ) { if ( way == null ) { LOGGER . warning ( "way is null" ) ; return null ; } if ( way . isForcePolygonLine ( ) ) { // may build a single line string if inner ways are empty return buildMultiLineString ( way , innerWays ) ; } if ( way . getShape ( ) != TDWay . LINE || innerWays != null && innerWays . size ( ) > 0 ) { // Have to be careful here about polygons and lines again, the problem with // polygons is that a certain direction is forced, so we do not want to reverse // closed lines that are not meant to be polygons // may contain holes if inner ways are not empty Polygon polygon = buildPolygon ( way , innerWays ) ; if ( polygon . isValid ( ) ) { return polygon ; } return repairInvalidPolygon ( polygon ) ; } // not a closed line return buildLineString ( way ) ; }
Converts a way with potential inner ways to a JTS geometry .