public abstract class GeometryTransformer extends Object
Geometry into
an output 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 #transformMultiPolygon(MultiPolygon, Geometry)transformMultiPolygon
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 #transform(Geometry)transform method itself will always
return a non-null Geometry object (but this may be empty).
| Modifier and Type | Field and Description |
|---|---|
protected GeometryFactory |
factory |
| Constructor and Description |
|---|
GeometryTransformer() |
| Modifier and Type | Method and Description |
|---|---|
protected LineString |
copy(LineString seq)
Convenience method which provides statndard way of copying
LineStrings |
Geometry |
getInputGeometry()
Utility function to make input geometry available
|
Geometry |
transform(Geometry inputGeom) |
protected LineString |
transformCoordinates(LineString coords,
Geometry parent)
Transforms a
LineString. |
protected Geometry |
transformGeometryCollection(GeometryCollection geom,
Geometry parent) |
protected Geometry |
transformLinearRing(LinearRing geometry,
Geometry parent)
Transforms a LinearRing.
|
protected Geometry |
transformLineString(LineString geom,
Geometry parent)
Transforms a
LineString geometry. |
protected Geometry |
transformMultiLineString(MultiLineString geom,
Geometry parent) |
protected Geometry |
transformMultiPoint(MultiPoint geom,
Geometry parent) |
protected Geometry |
transformMultiPolygon(MultiPolygon geom,
Geometry parent) |
protected abstract Geometry |
transformPoint(Point point,
Geometry parent) |
protected Geometry |
transformPolygon(Polygon geom,
Geometry parent) |
protected GeometryFactory factory
protected final LineString copy(LineString seq)
LineStringsseq - the sequence to copypublic Geometry getInputGeometry()
protected LineString transformCoordinates(LineString coords, Geometry parent)
LineString.
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.coords - the coordinates to transformparent - the parent geometryprotected Geometry transformGeometryCollection(GeometryCollection geom, Geometry parent)
protected Geometry transformLinearRing(LinearRing geometry, Geometry parent)
geom - the ring to simplifyparent - the parent geometryprotected Geometry transformLineString(LineString geom, Geometry parent)
LineString geometry.geom - parent - protected Geometry transformMultiLineString(MultiLineString geom, Geometry parent)
protected Geometry transformMultiPoint(MultiPoint geom, Geometry parent)
protected Geometry transformMultiPolygon(MultiPolygon geom, Geometry parent)
Copyright © 2015 Revolution Systems Inc.. All rights reserved.