Class GeometryTransformer
- java.lang.Object
-
- org.locationtech.jts.geom.util.GeometryTransformer
-
public class GeometryTransformer extends java.lang.Object
A framework for processes which transform an inputGeometry
into an outputGeometry
, possibly changing its structure and type(s). This class is a framework for implementing subclasses which perform transformations on various different Geometry subclasses. It provides an easy way of applying specific transformations to given geometry types, while allowing unhandled types to be simply copied. Also, the framework ensures that if subcomponents change type the parent geometries types change appropriately to maintain valid structure. Subclasses will override whichevertransformX
methods they need to to handle particular Geometry types.A typically usage would be a transformation class that transforms Polygons into Polygons, LineStrings or Points, depending on the geometry of the input (For instance, a simplification operation). This class would likely need to override the
transformMultiPolygon(MultiPolygon, Geometry)
method to ensure that if input Polygons change type the result is a GeometryCollection, not a MultiPolygon.The default behaviour of this class is simply to recursively transform each Geometry component into an identical object by deep copying down to the level of, but not including, coordinates.
All
transformX
methods may returnnull
, to avoid creating empty or invalid geometry objects. This will be handled correctly by the transformer.transformXXX
methods should always return valid geometry - if they cannot do this they should returnnull
(for instance, it may not be possible for a transformLineString implementation to return at least two points - in this case, it should returnnull
). Thetransform(Geometry)
method itself will always return a non-null Geometry object (but this may be empty).- Version:
- 1.7
- See Also:
GeometryEditor
-
-
Constructor Summary
Constructors Constructor Description GeometryTransformer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Geometry
getInputGeometry()
Utility function to make input geometry availableGeometry
transform(Geometry inputGeom)
-