Table of Contents

Class Cleaning

Namespace
SpatialNET
Assembly
SpatialNET.Extensions.dll

Clean-up of geometries (ADR 0027): RemoveHoles, RemoveSmallParts, SnapToGrid and ReducePrecision. Results are created through the factory and restricted to what it supports (SupportsZ, SupportsM).

public static class Cleaning

Inheritance

Inherited Members

Methods

ReducePrecision(IGeometry2D, double, IGeometryFactory?)

Reduces the precision of a geometry to a grid and keeps it valid (ADR 0027): the geometry is snap-rounded by the overlay core like in Union (ADR 0005). A polygon is made valid under even-odd (as MakeValid, ADR 0020), so parts that collapse vanish; a polyline is noded and its duplicates collapse (as Union, ADR 0018); a multipoint loses its duplicates; a point is rounded. Every vertex of the result lies on the grid. Z and M follow the rules of the overlays (ADR 0015).

public static IGeometry2D ReducePrecision(this IGeometry2D geometry, double gridSize, IGeometryFactory? factory = null)

Parameters

geometry IGeometry2D

The geometry.

gridSize double

The distance of the grid lines; finite and greater than 0.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IGeometry2D

Exceptions

ArgumentNullException

geometry is null.

ArgumentOutOfRangeException

gridSize is not finite or not greater than 0.

NotSupportedException

geometry is not a known geometry kind.

InvalidOperationException

No factory available.

RemoveHoles(IPolygon2D, double, IGeometryFactory?)

Removes the holes of a polygon whose area is smaller than minArea; the others stay. Without a limit (the default System.Double.PositiveInfinity) every hole is removed. Shells and parts stay as they are; the rings are normalized (ADR 0003).

public static IPolygon2D RemoveHoles(this IPolygon2D polygon, double minArea = Infinity, IGeometryFactory? factory = null)

Parameters

polygon IPolygon2D

The polygon.

minArea double

The smallest area a hole must have to stay; not negative, not NaN. 0 keeps every hole.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolygon2D

Exceptions

ArgumentNullException

polygon is null.

ArgumentOutOfRangeException

minArea is negative or NaN.

InvalidOperationException

No factory available.

RemoveSmallParts(IPolygon2D, double, IGeometryFactory?)

Removes the parts of a polygon whose area (shell minus holes) is smaller than minArea.

public static IPolygon2D RemoveSmallParts(this IPolygon2D polygon, double minArea, IGeometryFactory? factory = null)

Parameters

polygon IPolygon2D

The polygon.

minArea double

The smallest area a part must have to stay; not negative, not NaN.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolygon2D

Exceptions

ArgumentNullException

polygon is null.

ArgumentOutOfRangeException

minArea is negative or NaN.

InvalidOperationException

No factory available.

RemoveSmallParts(IPolyline2D, double, IGeometryFactory?)

Removes the paths of a polyline that are shorter than minLength.

public static IPolyline2D RemoveSmallParts(this IPolyline2D line, double minLength, IGeometryFactory? factory = null)

Parameters

line IPolyline2D

The polyline.

minLength double

The smallest length a path must have to stay; not negative, not NaN.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IPolyline2D

Exceptions

ArgumentNullException

line is null.

ArgumentOutOfRangeException

minLength is negative or NaN.

InvalidOperationException

No factory available.

RemoveSmallParts(IGeometry2D, double, IGeometryFactory?)

Removes the small parts of any geometry: polygon parts by area, polyline paths by length (see the overloads); a point or multipoint has no size and is copied unchanged.

public static IGeometry2D RemoveSmallParts(this IGeometry2D geometry, double minSize, IGeometryFactory? factory = null)

Parameters

geometry IGeometry2D

The geometry.

minSize double

The smallest area (polygon) or length (polyline) that a part must have to stay; not negative, not NaN.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IGeometry2D

Exceptions

ArgumentNullException

geometry is null.

ArgumentOutOfRangeException

minSize is negative or NaN.

NotSupportedException

geometry is not a known geometry kind.

InvalidOperationException

No factory available.

SnapToGrid(IGeometry2D, double, IGeometryFactory?)

Rounds X and Y of every vertex to the nearest multiple of gridSize (halves away from zero) and nothing else (ADR 0027). Vertices that fall together are merged (consecutive repeats of a path or ring), paths with fewer than two and rings with fewer than three distinct vertices are dropped, and a part whose shell collapses goes with its holes. The result may be invalid: rounding can make edges cross or touch. Use SpatialNET.Cleaning.ReducePrecision(SpatialNET.IGeometry2D,System.Double,SpatialNET.IGeometryFactory) for a valid result. Z and M of a merged vertex are those of the first one. The points of a multipoint all stay, also if they now coincide.

public static IGeometry2D SnapToGrid(this IGeometry2D geometry, double gridSize, IGeometryFactory? factory = null)

Parameters

geometry IGeometry2D

The geometry.

gridSize double

The distance of the grid lines; finite and greater than 0.

factory IGeometryFactory?

The factory; null = SpatialNET.GeometryFactory.Default.

Returns

IGeometry2D

Exceptions

ArgumentNullException

geometry is null.

ArgumentOutOfRangeException

gridSize is not finite or not greater than 0.

NotSupportedException

geometry is not a known geometry kind.

InvalidOperationException

No factory available, or a rounded coordinate leaves the range of System.Double.