Package org.n52.shetland.util
Class JTSHelper
java.lang.Object
org.n52.shetland.util.JTSHelper
Utility class for the Java Topology Suite.
- Since:
- 1.0.0
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.locationtech.jts.geom.EnvelopecreateEnvelopeFromLowerUpperCorner(String lowerCorner, String upperCorner) static org.locationtech.jts.geom.GeometrycreateGeometryFromWKT(String wkt, int srid) Creates a JTS Geometry from an WKT representation.static org.locationtech.jts.geom.GeometrycreatePolygonFromEnvelope(double[] envelope, int srid) static org.locationtech.jts.geom.GeometrycreatePolygonFromEnvelope(double minx, double miny, double maxx, double maxy, int srid) static StringcreateWKTPointFromCoordinateString(String coordinates) Creates a WKT Point string form coordinate string.static StringcreateWKTPolygonFromEnvelope(String lowerCorner, String upperCorner) Creates a WKT Polygon representation from lower and upper corner values.static StringgetCoordinatesString(org.locationtech.jts.geom.Coordinate[] sourceCoords) static StringgetCoordinatesString(org.locationtech.jts.geom.Geometry geom) Get the coordinates of a Geometry as String.protected static StringBuildergetCoordinateString(StringBuilder builder, org.locationtech.jts.geom.Coordinate coordinate) static org.locationtech.jts.geom.Coordinate[]getExteriorRingCoordinatesFromPolygon(org.locationtech.jts.geom.Polygon polygon) Fix for Binary-Incompatible-Change in JTS 1.17.0 Polygon getExteriorRing() which returns LinearRing instead of a LineString.static org.locationtech.jts.geom.GeometryFactorygetGeometryFactory(org.locationtech.jts.geom.Geometry geometry) static org.locationtech.jts.geom.GeometryFactorygetGeometryFactoryForSRID(int srid) static org.n52.shetland.util.JTSHelper.SwitchCoordinateGeometryFactorystatic org.locationtech.jts.io.WKTReadergetWKTReaderForSRID(int srid) static booleanisNotEmpty(org.locationtech.jts.geom.Geometry geometry) static <G extends org.locationtech.jts.geom.Geometry>
GswitchCoordinateAxisOrder(G geometry) Switches the coordinates of a JTS Geometry.
-
Field Details
-
WKT_POLYGON
- See Also:
-
WKT_POINT
- See Also:
-
COORDINATE_SWITCHING_FILTER
public static final org.locationtech.jts.geom.CoordinateFilter COORDINATE_SWITCHING_FILTER
-
-
Constructor Details
-
JTSHelper
protected JTSHelper()
-
-
Method Details
-
createGeometryFromWKT
public static org.locationtech.jts.geom.Geometry createGeometryFromWKT(String wkt, int srid) throws org.locationtech.jts.io.ParseException Creates a JTS Geometry from an WKT representation. Switches the coordinate order if needed.- Parameters:
wkt- WKT representation of the geometrysrid- the SRID of the newly created geometry- Returns:
- JTS Geometry object
- Throws:
org.locationtech.jts.io.ParseException- If an error occurs
-
getWKTReaderForSRID
public static org.locationtech.jts.io.WKTReader getWKTReaderForSRID(int srid) -
getCoordinatesString
Get the coordinates of a Geometry as String.- Parameters:
geom- Geometry to get coordinates- Returns:
- Coordinates as String
-
getCoordinatesString
-
getCoordinateString
protected static StringBuilder getCoordinateString(StringBuilder builder, org.locationtech.jts.geom.Coordinate coordinate) -
createWKTPolygonFromEnvelope
Creates a WKT Polygon representation from lower and upper corner values.- Parameters:
lowerCorner- Lower corner coordinatesupperCorner- Upper corner coordinates- Returns:
- WKT Polygon
-
createEnvelopeFromLowerUpperCorner
-
createPolygonFromEnvelope
public static org.locationtech.jts.geom.Geometry createPolygonFromEnvelope(double[] envelope, int srid) -
createPolygonFromEnvelope
public static org.locationtech.jts.geom.Geometry createPolygonFromEnvelope(double minx, double miny, double maxx, double maxy, int srid) -
switchCoordinateAxisOrder
public static <G extends org.locationtech.jts.geom.Geometry> G switchCoordinateAxisOrder(G geometry) Switches the coordinates of a JTS Geometry.- Type Parameters:
G- the geometry type- Parameters:
geometry- Geometry to switch coordinates.- Returns:
- Geometry with switched coordinates
-
getGeometryFactory
public static org.locationtech.jts.geom.GeometryFactory getGeometryFactory(org.locationtech.jts.geom.Geometry geometry) -
getGeometryFactoryForSRID
public static org.locationtech.jts.geom.GeometryFactory getGeometryFactoryForSRID(int srid) -
getSwitchCoordinateGeometryFactoryForSRID
public static org.n52.shetland.util.JTSHelper.SwitchCoordinateGeometryFactory getSwitchCoordinateGeometryFactoryForSRID(int srid) -
createWKTPointFromCoordinateString
Creates a WKT Point string form coordinate string.- Parameters:
coordinates- Coordinate string- Returns:
- WKT Point string
-
isNotEmpty
public static boolean isNotEmpty(org.locationtech.jts.geom.Geometry geometry) -
getExteriorRingCoordinatesFromPolygon
public static org.locationtech.jts.geom.Coordinate[] getExteriorRingCoordinatesFromPolygon(org.locationtech.jts.geom.Polygon polygon) Fix for Binary-Incompatible-Change in JTS 1.17.0 Polygon getExteriorRing() which returns LinearRing instead of a LineString. This changes occurs errors in the SOS with Hinernate/Geolatte until the 3rd party libraries have not updated to JTS 1.17.0.- Parameters:
polygon- polygon to get exterior ring from- Returns:
- the coordinates
-