GeoFenceDensify(Distance, Shape) Method
Densifies the polygon by adding additional points along each edge at specified intervals.
Namespace: CoordinateSharpAssembly: CoordinateSharp (in CoordinateSharp.dll) Version: 3.1.1.1
XMLNS for XAML: Not mapped to an xmlns.
public void Densify(
Distance distance,
Shape shape
)
Parameters
- distance Distance
- The distance between points along the polygon's edges. This distance determines how frequently new points are inserted into the polygon
- shape Shape
- Specify earth shape. Sphere is more efficient, but less precise than ellipsoid.
This method is particularly useful for large polygons where the curvature of the Earth can cause
significant distortion in geographic calculations. By adding more points at regular intervals,
the polygon better conforms to the curved surface of the Earth, reducing errors in area calculations,
perimeter calculations, and point-in-polygon tests.
The function automatically calculates intermediate points based on the great-circle distance between
existing vertices, ensuring that the new points adhere to the true geographic shape of the polygon.
This is essential for maintaining geographic integrity when performing spatial operations or visualizations.
Note: The densification process increases the number of vertices in the polygon, which may impact performance
and memory usage in spatial computations and data storage. Optimal use of this function depends on the required
precision and the geographic extent of the application.
Here is how you might use this function to densify a polygon representing a large geographic area:
//Create a four point GeoFence around Utah
List<GeoFence.Point> points = new List<GeoFence.Point>();
points.Add(new GeoFence.Point(41.003444, -109.045223));
points.Add(new GeoFence.Point(41.003444, -102.041524));
points.Add(new GeoFence.Point(36.993076, -102.041524));
points.Add(new GeoFence.Point(36.993076, -109.045223));
points.Add(new GeoFence.Point(41.003444, -109.045223));
GeoFence gf = new GeoFence(points);
gf.Densify(new Distance(10, DistanceType.Kilometers), Shape.Sphere);
//The gf.Points list now contains additional points at intervals of approximately 10 kilometers.