Module geodesy.geodesic_nearest
Find the nearest point on a route segment to a geographic position.
Supply the two endpoints of a shortest geodesic segment and the position to check. The result gives the closest point on that finite segment and its distance from the position. If the closest point on the extended route would lie beyond an endpoint, the result uses the nearer endpoint.
Supporting-line quantities are also returned explicitly:
- alongTrack is signed from A in the A->B orientation;
- signedCrossTrack is positive to the right of the oriented supporting
geodesic and negative to the left;
- supportingFoot is the local perpendicular intercept on that supporting
geodesic.
When the nearest bounded-segment point is an endpoint, nearestDistance
is the true endpoint distance while signedCrossTrack continues to refer
only to the supporting geodesic. The two quantities are intentionally not
conflated.
The ellipsoidal kernel follows Karney's gnomonic interception construction
using m12 and M12 from the existing geodesic family. No spherical
cross-track shortcut is used.
Very distant / antipodal configurations for which the local ellipsoidal gnomonic construction is not defined or does not converge fail through the checked API instead of claiming a globally unique infinite-line intercept.
Date
October 7, 2026
Functions
| Name | Description |
|---|---|
nearestPointOnSegment(solver, start, end, target)
|
Find the nearest point on a bounded oriented ellipsoidal geodesic segment. |
tryNearestPointOnSegment(solver, start, end, target, result)
|
Find the point on a finite route segment closest to a position. |
Structs
| Name | Description |
|---|---|
GeodesicSegmentNearestResult
|
Result of nearest-point evaluation on a bounded geodesic segment. |
Enums
| Name | Description |
|---|---|
GeodesicSegmentNearestKind
|
Location of the nearest point on a bounded oriented geodesic segment. |