Class GeometrySnapper
Snaps the vertices and segments of a Geometry to another Geometry's vertices. A snap distance tolerance is used to control where snapping is performed. Snapping one geometry to another can improve robustness for overlay operations by eliminating nearly-coincident edges (which cause problems during noding and intersection calculation). It can also be used to eliminate artifacts such as narrow slivers, spikes and gores. Too much snapping can result in invalid topology beging created, so the number and location of snapped vertices is decided using heuristics to determine when it is safe to snap. This can result in some potential snaps being omitted, however.
Inherited Members
Namespace: NetTopologySuite.Operation.Overlay.Snap
Assembly: NetTopologySuite.dll
Syntax
public class GeometrySnapper
Constructors
| Edit this page View SourceGeometrySnapper(Geometry)
Creates a new snapper acting on the given geometry
Declaration
public GeometrySnapper(Geometry g)
Parameters
Type | Name | Description |
---|---|---|
Geometry | g | the geometry to snap |
Methods
| Edit this page View SourceComputeOverlaySnapTolerance(Geometry)
Estimates the snap tolerance for a Geometry, taking into account its precision model.
Declaration
public static double ComputeOverlaySnapTolerance(Geometry g)
Parameters
Type | Name | Description |
---|---|---|
Geometry | g |
Returns
Type | Description |
---|---|
double | The estimated snap tolerance |
ComputeOverlaySnapTolerance(Geometry, Geometry)
Declaration
public static double ComputeOverlaySnapTolerance(Geometry g0, Geometry g1)
Parameters
Type | Name | Description |
---|---|---|
Geometry | g0 | |
Geometry | g1 |
Returns
Type | Description |
---|---|
double |
ComputeSizeBasedSnapTolerance(Geometry)
Declaration
public static double ComputeSizeBasedSnapTolerance(Geometry g)
Parameters
Type | Name | Description |
---|---|---|
Geometry | g |
Returns
Type | Description |
---|---|
double |
Snap(Geometry, Geometry, double)
Snaps two geometries together with a given tolerance.
Declaration
public static Geometry[] Snap(Geometry g0, Geometry g1, double snapTolerance)
Parameters
Type | Name | Description |
---|---|---|
Geometry | g0 | |
Geometry | g1 | |
double | snapTolerance |
Returns
Type | Description |
---|---|
Geometry[] |
SnapTo(Geometry, double)
Snaps the vertices in the component LineStrings of the source geometry to the vertices of the given snap geometry.
Declaration
public Geometry SnapTo(Geometry g, double tolerance)
Parameters
Type | Name | Description |
---|---|---|
Geometry | g | a geometry to snap the source to |
double | tolerance |
Returns
Type | Description |
---|---|
Geometry | a new snapped Geometry |
SnapToSelf(Geometry, double, bool)
Snaps a geometry to itself. Allows optionally cleaning the result to ensure it is topologically valid (which fixes issues such as topology collapses in polygonal inputs). Snapping a geometry to itself can remove artifacts such as very narrow slivers, gores and spikes.
Declaration
public static Geometry SnapToSelf(Geometry geom, double snapTolerance, bool cleanResult)
Parameters
Type | Name | Description |
---|---|---|
Geometry | geom | the geometry to snap |
double | snapTolerance | the snapping tolerance |
bool | cleanResult | whether the result should be made valid |
Returns
Type | Description |
---|---|
Geometry | a new snapped Geometry |
SnapToSelf(double, bool)
Declaration
public Geometry SnapToSelf(double snapTolerance, bool cleanResult)
Parameters
Type | Name | Description |
---|---|---|
double | snapTolerance | The snapping tolerance |
bool | cleanResult | Whether the result should be made valid |
Returns
Type | Description |
---|---|
Geometry | The geometry snapped to itself |