com.vividsolutions.jts.geom.util

Class GeometryTransformer


public class GeometryTransformer
extends java.lang.Object

A framework for processes which transform an input 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 handles ensuring 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 that may transform Polygons into Polygons, LineStrings or Points. This class would likely need to override the 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 to simply recursively transform each Geometry component into an identical object by copying.

Note that all transformX methods may return null, to avoid creating empty geometry objects. This will be handled correctly by the transformer. The @link transform} method itself will always return a geometry object.

Version:
1.6
See Also:
GeometryEditor

Field Summary

protected GeometryFactory
factory

Constructor Summary

GeometryTransformer()

Method Summary

protected CoordinateSequence
copy(CoordinateSequence seq)
Convenience method which provides statndard way of copying CoordinateSequences
protected CoordinateSequence
createCoordinateSequence(Coordinate[] coords)
Convenience method which provides statndard way of creating a CoordinateSequence
Geometry
getInputGeometry()
Geometry
transform(Geometry inputGeom)
protected CoordinateSequence
transformCoordinates(CoordinateSequence coords, Geometry parent)
protected Geometry
transformGeometryCollection(GeometryCollection geom, Geometry parent)
protected Geometry
transformLineString(LineString geom, Geometry parent)
protected Geometry
transformLinearRing(LinearRing geom, Geometry parent)
protected Geometry
transformMultiLineString(MultiLineString geom, Geometry parent)
protected Geometry
transformMultiPoint(MultiPoint geom, Geometry parent)
protected Geometry
transformMultiPolygon(MultiPolygon geom, Geometry parent)
protected Geometry
transformPoint(Point geom, Geometry parent)
protected Geometry
transformPolygon(Polygon geom, Geometry parent)

Field Details

factory

protected GeometryFactory factory

Constructor Details

GeometryTransformer

public GeometryTransformer()

Method Details

copy

protected final CoordinateSequence copy(CoordinateSequence seq)
Convenience method which provides statndard way of copying CoordinateSequences
Parameters:
seq - the sequence to copy
Returns:
a deep copy of the sequence

createCoordinateSequence

protected final CoordinateSequence createCoordinateSequence(Coordinate[] coords)
Convenience method which provides statndard way of creating a CoordinateSequence
Parameters:
coords - the coordinate array to copy
Returns:
a coordinate sequence for the array

getInputGeometry

public Geometry getInputGeometry()

transform

public final Geometry transform(Geometry inputGeom)

transformCoordinates

protected CoordinateSequence transformCoordinates(CoordinateSequence coords,
                                                  Geometry parent)

transformGeometryCollection

protected Geometry transformGeometryCollection(GeometryCollection geom,
                                               Geometry parent)

transformLineString

protected Geometry transformLineString(LineString geom,
                                       Geometry parent)

transformLinearRing

protected Geometry transformLinearRing(LinearRing geom,
                                       Geometry parent)

transformMultiLineString

protected Geometry transformMultiLineString(MultiLineString geom,
                                            Geometry parent)

transformMultiPoint

protected Geometry transformMultiPoint(MultiPoint geom,
                                       Geometry parent)

transformMultiPolygon

protected Geometry transformMultiPolygon(MultiPolygon geom,
                                         Geometry parent)

transformPoint

protected Geometry transformPoint(Point geom,
                                  Geometry parent)

transformPolygon

protected Geometry transformPolygon(Polygon geom,
                                    Geometry parent)