lineChunk
描述
¥Description
将 LineString 划分为指定长度的块。如果直线短于线段长度,则返回原始直线。
¥Divides a LineString into chunks of a specified length. If the line is shorter than the segment length then the original line is returned.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
geojson | FeatureCollection | 几何图形 | 特性<LineString | MultiLineString> | 待分割的线 |
segmentLength | number | 每个段的长度 |
options? | 对象 | 可选参数(默认 {}) |
options.units? | string | 单位可以是度、弧度、英里或公里(默认 'kilometers') |
options.reverse? | boolean | 反转坐标,使第一个分块段从末尾开始(默认为 false) |
返回
¥Returns
FeatureCollection<LineString> 线段集合
¥FeatureCollection<LineString> collection of line segments
示例
¥Examples
var line = turf.lineString([
[-95, 40],
[-93, 45],
[-85, 50],
]);
var chunk = turf.lineChunk(line, 15, { units: "miles" });
安装
¥Installation
$ npm install @turf/line-chunk
import { lineChunk } from "@turf/line-chunk";
const result = lineChunk(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.lineChunk(...);