Class OverlayNG
Computes the geometric overlay of two Geometrys, using an explicit precision model to allow robust computation.
The overlay can be used to determine any of the following set-theoretic operations (boolean combinations) of the geometries:
- Intersectionall points which lie in both geometries
- Unionall points which lie in at least one geometry
- Differenceall points which lie in the first geometry but not the second
- SymDifferenceall points which lie in one geometry but not both
The precision model used for the computation can be supplied independent of the precision model of the input geometry. The main use for this is to allow using a fixed precision for geometry with a floating precision model. This does two things: ensures robust computation; and forces the output to be validly rounded to the precision model.
For fixed precision models noding is performed using a SnapRoundingNoder. This provides robust computation(as long as precision is limited to around 13 decimal digits).
For floating precision an MCIndexNoder is used. This is not fully robust, so can sometimes result in TopologyExceptions being thrown. For robust full-precision overlay see OverlayNGRobust.
A custom INoder can be supplied. This allows using a more performant noding strategy in specific cases, for instance in CoverageUnion.
Note: If a SnappingNoder is used it is best to specify a fairly small snap tolerance, since the intersection clipping optimization can interact with the snapping to alter the result.
Optionally the overlay computation can process using strict mode
(via StrictMode = true
).
In strict mode result semantics are:
- Lines and Points resulting from topology collapses are not included in the result
- Result geometry is homogeneous for the Intersection and Difference operations.
- Result geometry is homogeneous for the Union and SymDifference operations if the inputs have the same dimension
- Results are simpler
- Overlay operations are easily chainable without needing to remove lower-dimension elements
If a robustness error occurs, a TopologyException is thrown. These are usually caused by numerical rounding causing the noding output to not be fully noded. For robust computation with full-precision OverlayNGRobust can be used.
Inherited Members
Namespace: NetTopologySuite.Operation.OverlayNG
Assembly: NetTopologySuite.dll
Syntax
public sealed class OverlayNG
Constructors
| Improve this Doc View SourceOverlayNG(Geometry, Geometry, PrecisionModel, SpatialFunction)
Creates an overlay operation on the given geometries, with a defined precision model.
Declaration
public OverlayNG(Geometry geom0, Geometry geom1, PrecisionModel pm, SpatialFunction opCode)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geom0 | The A operand geometry |
Geometry | geom1 | The B operand geometry (may be |
PrecisionModel | pm | The precision model to use |
SpatialFunction | opCode | The overlay opcode |
OverlayNG(Geometry, Geometry, SpatialFunction)
Creates an overlay operation on the given geometries using the precision model of the geometries.
The noder is chosen according to the precision model specified.
Declaration
public OverlayNG(Geometry geom0, Geometry geom1, SpatialFunction opCode)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geom0 | The A operand geometry |
Geometry | geom1 | The B operand geometry (may be |
SpatialFunction | opCode | The overlay opcode |
Fields
| Improve this Doc View SourceDIFFERENCE
The code for the Difference overlay operation.
Declaration
public const SpatialFunction DIFFERENCE = SpatialFunction.Difference
Field Value
Type | Description |
---|---|
SpatialFunction |
INTERSECTION
The code for the Intersection overlay operation.
Declaration
public const SpatialFunction INTERSECTION = SpatialFunction.Intersection
Field Value
Type | Description |
---|---|
SpatialFunction |
SYMDIFFERENCE
The code for the Symmetric Difference overlay operation.
Declaration
public const SpatialFunction SYMDIFFERENCE = SpatialFunction.SymDifference
Field Value
Type | Description |
---|---|
SpatialFunction |
UNION
The code for the Union overlay operation.
Declaration
public const SpatialFunction UNION = SpatialFunction.Union
Field Value
Type | Description |
---|---|
SpatialFunction |
Properties
| Improve this Doc View SourceAreaResultOnly
Gets or sets whether the result can contain only Polygon components. This is used if it is known that the result must be an (possibly empty) area.
Declaration
public bool AreaResultOnly { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
|
Noder
Declaration
public INoder Noder { get; set; }
Property Value
Type | Description |
---|---|
INoder |
Optimized
Gets or sets a value indicating whether overlay processing optimizations are enabled.
It may be useful to disable optimizations for testing purposes.
Default is true
(optimization enabled).
Declaration
public bool Optimized { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
OutputEdges
Declaration
public bool OutputEdges { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
OutputNodedEdges
Declaration
public bool OutputNodedEdges { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
OutputResultEdges
Declaration
public bool OutputResultEdges { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
StrictMode
Gets or sets whether the overlay results are computed according to strict mode semantics.
- Lines resulting from topology collapse are not included
- Result geometry is homogeneous for the Intersection and Difference operations.
- Result geometry is homogeneous for the Union and SymDifference operations if the inputs have the same dimension
Declaration
public bool StrictMode { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Methods
| Improve this Doc View SourceGetResult()
Gets the result of the overlay operation. e
Declaration
public Geometry GetResult()
Returns
Type | Description |
---|---|
Geometry | The result of the overlay operation. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown, if the input is not supported (e.g. a mixed-dimension geometry) |
TopologyException | Thrown, if a robustness error occurs |
Overlay(Geometry, Geometry, SpatialFunction)
Computes an overlay operation on the given geometry operands, using the precision model of the geometry. and an appropriate noder.
The noder is chosen according to the precision model specified.
- For Fixed a snap-rounding noder is used, and the computation is robust.
- For Floating a non-snapping noder is used, and this computation may not be robust. If errors occur a TopologyException is thrown.
Declaration
public static Geometry Overlay(Geometry geom0, Geometry geom1, SpatialFunction opCode)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geom0 | The first geometry argument |
Geometry | geom1 | The second geometry argument |
SpatialFunction | opCode | The code for the desired overlay operation |
Returns
Type | Description |
---|---|
Geometry | The result of the overlay operation |
Overlay(Geometry, Geometry, SpatialFunction, PrecisionModel)
Computes an overlay operation for the given geometry operands, with the noding strategy determined by the precision model.
Declaration
public static Geometry Overlay(Geometry geom0, Geometry geom1, SpatialFunction opCode, PrecisionModel pm)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geom0 | The first geometry argument |
Geometry | geom1 | The second geometry argument |
SpatialFunction | opCode | The code for the desired overlay operation |
PrecisionModel | pm | The precision model to use |
Returns
Type | Description |
---|---|
Geometry | The result of the overlay operation |
Overlay(Geometry, Geometry, SpatialFunction, PrecisionModel, INoder)
Computes an overlay operation for the given geometry operands, using a supplied INoder.
Declaration
public static Geometry Overlay(Geometry geom0, Geometry geom1, SpatialFunction opCode, PrecisionModel pm, INoder noder)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geom0 | The first geometry argument |
Geometry | geom1 | The second geometry argument |
SpatialFunction | opCode | The code for the desired overlay operation |
PrecisionModel | pm | The precision model to use (which may be null if the noder does not use one) |
INoder | noder | The noder to use |
Returns
Type | Description |
---|---|
Geometry | The result of the overlay operation |
Overlay(Geometry, Geometry, SpatialFunction, INoder)
Computes an overlay operation on the given geometry operands, using a supplied INoder.
Declaration
public static Geometry Overlay(Geometry geom0, Geometry geom1, SpatialFunction opCode, INoder noder)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geom0 | The first geometry argument |
Geometry | geom1 | The second geometry argument |
SpatialFunction | opCode | The code for the desired overlay operation |
INoder | noder | The noder to use |
Returns
Type | Description |
---|---|
Geometry | The result of the overlay operation |