Package org.bremersee.geojson
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
ConstructorsConstructorDescriptionInstantiates 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 TypeMethodDescriptionstatic org.locationtech.jts.geom.GeometrycopyAndApplyFilters(org.locationtech.jts.geom.Geometry geometry, Collection<? extends org.locationtech.jts.geom.CoordinateFilter> filters) Copy and apply filters.static org.locationtech.jts.geom.GeometrycopyAndApplyFilters(org.locationtech.jts.geom.Geometry geometry, org.locationtech.jts.geom.CoordinateFilter... filters) Copy and apply filters.static org.locationtech.jts.geom.CoordinatecreateCoordinate(double x, double y) Creates a coordinate.static org.locationtech.jts.geom.CoordinateCreates a coordinate.static org.locationtech.jts.geom.CoordinatecreateCoordinate(LatLonAware latLon) Create coordinate.org.locationtech.jts.geom.GeometryCollectioncreateGeometryCollection(Collection<? extends org.locationtech.jts.geom.Geometry> geometries) Create geometry collection.org.locationtech.jts.geom.GeometrycreateGeometryFromWellKnownText(InputStream inputStream, Charset charset) Reads a Well-Known Text representation of a Geometry from anInputStream.org.locationtech.jts.geom.GeometryReads a Well-Known Text representation of a Geometry from aReader.org.locationtech.jts.geom.GeometryReads a Well-Known Text representation of a Geometry from aString.static LatitudeLongitudecreateLatitudeLongitude(org.locationtech.jts.geom.Coordinate coordinate) Create latitude longitude.static LatitudeLongitudecreateLatitudeLongitude(org.locationtech.jts.geom.Point point) Create latitude longitude.static LatLoncreateLatLon(org.locationtech.jts.geom.Coordinate coordinate) Create lat lon.static LatLoncreateLatLon(org.locationtech.jts.geom.Point point) Create lat lon.org.locationtech.jts.geom.LinearRingcreateLinearRing(Collection<? extends org.locationtech.jts.geom.Coordinate> coordinates) Creates a LinearRing using the given coordinates.org.locationtech.jts.geom.LineStringcreateLineString(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.MultiLineStringcreateMultiLineString(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.MultiPointcreateMultiPoint(Collection<? extends org.locationtech.jts.geom.Point> points) Creates a MultiPoint using the given Points.org.locationtech.jts.geom.MultiPolygoncreateMultiPolygon(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.PointcreatePoint(double x, double y) Create point.org.locationtech.jts.geom.PointcreatePoint(BigDecimal x, BigDecimal y) Create point.org.locationtech.jts.geom.PointcreatePoint(LatLonAware latLon) Create point.org.locationtech.jts.geom.PolygoncreatePolygon(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 booleanequals(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.PolygongetBoundingBoxAsPolygon2D(double[] boundingBox) Returns a polygon from the bounding box.org.locationtech.jts.geom.PolygongetBoundingBoxAsPolygon2D(org.locationtech.jts.geom.Geometry geometry) Returns the bounding box of the geometry as polygon.static org.locationtech.jts.geom.CoordinategetNorthEast(double[] boundingBox) Returns the coordinate in the north-east.static org.locationtech.jts.geom.CoordinategetNorthWest(double[] boundingBox) Returns the coordinate in the north-west.static org.locationtech.jts.geom.CoordinategetSouthEast(double[] boundingBox) Returns the coordinate in the south-east.static org.locationtech.jts.geom.CoordinategetSouthWest(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
-
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 modelsrid- the sridcoordinateSequenceFactory- 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 modelsrid- 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 valuey- the y value- Returns:
- the coordinate
-
createCoordinate
Creates a coordinate.- Parameters:
x- the x valuey- the y value- Returns:
- the coordinate
- Throws:
IllegalArgumentException- if x or y isnull
-
createCoordinate
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 xy- the y- Returns:
- the point
-
createPoint
Create point.- Parameters:
x- the xy- the y- Returns:
- the point
-
createPoint
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 theLineString- 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 createdholes- 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 theMultiPoint- 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- theLineStrings of theMultiLineString- 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
Create lat lon.- Parameters:
coordinate- the coordinate- Returns:
- the lat lon
-
createLatLon
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
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 geometryg2- another geometry- Returns:
trueif the geometries are equal otherwisefalse
-
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:
nullif 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:
nullif 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
nullif the bounding box isnullor 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 aString.- 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 aReader.- Parameters:
reader- aReaderwhich will return a string (see the OpenGIS Simple Features Specification)- Returns:
- a Geometry read from reader
- Throws:
IllegalArgumentException- if a parsing problem occursIOException- 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 anInputStream.- Parameters:
inputStream- anInputStreamwhich 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 occursIOException- 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 geometryfilters- 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 geometryfilters- the filters- Returns:
- the copied and filtered geometry
-