Class Smoothing
- Namespace
- SpatialNET
- Assembly
- SpatialNET.Extensions.dll
Rounding of lines (ADR 0043): Smooth replaces the corners of a polyline, or the rings of a polygon, by curves. It is meant for contour lines
and everything else that was digitised or computed as a chain of straight pieces.
public static class SmoothingInheritance
Inherited Members
Methods
Smooth(IPolyline2D, int, SmoothingMethod, IGeometryFactory?)
Smooths a polyline (ADR 0043): every path is replaced by a curve with 2^iterations times as many segments. The ends of an open path stay
where they are, a closed path (the first point equals the last) is smoothed all the way round, and Z and M are interpolated linearly along the
segments (so a contour line keeps its height, and M stays monotonic). A path of two points has nothing to smooth.
public static IPolyline2D Smooth(this IPolyline2D line, int iterations = 2, SmoothingMethod method = SmoothingMethod.Chaikin, IGeometryFactory? factory = null)Parameters
lineIPolyline2D-
The polyline.
iterationsint-
How often the segments are halved, from 0 (a copy) to 10; 2 to 3 look smooth.
methodSmoothingMethod-
The kind of curve.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Remarks
The result follows the input within a part of the longest segment (for SpatialNET.SmoothingMethod.Chaikin within half of it), but two lines that run closer to each other than that can cross after smoothing. Contour lines of a surface can be kept apart by smoothing the surface instead, SpatialNET.Triangulation.Resample(System.Double,System.Boolean).
Exceptions
- ArgumentNullException
-
lineisnull. - ArgumentOutOfRangeException
-
iterationsis not from 0 to 10, or the result would be unreasonably large;methodis not a known method. - InvalidOperationException
-
No factory available.
Smooth(IPolygon2D, int, SmoothingMethod, IGeometryFactory?)
Smooths the rings of a polygon after their normalization (shells counter-clockwise, holes clockwise), every ring all the way round. See
SpatialNET.Smoothing.Smooth(SpatialNET.IPolyline2D,System.Int32,SpatialNET.SmoothingMethod,SpatialNET.IGeometryFactory). A ring is cut inwards at its convex corners and outwards at the
reflex ones, so a polygon whose parts lie closer to each other than the curve moves can become invalid; MakeValid repairs it.
public static IPolygon2D Smooth(this IPolygon2D polygon, int iterations = 2, SmoothingMethod method = SmoothingMethod.Chaikin, IGeometryFactory? factory = null)Parameters
polygonIPolygon2D-
The polygon.
iterationsint-
How often the segments are halved, from 0 (a copy) to 10.
methodSmoothingMethod-
The kind of curve.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
polygonisnull. - ArgumentOutOfRangeException
-
iterationsis not from 0 to 10, or the result would be unreasonably large;methodis not a known method. - InvalidOperationException
-
No factory available.
Smooth(IGeometry2D, int, SmoothingMethod, IGeometryFactory?)
Smooths a polyline or polygon; a point or multipoint is copied unchanged.
public static IGeometry2D Smooth(this IGeometry2D geometry, int iterations = 2, SmoothingMethod method = SmoothingMethod.Chaikin, IGeometryFactory? factory = null)Parameters
geometryIGeometry2D-
The geometry.
iterationsint-
How often the segments are halved, from 0 (a copy) to 10.
methodSmoothingMethod-
The kind of curve.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
geometryisnull. - ArgumentOutOfRangeException
-
iterationsis not from 0 to 10, or the result would be unreasonably large;methodis not a known method. - NotSupportedException
-
geometryis not a known geometry kind. - InvalidOperationException
-
No factory available.
SmoothToTolerance(IPolyline2D, double, SmoothingMethod, IGeometryFactory?)
Smooths a polyline until it is smooth to a distance (ADR 0043) instead of by a number of iterations: the segments are halved as often as it takes
for no vertex to lie further than tolerance from the straight line between its two neighbours, so that the result looks like a
curve at the scale of the tolerance, and no finer. A line that is that smooth already is returned as it is. Everything else is as for
SpatialNET.Smoothing.Smooth(SpatialNET.IPolyline2D,System.Int32,SpatialNET.SmoothingMethod,SpatialNET.IGeometryFactory).
public static IPolyline2D SmoothToTolerance(this IPolyline2D line, double tolerance, SmoothingMethod method = SmoothingMethod.Chaikin, IGeometryFactory? factory = null)Parameters
lineIPolyline2D-
The polyline.
tolerancedouble-
The largest distance of a vertex from the line between its neighbours; finite and greater than 0.
methodSmoothingMethod-
The kind of curve.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Remarks
At most 10 iterations are made for SpatialNET.SmoothingMethod.Chaikin, and for SpatialNET.SmoothingMethod.CatmullRom every segment of the
line is cut into at most 1024 pieces, and the work stops where the result would exceed the vertex budget of Densify; a very small
tolerance gives the finest that is allowed. The tolerance is in the units of the coordinates (give it in metres for a map in metres).
Exceptions
- ArgumentNullException
-
lineisnull. - ArgumentOutOfRangeException
-
toleranceis not finite or not greater than 0;methodis not a known method. - InvalidOperationException
-
No factory available.
SmoothToTolerance(IPolygon2D, double, SmoothingMethod, IGeometryFactory?)
Smooths the rings of a polygon until they are smooth to a distance, see SpatialNET.Smoothing.SmoothToTolerance(SpatialNET.IPolyline2D,System.Double,SpatialNET.SmoothingMethod,SpatialNET.IGeometryFactory). The rings are normalized first (shells counter-clockwise, holes clockwise); a polygon whose parts are closer together than the curve moves can become invalid.
public static IPolygon2D SmoothToTolerance(this IPolygon2D polygon, double tolerance, SmoothingMethod method = SmoothingMethod.Chaikin, IGeometryFactory? factory = null)Parameters
polygonIPolygon2D-
The polygon.
tolerancedouble-
The largest distance of a vertex from the line between its neighbours; finite and greater than 0.
methodSmoothingMethod-
The kind of curve.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
polygonisnull. - ArgumentOutOfRangeException
-
toleranceis not finite or not greater than 0;methodis not a known method. - InvalidOperationException
-
No factory available.
SmoothToTolerance(IGeometry2D, double, SmoothingMethod, IGeometryFactory?)
Smooths a polyline or polygon to a distance; a point or multipoint is copied unchanged.
public static IGeometry2D SmoothToTolerance(this IGeometry2D geometry, double tolerance, SmoothingMethod method = SmoothingMethod.Chaikin, IGeometryFactory? factory = null)Parameters
geometryIGeometry2D-
The geometry.
tolerancedouble-
The largest distance of a vertex from the line between its neighbours; finite and greater than 0.
methodSmoothingMethod-
The kind of curve.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
geometryisnull. - ArgumentOutOfRangeException
-
toleranceis not finite or not greater than 0;methodis not a known method. - NotSupportedException
-
geometryis not a known geometry kind. - InvalidOperationException
-
No factory available.