index.d.cts 1.4 KB

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