Top
GeometryFactory(PrecisionModel, int, CoordinateSequenceFactory)
GeometryFactory(CoordinateSequenceFactory)
GeometryFactory(PrecisionModel)
GeometryFactory(PrecisionModel, int)
GeometryFactory()
createPointFromInternalCoord(Coordinate, Geometry): Point
toPointArray(Collection): Point[]
toGeometryArray(Collection): Geometry[]
toLinearRingArray(Collection): LinearRing[]
toLineStringArray(Collection): LineString[]
toPolygonArray(Collection): Polygon[]
toMultiPolygonArray(Collection): MultiPolygon[]
toMultiLineStringArray(Collection): MultiLineString[]
toMultiPointArray(Collection): MultiPoint[]
toGeometry(Envelope): Geometry
getPrecisionModel(): PrecisionModel
createPoint(): Point
createPoint(Coordinate): Point
createPoint(CoordinateSequence): Point
createMultiLineString(): MultiLineString
createMultiLineString(LineString[]): MultiLineString
createGeometryCollection(): GeometryCollection
createGeometryCollection(Geometry[]): GeometryCollection
createMultiPolygon(): MultiPolygon
createMultiPolygon(Polygon[]): MultiPolygon
createLinearRing(): LinearRing
createLinearRing(Coordinate[]): LinearRing
createLinearRing(CoordinateSequence): LinearRing
createMultiPoint(): MultiPoint
createMultiPoint(Point[]): MultiPoint
createMultiPoint(Coordinate[]): MultiPoint
createMultiPointFromCoords(Coordinate[]): MultiPoint
createMultiPoint(CoordinateSequence): MultiPoint
createPolygon(LinearRing, LinearRing[]): Polygon
createPolygon(CoordinateSequence): Polygon
createPolygon(Coordinate[]): Polygon
createPolygon(LinearRing): Polygon
createPolygon(): Polygon
buildGeometry(Collection): Geometry
createLineString(): LineString
createLineString(Coordinate[]): LineString
createLineString(CoordinateSequence): LineString
createEmpty(int): Geometry
createGeometry(Geometry): Geometry
getSRID(): int
getCoordinateSequenceFactory(): CoordinateSequenceFactory
Bottom

Class GeometryFactory

Hierarchy: Object , GeometryFactory
All Implemented Interfaces: Serializable
public class GeometryFactory
implements Serializable
Supplies a set of utility methods for building Geometry objects from lists of Coordinates.

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.

Other

  • version: 1.7
public GeometryFactory(PrecisionModel precisionModel, int SRID, CoordinateSequenceFactory coordinateSequenceFactory)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel, spatial-reference ID, and CoordinateSequence implementation.
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.
public GeometryFactory(PrecisionModel precisionModel)
Constructs a GeometryFactory that generates Geometries having the given PrecisionModel and the default CoordinateSequence implementation.
Parameters:
precisionModel - precisionModel the PrecisionModel to use
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.
Parameters:
precisionModel - precisionModel the PrecisionModel to use
SRID - SRID the SRID to use
public GeometryFactory()
Constructs a GeometryFactory that generates Geometries having a floating PrecisionModel and a spatial-reference ID of 0.
public static Point createPointFromInternalCoord(Coordinate coord, Geometry exemplar)
public static Point[] toPointArray(Collection points)
Converts the List to an array.
Parameters:
points - points the List of Points to convert
Returns:
the List in array format
public static Geometry[] toGeometryArray(Collection geometries)
Converts the List to an array.
Parameters:
geometries - geometries the list of Geometry's to convert
Returns:
the List in array format
public static LinearRing[] toLinearRingArray(Collection linearRings)
Converts the List to an array.
Parameters:
linearRings - linearRings the List of LinearRings to convert
Returns:
the List in array format
public static LineString[] toLineStringArray(Collection lineStrings)
Converts the List to an array.
Parameters:
lineStrings - lineStrings the List of LineStrings to convert
Returns:
the List in array format
public static Polygon[] toPolygonArray(Collection polygons)
Converts the List to an array.
Parameters:
polygons - polygons the List of Polygons to convert
Returns:
the List in array format
public static MultiPolygon[] toMultiPolygonArray(Collection multiPolygons)
Converts the List to an array.
Parameters:
multiPolygons - multiPolygons the List of MultiPolygons to convert
Returns:
the List in array format
public static MultiLineString[] toMultiLineStringArray(Collection multiLineStrings)
Converts the List to an array.
Parameters:
multiLineStrings - multiLineStrings the List of MultiLineStrings to convert
Returns:
the List in array format
public static MultiPoint[] toMultiPointArray(Collection multiPoints)
Converts the List to an array.
Parameters:
multiPoints - multiPoints the List of MultiPoints to convert
Returns:
the List in array format
public Geometry toGeometry(Envelope envelope)
Creates a 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:

  • null : returns an empty Point
  • a point : returns a non-empty Point
  • a line : returns a two-point LineString
  • a rectangle : returns a Polygon whose points are (minx, miny), (minx, maxy), (maxx, maxy), (maxx, miny), (minx, miny).
Parameters:
envelope - envelope the Envelope to convert
Returns:
an empty Point (for null Envelopes), a Point (when min x = max x and min y = max y) or a Polygon (in all other cases)
public PrecisionModel getPrecisionModel()
Returns the PrecisionModel that Geometries created by this factory will be associated with.
Returns:
the PrecisionModel for this factory
public Point createPoint()
Constructs an empty Point geometry.
Returns:
an empty Point
public Point createPoint(Coordinate coordinate)
Creates a Point using the given Coordinate. A null Coordinate creates an empty Geometry.
Parameters:
coordinate - coordinate a Coordinate, or null
Returns:
the created Point
public Point createPoint(CoordinateSequence coordinates)
Creates a Point using the given CoordinateSequence; a null or empty CoordinateSequence will create an empty Point.
Parameters:
coordinates - coordinates a CoordinateSequence (possibly empty), or null
Returns:
the created Point
public MultiLineString createMultiLineString()
Constructs an empty MultiLineString geometry.
Returns:
an empty MultiLineString
public MultiLineString createMultiLineString(LineString[] lineStrings)
Creates a MultiLineString using the given LineStrings; a null or empty array will create an empty MultiLineString.
Parameters:
lineStrings - lineStrings LineStrings, each of which may be empty but not null
Returns:
the created MultiLineString
public GeometryCollection createGeometryCollection()
Constructs an empty GeometryCollection geometry.
Returns:
an empty GeometryCollection
public GeometryCollection createGeometryCollection(Geometry[] geometries)
Creates a GeometryCollection using the given Geometries; a null or empty array will create an empty GeometryCollection.
Parameters:
geometries - geometries an array of Geometries, each of which may be empty but not null, or null
Returns:
the created GeometryCollection
public MultiPolygon createMultiPolygon()
Constructs an empty MultiPolygon geometry.
Returns:
an empty MultiPolygon
public MultiPolygon createMultiPolygon(Polygon[] polygons)
Creates a MultiPolygon using the given Polygons; a null or empty array will create an empty Polygon. The polygons must conform to the assertions specified in the OpenGIS Simple Features Specification for SQL.
Parameters:
polygons - polygons Polygons, each of which may be empty but not null
Returns:
the created MultiPolygon
public LinearRing createLinearRing()
Constructs an empty LinearRing geometry.
Returns:
an empty LinearRing
public LinearRing createLinearRing(Coordinate[] coordinates)
Creates a LinearRing using the given Coordinates. A null or empty array creates an empty LinearRing. The points must form a closed and simple linestring.
Parameters:
coordinates - coordinates an array without null elements, or an empty array, or null
Returns:
the created LinearRing
Throws:
IllegalArgumentException - IllegalArgumentException if the ring is not closed, or has too few points
public LinearRing createLinearRing(CoordinateSequence coordinates)
Creates a LinearRing using the given CoordinateSequence. A null or empty array creates an empty LinearRing. The points must form a closed and simple linestring.
Parameters:
coordinates - coordinates a CoordinateSequence (possibly empty), or null
Returns:
the created LinearRing
Throws:
IllegalArgumentException - IllegalArgumentException if the ring is not closed, or has too few points
public MultiPoint createMultiPoint()
Constructs an empty MultiPoint geometry.
Returns:
an empty MultiPoint
public MultiPoint createMultiPoint(Point[] point)
Creates a MultiPoint using the given Points. A null or empty array will create an empty MultiPoint.
Parameters:
point - point an array of Points (without null elements), or an empty array, or null
Returns:
a MultiPoint object
public MultiPoint createMultiPoint(Coordinate[] coordinates)
Creates a MultiPoint using the given Coordinates. A null or empty array will create an empty MultiPoint.
Parameters:
coordinates - coordinates an array (without null elements), or an empty array, or null
Returns:
a MultiPoint object
Deprecation:
Use GeometryFactory.createMultiPointFromCoords instead
public MultiPoint createMultiPointFromCoords(Coordinate[] coordinates)
Creates a MultiPoint using the given Coordinates. A null or empty array will create an empty MultiPoint.
Parameters:
coordinates - coordinates an array (without null elements), or an empty array, or null
Returns:
a MultiPoint object
public MultiPoint createMultiPoint(CoordinateSequence coordinates)
Creates a MultiPoint using the points in the given CoordinateSequence. A null or empty CoordinateSequence creates an empty MultiPoint.
Parameters:
coordinates - coordinates a CoordinateSequence (possibly empty), or null
Returns:
a MultiPoint geometry
public Polygon createPolygon(LinearRing shell, LinearRing[] holes)
Constructs a Polygon with the given exterior boundary and interior boundaries.
Parameters:
shell - shell the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.
holes - holes the inner boundaries of the new Polygon, or null or empty LinearRing s if the empty geometry is to be created.
Throws:
IllegalArgumentException - IllegalArgumentException if a ring is invalid
public Polygon createPolygon(CoordinateSequence shell)
Constructs a Polygon with the given exterior boundary.
Parameters:
shell - shell the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.
Throws:
IllegalArgumentException - IllegalArgumentException if the boundary ring is invalid
public Polygon createPolygon(Coordinate[] shell)
Constructs a Polygon with the given exterior boundary.
Parameters:
shell - shell the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.
Throws:
IllegalArgumentException - IllegalArgumentException if the boundary ring is invalid
public Polygon createPolygon(LinearRing shell)
Constructs a Polygon with the given exterior boundary.
Parameters:
shell - shell the outer boundary of the new Polygon, or null or an empty LinearRing if the empty geometry is to be created.
Throws:
IllegalArgumentException - IllegalArgumentException if the boundary ring is invalid
public Polygon createPolygon()
Constructs an empty Polygon geometry.
Returns:
an empty polygon
public Geometry buildGeometry(Collection geomList)
Build an appropriate Geometry, MultiGeometry, or GeometryCollection to contain the Geometrys in it. For example:
  • If geomList contains a single Polygon, the Polygon is returned.
  • If geomList contains several Polygons, a MultiPolygon is returned.
  • If geomList contains some Polygons and some LineStrings, 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.
Parameters:
geomList - geomList the Geometrys to combine
Returns:
a Geometry of the "smallest", "most type-specific" class that can contain the elements of geomList .
public LineString createLineString()
Constructs an empty LineString geometry.
Returns:
an empty LineString
public LineString createLineString(Coordinate[] coordinates)
Creates a LineString using the given Coordinates. A null or empty array creates an empty LineString.
Parameters:
coordinates - coordinates an array without null elements, or an empty array, or null
public LineString createLineString(CoordinateSequence coordinates)
Creates a LineString using the given CoordinateSequence. A null or empty CoordinateSequence creates an empty LineString.
Parameters:
coordinates - coordinates a CoordinateSequence (possibly empty), or null
public Geometry createEmpty(int dimension)
Creates an empty atomic geometry of the given dimension. If passed a dimension of -1 will create an empty GeometryCollection.
Parameters:
dimension - dimension the required dimension (-1, 0, 1 or 2)
Returns:
an empty atomic geometry of given dimension
public Geometry createGeometry(Geometry g)
Creates a deep copy of the input Geometry. The CoordinateSequenceFactory defined for this factory is used to copy the CoordinateSequences 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.

See also:
Geometry#copy()
Returns:
a deep copy of the input geometry, using the CoordinateSequence type of this factory
public int getSRID()
Gets the SRID value defined for this factory.
Returns:
the factory SRID value
public CoordinateSequenceFactory getCoordinateSequenceFactory()