distance
描述
¥Description
Calculates the distance between two coordinates in degrees, radians, miles, or kilometers.This uses the 半正矢公式 to account for global curvature.
¥Calculates the distance between two coordinates in degrees, radians, miles, or kilometers. This uses the Haversine formula to account for global curvature.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
from | 坐标系 | 原点坐标 |
to | 坐标系 | 目标坐标 |
options? | 对象 | 可选参数(默认 ) |
options.units? | string | can be degrees, radians, miles, or kilometers (default 'kilometers') |
返回
¥Returns
number distance between the two coordinates
示例
¥Examples
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);
安装
¥Installation
$ npm install @turf/distance
import { distance } from "@turf/distance";
const result = distance(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.distance(...);