index.d.cts 1.0 KB

1234567891011121314151617181920212223242526272829
  1. import { Coord, Units } from '@turf/helpers';
  2. /**
  3. * Calculates the distance between two {@link Coord|coordinates} in degrees, radians, miles, or kilometers.
  4. * This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
  5. *
  6. * @function
  7. * @param {Coord} from origin coordinate
  8. * @param {Coord} to destination coordinate
  9. * @param {Object} [options={}] Optional parameters
  10. * @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
  11. * @returns {number} distance between the two coordinates
  12. * @example
  13. * var from = turf.point([-75.343, 39.984]);
  14. * var to = turf.point([-75.534, 39.123]);
  15. * var options = {units: 'miles'};
  16. *
  17. * var distance = turf.distance(from, to, options);
  18. *
  19. * //addToMap
  20. * var addToMap = [from, to];
  21. * from.properties.distance = distance;
  22. * to.properties.distance = distance;
  23. */
  24. declare function distance(from: Coord, to: Coord, options?: {
  25. units?: Units;
  26. }): number;
  27. export { distance as default, distance };