index.d.cts 1.2 KB

1234567891011121314151617181920212223242526272829
  1. import { Feature, LineString } from 'geojson';
  2. import { Coord, Units } from '@turf/helpers';
  3. /**
  4. * Calculates the distance between a given point and the nearest point on a
  5. * line. Sometimes referred to as the cross track distance.
  6. *
  7. * @function
  8. * @param {Feature<Point>|Array<number>} pt Feature or Geometry
  9. * @param {Feature<LineString>} line GeoJSON Feature or Geometry
  10. * @param {Object} [options={}] Optional parameters
  11. * @param {string} [options.units="kilometers"] can be anything supported by turf/convertLength
  12. * (ex: degrees, radians, miles, or kilometers)
  13. * @param {string} [options.method="geodesic"] whether to calculate the distance based on geodesic (spheroid) or
  14. * planar (flat) method. Valid options are 'geodesic' or 'planar'.
  15. * @returns {number} distance between point and line
  16. * @example
  17. * var pt = turf.point([0, 0]);
  18. * var line = turf.lineString([[1, 1],[-1, 1]]);
  19. *
  20. * var distance = turf.pointToLineDistance(pt, line, {units: 'miles'});
  21. * //=69.11854715938406
  22. */
  23. declare function pointToLineDistance(pt: Coord, line: Feature<LineString> | LineString, options?: {
  24. units?: Units;
  25. method?: "geodesic" | "planar";
  26. }): number;
  27. export { pointToLineDistance as default, pointToLineDistance };