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 CleaningInheritance
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
geometryIGeometry2D-
The geometry.
gridSizedouble-
The distance of the grid lines; finite and greater than 0.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
geometryisnull. - ArgumentOutOfRangeException
-
gridSizeis not finite or not greater than 0. - NotSupportedException
-
geometryis 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
polygonIPolygon2D-
The polygon.
minAreadouble-
The smallest area a hole must have to stay; not negative, not
NaN. 0 keeps every hole. factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
polygonisnull. - ArgumentOutOfRangeException
-
minAreais negative orNaN. - 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
polygonIPolygon2D-
The polygon.
minAreadouble-
The smallest area a part must have to stay; not negative, not
NaN. factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
polygonisnull. - ArgumentOutOfRangeException
-
minAreais negative orNaN. - 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
lineIPolyline2D-
The polyline.
minLengthdouble-
The smallest length a path must have to stay; not negative, not
NaN. factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
lineisnull. - ArgumentOutOfRangeException
-
minLengthis negative orNaN. - 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
geometryIGeometry2D-
The geometry.
minSizedouble-
The smallest area (polygon) or length (polyline) that a part must have to stay; not negative, not
NaN. factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
geometryisnull. - ArgumentOutOfRangeException
-
minSizeis negative orNaN. - NotSupportedException
-
geometryis 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
geometryIGeometry2D-
The geometry.
gridSizedouble-
The distance of the grid lines; finite and greater than 0.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
geometryisnull. - ArgumentOutOfRangeException
-
gridSizeis not finite or not greater than 0. - NotSupportedException
-
geometryis not a known geometry kind. - InvalidOperationException
-
No factory available, or a rounded coordinate leaves the range of System.Double.