28 lines
1.0 KiB
TypeScript
Executable File
28 lines
1.0 KiB
TypeScript
Executable File
import { Coord, Units, Point } from "@turf/helpers";
|
|
/**
|
|
* Calculates the distance between two {@link Point|points} in degrees, radians, miles, or kilometers.
|
|
* This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
|
|
*
|
|
* @name distance
|
|
* @param {Coord | Point} from origin point or coordinate
|
|
* @param {Coord | Point} to destination point or coordinate
|
|
* @param {Object} [options={}] Optional parameters
|
|
* @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
|
|
* @returns {number} distance between the two points
|
|
* @example
|
|
* var from = turf.point([-75.343, 39.984]);
|
|
* var to = turf.point([-75.534, 39.123]);
|
|
* var options = {units: 'miles'};
|
|
*
|
|
* var distance = turf.distance(from, to, options);
|
|
*
|
|
* //addToMap
|
|
* var addToMap = [from, to];
|
|
* from.properties.distance = distance;
|
|
* to.properties.distance = distance;
|
|
*/
|
|
declare function distance(from: Coord | Point, to: Coord | Point, options?: {
|
|
units?: Units;
|
|
}): number;
|
|
export default distance;
|