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);
    }
@Test
    public void testBuildGeometryFromInValidPolygon() {
        // Some of these tests do not really make sense, as not everything that is a closed line
        // should be a polygon in OSM.
        String testfile = "invalid-polygon.wkt";
        // String expectedfile = "invalid-polygon-repaired.wkt";

        List<TDWay> ways = MockingUtils.wktPolygonToWays(testfile);
        Geometry geometry = JTSUtils.toJtsGeometry(ways.get(0), ways.subList(1, ways.size()));
        Assert.isTrue(geometry instanceof LineString);
        Assert.isTrue(geometry.isValid());
    }