Overview | Package | Class | Tree | Deprecated | Index | Help
| JTS Topology Suite version 1.13
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.vividsolutions.jts.geom.util
Class GeometryTransformer

    java.lang.Object
      com.vividsolutions.jts.geom.util.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 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).

Version:
  1.7
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 `CoordinateSequence`s
`protected CoordinateSequence` | `createCoordinateSequence(Coordinate[] coords)` Convenience method which provides standard way of creating a `CoordinateSequence`
`Geometry` | `getInputGeometry()` Utility function to make input geometry available
`Geometry` | `transform(Geometry inputGeom)`
`protected CoordinateSequence` | `transformCoordinates(CoordinateSequence coords, Geometry parent)` Transforms a `CoordinateSequence`.
`protected Geometry` | `transformGeometryCollection(GeometryCollection geom, Geometry parent)`
`protected Geometry` | `transformLinearRing(LinearRing geom, 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 Geometry` | `transformPoint(Point geom, Geometry parent)`
`protected Geometry` | `transformPolygon(Polygon geom, Geometry parent)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### factory

    protected GeometryFactory factory

Constructor Detail

### GeometryTransformer

    public GeometryTransformer()

Method Detail

### getInputGeometry

    public Geometry getInputGeometry()

  Utility function to make input geometry available

  Returns:
    the input geometry

### transform

    public final Geometry transform(Geometry inputGeom)

### createCoordinateSequence

    protected final CoordinateSequence createCoordinateSequence(Coordinate[] coords)

  Convenience method which provides standard way of creating a `CoordinateSequence`

  Parameters:
    `coords` - the coordinate array to copy
  Returns:
    a coordinate sequence for the array

### copy

    protected final CoordinateSequence copy(CoordinateSequence seq)

  Convenience method which provides statndard way of copying `CoordinateSequence`s

  Parameters:
    `seq` - the sequence to copy
  Returns:
    a deep copy of the sequence

### transformCoordinates

    protected CoordinateSequence transformCoordinates(CoordinateSequence coords,
                                                      Geometry parent)

  Transforms a `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.

  Parameters:
    `coords` - the coordinates to transform
    `parent` - the parent geometry
  Returns:
    the transformed coordinates

### transformPoint

    protected Geometry transformPoint(Point geom,
                                      Geometry parent)

### transformMultiPoint

    protected Geometry transformMultiPoint(MultiPoint geom,
                                           Geometry parent)

### transformLinearRing

    protected Geometry transformLinearRing(LinearRing geom,
                                           Geometry parent)

  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 degnerate 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)

  Parameters:
    `geom` - the ring to simplify
    `parent` - the parent geometry
  Returns:
    a LinearRing if the transformation resulted in a structurally valid ring

### transformLineString

    protected Geometry transformLineString(LineString geom,
                                           Geometry parent)

  Transforms a `LineString` geometry.

  Parameters:
    `geom` -
    `parent` -
  Returns:

### transformMultiLineString

    protected Geometry transformMultiLineString(MultiLineString geom,
                                                Geometry parent)

### transformPolygon

    protected Geometry transformPolygon(Polygon geom,
                                        Geometry parent)

### transformMultiPolygon

    protected Geometry transformMultiPolygon(MultiPolygon geom,
                                             Geometry parent)

### transformGeometryCollection

    protected Geometry transformGeometryCollection(GeometryCollection geom,
                                                   Geometry parent)

Overview | Package | Class | Tree | Deprecated | Index | Help
| JTS Topology Suite version 1.13
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD