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 | Geometry | Feature<LineString | MultiLineString> | 要分割的线 |
| segmentLength | 数字 | 每个片段的长度是多少 |
| options? | 对象 | 可选参数 (默认 {}) |
| options.units? | 单位 | 支持所有有效的 Turf 单位 (默认 '公里') |
| options.reverse? | 布尔值 | 将坐标反转以使第一个分块段从末尾开始 (默认 false) |
返回
🌐 Returns
FeatureCollection<LineString> 线段集合
示例
🌐 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(...);