pointToLineDistance

fun pointToLineDistance(point: Point, line: LineString, units: Units = Units.Kilometers, method: DistanceMethod = DistanceMethod.GEODESIC): Double
fun pointToLineDistance(position: Position, line: LineString, units: Units = Units.Kilometers, method: DistanceMethod = DistanceMethod.GEODESIC): Double

Calculates the distance between a given point and the nearest point on a line. Sometimes referred to as the cross track distance.

Return

distance between point and line

Parameters

position

given Position

line

LineString to calculate distance to

units

can be anything supported by turf/convertLength (ex: degrees, radians, miles, or kilometers)

method

whether to calculate the distance based on geodesic (spheroid) or planar (flat) method. Valid options are 'geodesic' or 'planar'.