Package org.geotools.geometry.jts
Class GeometryCoordinateSequenceTransformer
- Object
-
- GeometryCoordinateSequenceTransformer
-
public class GeometryCoordinateSequenceTransformer extends Object
Service object that takes a geometry and applies aMathTransform
to the coordinates it contains, creating a new geometry as the transformed output.The standard usage pattern is to supply a
MathTransform
and @link CoordinateReferenceSystem} explicitly. Thetransform(Geometry)
method can then be used to construct transformed geometries using theGeometryFactory
andCoordinateSequenceFactory
of the input geometry.- Author:
- Andrea Aime, Martin Davis
-
-
Constructor Summary
Constructors Constructor Description GeometryCoordinateSequenceTransformer()
Creates a transformer which uses theCoordinateSequenceFactory
of the source geometries.GeometryCoordinateSequenceTransformer(CoordinateSequenceTransformer transformer)
Creates a transformer which uses a client-specifiedCoordinateSequenceTransformer
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
Sets the target coordinate reference system.void
setMathTransform(MathTransform transform)
Sets the math transform to be used for transformationGeometry
transform(Geometry g)
Applies the transform to the provided geometry, creating a new transformed geometry.LineString
transformLineString(LineString ls, GeometryFactory gf)
Point
transformPoint(Point point, GeometryFactory gf)
Polygon
transformPolygon(Polygon polygon, GeometryFactory gf)
-
-
-
Constructor Detail
-
GeometryCoordinateSequenceTransformer
public GeometryCoordinateSequenceTransformer()
Creates a transformer which uses theCoordinateSequenceFactory
of the source geometries.
-
GeometryCoordinateSequenceTransformer
public GeometryCoordinateSequenceTransformer(CoordinateSequenceTransformer transformer)
Creates a transformer which uses a client-specifiedCoordinateSequenceTransformer
.WARNING: The CoordinateSequenceTransformer must use the same
CoordinateSequenceFactory
as the output GeometryFactory, so that geometries are constructed consistently.
-
-
Method Detail
-
setMathTransform
public void setMathTransform(MathTransform transform)
Sets the math transform to be used for transformation
-
setCoordinateReferenceSystem
public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs)
Sets the target coordinate reference system.This value is used to set the coordinate reference system of geometries after they have been transformed.
- Parameters:
crs
- The target coordinate reference system.
-
transform
public Geometry transform(Geometry g) throws TransformException
Applies the transform to the provided geometry, creating a new transformed geometry.- Parameters:
g
- the geometry to transform- Returns:
- a new transformed geometry
- Throws:
TransformException
-
transformLineString
public LineString transformLineString(LineString ls, GeometryFactory gf) throws TransformException
- Throws:
TransformException
-
transformPoint
public Point transformPoint(Point point, GeometryFactory gf) throws TransformException
- Throws:
TransformException
-
transformPolygon
public Polygon transformPolygon(Polygon polygon, GeometryFactory gf) throws TransformException
- Throws:
TransformException
-
-