Class GeoJsonGeometryFactory

java.lang.Object
org.locationtech.jts.geom.GeometryFactory
org.bremersee.geojson.GeoJsonGeometryFactory
All Implemented Interfaces:
Serializable

public class GeoJsonGeometryFactory extends org.locationtech.jts.geom.GeometryFactory
The geo json geometry factory.
Author:
Christian Bremer
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiates a new geo json geometry factory.
    GeoJsonGeometryFactory(org.locationtech.jts.geom.CoordinateSequenceFactory coordinateSequenceFactory)
    Instantiates a new geo json geometry factory.
    GeoJsonGeometryFactory(org.locationtech.jts.geom.PrecisionModel precisionModel)
    Instantiates a new geo json geometry factory.
    GeoJsonGeometryFactory(org.locationtech.jts.geom.PrecisionModel precisionModel, int srid)
    Instantiates a new geo json geometry factory.
    GeoJsonGeometryFactory(org.locationtech.jts.geom.PrecisionModel precisionModel, int srid, org.locationtech.jts.geom.CoordinateSequenceFactory coordinateSequenceFactory)
    Instantiates a new geo json geometry factory.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.locationtech.jts.geom.Geometry
    copyAndApplyFilters(org.locationtech.jts.geom.Geometry geometry, Collection<? extends org.locationtech.jts.geom.CoordinateFilter> filters)
    Copy and apply filters.
    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
    Creates a coordinate.
    static org.locationtech.jts.geom.Coordinate
    Create coordinate.
    org.locationtech.jts.geom.GeometryCollection
    createGeometryCollection(Collection<? extends org.locationtech.jts.geom.Geometry> geometries)
    Create geometry collection.
    org.locationtech.jts.geom.Geometry
    Reads a Well-Known Text representation of a Geometry from an InputStream.
    org.locationtech.jts.geom.Geometry
    Reads a Well-Known Text representation of a Geometry from a Reader.
    org.locationtech.jts.geom.Geometry
    Reads a Well-Known Text representation of a Geometry from a String.
    createLatitudeLongitude(org.locationtech.jts.geom.Coordinate coordinate)
    Create latitude longitude.
    createLatitudeLongitude(org.locationtech.jts.geom.Point point)
    Create latitude longitude.
    static LatLon
    createLatLon(org.locationtech.jts.geom.Coordinate coordinate)
    Create lat lon.
    static LatLon
    createLatLon(org.locationtech.jts.geom.Point point)
    Create lat lon.
    org.locationtech.jts.geom.LinearRing
    createLinearRing(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates)
    Creates a LinearRing using the given coordinates.
    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.
    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.
    org.locationtech.jts.geom.MultiPoint
    createMultiPoint(Collection<? extends org.locationtech.jts.geom.Point> points)
    Creates a MultiPoint using the given Points.
    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.
    org.locationtech.jts.geom.Point
    createPoint(double x, double y)
    Create point.
    org.locationtech.jts.geom.Point
    Create point.
    org.locationtech.jts.geom.Point
    Create point.
    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 boolean
    equals(org.locationtech.jts.geom.Geometry g1, org.locationtech.jts.geom.Geometry g2)
    Checks whether two geometry objects are equal.
    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).
    org.locationtech.jts.geom.Polygon
    getBoundingBoxAsPolygon2D(double[] boundingBox)
    Returns a polygon from the bounding box.
    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.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.

    Methods inherited from class org.locationtech.jts.geom.GeometryFactory

    buildGeometry, createEmpty, createGeometry, createGeometryCollection, createGeometryCollection, createLinearRing, createLinearRing, createLinearRing, createLineString, createLineString, createLineString, createMultiLineString, createMultiLineString, createMultiPoint, createMultiPoint, createMultiPoint, createMultiPoint, createMultiPointFromCoords, createMultiPolygon, createMultiPolygon, createPoint, createPoint, createPoint, createPointFromInternalCoord, createPolygon, createPolygon, createPolygon, createPolygon, createPolygon, getCoordinateSequenceFactory, getPrecisionModel, getSRID, toGeometry, toGeometryArray, toLinearRingArray, toLineStringArray, toMultiLineStringArray, toMultiPointArray, toMultiPolygonArray, toPointArray, toPolygonArray

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • GeoJsonGeometryFactory

      public GeoJsonGeometryFactory(org.locationtech.jts.geom.PrecisionModel precisionModel, int srid, org.locationtech.jts.geom.CoordinateSequenceFactory coordinateSequenceFactory)
      Instantiates a new geo json geometry factory.
      Parameters:
      precisionModel - the precision model
      srid - the srid
      coordinateSequenceFactory - the coordinate sequence factory
    • GeoJsonGeometryFactory

      public GeoJsonGeometryFactory(org.locationtech.jts.geom.CoordinateSequenceFactory coordinateSequenceFactory)
      Instantiates a new geo json geometry factory.
      Parameters:
      coordinateSequenceFactory - the coordinate sequence factory
    • GeoJsonGeometryFactory

      public GeoJsonGeometryFactory(org.locationtech.jts.geom.PrecisionModel precisionModel)
      Instantiates a new geo json geometry factory.
      Parameters:
      precisionModel - the precision model
    • GeoJsonGeometryFactory

      public GeoJsonGeometryFactory(org.locationtech.jts.geom.PrecisionModel precisionModel, int srid)
      Instantiates a new geo json geometry factory.
      Parameters:
      precisionModel - the precision model
      srid - the srid
    • GeoJsonGeometryFactory

      public GeoJsonGeometryFactory()
      Instantiates a new geo json geometry factory.
  • Method Details

    • 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
    • createCoordinate

      public static org.locationtech.jts.geom.Coordinate createCoordinate(LatLonAware latLon)
      Create coordinate.
      Parameters:
      latLon - the lat lon
      Returns:
      the coordinate
    • createPoint

      public org.locationtech.jts.geom.Point createPoint(double x, double y)
      Create point.
      Parameters:
      x - the x
      y - the y
      Returns:
      the point
    • createPoint

      public org.locationtech.jts.geom.Point createPoint(BigDecimal x, BigDecimal y)
      Create point.
      Parameters:
      x - the x
      y - the y
      Returns:
      the point
    • createPoint

      public org.locationtech.jts.geom.Point createPoint(LatLonAware latLon)
      Create point.
      Parameters:
      latLon - the lat lon
      Returns:
      the point
    • createLineString

      public 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
    • createLinearRing

      public 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
    • createPolygon

      public 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
    • createMultiPoint

      public 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
    • createMultiLineString

      public 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
    • createMultiPolygon

      public 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
    • createGeometryCollection

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

      public static LatLon createLatLon(org.locationtech.jts.geom.Coordinate coordinate)
      Create lat lon.
      Parameters:
      coordinate - the coordinate
      Returns:
      the lat lon
    • createLatLon

      public static LatLon createLatLon(org.locationtech.jts.geom.Point point)
      Create lat lon.
      Parameters:
      point - the point
      Returns:
      the lat lon
    • createLatitudeLongitude

      public static LatitudeLongitude createLatitudeLongitude(org.locationtech.jts.geom.Coordinate coordinate)
      Create latitude longitude.
      Parameters:
      coordinate - the coordinate
      Returns:
      the latitude longitude
    • createLatitudeLongitude

      public static LatitudeLongitude createLatitudeLongitude(org.locationtech.jts.geom.Point point)
      Create latitude longitude.
      Parameters:
      point - the point
      Returns:
      the latitude longitude
    • 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 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 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
    • createGeometryFromWellKnownText

      public org.locationtech.jts.geom.Geometry createGeometryFromWellKnownText(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
    • createGeometryFromWellKnownText

      public org.locationtech.jts.geom.Geometry createGeometryFromWellKnownText(Reader reader) throws IllegalArgumentException, IOException
      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
      IOException - if io problems occurs
    • createGeometryFromWellKnownText

      public org.locationtech.jts.geom.Geometry createGeometryFromWellKnownText(InputStream inputStream, Charset charset) throws IllegalArgumentException, IOException
      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)
      charset - the charset to use
      Returns:
      a Geometry read from the input stream
      Throws:
      IllegalArgumentException - if a parsing problem occurs
      IOException - if io problems occurs
    • 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
    • copyAndApplyFilters

      public static org.locationtech.jts.geom.Geometry copyAndApplyFilters(org.locationtech.jts.geom.Geometry geometry, Collection<? extends org.locationtech.jts.geom.CoordinateFilter> filters)
      Copy and apply filters.
      Parameters:
      geometry - the geometry
      filters - the filters
      Returns:
      the copied and filtered geometry