public class GeometryFactory extends Object implements Serializable
Note that the factory constructor methods do not change the input coordinates in any way. In particular, they are not rounded to the supplied PrecisionModel. It is assumed that input Coordinates meet the given precision.
Instances of this class are thread-safe.
Constructor and Description |
---|
GeometryFactory()
Constructs a GeometryFactory that generates Geometries having a floating
PrecisionModel and a spatial-reference ID of 0.
|
GeometryFactory(CoordinateSequenceFactory coordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given
CoordinateSequence implementation, a double-precision floating PrecisionModel and a
spatial-reference ID of 0.
|
GeometryFactory(PrecisionModel precisionModel)
Constructs a GeometryFactory that generates Geometries having the given
PrecisionModel and the default CoordinateSequence
implementation. |
GeometryFactory(PrecisionModel precisionModel,
int SRID)
Constructs a GeometryFactory that generates Geometries having the given
PrecisionModel and spatial-reference ID, and the default CoordinateSequence
implementation. |
GeometryFactory(PrecisionModel precisionModel,
int SRID,
CoordinateSequenceFactory coordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given
PrecisionModel, spatial-reference ID, and CoordinateSequence implementation.
|
Modifier and Type | Method and Description |
---|---|
Geometry |
buildGeometry(Collection geomList)
Build an appropriate
Geometry , MultiGeometry , or
GeometryCollection to contain the Geometry s in
it. |
Geometry |
createEmpty(int dimension)
Creates an empty atomic geometry of the given dimension.
|
Geometry |
createGeometry(Geometry g)
Creates a deep copy of the input
Geometry . |
GeometryCollection |
createGeometryCollection()
Constructs an empty
GeometryCollection geometry. |
GeometryCollection |
createGeometryCollection(Geometry[] geometries)
Creates a GeometryCollection using the given Geometries; a null or empty
array will create an empty GeometryCollection.
|
LinearRing |
createLinearRing()
Constructs an empty
LinearRing geometry. |
LinearRing |
createLinearRing(Coordinate[] coordinates)
Creates a
LinearRing using the given Coordinate s. |
LinearRing |
createLinearRing(CoordinateSequence coordinates)
Creates a
LinearRing using the given CoordinateSequence . |
LineString |
createLineString()
Constructs an empty
LineString geometry. |
LineString |
createLineString(Coordinate[] coordinates)
Creates a LineString using the given Coordinates.
|
LineString |
createLineString(CoordinateSequence coordinates)
Creates a LineString using the given CoordinateSequence.
|
MultiLineString |
createMultiLineString()
Constructs an empty
MultiLineString geometry. |
MultiLineString |
createMultiLineString(LineString[] lineStrings)
Creates a MultiLineString using the given LineStrings; a null or empty
array will create an empty MultiLineString.
|
MultiPoint |
createMultiPoint()
Constructs an empty
MultiPoint geometry. |
MultiPoint |
createMultiPoint(Coordinate[] coordinates)
Deprecated.
|
MultiPoint |
createMultiPoint(CoordinateSequence coordinates)
Creates a
MultiPoint using the
points in the given CoordinateSequence . |
MultiPoint |
createMultiPoint(Point[] point)
Creates a
MultiPoint using the given Point s. |
MultiPoint |
createMultiPointFromCoords(Coordinate[] coordinates)
Creates a
MultiPoint using the given Coordinate s. |
MultiPolygon |
createMultiPolygon()
Constructs an empty
MultiPolygon geometry. |
MultiPolygon |
createMultiPolygon(Polygon[] polygons)
Creates a MultiPolygon using the given Polygons; a null or empty array
will create an empty Polygon.
|
Point |
createPoint()
Constructs an empty
Point geometry. |
Point |
createPoint(Coordinate coordinate)
Creates a Point using the given Coordinate.
|
Point |
createPoint(CoordinateSequence coordinates)
Creates a Point using the given CoordinateSequence; a null or empty
CoordinateSequence will create an empty Point.
|
static Point |
createPointFromInternalCoord(Coordinate coord,
Geometry exemplar) |
Polygon |
createPolygon()
Constructs an empty
Polygon geometry. |
Polygon |
createPolygon(Coordinate[] shell)
Constructs a
Polygon with the given exterior boundary. |
Polygon |
createPolygon(CoordinateSequence shell)
Constructs a
Polygon with the given exterior boundary. |
Polygon |
createPolygon(LinearRing shell)
Constructs a
Polygon with the given exterior boundary. |
Polygon |
createPolygon(LinearRing shell,
LinearRing[] holes)
Constructs a
Polygon with the given exterior boundary and
interior boundaries. |
CoordinateSequenceFactory |
getCoordinateSequenceFactory() |
PrecisionModel |
getPrecisionModel()
Returns the PrecisionModel that Geometries created by this factory
will be associated with.
|
int |
getSRID()
Gets the SRID value defined for this factory.
|
Geometry |
toGeometry(Envelope envelope)
Creates a
Geometry with the same extent as the given envelope. |
static Geometry[] |
toGeometryArray(Collection geometries)
Converts the
List to an array. |
static LinearRing[] |
toLinearRingArray(Collection linearRings)
Converts the
List to an array. |
static LineString[] |
toLineStringArray(Collection lineStrings)
Converts the
List to an array. |
static MultiLineString[] |
toMultiLineStringArray(Collection multiLineStrings)
Converts the
List to an array. |
static MultiPoint[] |
toMultiPointArray(Collection multiPoints)
Converts the
List to an array. |
static MultiPolygon[] |
toMultiPolygonArray(Collection multiPolygons)
Converts the
List to an array. |
static Point[] |
toPointArray(Collection points)
Converts the
List to an array. |
static Polygon[] |
toPolygonArray(Collection polygons)
Converts the
List to an array. |
public GeometryFactory(PrecisionModel precisionModel, int SRID, CoordinateSequenceFactory coordinateSequenceFactory)
public GeometryFactory(CoordinateSequenceFactory coordinateSequenceFactory)
public GeometryFactory(PrecisionModel precisionModel)
PrecisionModel
and the default CoordinateSequence
implementation.precisionModel
- the PrecisionModel to usepublic GeometryFactory(PrecisionModel precisionModel, int SRID)
PrecisionModel
and spatial-reference ID, and the default CoordinateSequence
implementation.precisionModel
- the PrecisionModel to useSRID
- the SRID to usepublic GeometryFactory()
public static Point createPointFromInternalCoord(Coordinate coord, Geometry exemplar)
public static Point[] toPointArray(Collection points)
List
to an array.points
- the List
of Points to convertList
in array formatpublic static Geometry[] toGeometryArray(Collection geometries)
List
to an array.geometries
- the list of Geometry's
to convertList
in array formatpublic static LinearRing[] toLinearRingArray(Collection linearRings)
List
to an array.linearRings
- the List
of LinearRings to convertList
in array formatpublic static LineString[] toLineStringArray(Collection lineStrings)
List
to an array.lineStrings
- the List
of LineStrings to convertList
in array formatpublic static Polygon[] toPolygonArray(Collection polygons)
List
to an array.polygons
- the List
of Polygons to convertList
in array formatpublic static MultiPolygon[] toMultiPolygonArray(Collection multiPolygons)
List
to an array.multiPolygons
- the List
of MultiPolygons to convertList
in array formatpublic static MultiLineString[] toMultiLineStringArray(Collection multiLineStrings)
List
to an array.multiLineStrings
- the List
of MultiLineStrings to convertList
in array formatpublic static MultiPoint[] toMultiPointArray(Collection multiPoints)
List
to an array.multiPoints
- the List
of MultiPoints to convertList
in array formatpublic Geometry toGeometry(Envelope envelope)
Geometry
with the same extent as the given envelope.
The Geometry returned is guaranteed to be valid.
To provide this behaviour, the following cases occur:
If the Envelope
is:
Point
Point
LineString
Polygon
whose points are (minx, miny),
(minx, maxy), (maxx, maxy), (maxx, miny), (minx, miny).
envelope
- the Envelope
to convertPoint
(for null Envelope
s),
a Point
(when min x = max x and min y = max y) or a
Polygon
(in all other cases)public PrecisionModel getPrecisionModel()
public Point createPoint(Coordinate coordinate)
coordinate
- a Coordinate, or nullpublic Point createPoint(CoordinateSequence coordinates)
coordinates
- a CoordinateSequence (possibly empty), or nullpublic MultiLineString createMultiLineString()
MultiLineString
geometry.public MultiLineString createMultiLineString(LineString[] lineStrings)
lineStrings
- LineStrings, each of which may be empty but not nullpublic GeometryCollection createGeometryCollection()
GeometryCollection
geometry.public GeometryCollection createGeometryCollection(Geometry[] geometries)
geometries
- an array of Geometries, each of which may be empty but not null, or nullpublic MultiPolygon createMultiPolygon()
MultiPolygon
geometry.public MultiPolygon createMultiPolygon(Polygon[] polygons)
polygons
- Polygons, each of which may be empty but not nullpublic LinearRing createLinearRing()
LinearRing
geometry.public LinearRing createLinearRing(Coordinate[] coordinates)
LinearRing
using the given Coordinate
s.
A null or empty array creates an empty LinearRing.
The points must form a closed and simple linestring.coordinates
- an array without null elements, or an empty array, or nullIllegalArgumentException
- if the ring is not closed, or has too few pointspublic LinearRing createLinearRing(CoordinateSequence coordinates)
LinearRing
using the given CoordinateSequence
.
A null or empty array creates an empty LinearRing.
The points must form a closed and simple linestring.coordinates
- a CoordinateSequence (possibly empty), or nullIllegalArgumentException
- if the ring is not closed, or has too few pointspublic MultiPoint createMultiPoint()
MultiPoint
geometry.public MultiPoint createMultiPoint(Point[] point)
MultiPoint
using the given Point
s.
A null or empty array will create an empty MultiPoint.point
- an array of Points (without null elements), or an empty array, or null
public MultiPoint createMultiPoint(Coordinate[] coordinates)
createMultiPointFromCoords(org.locationtech.jts.geom.Coordinate[])
insteadMultiPoint
using the given Coordinate
s.
A null or empty array will create an empty MultiPoint.coordinates
- an array (without null elements), or an empty array, or null
public MultiPoint createMultiPointFromCoords(Coordinate[] coordinates)
MultiPoint
using the given Coordinate
s.
A null or empty array will create an empty MultiPoint.coordinates
- an array (without null elements), or an empty array, or null
public MultiPoint createMultiPoint(CoordinateSequence coordinates)
MultiPoint
using the
points in the given CoordinateSequence
.
A null
or empty CoordinateSequence creates an empty MultiPoint.coordinates
- a CoordinateSequence (possibly empty), or null
public Polygon createPolygon(LinearRing shell, LinearRing[] holes)
Polygon
with the given exterior boundary and
interior boundaries.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.IllegalArgumentException
- if a ring is invalidpublic Polygon createPolygon(CoordinateSequence shell)
Polygon
with the given exterior boundary.shell
- the outer boundary of the new Polygon
, or
null
or an empty LinearRing
if
the empty geometry is to be created.IllegalArgumentException
- if the boundary ring is invalidpublic Polygon createPolygon(Coordinate[] shell)
Polygon
with the given exterior boundary.shell
- the outer boundary of the new Polygon
, or
null
or an empty LinearRing
if
the empty geometry is to be created.IllegalArgumentException
- if the boundary ring is invalidpublic Polygon createPolygon(LinearRing shell)
Polygon
with the given exterior boundary.shell
- the outer boundary of the new Polygon
, or
null
or an empty LinearRing
if
the empty geometry is to be created.IllegalArgumentException
- if the boundary ring is invalidpublic Polygon createPolygon()
Polygon
geometry.public Geometry buildGeometry(Collection geomList)
Geometry
, MultiGeometry
, or
GeometryCollection
to contain the Geometry
s in
it.
For example:geomList
contains a single Polygon
,
the Polygon
is returned.
geomList
contains several Polygon
s, a
MultiPolygon
is returned.
geomList
contains some Polygon
s and
some LineString
s, a GeometryCollection
is
returned.
geomList
is empty, an empty GeometryCollection
is returned
geomList
- the Geometry
s to combineGeometry
of the "smallest", "most
type-specific" class that can contain the elements of geomList
.public LineString createLineString()
LineString
geometry.public LineString createLineString(Coordinate[] coordinates)
coordinates
- an array without null elements, or an empty array, or nullpublic LineString createLineString(CoordinateSequence coordinates)
coordinates
- a CoordinateSequence (possibly empty), or nullpublic Geometry createEmpty(int dimension)
GeometryCollection
.dimension
- the required dimension (-1, 0, 1 or 2)public Geometry createGeometry(Geometry g)
Geometry
.
The CoordinateSequenceFactory
defined for this factory
is used to copy the CoordinateSequence
s
of the input geometry.
This is a convenient way to change the CoordinateSequence used to represent a geometry, or to change the factory used for a geometry.
Geometry.copy()
can also be used to make a deep copy,
but it does not allow changing the CoordinateSequence type.
Geometry.copy()
public int getSRID()
public CoordinateSequenceFactory getCoordinateSequenceFactory()
Copyright © 2022. All rights reserved.