Class GeometryEditorEx
- java.lang.Object
-
- org.locationtech.jtslab.geom.util.GeometryEditorEx
-
public class GeometryEditorEx extends java.lang.Object
A class which supports creating newGeometry
s which are modifications of existing ones, maintaining the same type structure. Geometry objects are intended to be treated as immutable. This class "modifies" Geometrys by traversing them, applying a user-definedGeometryEditorEx.GeometryEditorOperation
,GeometryEditorEx.CoordinateSequenceOperation
orGeometryEditorEx.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, deleting or modifying 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.
GeometryTransformer
.This class supports creating an edited Geometry using a different
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.Usage Notes
- The resulting Geometry is not checked for validity.
If validity needs to be enforced, the new Geometry's
Geometry.isValid()
method should be called. - By default the UserData of the input geometry is not copied to the result.
- Version:
- 1.7
- See Also:
GeometryTransformer
,Geometry.isValid()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GeometryEditorEx.CoordinateOperation
AGeometryEditorEx.GeometryEditorOperation
which edits the coordinate list of aGeometry
.static class
GeometryEditorEx.CoordinateSequenceOperation
static interface
GeometryEditorEx.GeometryEditorOperation
A interface which specifies an edit operation for Geometries.static class
GeometryEditorEx.NoOpGeometryOperation
A GeometryEditorOperation which does not modify the input geometry.
-
Constructor Summary
Constructors Constructor Description GeometryEditorEx()
Creates a new GeometryEditor object which will create editedGeometry
s with the sameGeometryFactory
as the input Geometry.GeometryEditorEx(GeometryFactory targetFactory)
Creates a new GeometryEditor object which will create editedGeometry
s with the givenGeometryFactory
.GeometryEditorEx(GeometryEditorEx.GeometryEditorOperation operation)
Creates a GeometryEditor which edits geometries using a givenGeometryOperation
and the sameGeometryFactory
as the input Geometry.GeometryEditorEx(GeometryEditorEx.GeometryEditorOperation operation, GeometryFactory targetFactory)
Creates a GeometryEditor which edits geometries using a givenGeometryOperation
and the givenGeometryFactory
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Geometry
edit(Geometry geometry)
Edit aGeometry
.void
setCopyUserData(boolean isUserDataCopied)
Sets whether the User Data is copied to the edit result.
-
-
-
Constructor Detail
-
GeometryEditorEx
public GeometryEditorEx()
Creates a new GeometryEditor object which will create editedGeometry
s with the sameGeometryFactory
as the input Geometry.
-
GeometryEditorEx
public GeometryEditorEx(GeometryFactory targetFactory)
Creates a new GeometryEditor object which will create editedGeometry
s with the givenGeometryFactory
.- Parameters:
targetFactory
- the GeometryFactory to create edited Geometrys with
-
GeometryEditorEx
public GeometryEditorEx(GeometryEditorEx.GeometryEditorOperation operation)
Creates a GeometryEditor which edits geometries using a givenGeometryOperation
and the sameGeometryFactory
as the input Geometry.- Parameters:
operation
- the edit operation to use
-
GeometryEditorEx
public GeometryEditorEx(GeometryEditorEx.GeometryEditorOperation operation, GeometryFactory targetFactory)
Creates a GeometryEditor which edits geometries using a givenGeometryOperation
and the givenGeometryFactory
.- Parameters:
operation
- the edit operation to usetargetFactory
- the GeometryFactory to create edited Geometrys with
-
-
Method Detail
-
setCopyUserData
public void setCopyUserData(boolean isUserDataCopied)
Sets whether the User Data is copied to the edit result. Only the object reference is copied.- Parameters:
isUserDataCopied
- true if the input user data should be copied.
-
edit
public Geometry edit(Geometry geometry)
Edit aGeometry
. Clients can create subclasses ofGeometryEditorEx.GeometryEditorOperation
orGeometryEditorEx.CoordinateOperation
to perform required modifications.- Parameters:
geometry
- the Geometry to edit- Returns:
- a new
Geometry
which is the result of the editing (which may be empty)
-
-