Class GeometryDistance
Precise (not bounding-box) planar geometry helpers shared by the
distance- and containment-ranking tools (nearest_features, the
precise mode of query_features).
public static class GeometryDistance
- Inheritance
-
GeometryDistance
- Inherited Members
Remarks
All distances are computed with a fast local equirectangular projection: latitude differences scale by a constant MetersPerDegreeLatitude and longitude differences scale by the same constant times the cosine of the mean latitude. This is accurate to a fraction of a percent over the spans of a single S-100 dataset and avoids pulling in a full geodesy library, matching the approximation already used by the identify-features query.
Unlike the vertex-only approximation in that tool, the helpers here measure distance to the nearest point on a segment (not just to vertices) and treat an area feature's distance as zero when the query point lies inside its exterior ring (interior-ring holes honoured).
Fields
MetersPerDegreeLatitude
Metres per degree of latitude (WGS-84 mean).
public const double MetersPerDegreeLatitude = 111320
Field Value
Methods
Bearing(GeoPoint, double, double)
Returns the great-circle initial bearing (degrees true, [0, 360))
from from toward the point (toLat, toLon).
public static double Bearing(GeoPoint from, double toLat, double toLon)
Parameters
Returns
ContainsPoint(IReadOnlyList<GeoPosition>, GeoPoint)
Planar ray-cast point-in-ring test. A point on the boundary is reported as inside. Rings shorter than four points are treated as empty.
public static bool ContainsPoint(IReadOnlyList<GeoPosition> ring, GeoPoint point)
Parameters
ringIReadOnlyList<GeoPosition>pointGeoPoint
Returns
Measure(IS100Feature, GeoPoint)
Measures point against feature's
geometry, returning null when the feature carries no geometry.
public static GeometryDistance.FeatureDistance? Measure(IS100Feature feature, GeoPoint point)
Parameters
featureIS100FeaturepointGeoPoint
Returns
Remarks
Surface geometry takes precedence over curve, which takes precedence over point — matching the preference order used elsewhere in the tools surface.
Meters(GeoPoint, double, double)
Distance in metres between two points (equirectangular).
public static double Meters(GeoPoint a, double lat, double lon)
Parameters
Returns
PointToSegment(GeoPoint, GeoPosition, GeoPosition)
Returns the distance in metres from point to the
nearest point on the segment a–b,
together with that nearest point. The projection is performed in a
local metric frame centred on the query point so the result is a
true perpendicular distance, not merely the nearer endpoint.
public static (double Distance, double Lat, double Lon) PointToSegment(GeoPoint point, GeoPosition a, GeoPosition b)
Parameters
pointGeoPointaGeoPositionbGeoPosition