Class Shapes
- Namespace
- SpatialNET
- Assembly
- SpatialNET.Extensions.dll
Bounding shapes and label points (ADR 0026): MinimumRotatedRectangle, MinimumBoundingCircle and Polylabel.
public static class ShapesInheritance
Inherited Members
Methods
ConcaveHull(IGeometry2D, double, bool, IGeometryFactory?)
A concave hull of the vertices of a geometry (ADR 0029): a polygon that contains every vertex and follows their arrangement more
closely than the convex hull. It starts from the Delaunay triangulation and takes triangles away from the border, longest border edge
first, as long as an edge is longer than maxEdgeLength and the polygon stays connected and keeps every vertex.
With a limit of at least the longest edge the result is the convex hull; with a smaller one it can be much tighter, and it is
never smaller than what the points allow. The limit decides what counts as "too far": a larger one fills gaps, a smaller one
opens bays.
public static IGeometry2D ConcaveHull(this IGeometry2D geometry, double maxEdgeLength, bool holesAllowed = false, IGeometryFactory? factory = null)Parameters
geometryIGeometry2D-
The geometry.
maxEdgeLengthdouble-
The longest border edge that stays, in the unit of the coordinates; not negative, not
NaN. System.Double.PositiveInfinity gives the convex hull. holesAllowedbool-
trueif the polygon may have holes. factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Remarks
Without holesAllowed the result is one polygon without holes. With it, interior triangles of which all vertices are
interior and which have an edge longer than the limit open holes that grow the same way; a hole never touches the border or another
hole. As for SpatialNET.Shapes.ConvexHull(SpatialNET.IGeometry2D,SpatialNET.IGeometryFactory) a geometry with fewer than three different or only collinear vertices gives a point, the
line between the extreme points, or an empty polygon. Z of a vertex is kept, M is not.
Exceptions
- ArgumentNullException
-
geometryisnull. - ArgumentOutOfRangeException
-
maxEdgeLengthis negative orNaN. - NotSupportedException
-
geometryis not a known geometry kind. - InvalidOperationException
-
No factory available.
ConcaveHullByRatio(IGeometry2D, double, bool, IGeometryFactory?)
A concave hull with the limit given as a ratio (ADR 0029): 1 gives the convex hull, 0 the tightest hull the points allow, and
in between the limit is the shortest edge of the Delaunay triangulation plus edgeLengthRatio times the
difference between its longest and its shortest edge, which makes the ratio independent of the scale. See
SpatialNET.Shapes.ConcaveHull(SpatialNET.IGeometry2D,System.Double,System.Boolean,SpatialNET.IGeometryFactory).
public static IGeometry2D ConcaveHullByRatio(this IGeometry2D geometry, double edgeLengthRatio, bool holesAllowed = false, IGeometryFactory? factory = null)Parameters
geometryIGeometry2D-
The geometry.
edgeLengthRatiodouble-
From 0 to 1.
holesAllowedbool-
trueif the polygon may have holes. factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
geometryisnull. - ArgumentOutOfRangeException
-
edgeLengthRatiois not from 0 to 1. - NotSupportedException
-
geometryis not a known geometry kind. - InvalidOperationException
-
No factory available.
ConvexHull(IGeometry2D, IGeometryFactory?)
The convex hull of all points. Depending on degeneracy a polygon (counter-clockwise), a polyline between the two extreme points (all points collinear) or a point; empty for empty input (as in JTS).
public static IGeometry2D ConvexHull(this IGeometry2D geometry, IGeometryFactory? factory = null)Parameters
geometryIGeometry2D-
The geometry.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
geometryisnull. - NotSupportedException
-
geometryis not a known geometry kind. - InvalidOperationException
-
No factory available.
DelaunayEdges(IGeometry2D, IGeometryFactory?)
The edges of the Delaunay triangulation of the vertices of a geometry (ADR 0036): every edge once, as one path, with Z of the vertices kept. The same vertices and triangulation as SpatialNET.Shapes.DelaunayTriangles(SpatialNET.IGeometry2D,SpatialNET.IGeometryFactory), drawn as lines or used as the graph of the neighbourhood of the points.
public static IPolyline2D DelaunayEdges(this IGeometry2D geometry, IGeometryFactory? factory = null)Parameters
geometryIGeometry2D-
The geometry.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
- IPolyline2D
-
The edges; empty if there are fewer than three different vertices or all of them are collinear.
Exceptions
- ArgumentNullException
-
geometryisnull. - NotSupportedException
-
geometryis not a known geometry kind. - InvalidOperationException
-
No factory available.
DelaunayTriangles(IGeometry2D, IGeometryFactory?)
The Delaunay triangulation of the vertices of a geometry (ADR 0029): triangles such that no vertex lies inside the circumcircle of a triangle. They tile the convex hull of the vertices. As for SpatialNET.Shapes.ConvexHull(SpatialNET.IGeometry2D,SpatialNET.IGeometryFactory) every vertex of every kind of geometry counts, with X and Y only; vertices with the same X and Y count once, and vertices that are not finite are ignored.
public static IReadOnlyList<IPolygon2D> DelaunayTriangles(this IGeometry2D geometry, IGeometryFactory? factory = null)Parameters
geometryIGeometry2D-
The geometry.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
- IReadOnlyList<IPolygon2D>
-
The triangles; empty if there are fewer than three different vertices or all of them are collinear.
Remarks
The result is a flat list of triangles, each a polygon with its vertices counter-clockwise, in no particular order (as for SpatialNET.Cutting.Cut(SpatialNET.IPolygon2D,SpatialNET.IPolyline2D,SpatialNET.IGeometryFactory,System.Nullable{System.Double})). Vertices on a common circle (the corners of a rectangle, a regular grid) allow several triangulations, all equally Delaunay; which one comes out is deterministic but not specified. Z of a vertex is kept, M is not.
Exceptions
- ArgumentNullException
-
geometryisnull. - NotSupportedException
-
geometryis not a known geometry kind. - InvalidOperationException
-
No factory available.
FastAlternativePolygonLabelsLazy(IPolygon2D, Coordinate, AlternativeLabelOptions?)
Alternative label points in the interior of the polygon, after the first one (seed) failed a collision
test, computed lazily: nothing is computed before the first point is asked for, and the caller stops at the first point that
fits. The points lie on horizontal scanlines, first the one through the seed, then lines that halve the envelope again and
again (½, ¼, ¾, ⅛, …); on each line the points closest to the seed come first. Every point lies strictly inside by the
even-odd rule over all rings (parts and holes need not be typed), keeps SpatialNET.AlternativeLabelOptions.Separation
from the seed and the points before and SpatialNET.AlternativeLabelOptions.MinClearance from the boundary. The order is
deterministic. An empty or degenerate polygon gives an empty sequence. Without Z and M.
public static IEnumerable<Coordinate> FastAlternativePolygonLabelsLazy(this IPolygon2D polygon, Coordinate seed, AlternativeLabelOptions? options = null)Parameters
polygonIPolygon2D-
The polygon.
seedCoordinate-
The point that failed, usually the result of SpatialNET.Shapes.FastPolygonLabel(SpatialNET.IPolygon2D).
optionsAlternativeLabelOptions?-
The options;
null= defaults.
Returns
Exceptions
- ArgumentNullException
-
polygonisnull. - ArgumentOutOfRangeException
-
A distance in
optionsis negative or not finite, or a count is negative.
FastPolygonLabel(IPolygon2D)
One point in the interior of the polygon for a map label, computed as cheaply as possible, where speed matters more than the nicest position. In order: the area centroid if it lies inside (even-odd over all rings, the rings need not be typed as shell or hole), the middle of the widest stretch of the horizontal line through the centroid or through the middle of the envelope, then SpatialNET.Measures.PointOnSurface(SpatialNET.IGeometry2D) and last SpatialNET.Shapes.Polylabel(SpatialNET.IPolygon2D,System.Nullable{System.Double}). The first steps are one or two passes over the vertices and allocate nothing but pooled buffers. Without Z and M.
public static Coordinate? FastPolygonLabel(this IPolygon2D polygon)Parameters
polygonIPolygon2D-
The polygon.
Returns
- Coordinate?
-
The point, or
nullif the polygon is empty or has no area.
Exceptions
- ArgumentNullException
-
polygonisnull.
MinimumBoundingCircle(IGeometry2D)
The smallest circle that contains the geometry (ADR 0026), found with the algorithm of Welzl on the convex hull, in a
fixed order, so that the result is deterministic. null for an empty geometry; a single point gives radius 0.
public static Circle? MinimumBoundingCircle(this IGeometry2D geometry)Parameters
geometryIGeometry2D-
The geometry.
Returns
- Circle?
-
The circle, or
nullif the geometry is empty.
Exceptions
- ArgumentNullException
-
geometryisnull. - NotSupportedException
-
geometryis not a known geometry kind.
MinimumRotatedRectangle(IGeometry2D, IGeometryFactory?)
The rectangle of least area that contains the geometry, turned to any angle (ADR 0026). A side of it lies on a side of the convex hull. Among rectangles of equal area the one of the first hull edge wins. Counter-clockwise, without Z and M. For a degenerate input the result is, as for SpatialNET.Shapes.ConvexHull(SpatialNET.IGeometry2D,SpatialNET.IGeometryFactory), a point or the line between the two extreme points, and an empty polygon for an empty geometry.
public static IGeometry2D MinimumRotatedRectangle(this IGeometry2D geometry, IGeometryFactory? factory = null)Parameters
geometryIGeometry2D-
The geometry.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default.
Returns
Exceptions
- ArgumentNullException
-
geometryisnull. - NotSupportedException
-
geometryis not a known geometry kind. - InvalidOperationException
-
No factory available.
Polylabel(IPolygon2D, double?)
The pole of inaccessibility (ADR 0026): the point of the polygon that is farthest from its boundary (the holes included),
found by the polylabel algorithm of Mapbox. It is a good place for a label. For a polygon of several parts it is the pole
of the part with the largest circle. The point is within tolerance of the optimum in its distance to the
boundary. Without Z and M. null for an empty polygon.
public static Coordinate? Polylabel(this IPolygon2D polygon, double? tolerance = null)Parameters
polygonIPolygon2D-
The polygon.
tolerancedouble?-
The accuracy of the distance to the boundary, in the unit of the coordinates; finite and greater than 0.
null= a thousandth of the larger side of the envelope.
Returns
- Coordinate?
-
The point, or
nullif the polygon is empty.
Exceptions
- ArgumentNullException
-
polygonisnull. - ArgumentOutOfRangeException
-
toleranceis not finite or not greater than 0.
Triangulate(IPolygon2D, IGeometryFactory?, double?)
The triangles inside a polygon (ADR 0038): a constrained Delaunay triangulation of its vertices without what lies outside its rings, as a flat list of polygons like SpatialNET.Shapes.DelaunayTriangles(SpatialNET.IGeometry2D,SpatialNET.IGeometryFactory). Every edge of a ring is an edge of a triangle, and holes are left out. See SpatialNET.Triangulation.FromPolygon(SpatialNET.IPolygon2D,SpatialNET.IGeometryFactory,System.Nullable{System.Double}) for the rules and for the triangulation itself, with neighbours.
public static IReadOnlyList<IPolygon2D> Triangulate(this IPolygon2D polygon, IGeometryFactory? factory = null, double? gridSize = null)Parameters
polygonIPolygon2D-
The polygon.
factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default. gridSizedouble?-
The grid for noding crossing rings;
null= cascade (global default, otherwise automatic).
Returns
- IReadOnlyList<IPolygon2D>
-
The triangles, counter-clockwise; empty for a polygon without area.
Exceptions
- ArgumentNullException
-
polygonisnull. - ArgumentOutOfRangeException
-
gridSizeis not finite or not greater than 0. - InvalidOperationException
-
No factory available.
VoronoiDiagram(IGeometry2D, IPolygon2D?, IGeometryFactory?, double?)
The Voronoi diagram of the vertices of a geometry (ADR 0036): for every site the area that lies nearer to it than to every other site (the Thiessen polygon). The cells are cut to a clip area, since the cells at the border of the sites are unbounded. As for SpatialNET.Shapes.DelaunayTriangles(SpatialNET.IGeometry2D,SpatialNET.IGeometryFactory) every vertex of every kind of geometry is a site, with X and Y only (Z of a site is kept in the result); vertices with the same X and Y count once, and vertices that are not finite are ignored.
public static IReadOnlyList<VoronoiCell> VoronoiDiagram(this IGeometry2D sites, IPolygon2D? clip = null, IGeometryFactory? factory = null, double? gridSize = null)Parameters
sitesIGeometry2D-
The geometry whose vertices are the sites.
clipIPolygon2D?-
The area to which the cells are cut;
null= the widened envelope of the sites. factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default. gridSizedouble?-
The grid to which the cells are rounded;
null= cascade (global default, otherwise automatic).
Returns
- IReadOnlyList<VoronoiCell>
-
The cells; empty if there is no site or the clip area has no area.
Remarks
The result has one entry per distinct site, in the order in which the sites first occur. The cells have no gaps and do not overlap:
their areas add up to the area of the clip area. The corners of the cells are rounded to a grid (see gridSize) and
the cells are valid; where a cell would collapse at the size of the grid, it is empty.
Without clip the clip area is the envelope of the sites, widened on every side by half of its larger extent
(by 1 if it has none). With a polygon the cells are cut with it, which is what a service area within a boundary needs: a site outside the
polygon can still have a cell inside it, and a cell that does not reach the polygon is empty. Use Envelope2D.ToPolygon for a rectangle.
Exceptions
- ArgumentNullException
-
sitesisnull. - ArgumentOutOfRangeException
-
gridSizeis not finite or not greater than 0. - NotSupportedException
-
A geometry is not a known geometry kind.
- InvalidOperationException
-
No factory available.
VoronoiEdges(IGeometry2D, IPolygon2D?, IGeometryFactory?, double?)
The edges of the Voronoi diagram (ADR 0036): the lines between neighbouring cells, one path per edge, without the edges on the border of the clip area. The same sites, clip area and grid as SpatialNET.Shapes.VoronoiDiagram(SpatialNET.IGeometry2D,SpatialNET.IPolygon2D,SpatialNET.IGeometryFactory,System.Nullable{System.Double}), which has the cells themselves.
public static IPolyline2D VoronoiEdges(this IGeometry2D sites, IPolygon2D? clip = null, IGeometryFactory? factory = null, double? gridSize = null)Parameters
sitesIGeometry2D-
The geometry whose vertices are the sites.
clipIPolygon2D?-
The area to which the edges are cut;
null= the widened envelope of the sites. factoryIGeometryFactory?-
The factory;
null= SpatialNET.GeometryFactory.Default. gridSizedouble?-
The grid to which the edges are rounded;
null= cascade (global default, otherwise automatic).
Returns
- IPolyline2D
-
The edges; empty if there are fewer than two sites or the clip area has no area.
Exceptions
- ArgumentNullException
-
sitesisnull. - ArgumentOutOfRangeException
-
gridSizeis not finite or not greater than 0. - NotSupportedException
-
A geometry is not a known geometry kind.
- InvalidOperationException
-
No factory available.