Class GeometryEditor
A class which supports creating new Geometrys which are modifications of existing ones, maintaining the same type structure.
Inherited Members
Namespace: NetTopologySuite.Geometries.Utilities
Assembly: NetTopologySuite.dll
Syntax
public class GeometryEditor
Remarks
Geometry objects are intended to be treated as immutable. This class allows you to "modifies" a Geometrys by traversing them, applying a user-defined GeometryEditor.IGeometryEditorOperation, GeometryEditor.CoordinateSequenceOperation or GeometryEditor.CoordinateOperation and creating a 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 modified 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 point 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 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 IsValid method should be called.
- By default the UserData of the input geometry is not copied to the result.
Constructors
| Improve this Doc View SourceGeometryEditor()
Creates a new GeometryEditor object which will create edited Geometry with the same GeometryFactory as the input Geometry.
Declaration
public GeometryEditor()
GeometryEditor(GeometryFactory)
Creates a new GeometryEditor object which will create edited Geometrys with the given GeometryFactory.
Declaration
public GeometryEditor(GeometryFactory factory)
Parameters
Type | Name | Description |
---|---|---|
GeometryFactory | factory | The GeometryFactory to create the edited Geometry with. |
Properties
| Improve this Doc View SourceCopyUserData
Gets or sets a value indicating if the User Data is copied to the edit result. If so, only the object reference is copied.
Declaration
public bool CopyUserData { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc View SourceEdit(Geometry, GeometryEditor.IGeometryEditorOperation)
Edit the input Geometry
with the given edit operation.
Clients can create subclasses of GeometryEditorOperation or
CoordinateOperation to perform required modifications.
Declaration
public Geometry Edit(Geometry geometry, GeometryEditor.IGeometryEditorOperation operation)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geometry | The Geometry to edit. |
GeometryEditor.IGeometryEditorOperation | operation | The edit operation to carry out. |
Returns
Type | Description |
---|---|
Geometry | A new |