Package org.n52.shetland.util
Class JTSHelper
- java.lang.Object
-
- org.n52.shetland.util.JTSHelper
-
public class JTSHelper extends Object
Utility class for the Java Topology Suite.- Since:
- 1.0.0
-
-
Field Summary
Fields Modifier and Type Field Description static org.locationtech.jts.geom.CoordinateFilterCOORDINATE_SWITCHING_FILTERstatic StringWKT_POINTstatic StringWKT_POLYGON
-
Constructor Summary
Constructors Modifier Constructor Description protectedJTSHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static 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.SwitchCoordinateGeometryFactorygetSwitchCoordinateGeometryFactoryForSRID(int srid)static 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 Detail
-
WKT_POLYGON
public static final String WKT_POLYGON
- See Also:
- Constant Field Values
-
WKT_POINT
public static final String WKT_POINT
- See Also:
- Constant Field Values
-
COORDINATE_SWITCHING_FILTER
public static final org.locationtech.jts.geom.CoordinateFilter COORDINATE_SWITCHING_FILTER
-
-
Method Detail
-
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
public static String getCoordinatesString(org.locationtech.jts.geom.Geometry geom)
Get the coordinates of a Geometry as String.- Parameters:
geom- Geometry to get coordinates- Returns:
- Coordinates as String
-
getCoordinatesString
public static String getCoordinatesString(org.locationtech.jts.geom.Coordinate[] sourceCoords)
-
getCoordinateString
protected static StringBuilder getCoordinateString(StringBuilder builder, org.locationtech.jts.geom.Coordinate coordinate)
-
createWKTPolygonFromEnvelope
public static String createWKTPolygonFromEnvelope(String lowerCorner, String upperCorner)
Creates a WKT Polygon representation from lower and upper corner values.- Parameters:
lowerCorner- Lower corner coordinatesupperCorner- Upper corner coordinates- Returns:
- WKT Polygon
-
createEnvelopeFromLowerUpperCorner
public static org.locationtech.jts.geom.Envelope createEnvelopeFromLowerUpperCorner(String lowerCorner, String upperCorner)
-
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
public static String createWKTPointFromCoordinateString(String coordinates)
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
-
-