index.d.ts 1.2 KB

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