Class GeometryUtils


  • public abstract class GeometryUtils
    extends Object
    Utility methods for geometry objects.
    Author:
    Christian Bremer
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static org.locationtech.jts.geom.Geometry copyAndApplyFilters​(org.locationtech.jts.geom.Geometry geometry, org.locationtech.jts.geom.CoordinateFilter... filters)
      Copy and apply filters.
      static org.locationtech.jts.geom.Coordinate createCoordinate​(double x, double y)
      Creates a coordinate.
      static org.locationtech.jts.geom.Coordinate createCoordinate​(BigDecimal x, BigDecimal y)
      Creates a coordinate.
      static org.locationtech.jts.geom.Coordinate createCoordinateWGS84​(double latitude, double longitude)
      Creates a coordinate.
      static org.locationtech.jts.geom.Coordinate createCoordinateWGS84​(BigDecimal latitude, BigDecimal longitude)
      Creates a coordinate.
      static org.locationtech.jts.geom.GeometryCollection createGeometryCollection​(Collection<? extends org.locationtech.jts.geom.Geometry> geometries)
      Create geometry collection geometry collection.
      static org.locationtech.jts.geom.GeometryCollection createGeometryCollection​(Collection<? extends org.locationtech.jts.geom.Geometry> geometries, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Create geometry collection geometry collection.
      static org.locationtech.jts.geom.GeometryCollection createGeometryCollection​(org.locationtech.jts.geom.Geometry... geometries)
      Create geometry collection geometry collection.
      static org.locationtech.jts.geom.LinearRing createLinearRing​(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates)
      Creates a LinearRing using the given coordinates.
      static org.locationtech.jts.geom.LinearRing createLinearRing​(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Creates a LinearRing using the given coordinates.
      static org.locationtech.jts.geom.LineString createLineString​(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates)
      Creates a LineString using the given coordinates; a null or empty collection will create an empty LineString.
      static org.locationtech.jts.geom.LineString createLineString​(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Creates a LineString using the given coordinates; a null or empty collection will create an empty LineString.
      static org.locationtech.jts.geom.MultiLineString createMultiLineString​(Collection<? extends org.locationtech.jts.geom.LineString> lineStrings)
      Creates a MultiLineString using the given LineStrings; a null or empty collection will create an empty MultiLineString.
      static org.locationtech.jts.geom.MultiLineString createMultiLineString​(Collection<? extends org.locationtech.jts.geom.LineString> lineStrings, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Creates a MultiLineString using the given LineStrings; a null or empty collection will create an empty MultiLineString.
      static org.locationtech.jts.geom.MultiPoint createMultiPoint​(Collection<? extends org.locationtech.jts.geom.Point> points)
      Creates a MultiPoint using the given Points.
      static org.locationtech.jts.geom.MultiPoint createMultiPoint​(Collection<? extends org.locationtech.jts.geom.Point> points, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Creates a MultiPoint using the given Points.
      static org.locationtech.jts.geom.MultiPolygon createMultiPolygon​(Collection<? extends org.locationtech.jts.geom.Polygon> polygons)
      Creates a MultiPolygon using the given Polygons; a null or empty array will create an empty Polygon.
      static org.locationtech.jts.geom.MultiPolygon createMultiPolygon​(Collection<? extends org.locationtech.jts.geom.Polygon> polygons, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Creates a MultiPolygon using the given Polygons; a null or empty array will create an empty Polygon.
      static org.locationtech.jts.geom.Point createPoint​(double x, double y)
      Creates a point.
      static org.locationtech.jts.geom.Point createPoint​(double x, double y, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Creates a point.
      static org.locationtech.jts.geom.Point createPoint​(BigDecimal x, BigDecimal y)
      Creates a point.
      static org.locationtech.jts.geom.Point createPoint​(BigDecimal x, BigDecimal y, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Creates a point.
      static org.locationtech.jts.geom.Point createPoint​(org.locationtech.jts.geom.Coordinate coordinate)
      Creates a Point using the given Coordinate; a null Coordinate will create an empty Geometry.
      static org.locationtech.jts.geom.Point createPoint​(org.locationtech.jts.geom.Coordinate coordinate, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Creates a Point using the given Coordinate; a null Coordinate will create an empty Geometry.
      static org.locationtech.jts.geom.Point createPointWGS84​(double latitude, double longitude)
      Creates a point from WGS84 latitude and longitude.
      Latitude becomes the y-value.
      Longitude becomes the x-value.
      static org.locationtech.jts.geom.Point createPointWGS84​(double latitude, double longitude, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Creates a point from WGS84 latitude and longitude.
      Latitude becomes the y-value.
      Longitude becomes the x-value.
      static org.locationtech.jts.geom.Point createPointWGS84​(BigDecimal latitude, BigDecimal longitude)
      Creates a point from WGS84 latitude and longitude.
      Latitude becomes the y-value.
      Longitude becomes the x-value.
      static org.locationtech.jts.geom.Point createPointWGS84​(BigDecimal latitude, BigDecimal longitude, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Creates a point from WGS84 latitude and longitude.
      Latitude becomes the y-value.
      Longitude becomes the x-value.
      static org.locationtech.jts.geom.Polygon createPolygon​(org.locationtech.jts.geom.LinearRing shell)
      Constructs a Polygon with the given exterior boundary.
      static org.locationtech.jts.geom.Polygon createPolygon​(org.locationtech.jts.geom.LinearRing shell, Collection<? extends org.locationtech.jts.geom.LinearRing> holes)
      Constructs a Polygon with the given exterior boundary and interior boundaries.
      static org.locationtech.jts.geom.Polygon createPolygon​(org.locationtech.jts.geom.LinearRing shell, Collection<? extends org.locationtech.jts.geom.LinearRing> holes, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Constructs a Polygon with the given exterior boundary and interior boundaries.
      static org.locationtech.jts.geom.Polygon createPolygon​(org.locationtech.jts.geom.LinearRing shell, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Constructs a Polygon with the given exterior boundary.
      static boolean equals​(org.locationtech.jts.geom.Geometry g1, org.locationtech.jts.geom.Geometry g2)
      Checks whether two geometry objects are equal.
      static org.locationtech.jts.geom.Geometry fromWKT​(InputStream inputStream, String charsetName)
      Reads a Well-Known Text representation of a Geometry from an InputStream.
      static org.locationtech.jts.geom.Geometry fromWKT​(InputStream inputStream, String charsetName, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Reads a Well-Known Text representation of a Geometry from an InputStream.
      static org.locationtech.jts.geom.Geometry fromWKT​(Reader reader)
      Reads a Well-Known Text representation of a Geometry from a Reader.
      static org.locationtech.jts.geom.Geometry fromWKT​(Reader reader, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Reads a Well-Known Text representation of a Geometry from a Reader.
      static org.locationtech.jts.geom.Geometry fromWKT​(String wkt)
      Reads a Well-Known Text representation of a Geometry from a String.
      static org.locationtech.jts.geom.Geometry fromWKT​(String wkt, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Reads a Well-Known Text representation of a Geometry from a String.
      static double[] getBoundingBox​(Collection<? extends org.locationtech.jts.geom.Geometry> geometries)
      Calculate the bounding box of the specified geometries.
      static double[] getBoundingBox​(org.locationtech.jts.geom.Geometry geometry)
      Calculate the bounding box of the specified geometry (see bounding-boxes).
      static org.locationtech.jts.geom.Polygon getBoundingBoxAsPolygon2D​(double[] boundingBox)
      Returns a polygon from the bounding box.
      static org.locationtech.jts.geom.Polygon getBoundingBoxAsPolygon2D​(double[] boundingBox, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Returns a polygon from the bounding box.
      static org.locationtech.jts.geom.Polygon getBoundingBoxAsPolygon2D​(org.locationtech.jts.geom.Geometry geometry)
      Returns the bounding box of the geometry as polygon.
      static org.locationtech.jts.geom.Polygon getBoundingBoxAsPolygon2D​(org.locationtech.jts.geom.Geometry geometry, org.locationtech.jts.geom.GeometryFactory geometryFactory)
      Returns the bounding box of the geometry as polygon.
      static double getLatitudeWGS84​(org.locationtech.jts.geom.Coordinate coordinate)
      Gets latitude value of WGS84.
      static double getLongitudeWGS84​(org.locationtech.jts.geom.Coordinate coordinate)
      Gets longitude value of WGS84.
      static org.locationtech.jts.geom.Coordinate getNorthEast​(double[] boundingBox)
      Returns the coordinate in the north-east.
      static org.locationtech.jts.geom.Coordinate getNorthWest​(double[] boundingBox)
      Returns the coordinate in the north-west.
      static org.locationtech.jts.geom.Coordinate getSouthEast​(double[] boundingBox)
      Returns the coordinate in the south-east.
      static org.locationtech.jts.geom.Coordinate getSouthWest​(double[] boundingBox)
      Returns the coordinate in the south-west.
      static org.locationtech.jts.geom.Geometry swapCoordinates​(org.locationtech.jts.geom.Geometry geometry)
      Swap coordinates.
      static String toWKT​(org.locationtech.jts.geom.Geometry geometry)
      Returns the Well-known Text representation of this Geometry.
      static org.locationtech.jts.geom.Geometry transformMercatorToWgs84​(org.locationtech.jts.geom.Geometry geometry)
      Transforms the coordinates of the given geometry from mercator into WGS84.
      static org.locationtech.jts.geom.Geometry transformWgs84ToMercator​(org.locationtech.jts.geom.Geometry geometry)
      Transforms the coordinates of the given geometry from WGS84 into mercator.
    • Field Detail

      • EARTH_RADIUS_METERS

        public static final double EARTH_RADIUS_METERS
        The earth radius in meters.
        See Also:
        Constant Field Values
      • MERCATOR_MAX_LAT

        public static final double MERCATOR_MAX_LAT
        Maximum latitude for mercator projection.
        See Also:
        Constant Field Values
      • MERCATOR_MIN_LAT

        public static final double MERCATOR_MIN_LAT
        Minimum latitude for mercator projection.
        See Also:
        Constant Field Values
      • DEFAULT_SPATIAL_AUTHORITY

        public static final String DEFAULT_SPATIAL_AUTHORITY
        Default spatial authority: 'EPSG'.
        See Also:
        Constant Field Values
      • WGS84_SPATIAL_REFERENCE_ID

        public static final int WGS84_SPATIAL_REFERENCE_ID
        Reference ID of WGS84: '4326'.
        See Also:
        Constant Field Values
      • WGS84_CRS

        public static final String WGS84_CRS
        CRS (Coordinate reference system) of WGS84: 'EPSG:4326'.
        See Also:
        Constant Field Values
      • MERCATOR_SPATIAL_REFERENCE_ID

        public static final int MERCATOR_SPATIAL_REFERENCE_ID
        Reference ID of mercator projection: '3857'.
        See Also:
        Constant Field Values
      • MERCATOR_SPATIAL_REFERENCE_ID_ALT

        public static final int MERCATOR_SPATIAL_REFERENCE_ID_ALT
        Alternative reference ID of mercator: '900913'.
        See Also:
        Constant Field Values
      • MERCATOR_CRS

        public static final String MERCATOR_CRS
        CRS (Coordinate reference system) of mercator: 'EPSG:3857'.
        See Also:
        Constant Field Values
      • MERCATOR_CRS_ALT

        public static final String MERCATOR_CRS_ALT
        Alternative CRS (Coordinate reference system) of mercator: 'EPSG:900913'.
        See Also:
        Constant Field Values
    • Method Detail

      • equals

        public static boolean equals​(org.locationtech.jts.geom.Geometry g1,
                                     org.locationtech.jts.geom.Geometry g2)
        Checks whether two geometry objects are equal.

        Because the Geometry.equals(Geometry) method throws an exception, this method is used in the GeoJSON classes.

        Parameters:
        g1 - one geometry
        g2 - another geometry
        Returns:
        true if the geometries are equal otherwise false
      • getBoundingBox

        public static double[] getBoundingBox​(org.locationtech.jts.geom.Geometry geometry)
        Calculate the bounding box of the specified geometry (see bounding-boxes).

        A GeoJSON object MAY have a member named "bbox" to include information on the coordinate range for its Geometries, Features, or FeatureCollections. The value of the bbox member MUST be an array of length 2*n where n is the number of dimensions represented in the contained geometries, with all axes of the most southwesterly point followed by all axes of the more northeasterly point. The axes order of a bbox follows the axes order of geometries.

        Parameters:
        geometry - the geometry
        Returns:
        null if the bounding box can not be calculated, otherwise the bounding box
      • getBoundingBox

        public static double[] getBoundingBox​(Collection<? extends org.locationtech.jts.geom.Geometry> geometries)
        Calculate the bounding box of the specified geometries.
        Parameters:
        geometries - the geometries
        Returns:
        null if the bounding box can not be calculated, otherwise the bounding box
      • getSouthWest

        public static org.locationtech.jts.geom.Coordinate getSouthWest​(double[] boundingBox)
        Returns the coordinate in the south-west.
        Parameters:
        boundingBox - the bounding box
        Returns:
        the coordinate in the south-west
      • getNorthWest

        public static org.locationtech.jts.geom.Coordinate getNorthWest​(double[] boundingBox)
        Returns the coordinate in the north-west.
        Parameters:
        boundingBox - the bounding box
        Returns:
        the coordinate in the north-west
      • getNorthEast

        public static org.locationtech.jts.geom.Coordinate getNorthEast​(double[] boundingBox)
        Returns the coordinate in the north-east.
        Parameters:
        boundingBox - the bounding box
        Returns:
        the coordinate in the north-east
      • getSouthEast

        public static org.locationtech.jts.geom.Coordinate getSouthEast​(double[] boundingBox)
        Returns the coordinate in the south-east.
        Parameters:
        boundingBox - the bounding box
        Returns:
        the coordinate in the south-east
      • getBoundingBoxAsPolygon2D

        public static org.locationtech.jts.geom.Polygon getBoundingBoxAsPolygon2D​(double[] boundingBox)
        Returns a polygon from the bounding box.
        Parameters:
        boundingBox - the bounding bos
        Returns:
        the polygon or null if the bounding box is null or empty
      • getBoundingBoxAsPolygon2D

        public static org.locationtech.jts.geom.Polygon getBoundingBoxAsPolygon2D​(double[] boundingBox,
                                                                                  org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Returns a polygon from the bounding box.
        Parameters:
        boundingBox - the bounding bos
        geometryFactory - the geometry factory
        Returns:
        the polygon or null if the bounding box is null or empty
      • getBoundingBoxAsPolygon2D

        public static org.locationtech.jts.geom.Polygon getBoundingBoxAsPolygon2D​(org.locationtech.jts.geom.Geometry geometry)
        Returns the bounding box of the geometry as polygon.
        Parameters:
        geometry - the geometry
        Returns:
        the bounding box of the geometry as polygon
      • getBoundingBoxAsPolygon2D

        public static org.locationtech.jts.geom.Polygon getBoundingBoxAsPolygon2D​(org.locationtech.jts.geom.Geometry geometry,
                                                                                  org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Returns the bounding box of the geometry as polygon.
        Parameters:
        geometry - the geometry
        geometryFactory - the geometry factory to use
        Returns:
        the bounding box of the geometry as polygon
      • toWKT

        public static String toWKT​(org.locationtech.jts.geom.Geometry geometry)
        Returns the Well-known Text representation of this Geometry. For a definition of the Well-known Text format, see the OpenGIS Simple Features Specification.
        Parameters:
        geometry - the geometry
        Returns:
        the Well-known Text representation of this Geometry
      • fromWKT

        public static org.locationtech.jts.geom.Geometry fromWKT​(String wkt)
                                                          throws IllegalArgumentException
        Reads a Well-Known Text representation of a Geometry from a String.
        Parameters:
        wkt - one or more strings (see the OpenGIS Simple Features Specification) separated by whitespace
        Returns:
        a Geometry specified by wellKnownText
        Throws:
        IllegalArgumentException - if a parsing problem occurs
      • fromWKT

        public static org.locationtech.jts.geom.Geometry fromWKT​(String wkt,
                                                                 org.locationtech.jts.geom.GeometryFactory geometryFactory)
                                                          throws IllegalArgumentException
        Reads a Well-Known Text representation of a Geometry from a String.
        Parameters:
        wkt - one or more strings (see the OpenGIS Simple Features Specification) separated by whitespace
        geometryFactory - the geometry factory to use
        Returns:
        a Geometry specified by wellKnownText
        Throws:
        IllegalArgumentException - if a parsing problem occurs
      • fromWKT

        public static org.locationtech.jts.geom.Geometry fromWKT​(Reader reader)
                                                          throws IllegalArgumentException
        Reads a Well-Known Text representation of a Geometry from a Reader.
        Parameters:
        reader - a Reader which will return a string (see the OpenGIS Simple Features Specification)
        Returns:
        a Geometry read from reader
        Throws:
        IllegalArgumentException - if a parsing problem occurs
      • fromWKT

        public static org.locationtech.jts.geom.Geometry fromWKT​(Reader reader,
                                                                 org.locationtech.jts.geom.GeometryFactory geometryFactory)
                                                          throws IllegalArgumentException
        Reads a Well-Known Text representation of a Geometry from a Reader.
        Parameters:
        reader - a Reader which will return a string (see the OpenGIS Simple Features Specification)
        geometryFactory - the geometry factory to use
        Returns:
        a Geometry read from reader
        Throws:
        IllegalArgumentException - if a parsing problem occurs
      • fromWKT

        public static org.locationtech.jts.geom.Geometry fromWKT​(InputStream inputStream,
                                                                 String charsetName)
                                                          throws IllegalArgumentException
        Reads a Well-Known Text representation of a Geometry from an InputStream.
        Parameters:
        inputStream - an InputStream which will return a string (see the OpenGIS Simple Features Specification)
        charsetName - the charset to use
        Returns:
        a Geometry read from the input stream
        Throws:
        IllegalArgumentException - if a parsing problem occurs
      • fromWKT

        public static org.locationtech.jts.geom.Geometry fromWKT​(InputStream inputStream,
                                                                 String charsetName,
                                                                 org.locationtech.jts.geom.GeometryFactory geometryFactory)
                                                          throws IllegalArgumentException
        Reads a Well-Known Text representation of a Geometry from an InputStream.
        Parameters:
        inputStream - an InputStream which will return a string (see the OpenGIS Simple Features Specification)
        charsetName - the charset to use
        geometryFactory - the geometry factory to use
        Returns:
        a Geometry read from the input stream
        Throws:
        IllegalArgumentException - if a parsing problem occurs
      • createCoordinate

        public static org.locationtech.jts.geom.Coordinate createCoordinate​(double x,
                                                                            double y)
        Creates a coordinate.
        Parameters:
        x - the x value
        y - the y value
        Returns:
        the coordinate
      • createCoordinate

        public static org.locationtech.jts.geom.Coordinate createCoordinate​(BigDecimal x,
                                                                            BigDecimal y)
        Creates a coordinate.
        Parameters:
        x - the x value
        y - the y value
        Returns:
        the coordinate
        Throws:
        IllegalArgumentException - if x or y is null
      • createCoordinateWGS84

        public static org.locationtech.jts.geom.Coordinate createCoordinateWGS84​(double latitude,
                                                                                 double longitude)
        Creates a coordinate.
        Parameters:
        latitude - the latitude value
        longitude - the longitude value
        Returns:
        the coordinate
      • createCoordinateWGS84

        public static org.locationtech.jts.geom.Coordinate createCoordinateWGS84​(BigDecimal latitude,
                                                                                 BigDecimal longitude)
        Creates a coordinate.
        Parameters:
        latitude - the latitude value
        longitude - the longitude value
        Returns:
        the coordinate
        Throws:
        IllegalArgumentException - if latitude or longitude is null
      • getLatitudeWGS84

        public static double getLatitudeWGS84​(org.locationtech.jts.geom.Coordinate coordinate)
        Gets latitude value of WGS84.
        Parameters:
        coordinate - the coordinate
        Returns:
        the latitude
      • getLongitudeWGS84

        public static double getLongitudeWGS84​(org.locationtech.jts.geom.Coordinate coordinate)
        Gets longitude value of WGS84.
        Parameters:
        coordinate - the coordinate
        Returns:
        the longitude
      • createPoint

        public static org.locationtech.jts.geom.Point createPoint​(double x,
                                                                  double y)
        Creates a point.
        Parameters:
        x - the x value
        y - the y value
        Returns:
        the point
      • createPoint

        public static org.locationtech.jts.geom.Point createPoint​(double x,
                                                                  double y,
                                                                  org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Creates a point.
        Parameters:
        x - the x value
        y - the y value
        geometryFactory - the geometry factory to use
        Returns:
        the point
      • createPoint

        public static org.locationtech.jts.geom.Point createPoint​(BigDecimal x,
                                                                  BigDecimal y)
        Creates a point.
        Parameters:
        x - the x value
        y - the y value
        Returns:
        the point
      • createPoint

        public static org.locationtech.jts.geom.Point createPoint​(BigDecimal x,
                                                                  BigDecimal y,
                                                                  org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Creates a point.
        Parameters:
        x - the x value
        y - the y value
        geometryFactory - the geometry factory to use
        Returns:
        the point
      • createPoint

        public static org.locationtech.jts.geom.Point createPoint​(org.locationtech.jts.geom.Coordinate coordinate)
        Creates a Point using the given Coordinate; a null Coordinate will create an empty Geometry.
        Parameters:
        coordinate - the coordinate of the point
        Returns:
        the point
      • createPoint

        public static org.locationtech.jts.geom.Point createPoint​(org.locationtech.jts.geom.Coordinate coordinate,
                                                                  org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Creates a Point using the given Coordinate; a null Coordinate will create an empty Geometry.
        Parameters:
        coordinate - the coordinate of the point
        geometryFactory - the geometry factory to use
        Returns:
        the point
      • createPointWGS84

        public static org.locationtech.jts.geom.Point createPointWGS84​(double latitude,
                                                                       double longitude)
        Creates a point from WGS84 latitude and longitude.
        Latitude becomes the y-value.
        Longitude becomes the x-value.
        Parameters:
        latitude - the latitude in degrees
        longitude - the longitude in degrees
        Returns:
        the point
      • createPointWGS84

        public static org.locationtech.jts.geom.Point createPointWGS84​(BigDecimal latitude,
                                                                       BigDecimal longitude)
        Creates a point from WGS84 latitude and longitude.
        Latitude becomes the y-value.
        Longitude becomes the x-value.
        Parameters:
        latitude - the latitude in degrees
        longitude - the longitude in degrees
        Returns:
        the point
      • createPointWGS84

        public static org.locationtech.jts.geom.Point createPointWGS84​(double latitude,
                                                                       double longitude,
                                                                       org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Creates a point from WGS84 latitude and longitude.
        Latitude becomes the y-value.
        Longitude becomes the x-value.
        Parameters:
        latitude - the latitude in degrees
        longitude - the longitude in degrees
        geometryFactory - the geometry factory to use
        Returns:
        the point
      • createPointWGS84

        public static org.locationtech.jts.geom.Point createPointWGS84​(BigDecimal latitude,
                                                                       BigDecimal longitude,
                                                                       org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Creates a point from WGS84 latitude and longitude.
        Latitude becomes the y-value.
        Longitude becomes the x-value.
        Parameters:
        latitude - the latitude in degrees
        longitude - the longitude in degrees
        geometryFactory - the geometry factory to use
        Returns:
        the point
      • createMultiPoint

        public static org.locationtech.jts.geom.MultiPoint createMultiPoint​(Collection<? extends org.locationtech.jts.geom.Point> points)
        Creates a MultiPoint using the given Points. A null or empty collection will create an empty MultiPoint.
        Parameters:
        points - the points of the MultiPoint
        Returns:
        the MultiPoint
      • createMultiPoint

        public static org.locationtech.jts.geom.MultiPoint createMultiPoint​(Collection<? extends org.locationtech.jts.geom.Point> points,
                                                                            org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Creates a MultiPoint using the given Points. A null or empty collection will create an empty MultiPoint.
        Parameters:
        points - the points of the MultiPoint
        geometryFactory - the geometry factory to use
        Returns:
        the MultiPoint
      • createLineString

        public static org.locationtech.jts.geom.LineString createLineString​(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates)
        Creates a LineString using the given coordinates; a null or empty collection will create an empty LineString. Consecutive points must not be equal.
        Parameters:
        coordinates - the coordinates of the LineString
        Returns:
        the LineString
      • createLineString

        public static org.locationtech.jts.geom.LineString createLineString​(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates,
                                                                            org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Creates a LineString using the given coordinates; a null or empty collection will create an empty LineString. Consecutive points must not be equal.
        Parameters:
        coordinates - the coordinates of the LineString
        geometryFactory - the geometry factory to use
        Returns:
        the LineString
      • createMultiLineString

        public static org.locationtech.jts.geom.MultiLineString createMultiLineString​(Collection<? extends org.locationtech.jts.geom.LineString> lineStrings)
        Creates a MultiLineString using the given LineStrings; a null or empty collection will create an empty MultiLineString.
        Parameters:
        lineStrings - the LineStrings of the MultiLineString
        Returns:
        the MultiLineString
      • createMultiLineString

        public static org.locationtech.jts.geom.MultiLineString createMultiLineString​(Collection<? extends org.locationtech.jts.geom.LineString> lineStrings,
                                                                                      org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Creates a MultiLineString using the given LineStrings; a null or empty collection will create an empty MultiLineString.
        Parameters:
        lineStrings - the LineStrings of the MultiLineString
        geometryFactory - the geometry factory to use
        Returns:
        the MultiLineString
      • createLinearRing

        public static org.locationtech.jts.geom.LinearRing createLinearRing​(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates)
        Creates a LinearRing using the given coordinates. A null or empty coordinates will create an empty LinearRing.
        Parameters:
        coordinates - the coordinates
        Returns:
        the created LinearRing
      • createLinearRing

        public static org.locationtech.jts.geom.LinearRing createLinearRing​(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates,
                                                                            org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Creates a LinearRing using the given coordinates. A null or empty coordinates will create an empty LinearRing.
        Parameters:
        coordinates - the coordinates
        geometryFactory - the geometry factory
        Returns:
        the created LinearRing
      • createPolygon

        public static org.locationtech.jts.geom.Polygon createPolygon​(org.locationtech.jts.geom.LinearRing shell)
        Constructs a Polygon with the given exterior boundary.
        Parameters:
        shell - the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created
        Returns:
        the created Polygon
      • createPolygon

        public static org.locationtech.jts.geom.Polygon createPolygon​(org.locationtech.jts.geom.LinearRing shell,
                                                                      org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Constructs a Polygon with the given exterior boundary.
        Parameters:
        shell - the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created
        geometryFactory - the geometry factory
        Returns:
        the created Polygon
      • createPolygon

        public static org.locationtech.jts.geom.Polygon createPolygon​(org.locationtech.jts.geom.LinearRing shell,
                                                                      Collection<? extends org.locationtech.jts.geom.LinearRing> holes)
        Constructs a Polygon with the given exterior boundary and interior boundaries.
        Parameters:
        shell - the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created
        holes - the inner boundaries of the new Polygon, or null or empty LinearRing s if the empty geometry is to be created
        Returns:
        the created Polygon
      • createPolygon

        public static org.locationtech.jts.geom.Polygon createPolygon​(org.locationtech.jts.geom.LinearRing shell,
                                                                      Collection<? extends org.locationtech.jts.geom.LinearRing> holes,
                                                                      org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Constructs a Polygon with the given exterior boundary and interior boundaries.
        Parameters:
        shell - the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created
        holes - the inner boundaries of the new Polygon, or null or empty LinearRing s if the empty geometry is to be created
        geometryFactory - the geometry factory
        Returns:
        the created Polygon
      • createMultiPolygon

        public static org.locationtech.jts.geom.MultiPolygon createMultiPolygon​(Collection<? extends org.locationtech.jts.geom.Polygon> polygons)
        Creates a MultiPolygon using the given Polygons; a null or empty array will create an empty Polygon.
        Parameters:
        polygons - the polygons
        Returns:
        the multi polygon
      • createMultiPolygon

        public static org.locationtech.jts.geom.MultiPolygon createMultiPolygon​(Collection<? extends org.locationtech.jts.geom.Polygon> polygons,
                                                                                org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Creates a MultiPolygon using the given Polygons; a null or empty array will create an empty Polygon.
        Parameters:
        polygons - the polygons
        geometryFactory - the geometry factory
        Returns:
        the multi polygon
      • createGeometryCollection

        public static org.locationtech.jts.geom.GeometryCollection createGeometryCollection​(org.locationtech.jts.geom.Geometry... geometries)
        Create geometry collection geometry collection.
        Parameters:
        geometries - the geometries
        Returns:
        the geometry collection
      • createGeometryCollection

        public static org.locationtech.jts.geom.GeometryCollection createGeometryCollection​(Collection<? extends org.locationtech.jts.geom.Geometry> geometries)
        Create geometry collection geometry collection.
        Parameters:
        geometries - the geometries
        Returns:
        the geometry collection
      • createGeometryCollection

        public static org.locationtech.jts.geom.GeometryCollection createGeometryCollection​(Collection<? extends org.locationtech.jts.geom.Geometry> geometries,
                                                                                            org.locationtech.jts.geom.GeometryFactory geometryFactory)
        Create geometry collection geometry collection.
        Parameters:
        geometries - the geometries
        geometryFactory - the geometry factory
        Returns:
        the geometry collection
      • copyAndApplyFilters

        public static org.locationtech.jts.geom.Geometry copyAndApplyFilters​(org.locationtech.jts.geom.Geometry geometry,
                                                                             org.locationtech.jts.geom.CoordinateFilter... filters)
        Copy and apply filters.
        Parameters:
        geometry - the geometry
        filters - the filters
        Returns:
        the copied and filtered geometry
      • transformWgs84ToMercator

        public static org.locationtech.jts.geom.Geometry transformWgs84ToMercator​(org.locationtech.jts.geom.Geometry geometry)
        Transforms the coordinates of the given geometry from WGS84 into mercator.
        Parameters:
        geometry - the geometry
        Returns:
        the transformed (cloned) geometry
      • transformMercatorToWgs84

        public static org.locationtech.jts.geom.Geometry transformMercatorToWgs84​(org.locationtech.jts.geom.Geometry geometry)
        Transforms the coordinates of the given geometry from mercator into WGS84.
        Parameters:
        geometry - the geometry
        Returns:
        the transformed (cloned) geometry
      • swapCoordinates

        public static org.locationtech.jts.geom.Geometry swapCoordinates​(org.locationtech.jts.geom.Geometry geometry)
        Swap coordinates.
        Parameters:
        geometry - the geometry
        Returns:
        the geometry with swapped coordinates