GeometryTransformer class
A framework for processes which transform an input {@link Geometry} into
an output {@link Geometry}, 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 whichever transformX
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 {@link #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 return null
,
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 return null
(for instance, it may not be possible for a transformLineString implementation
to return at least two points - in this case, it should return null
).
The {@link #transform(Geometry)} method itself will always
return a non-null Geometry object (but this may be empty).
@version 1.7
@see GeometryEditor
- Implementers
Constructors
Properties
- factory ↔ GeometryFactory
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- inputGeom ↔ Geometry
-
Possible extensions:
getParent() method to return immediate parent e.g. of LinearRings in Polygons
getter/setter pair
- preserveCollections ↔ bool
-
true
if the output from a collection argument should still be a collectiongetter/setter pair - preserveGeometryCollectionType ↔ bool
-
true
if a homogenous collection result from a {@link GeometryCollection} should still be a general GeometryCollectiongetter/setter pair - preserveType ↔ bool
-
true
if the type of the input should be preservedgetter/setter pair - pruneEmptyGeometry ↔ bool
-
true
if empty geometries should not be included in the resultgetter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
copy(
CoordinateSequence seq) → CoordinateSequence - Convenience method which provides a standard way of copying {@link CoordinateSequence}s @param seq the sequence to copy @return a deep copy of the sequence
-
createCoordinateSequence(
List< Coordinate> coords) → CoordinateSequence - Convenience method which provides standard way of creating a {@link CoordinateSequence}
-
getInputGeometry(
) → Geometry - Utility function to make input geometry available
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transform(
Geometry inputGeom) → Geometry -
transformCoordinates(
CoordinateSequence coords, Geometry parent) → CoordinateSequence - Transforms a {@link CoordinateSequence}. This method should always return a valid coordinate list for the desired result type. (E.g. a coordinate list for a LineString must have 0 or at least 2 points). If this is not possible, return an empty sequence - this will be pruned out.
-
transformGeometryCollection(
GeometryCollection geom, Geometry parent) → Geometry -
transformLinearRing(
LinearRing geom, Geometry parent) → Geometry - Transforms a LinearRing. The transformation of a LinearRing may result in a coordinate sequence which does not form a structurally valid ring (i.e. a degenerate ring of 3 or fewer points). In this case a LineString is returned. Subclasses may wish to override this method and check for this situation (e.g. a subclass may choose to eliminate degenerate linear rings)
-
transformLineString(
LineString geom, Geometry parent) → Geometry - Transforms a {@link LineString} geometry.
-
transformMultiLineString(
MultiLineString geom, Geometry parent) → Geometry -
transformMultiPoint(
MultiPoint geom, Geometry parent) → Geometry -
transformMultiPolygon(
MultiPolygon geom, Geometry parent) → Geometry -
transformPoint(
Point geom, Geometry parent) → Geometry -
transformPolygon(
Polygon geom, Geometry parent) → Geometry
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited