org.locationtech.jts.geom.GeometryFactory factory = convertFactory(geometry.getFactory()); return factory.createPoint(convertCoordinate(geometry.getCoordinate())); case LINE_STRING: return factory.createLineString(convertCoordinates(geometry.getCoordinates())); case POLYGON: { com.vividsolutions.jts.geom.Polygon p = (com.vividsolutions.jts.geom.Polygon) geometry; org.locationtech.jts.geom.LinearRing[] holes = new org.locationtech.jts.geom.LinearRing[n]; for (int i = 0; i < n; ++i) { holes[i] = createLinearRing(factory, p.getInteriorRingN(i)); return factory.createPolygon(createLinearRing(factory, p.getExteriorRing()), holes); List<org.locationtech.jts.geom.Geometry> array = new ArrayList<>(n); for (int i = 0; i < n; ++i) { array.add(convert(geometry.getGeometryN(i)));
/** * Convert the supplied {@code Coordinate} array. * * @param coordinates the coordinates * * @return the converted coordinates */ private org.locationtech.jts.geom.Coordinate[] convertCoordinates( com.vividsolutions.jts.geom.Coordinate[] coordinates) { int n = coordinates.length; org.locationtech.jts.geom.Coordinate[] array = new org.locationtech.jts.geom.Coordinate[n]; for (int i = 0; i < n; ++i) { array[i] = convertCoordinate(coordinates[i]); } return array; }
/** * Convert the supplied {@code LineString} to a {@code LinearRing}. * * @param factory the geometry factory * @param geometry the line string * * @return the linear ring */ private org.locationtech.jts.geom.LinearRing createLinearRing( org.locationtech.jts.geom.GeometryFactory factory, com.vividsolutions.jts.geom.LineString geometry) { return factory.createLinearRing(convertCoordinates(geometry.getCoordinates())); } }
/** * Convert the supplied {@code GeometryFactory}. * * @param factory the factory * * @return the converted factory */ private org.locationtech.jts.geom.GeometryFactory convertFactory( com.vividsolutions.jts.geom.GeometryFactory factory) { return new org.locationtech.jts.geom.GeometryFactory( convertPrecisionModel(factory.getPrecisionModel()), factory.getSRID()); }
/** * Convert from old-style VividSolutions Envelops to new-style LocationTech Envelopes. * * @param envelope the envelope * * @return the converted envelope */ public static org.locationtech.jts.geom.Envelope convert(com.vividsolutions.jts.geom.Envelope envelope) { return VS2LT_CONVERTER.convert(envelope); }
/** * Convert from old-style VividSolutions Geometry to new-style LocationTech Geometry. * * @param geometry the geometry * * @return the converted geometry */ public static org.locationtech.jts.geom.Geometry convert(com.vividsolutions.jts.geom.Geometry geometry) { return VS2LT_CONVERTER.convert(geometry); }