Skip to main content
Version: 7.3.0

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

名称类型描述
geojsonFeatureCollection | Geometry | Feature<LineString | MultiLineString>要拆分的行
segmentLengthnumber制作每个段落需要多长时间
options?Object可选参数 (默认 {})
options.units?Units支持所有有效的 Turf 单位 (默认 '公里')
options.reverse?boolean将坐标反转,以便第一个分块段从末尾开始 (默认 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(...);