index.d.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { Polygon, Feature, FeatureCollection, LineString } from 'geojson';
  2. import { Coord, Units } from '@turf/helpers';
  3. /**
  4. * Returns the shortest {@link LineString|path} from {@link Point|start} to {@link Point|end} without colliding with
  5. * any {@link Feature} in obstacles {@link FeatureCollection}<{@link Polygon}>
  6. *
  7. * @function
  8. * @param {Coord} start point
  9. * @param {Coord} end point
  10. * @param {Object} [options={}] optional parameters
  11. * @param {Polygon|Feature<Polygon>|FeatureCollection<Polygon>} [options.obstacles] areas which path cannot travel
  12. * @param {Units} [options.units='kilometers'] unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ...
  13. * @param {number} [options.resolution=100] distance between matrix points on which the path will be calculated
  14. * @returns {Feature<LineString>} shortest path between start and end
  15. * @example
  16. * var start = [-5, -6];
  17. * var end = [9, -6];
  18. * var options = {
  19. * obstacles: turf.polygon([[[0, -7], [5, -7], [5, -3], [0, -3], [0, -7]]]).geometry
  20. * };
  21. *
  22. * var path = turf.shortestPath(start, end, options);
  23. *
  24. * //addToMap
  25. * var addToMap = [start, end, options.obstacles, path];
  26. */
  27. declare function shortestPath(start: Coord, end: Coord, options?: {
  28. obstacles?: Polygon | Feature<Polygon> | FeatureCollection<Polygon>;
  29. units?: Units;
  30. resolution?: number;
  31. }): Feature<LineString>;
  32. export { shortestPath as default, shortestPath };