public class GeometryFactory extends Object implements Serializable, MapSerializer
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 Point meet the given precision.
| Modifier | Constructor and Description |
|---|---|
protected |
GeometryFactory(CoordinateSystem coordinateSystem,
int axisCount,
double... scales) |
protected |
GeometryFactory(int srid,
int axisCount,
double... scales) |
| Modifier and Type | Method and Description |
|---|---|
void |
addGeometries(List<Geometry> geometryList,
Geometry geometry) |
BoundingBox |
boundingBox() |
Geometry |
buildGeometry(Collection<? extends Geometry> geometries)
Build an appropriate
Geometry, MultiGeometry, or
GeometryCollection to contain the Geometrys in
it. |
static void |
clear() |
GeometryFactory |
convertAxisCount(int axisCount) |
GeometryFactory |
convertScales(double... scales) |
GeometryFactory |
convertSrid(int srid) |
double[] |
copyPrecise(double[] values) |
static GeometryFactory |
create(Map<String,Object> properties) |
Point |
createCoordinates(double... coordinates) |
Point |
createCoordinates(Point point) |
LineString |
createCoordinatesList(Collection<?> points) |
static GeometryFactory |
fixed(CoordinateSystem coordinateSystem,
int axisCount,
double... scales) |
static GeometryFactory |
fixed(int srid,
double... scales)
Get a GeometryFactory with the coordinate system, 2D axis (x & y) and a
fixed x, y precision model.
|
static GeometryFactory |
fixed(int srid,
int axisCount,
double... scales)
Get a GeometryFactory with the coordinate system, number of axis and a
fixed x, y & fixed z precision models.
|
static GeometryFactory |
fixedNoSrid(double... scales)
Get a GeometryFactory with no coordinate system, 3D axis (x, y & z) and
a fixed x, y & floating z precision models.
|
static GeometryFactory |
floating(CoordinateSystem coordinateSystem,
int axisCount)
get a geometry factory with a floating scale.
|
static GeometryFactory |
floating(int srid,
int axisCount)
Get a GeometryFactory with the coordinate system, number of axis and a
floating precision model.
|
static GeometryFactory |
floating3()
Get a GeometryFactory with no coordinate system, 3D axis (x, y & z) and
a floating precision model.
|
static GeometryFactory |
floating3(CoordinateSystem coordinateSystem)
get a 3d geometry factory with a floating scale.
|
static GeometryFactory |
floating3(int srid)
Get a GeometryFactory with the coordinate system, 3D axis (x, y & z)
and a floating precision models.
|
Geometry |
geometry() |
<V extends Geometry> |
geometry(Class<?> targetClass,
Geometry geometry)
Create a new geometry of the requested target geometry class.
|
<V extends Geometry> |
geometry(Collection<? extends Geometry> geometries)
Create a new geometry my flattening the input geometries, ignoring and null or empty
geometries.
|
<V extends Geometry> |
geometry(Geometry... geometries) |
Geometry |
geometry(Geometry geometry)
Creates a deep copy of the input
Geometry. |
<T extends Geometry> |
geometry(String wkt) |
<T extends Geometry> |
geometry(String wkt,
boolean useAxisCountFromGeometryFactory) |
GeometryCollection |
geometryCollection() |
<V extends GeometryCollection> |
geometryCollection(Collection<? extends Geometry> geometries) |
<V extends GeometryCollection> |
geometryCollection(Geometry... geometries) |
static GeometryFactory |
get(Object factory) |
int |
getAxisCount() |
static String |
getAxisName(int axisIndex) |
Point |
getCoordinates(Point point) |
CoordinatesOperation |
getCoordinatesOperation(GeometryFactory geometryFactory)
Get the
CoordinatesOperation to convert between this factory's and the other factory's
CoordinateSystem. |
CoordinateSystem |
getCoordinateSystem() |
static GeometryFactory |
getFactory(String wkt)
Get a GeometryFactory with the coordinate system, 3D axis (x, y & z)
and a floating precision models.
|
GeometryFactory |
getGeographicGeometryFactory() |
List<Geometry> |
getGeometries(Collection<? extends Geometry> geometries) |
LineString[] |
getLineStringArray(Collection<?> lines) |
int |
getMaximumSignificantDigits()
Returns the maximum number of significant digits provided by this
precision model.
|
Point[] |
getPointArray(Collection<?> pointsList) |
Polygon[] |
getPolygonArray(Collection<?> polygonList) |
Point[] |
getPrecise(Point... points) |
Point |
getPreciseCoordinates(Point point) |
double |
getResolution(int axisIndex) |
double |
getResolutionXy() |
double |
getResolutionZ() |
double |
getScale(int axisIndex) |
static double[] |
getScales(int axisCount,
double... scales) |
double |
getScaleXY() |
double |
getScaleZ() |
int |
getSrid()
Gets the srid value defined for this factory.
|
int |
hashCode() |
boolean |
hasM() |
boolean |
hasZ() |
protected void |
init(int axisCount,
double... scales) |
boolean |
isFloating() |
boolean |
isGeographics() |
boolean |
isProjected() |
boolean |
isSameCoordinateSystem(GeometryFactory geometryFactory) |
LinearRing |
linearRing() |
LinearRing |
linearRing(Collection<?> points) |
LinearRing |
linearRing(int axisCount,
double... coordinates) |
LinearRing |
linearRing(int axisCount,
int vertexCount,
double... coordinates) |
LinearRing |
linearRing(LineString points)
Creates a
LinearRing using the given LineString. |
LinearRing |
linearRing(Point... points)
Creates a
LinearRing using the given Coordinatess. |
LineSegment |
lineSegment(Point p0,
Point p1) |
LineString |
lineString() |
LineString |
lineString(Collection<?> points) |
LineString |
lineString(int axisCount,
double... coordinates) |
LineString |
lineString(int axisCount,
int vertexCount,
double... coordinates) |
LineString |
lineString(LineString lineString) |
LineString |
lineString(Point... points) |
void |
makePrecise(double... values) |
void |
makePrecise(double[] values,
double[] valuesPrecise) |
void |
makePrecise(int axisCount,
double... coordinates) |
double |
makePrecise(int axisIndex,
double value) |
double |
makeXyPrecise(double value) |
double |
makeZPrecise(double value) |
MultiLineString |
multiLineString(Collection<?> lines) |
MultiLineString |
multiLineString(Geometry geometry) |
MultiLineString |
multiLineString(LineString... lines)
Creates a MultiLineString using the given LineStrings; a null or empty
array will create an empty MultiLineString.
|
MultiLineString |
multiLineString(Object... lines) |
MultiPoint |
multiPoint() |
MultiPoint |
multiPoint(Collection<?> points) |
MultiPoint |
multiPoint(Geometry geometry) |
MultiPoint |
multiPoint(int axisCount,
double... coordinates) |
MultiPoint |
multiPoint(LineString coordinatesList)
Creates a
MultiPoint using the
points in the given LineString. |
MultiPoint |
multiPoint(Object... points) |
MultiPoint |
multiPoint(Point... points)
Creates a
MultiPoint using the given Points. |
MultiPolygon |
multiPolygon(Collection<?> polygons) |
MultiPolygon |
multiPolygon(Geometry geometry) |
MultiPolygon |
multiPolygon(Object... polygons) |
MultiPolygon |
multiPolygon(Polygon[] polygons)
Creates a MultiPolygon using the given Polygons; a null or empty array
will create an empty Polygon.
|
Point |
point()
Create an empty
Point. |
Point |
point(double... coordinates)
Create a new
Point from the specified point coordinates. |
Point |
point(LineString points)
Creates a Point using the given LineString; a null or empty
LineString will create an empty Point.
|
Point |
point(Object object)
Create a new
Point from the object using the following rules. |
Point |
point(Point point)
Create a new
Point from the specified point (Coordinates). |
PolygonImpl |
polygon() |
Polygon |
polygon(LinearRing shell)
Constructs a
Polygon with the given exterior boundary. |
Polygon |
polygon(LineString... rings) |
Polygon |
polygon(List<?> rings) |
Polygon |
polygon(Object... rings) |
Polygon |
polygon(Polygon polygon) |
<G extends Geometry> |
project(G geometry)
Project the geometry if it is in a different coordinate system
|
Map<String,Object> |
toMap()
Convert the object to a Map of property name, value pairs.
|
String |
toString() |
static GeometryFactory |
wgs84() |
static GeometryFactory |
worldMercator() |
protected GeometryFactory(CoordinateSystem coordinateSystem, int axisCount, double... scales)
protected GeometryFactory(int srid,
int axisCount,
double... scales)
public static void clear()
public static GeometryFactory create(Map<String,Object> properties)
public static GeometryFactory fixed(CoordinateSystem coordinateSystem, int axisCount, double... scales)
public static GeometryFactory fixed(int srid, double... scales)
Get a GeometryFactory with the coordinate system, 2D axis (x & y) and a fixed x, y precision model.
srid - The EPSG
coordinate system id.scaleXY - The scale factor used to round the x, y coordinates. The
precision is 1 / scaleXy. A scale factor of 1000 will give a
precision of 1 / 1000 = 1mm for projected coordinate systems using
metres.public static GeometryFactory fixed(int srid, int axisCount, double... scales)
Get a GeometryFactory with the coordinate system, number of axis and a fixed x, y & fixed z precision models.
srid - The EPSG
coordinate system id.axisCount - The number of coordinate axis. 2 for 2D x & y
coordinates. 3 for 3D x, y & z coordinates.scaleXY - The scale factor used to round the x, y coordinates. The
precision is 1 / scaleXy. A scale factor of 1000 will give a
precision of 1 / 1000 = 1mm for projected coordinate systems using
metres.scaleZ - The scale factor used to round the z coordinates. The
precision is 1 / scaleZ. A scale factor of 1000 will give a
precision of 1 / 1000 = 1mm for projected coordinate systems using
metres.public static GeometryFactory fixedNoSrid(double... scales)
Get a GeometryFactory with no coordinate system, 3D axis (x, y & z) and a fixed x, y & floating z precision models.
scaleXY - The scale factor used to round the x, y coordinates. The
precision is 1 / scaleXy. A scale factor of 1000 will give a
precision of 1 / 1000 = 1mm for projected coordinate systems using
metres.public static GeometryFactory floating(CoordinateSystem coordinateSystem, int axisCount)
public static GeometryFactory floating(int srid, int axisCount)
Get a GeometryFactory with the coordinate system, number of axis and a floating precision model.
srid - The EPSG
coordinate system id.axisCount - The number of coordinate axis. 2 for 2D x & y
coordinates. 3 for 3D x, y & z coordinates.public static GeometryFactory floating3()
Get a GeometryFactory with no coordinate system, 3D axis (x, y & z) and a floating precision model.
public static GeometryFactory floating3(CoordinateSystem coordinateSystem)
public static GeometryFactory floating3(int srid)
Get a GeometryFactory with the coordinate system, 3D axis (x, y & z) and a floating precision models.
srid - The EPSG
coordinate system id.public static GeometryFactory get(Object factory)
public static String getAxisName(int axisIndex)
public static GeometryFactory getFactory(String wkt)
Get a GeometryFactory with the coordinate system, 3D axis (x, y & z) and a floating precision models.
srid - The EPSG
coordinate system id.public static double[] getScales(int axisCount,
double... scales)
public static GeometryFactory wgs84()
public static GeometryFactory worldMercator()
public BoundingBox boundingBox()
public Geometry buildGeometry(Collection<? extends Geometry> geometries)
Geometry, MultiGeometry, or
GeometryCollection to contain the Geometrys in
it.
For example:geomList contains a single Polygon,
the Polygon is returned.
geomList contains several Polygons, a
MultiPolygon is returned.
geomList contains some Polygons and
some LineStrings, a GeometryCollection is
returned.
geomList is empty, an empty GeometryCollection
is returned
geometries - the Geometrys to combineGeometry of the "smallest", "most
type-specific" class that can contain the elements of geomList
.public GeometryFactory convertAxisCount(int axisCount)
public GeometryFactory convertScales(double... scales)
public GeometryFactory convertSrid(int srid)
public double[] copyPrecise(double[] values)
public Point createCoordinates(double... coordinates)
public LineString createCoordinatesList(Collection<?> points)
public Geometry geometry()
public <V extends Geometry> V geometry(Class<?> targetClass, Geometry geometry)
Create a new geometry of the requested target geometry class.
targetClass - geometry - public <V extends Geometry> V geometry(Collection<? extends Geometry> geometries)
GeometryCollection will be returned.
If there is one geometry that single geometry will be returned. Otherwise the result
will be a subclass of GeometryCollection.geometries - public Geometry geometry(Geometry geometry)
Geometry.
This is a convenient way to change the LineString used to represent a geometry, or to change the factory used for a geometry.
Geometry.clone() can also be used to make a deep copy,
but it does not allow changing the LineString type.
Geometry.clone()public <T extends Geometry> T geometry(String wkt, boolean useAxisCountFromGeometryFactory)
public GeometryCollection geometryCollection()
public <V extends GeometryCollection> V geometryCollection(Collection<? extends Geometry> geometries)
public <V extends GeometryCollection> V geometryCollection(Geometry... geometries)
public int getAxisCount()
public CoordinatesOperation getCoordinatesOperation(GeometryFactory geometryFactory)
Get the CoordinatesOperation to convert between this factory's and the other factory's
CoordinateSystem.
geometryFactory - The geometry factory to convert to.public CoordinateSystem getCoordinateSystem()
public GeometryFactory getGeographicGeometryFactory()
public List<Geometry> getGeometries(Collection<? extends Geometry> geometries)
public LineString[] getLineStringArray(Collection<?> lines)
public int getMaximumSignificantDigits()
This method would be more correctly called getMinimumDecimalPlaces, since it actually computes the number of decimal places that is required to correctly display the full precision of an ordinate value.
Since it is difficult to compute the required number of decimal places for scale factors which are not powers of 10, the algorithm uses a very rough approximation in this case. This has the side effect that for scale factors which are powers of 10 the value returned is 1 greater than the true value.
public Point[] getPointArray(Collection<?> pointsList)
public Polygon[] getPolygonArray(Collection<?> polygonList)
public double getResolution(int axisIndex)
public double getResolutionXy()
public double getResolutionZ()
public double getScale(int axisIndex)
public double getScaleXY()
public double getScaleZ()
public int getSrid()
public boolean hasM()
public boolean hasZ()
protected void init(int axisCount,
double... scales)
public boolean isFloating()
public boolean isGeographics()
public boolean isProjected()
public boolean isSameCoordinateSystem(GeometryFactory geometryFactory)
public LinearRing linearRing()
public LinearRing linearRing(Collection<?> points)
public LinearRing linearRing(int axisCount, double... coordinates)
public LinearRing linearRing(int axisCount, int vertexCount, double... coordinates)
public LinearRing linearRing(LineString points)
LinearRing using the given LineString.
A null or empty array creates an empty LinearRing.
The points must form a closed and simple linestring.coordinates - a LineString (possibly empty), or nullIllegalArgumentException - if the ring is not closed, or has too few pointspublic LinearRing linearRing(Point... points)
LinearRing using the given Coordinatess.
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 LineSegment lineSegment(Point p0, Point p1)
public LineString lineString()
public LineString lineString(Collection<?> points)
public LineString lineString(int axisCount, double... coordinates)
public LineString lineString(int axisCount, int vertexCount, double... coordinates)
public LineString lineString(LineString lineString)
public LineString lineString(Point... points)
public void makePrecise(double... values)
public void makePrecise(double[] values,
double[] valuesPrecise)
public double makePrecise(int axisIndex,
double value)
public void makePrecise(int axisCount,
double... coordinates)
public double makeXyPrecise(double value)
public double makeZPrecise(double value)
public MultiLineString multiLineString(Collection<?> lines)
public MultiLineString multiLineString(Geometry geometry)
public MultiLineString multiLineString(LineString... lines)
lineStrings - LineStrings, each of which may be empty but not nullpublic MultiLineString multiLineString(Object... lines)
public MultiPoint multiPoint()
public MultiPoint multiPoint(Collection<?> points)
public MultiPoint multiPoint(Geometry geometry)
public MultiPoint multiPoint(int axisCount, double... coordinates)
public MultiPoint multiPoint(LineString coordinatesList)
MultiPoint using the
points in the given LineString.
A null or empty LineString creates an empty MultiPoint.coordinates - a LineString (possibly empty), or nullpublic MultiPoint multiPoint(Object... points)
public MultiPoint multiPoint(Point... points)
MultiPoint using the given Points.
A null or empty array will create an empty MultiPoint.coordinates - an array (without null elements), or an empty array, or nullpublic MultiPolygon multiPolygon(Collection<?> polygons)
public MultiPolygon multiPolygon(Geometry geometry)
public MultiPolygon multiPolygon(Object... polygons)
public MultiPolygon multiPolygon(Polygon[] polygons)
polygons - Polygons, each of which may be empty but not nullpublic Point point(double... coordinates)
Create a new Point from the specified point coordinates.
If the point is null or has length < 2 an empty point will be returned.
The result point will have the same getAxisCount() from this factory.
Additional coordinates in the point will be ignored. If the point length is <
getAxisCount() then Double.NaN will be used for that axis.
point - The coordinates to create the point from.public Point point(LineString points)
points - a LineString (possibly empty), or nullpublic Point point(Object object)
Create a new Point from the object using the following rules.
null using point()Point using Geometry.copy(GeometryFactory)Coordinates using point(Point)LineString using point(LineString)double[] using point(double[])IllegalArgumentException.point - The coordinates to create the point from.IllegalArgumentException - If the object is not an instance of a supported class.public Point point(Point point)
Create a new Point from the specified point (Coordinates).
If the point is null or has Coordinates#getAxisCount() < 2 an empty
point will be returned. The result point will have the same getAxisCount() from this
factory. Additional axis in the point will be ignored. If the point has a smaller
Geometry.getAxisCount() then Double.NaN will be used for that axis.
point - The coordinates to create the point from.public PolygonImpl polygon()
public Polygon polygon(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 polygon(LineString... rings)
public <G extends Geometry> G project(G geometry)
geometry - public Map<String,Object> toMap()
MapSerializerConvert the object to a Map of property name, value pairs. The values can be one of the following supported types. Other values should be converted to one of these values.
toMap in interface MapSerializerCopyright © 2015 Revolution Systems Inc.. All rights reserved.