public class GeometryFactory
extends com.vividsolutions.jts.geom.GeometryFactory
The CPF provides an extended version of the Java Topology Suite (JTS) GeometryFactory to create JTS geometries. The extended version includes support for coordinate system projection, precision model, and controls on the number of axis.
The GeometryFactory
does not provide a public constructor. GeometryFactory
instances can
be obtained using the getFactory
static methods described below.
Modifier and Type | Method and Description |
---|---|
<G extends com.vividsolutions.jts.geom.Geometry> |
copy(G geometry)
Construct a new copy of an existing
Geometry . |
<T extends com.vividsolutions.jts.geom.Geometry> |
createGeometry(String wkt)
|
com.vividsolutions.jts.geom.LinearRing |
createLinearRing(double... coordinates)
Construct a new
LinearRing using the array of coordinates. |
com.vividsolutions.jts.geom.LineString |
createLineString(double... coordinates)
Construct a new
LineString using the array of coordinates. |
com.vividsolutions.jts.geom.MultiLineString |
createMultiLineString(Collection<?> lines)
Construct a new
MultiLineString using the list of lines. |
com.vividsolutions.jts.geom.MultiPoint |
createMultiPoint(List<?> points)
Construct a new
MultiPoint using the list of points. |
com.vividsolutions.jts.geom.Point |
createPoint(double... coordinates)
Construct a new point using the array of coordinates.
|
com.vividsolutions.jts.geom.Point |
createPoint(Object object) |
com.vividsolutions.jts.geom.Polygon |
createPolygon(List<?> rings)
Construct a new polygon using the list of rings.
|
int |
getAxisCount() |
static GeometryFactory |
getFactory()
Get a GeometryFactory with no coordinate system, 3D axis (x, y & z) and a floating precision model.
|
static GeometryFactory |
getFactory(double scaleXy)
Get a GeometryFactory with no coordinate system, 3D axis (x, y & z) and a fixed x, y &anp; floating z precision models.
|
static GeometryFactory |
getFactory(com.vividsolutions.jts.geom.Geometry geometry)
Get the geometry factory used for an existing geometry.
|
static GeometryFactory |
getFactory(int srid)
Get a GeometryFactory with the coordinate system, 3D axis (x, y & z) and a floating precision models.
|
static GeometryFactory |
getFactory(int srid,
double scaleXy)
Get a GeometryFactory with the coordinate system, 2D axis (x & y) and a fixed x, y precision model.
|
static GeometryFactory |
getFactory(int srid,
double scaleXy,
double scaleZ)
Get a GeometryFactory with no coordinate system, 3D axis (x, y & z) and a fixed x, y & floating z precision models.
|
static GeometryFactory |
getFactory(int srid,
int axisCount)
Get a GeometryFactory with the coordinate system, number of axis and a floating precision model.
|
static GeometryFactory |
getFactory(int srid,
int axisCount,
double scaleXy,
double scaleZ)
Get a GeometryFactory with the coordinate system, number of axis and a fixed x, y & fixed z precision models.
|
int |
getNumAxis() |
com.vividsolutions.jts.geom.Polygon[] |
getPolygonArray(Collection<?> polygonList) |
double |
getScaleXY() |
double |
getScaleZ() |
boolean |
hasM() |
boolean |
hasZ() |
com.vividsolutions.jts.geom.MultiPolygon |
multiPolygon(Collection<?> polygons)
Construct a new
MultiPolygon using the list of points. |
static String |
toWkt(com.vividsolutions.jts.geom.Geometry geometry) |
static String |
toWkt(com.vividsolutions.jts.geom.Geometry geometry,
boolean writeSrid) |
buildGeometry, createGeometry, createGeometryCollection, createLinearRing, createLinearRing, createLineString, createLineString, createMultiLineString, createMultiPoint, createMultiPoint, createMultiPoint, createMultiPolygon, createPoint, createPoint, createPointFromInternalCoord, createPolygon, createPolygon, createPolygon, createPolygon, getCoordinateSequenceFactory, getPrecisionModel, getSRID, toGeometry, toGeometryArray, toLinearRingArray, toLineStringArray, toMultiLineStringArray, toMultiPointArray, toMultiPolygonArray, toPointArray, toPolygonArray
public static GeometryFactory getFactory()
Get a GeometryFactory with no coordinate system, 3D axis (x, y & z) and a floating precision model.
public static GeometryFactory getFactory(double scaleXy)
Get a GeometryFactory with no coordinate system, 3D axis (x, y & z) and a fixed x, y &anp; 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 getFactory(com.vividsolutions.jts.geom.Geometry geometry)
geometry
- The geometry to get the factory from.public static GeometryFactory getFactory(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 getFactory(int srid, double scaleXy)
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 getFactory(int srid, double scaleXy, double scaleZ)
Get a GeometryFactory with no coordinate system, 3D axis (x, y & z) and a fixed x, y & floating z precision models.
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.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 getFactory(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 getFactory(int srid, int axisCount, double scaleXy, double scaleZ)
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 String toWkt(com.vividsolutions.jts.geom.Geometry geometry)
public static String toWkt(com.vividsolutions.jts.geom.Geometry geometry, boolean writeSrid)
public <G extends com.vividsolutions.jts.geom.Geometry> G copy(G geometry)
Construct a new copy of an existing Geometry
. If the geometry is in a different coordinate system
or precision model project the geometry to the coordinate system from this geometry factory
and apply the precision model.
The return type of this method will be auto-casted to the type of the variable the result is assigned to. Use Geometry as the type if it is not possible to guarantee that the geometry is of a specific geometry type.
G
- The class of geometry to cast the result to.geometry
- The geometry.public <T extends com.vividsolutions.jts.geom.Geometry> T createGeometry(String wkt)
Construct a new Geometry
from a WKT or
EWKT encoded geometry.
If the EWKT string includes a SRID the geometry will use read using that SRID and then
projected to the SRID of the geometry factory. If the SRID was not specified the geometry will
be assumed to be in the coordinate system of the geometry factory's SRID. The return type of
the WKT to geometry conversion will be auto-casted to the type of the variable the result is
assigned to. Use Geometry as the type if it is not possible to guarantee that the WKT is of a specific geometry type.
The following example shows a WGS84 EWKT polygon converted to a BC Albers polygon.
GeometryFactory geometryFactory = GeometryFactory.getFactory(3005, 1.0); String wkt = "SRID=4326;POLYGON((-122 50,-124 50,-124 51,-122 51,-122 50))"; Polygon polygon = createGeometry(wkt); System.out.println(polygon); // POLYGON((1286630 561884,1143372 555809,1140228 667065,1280345 673006,1286630 561884))
wkt
- The WKT or http://postgis.net/docs/manual-2.0/using_postgis_dbmanagement.html#EWKB_EWKT encoded geometry.public com.vividsolutions.jts.geom.LinearRing createLinearRing(double... coordinates)
Construct a new LinearRing
using the array of coordinates. The ring must form a closed loop.
The size of the array should be a multiple
of the number of axis. For example a 2D geometry will have x1,y1...,xN,yN values and a 3D x1,y1,z1...,xN,yN,zN.
Geographic coordinates are always longitude, latitude and projected easting, northing.
coordinates
- The coordinates.public com.vividsolutions.jts.geom.LineString createLineString(double... coordinates)
Construct a new LineString
using the array of coordinates. The size of the array should be a multiple
of the number of axis. For example a 2D geometry will have x1,y1...,xN,yN values and a 3D x1,y1,z1...,xN,yN,zN.
Geographic coordinates are always longitude, latitude and projected easting, northing.
coordinates
- The coordinates.public com.vividsolutions.jts.geom.MultiLineString createMultiLineString(Collection<?> lines)
Construct a new MultiLineString
using the list of lines. The first ring in the list is the exterior ring and
the other rings are the interior rings. The rings in the list can be any of the following types.
double[]
LineString
CoordinateSequence
For a double[]
the size of the array should be a multiple
of the number of axis. For example a 2D geometry will have x1,y1...,xN,yN values and a 3D x1,y1,z1...,xN,yN,zN.
Geographic coordinates are always longitude, latitude and projected easting, northing.
lines
- The list of lines.public com.vividsolutions.jts.geom.MultiPoint createMultiPoint(List<?> points)
Construct a new MultiPoint
using the list of points. The points in the list can be any of the following types.
double[]
Point
Coordinate
CoordinateSequence
For a double[]
the size of the array should be a multiple
of the number of axis. For example a 2D geometry will have x1,y1...,xN,yN values and a 3D x1,y1,z1...,xN,yN,zN.
Geographic coordinates are always longitude, latitude and projected easting, northing.
points
- The list of points.public com.vividsolutions.jts.geom.Point createPoint(double... coordinates)
Construct a new point using the array of coordinates. The size of the array should be the same as the number of axis used on this geometry factory. If the size is less then additional axis will be set to 0. If greater then those values will be ignored. For example a 2D geometry will have x,y values and a 3D x,y,z. Geographic coordinates are always longitude, latitude and projected easting, northing.
coordinates
- The coordinates.public com.vividsolutions.jts.geom.Point createPoint(Object object)
public com.vividsolutions.jts.geom.Polygon createPolygon(List<?> rings)
Construct a new polygon using the list of rings. The first ring in the list is the exterior ring and the other rings are the interior rings. The rings in the list can be any of the following types.
double[]
LineString
LinearRing
CoordinateSequence
For a double[]
the size of the array should be a multiple
of the number of axis. For example a 2D geometry will have x1,y1...,xN,yN values and a 3D x1,y1,z1...,xN,yN,zN.
Geographic coordinates are always longitude, latitude and projected easting, northing.
rings
- The list of rings.public int getAxisCount()
public int getNumAxis()
public com.vividsolutions.jts.geom.Polygon[] getPolygonArray(Collection<?> polygonList)
public double getScaleXY()
public double getScaleZ()
public boolean hasM()
public boolean hasZ()
public com.vividsolutions.jts.geom.MultiPolygon multiPolygon(Collection<?> polygons)
Construct a new MultiPolygon
using the list of points. The points in the list can be any of the following types.
Polygon
List
see createPolygon(List)
For a double[]
the size of the array should be a multiple
of the number of axis. For example a 2D geometry will have x1,y1...,xN,yN values and a 3D x1,y1,z1...,xN,yN,zN.
Geographic coordinates are always longitude, latitude and projected easting, northing.
polygons
- The list of polygons.Copyright © 2008–2017 Province of British Columbia. All rights reserved.