length
描述
🌐 Description
接受一个 GeoJSON 并以指定单位测量其长度,(Multi)Point 的距离将被忽略。
🌐 Takes a GeoJSON and measures its length in the specified units, (Multi)Point's distance are ignored.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | Feature<LineString | MultiLineString> | 用于测量的GeoJSON |
| options? | Object | 可选参数 (默认 {}) |
| options.units? | Units | 支持所有有效的 Turf 单位。_(默认公里) |
返回
🌐 Returns
number GeoJSON 的长度
示例
🌐 Examples
var line = turf.lineString([
[115, -32],
[131, -22],
[143, -25],
[150, -34],
]);
var length = turf.length(line, { units: "miles" });
安装
🌐 Installation
$ npm install @turf/length
import { length } from "@turf/length";
const result = length(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.length(...);