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

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

    java.lang.Object
      com.vividsolutions.jts.geom.util.GeometryEditor

public class GeometryEditor
extends java.lang.Object

A class which supports creating new `Geometry`s which are modifications of existing ones. Geometry objects are intended to be treated as immutable. This class "modifies" Geometrys by traversing them, applying a user-defined `GeometryEditOperation` or `GeometryEditor.CoordinateOperation` and creating new Geometrys with the same structure but (possibly) modified components.

Examples of the kinds of modifications which can be made are:

- the values of the coordinates may be changed. The editor does not check whether changing coordinate values makes the result Geometry invalid
- the coordinate lists may be changed (e.g. by adding or deleting coordinates). The modifed coordinate lists must be consistent with their original parent component (e.g. a LinearRing must always have at least 4 coordinates, and the first and last coordinate must be equal)
- components of the original geometry may be deleted ( e.g. holes may be removed from a Polygon, or LineStrings removed from a MultiLineString). Deletions will be propagated up the component tree appropriately.

All changes must be consistent with the original Geometry's structure (e.g. a `Polygon` cannot be collapsed into a `LineString`). If changing the structure is required, use a `GeometryTransformer`.

This class supports the case where an edited Geometry needs to be created under a new GeometryFactory, via the `GeometryEditor(GeometryFactory)` constructor. Examples of situations where this is required is if the geometry is transformed to a new SRID and/or a new PrecisionModel.

The resulting Geometry is not checked for validity. If validity needs to be enforced, the new Geometry's `#isValid` method should be called.

Version:
  1.7
See Also:
  `GeometryTransformer`, `Geometry.isValid()`

Nested Class Summary
`static class` | `GeometryEditor.CoordinateOperation` A `GeometryEditorOperation` which modifies the coordinate list of a `Geometry`.
`static interface` | `GeometryEditor.GeometryEditorOperation` A interface which specifies an edit operation for Geometries.

Constructor Summary
`GeometryEditor()` Creates a new GeometryEditor object which will create edited `Geometry`s with the same `GeometryFactory` as the input Geometry.
`GeometryEditor(GeometryFactory factory)` Creates a new GeometryEditor object which will create edited `Geometry`s with the given `GeometryFactory`.

Method Summary
`Geometry` | `edit(Geometry geometry, GeometryEditor.GeometryEditorOperation operation)` Edit the input `Geometry` with the given edit operation.

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

Constructor Detail

### GeometryEditor

    public GeometryEditor()

  Creates a new GeometryEditor object which will create edited `Geometry`s with the same `GeometryFactory` as the input Geometry.

### GeometryEditor

    public GeometryEditor(GeometryFactory factory)

  Creates a new GeometryEditor object which will create edited `Geometry`s with the given `GeometryFactory`.

Parameters:
  `factory` - the GeometryFactory to create edited Geometrys with

Method Detail

### edit

    public Geometry edit(Geometry geometry,
                         GeometryEditor.GeometryEditorOperation operation)

  Edit the input `Geometry` with the given edit operation. Clients can create subclasses of `GeometryEditor.GeometryEditorOperation` or `GeometryEditor.CoordinateOperation` to perform required modifications.

  Parameters:
    `geometry` - the Geometry to edit
    `operation` - the edit operation to carry out
  Returns:
    a new `Geometry` which is the result of the editing

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