Supplies a set of utility methods for building Geometry objects from lists
of Coordinates.
GeometryFactory
public GeometryFactory()
Constructs a GeometryFactory that generates Geometries having a floating
PrecisionModel and a spatial-reference ID of 0.
GeometryFactory
public 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
public GeometryFactory(PrecisionModel precisionModel)
Constructs a GeometryFactory that generates Geometries having the given
PrecisionModel
and the default CoordinateSequence
implementation.
precisionModel
- the PrecisionModel to use
GeometryFactory
public GeometryFactory(PrecisionModel precisionModel,
int SRID)
Constructs a GeometryFactory that generates Geometries having the given
PrecisionModel
and spatial-reference ID, and the default CoordinateSequence
implementation.
precisionModel
- the PrecisionModel to useSRID
- the SRID to use
GeometryFactory
public GeometryFactory(PrecisionModel precisionModel,
int SRID,
CoordinateSequenceFactory coordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given
PrecisionModel, spatial-reference ID, and CoordinateSequence implementation.
buildGeometry
public Geometry buildGeometry(Collection geomList)
Build an appropriate
Geometry
,
MultiGeometry
, or
GeometryCollection
to contain the
Geometry
s in
it.
For example:
- If
geomList
contains a single Polygon
,
the Polygon
is returned.
- If
geomList
contains several Polygon
s, a
MultiPolygon
is returned.
- If
geomList
contains some Polygon
s and
some LineString
s, a GeometryCollection
is
returned.
- If
geomList
is empty, an empty GeometryCollection
is returned
Note that this method does not "flatten" Geometries in the input, and hence if
any MultiGeometries are contained in the input a GeometryCollection containing
them will be returned.
geomList
- the Geometry
s to combine
- a
Geometry
of the "smallest", "most
type-specific" class that can contain the elements of geomList
.
createGeometry
public Geometry createGeometry(Geometry g)
- a clone of g based on a CoordinateSequence created by this
GeometryFactory's CoordinateSequenceFactory
createGeometryCollection
public GeometryCollection createGeometryCollection(Geometry[] geometries)
Creates a GeometryCollection using the given Geometries; a null or empty
array will create an empty GeometryCollection.
geometries
- Geometries, each of which may be empty but not null
createLineString
public LineString createLineString(CoordinateSequence coordinates)
Creates a LineString using the given CoordinateSequence; a null or empty CoordinateSequence will
create an empty LineString. Consecutive points must not be equal.
coordinates
- a CoordinateSequence possibly empty, or null
createLineString
public LineString createLineString(Coordinate[] coordinates)
Creates a LineString using the given Coordinates; a null or empty array will
create an empty LineString. Consecutive points must not be equal.
coordinates
- an array without null elements, or an empty array, or null
createLinearRing
public LinearRing createLinearRing(CoordinateSequence coordinates)
Creates a LinearRing using the given CoordinateSequence; a null or empty CoordinateSequence will
create an empty LinearRing. The points must form a closed and simple
linestring. Consecutive points must not be equal.
coordinates
- a CoordinateSequence possibly empty, or null
createLinearRing
public LinearRing createLinearRing(Coordinate[] coordinates)
Creates a LinearRing using the given Coordinates; a null or empty array will
create an empty LinearRing. The points must form a closed and simple
linestring. Consecutive points must not be equal.
coordinates
- an array without null elements, or an empty array, or null
createMultiLineString
public MultiLineString createMultiLineString(LineString[] lineStrings)
Creates a MultiLineString using the given LineStrings; a null or empty
array will create an empty MultiLineString.
lineStrings
- LineStrings, each of which may be empty but not null
createMultiPoint
public MultiPoint createMultiPoint(CoordinateSequence coordinates)
Creates a MultiPoint using the given CoordinateSequence; a null or empty CoordinateSequence will
create an empty MultiPoint.
coordinates
- a CoordinateSequence possibly empty, or null
createMultiPoint
public MultiPoint createMultiPoint(Coordinate[] coordinates)
Creates a MultiPoint using the given Coordinates; a null or empty array
will create an empty MultiPoint.
coordinates
- an array without null elements, or an empty array, or null
createMultiPoint
public MultiPoint createMultiPoint(Point[] point)
Creates a MultiPoint using the given Points; a null or empty array will
create an empty MultiPoint.
createMultiPolygon
public MultiPolygon createMultiPolygon(Polygon[] polygons)
polygons
- Polygons, each of which may be empty but not null
createPoint
public Point createPoint(Coordinate coordinate)
Creates a Point using the given Coordinate; a null Coordinate will create
an empty Geometry.
createPoint
public Point createPoint(CoordinateSequence coordinates)
Creates a Point using the given CoordinateSequence; a null or empty
CoordinateSequence will create an empty Point.
createPolygon
public Polygon createPolygon(LinearRing shell,
LinearRing[] holes)
Constructs a 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.
getPrecisionModel
public PrecisionModel getPrecisionModel()
Returns the PrecisionModel that Geometries created by this factory
will be associated with.
getSRID
public int getSRID()
toGeometry
public Geometry toGeometry(Envelope envelope)
If the Envelope
is a null Envelope
, returns an
empty Point
. If the Envelope
is a point, returns
a non-empty Point
. If the Envelope
is a
rectangle, returns a Polygon
whose points are (minx, miny),
(maxx, miny), (maxx, maxy), (minx, maxy), (minx, miny).
envelope
- the Envelope
to convert to a Geometry
- an empty
Point
(for null Envelope
s), a Point
(when min x = max x and min y = max y) or a
Polygon
(in all other cases)
toGeometryArray
public static Geometry[] toGeometryArray(Collection geometries)
Converts the List
to an array.
geometries
- the list of Geometry's
to convert
toLineStringArray
public static LineString[] toLineStringArray(Collection lineStrings)
Converts the List
to an array.
lineStrings
- the List
of LineStrings to convert
toLinearRingArray
public static LinearRing[] toLinearRingArray(Collection linearRings)
Converts the List
to an array.
linearRings
- the List
of LinearRings to convert
toMultiLineStringArray
public static MultiLineString[] toMultiLineStringArray(Collection multiLineStrings)
Converts the List
to an array.
multiLineStrings
- the List
of MultiLineStrings to convert
toMultiPointArray
public static MultiPoint[] toMultiPointArray(Collection multiPoints)
Converts the List
to an array.
multiPoints
- the List
of MultiPoints to convert
toMultiPolygonArray
public static MultiPolygon[] toMultiPolygonArray(Collection multiPolygons)
Converts the List
to an array.
multiPolygons
- the List
of MultiPolygons to convert
toPointArray
public static Point[] toPointArray(Collection points)
Converts the List
to an array.
points
- the List
of Points to convert
toPolygonArray
public static Polygon[] toPolygonArray(Collection polygons)
Converts the List
to an array.
polygons
- the List
of Polygons to convert