index.d.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. import { Feature, FeatureCollection, GeometryCollection, LineString, Point, Properties, Units } from "@turf/helpers";
  2. /**
  3. * Returns the closest {@link Point|point}, of a {@link FeatureCollection|collection} of points,
  4. * to a {@link LineString|line}. The returned point has a `dist` property indicating its distance to the line.
  5. *
  6. * @name nearestPointToLine
  7. * @param {FeatureCollection|GeometryCollection<Point>} points Point Collection
  8. * @param {Feature|Geometry<LineString>} line Line Feature
  9. * @param {Object} [options] Optional parameters
  10. * @param {string} [options.units='kilometers'] unit of the output distance property
  11. * (eg: degrees, radians, miles, or kilometers)
  12. * @param {Object} [options.properties={}] Translate Properties to Point
  13. * @returns {Feature<Point>} the closest point
  14. * @example
  15. * var pt1 = turf.point([0, 0]);
  16. * var pt2 = turf.point([0.5, 0.5]);
  17. * var points = turf.featureCollection([pt1, pt2]);
  18. * var line = turf.lineString([[1,1], [-1,1]]);
  19. *
  20. * var nearest = turf.nearestPointToLine(points, line);
  21. *
  22. * //addToMap
  23. * var addToMap = [nearest, line];
  24. */
  25. declare function nearestPointToLine<P = {
  26. dist: number;
  27. [key: string]: any;
  28. }>(points: FeatureCollection<Point> | Feature<GeometryCollection> | GeometryCollection, line: Feature<LineString> | LineString, options?: {
  29. units?: Units;
  30. properties?: Properties;
  31. }): Feature<Point, P>;
  32. export default nearestPointToLine;