Class Factory
java.lang.Object
org.apache.sis.internal.feature.Geometries<org.locationtech.jts.geom.Geometry>
org.apache.sis.internal.feature.jts.Factory
- All Implemented Interfaces:
Serializable
The factory of geometry objects backed by Java Topology Suite (JTS).
- Since:
- 0.7
- Version:
- 1.2
- Author:
- Johann Sorel (Geomatys), Martin Desruisseaux (Geomatys), Alexis Manin (Geomatys)
- See Also:
-
Field Summary
FieldsFields inherited from class org.apache.sis.internal.feature.Geometries
BIDIMENSIONAL, library, pointClass, polygonClass, polylineClass, rootClass, TRIDIMENSIONAL -
Method Summary
Modifier and TypeMethodDescriptionGeometryWrapper<org.locationtech.jts.geom.Geometry> castOrWrap(Object geometry) Returns a wrapper for the given<G>orGeometryWrapper<G>geometry.GeometryWrapper<org.locationtech.jts.geom.Geometry> createFromComponents(GeometryType type, Object components) Creates a geometry from components.GeometryWrapper<org.locationtech.jts.geom.Geometry> createMultiPolygon(Object[] geometries) Creates a multi-polygon from an array of JTSPolygonorLinearRing.createPoint(double x, double y) Creates a two-dimensional point from the given coordinates.createPoint(double x, double y, double z) Creates a three-dimensional point from the given coordinates.createPoint(float x, float y) Single-precision variant ofcreatePoint(double, double).org.locationtech.jts.geom.GeometrycreatePolyline(boolean polygon, int dimension, Vector... coordinates) Creates a polyline from the given coordinate values.protected GeometryWrapper<org.locationtech.jts.geom.Geometry> createWrapper(org.locationtech.jts.geom.Geometry geometry) Creates a wrapper for the given geometry instance.final org.locationtech.jts.geom.GeometryFactoryfactory(boolean isFloat) Returns the geometry factory to use for the given precision.Class<?> getGeometryClass(GeometryType type) Returns the geometry class of the given instance.GeometryWrapper<org.locationtech.jts.geom.Geometry> parseWKB(ByteBuffer data) Reads the given Well Known Binary (WKB).GeometryWrapper<org.locationtech.jts.geom.Geometry> Parses the given Well Known Text (WKT).protected ObjectInvoked at deserialization time for obtaining the unique instance of thisGeometriesclass.Methods inherited from class org.apache.sis.internal.feature.Geometries
createPoint, implementation, implementation, isKnownType, mergePolylines, supportSinglePrecision, toGeometry2D, unsupported, unsupported, unwrap, wrap
-
Field Details
-
INSTANCE
The singleton instance of this factory.- See Also:
-
-
Method Details
-
readResolve
Invoked at deserialization time for obtaining the unique instance of thisGeometriesclass.- Returns:
INSTANCE.- Throws:
ObjectStreamException- if the object state is invalid.
-
getGeometryClass
Returns the geometry class of the given instance.- Overrides:
getGeometryClassin classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
type- type of geometry for which the class is desired.- Returns:
- implementation class for the geometry of the specified type.
-
castOrWrap
Returns a wrapper for the given<G>orGeometryWrapper<G>geometry.- Specified by:
castOrWrapin classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
geometry- the geometry instance to wrap (can benull).- Returns:
- a wrapper for the given geometry implementation, or
null. - Throws:
ClassCastException- if the given geometry is not an instance of valid type.- See Also:
-
createWrapper
protected GeometryWrapper<org.locationtech.jts.geom.Geometry> createWrapper(org.locationtech.jts.geom.Geometry geometry) Creates a wrapper for the given geometry instance.- Specified by:
createWrapperin classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
geometry- the geometry to wrap.- Returns:
- wrapper for the given geometry.
- See Also:
-
factory
public final org.locationtech.jts.geom.GeometryFactory factory(boolean isFloat) Returns the geometry factory to use for the given precision.- Parameters:
isFloat-truefor single-precision, orfalsefor double-precision (default).- Returns:
- the JTS geometry factory for the given precision.
- See Also:
-
createPoint
Single-precision variant ofcreatePoint(double, double).- Overrides:
createPointin classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
x- the first coordinate value.y- the second coordinate value.- Returns:
- the point for the given coordinate values.
- See Also:
-
createPoint
Creates a two-dimensional point from the given coordinates.- Specified by:
createPointin classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
x- the first coordinate value.y- the second coordinate value.- Returns:
- the point for the given coordinate values.
- See Also:
-
createPoint
Creates a three-dimensional point from the given coordinates.- Specified by:
createPointin classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
x- the first coordinate value.y- the second coordinate value.z- the third coordinate value.- Returns:
- the point for the given coordinate values.
- See Also:
-
createPolyline
public org.locationtech.jts.geom.Geometry createPolyline(boolean polygon, int dimension, Vector... coordinates) Creates a polyline from the given coordinate values. EachDouble.NaNcoordinate value starts a new path.- Specified by:
createPolylinein classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
polygon- whether to return the path as a polygon instead of polyline.dimension- the number of dimensions (2<G> or 3<G>).coordinates- sequence of (x,y) or (x,y,z) tuples.- Returns:
- the geometric object for the given points.
- Throws:
UnsupportedOperationException- if this operation is not implemented for the given number of dimensions.
-
createMultiPolygon
Creates a multi-polygon from an array of JTSPolygonorLinearRing. If some geometries are actually linear rings, they will be converted to polygons.- Specified by:
createMultiPolygonin classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
geometries- the polygons or linear rings to put in a multi-polygons.- Returns:
- the multi-polygon.
- Throws:
ClassCastException- if an element in the array is not a JTS geometry.IllegalArgumentException- if an element is a non-closed linear string.
-
createFromComponents
public GeometryWrapper<org.locationtech.jts.geom.Geometry> createFromComponents(GeometryType type, Object components) Creates a geometry from components. The expectedcomponentstype depend on the target geometry type:- If
typeis a multi-geometry, then the components shall be an array ofPoint,Geometry,LineStringorPolygonelements, depending on the desired target type. - Otherwise the components shall be an array or collection of
PointorCoordinateinstances, or a JTS-specificCoordinateSequence.
- Specified by:
createFromComponentsin classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
type- type of geometry to create.components- the components. Valid classes depend on the type of geometry to create.- Returns:
- geometry built from the given components.
- Throws:
ClassCastException- if the given object is not an array or a collection of supported geometry components.
- If
-
parseWKT
public GeometryWrapper<org.locationtech.jts.geom.Geometry> parseWKT(String wkt) throws org.locationtech.jts.io.ParseException Parses the given Well Known Text (WKT).- Specified by:
parseWKTin classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
wkt- the Well Known Text to parse.- Returns:
- the geometry object for the given WKT.
- Throws:
org.locationtech.jts.io.ParseException- if the WKT cannot be parsed.- See Also:
-
parseWKB
public GeometryWrapper<org.locationtech.jts.geom.Geometry> parseWKB(ByteBuffer data) throws org.locationtech.jts.io.ParseException Reads the given Well Known Binary (WKB). This implementation does not change the buffer position.- Specified by:
parseWKBin classGeometries<org.locationtech.jts.geom.Geometry>- Parameters:
data- the sequence of bytes to parse.- Returns:
- the geometry object for the given WKB.
- Throws:
org.locationtech.jts.io.ParseException- if the WKB cannot be parsed.
-