Skip to main content
Version: 7.2.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 | 几何图形 | 特性<LineString | MultiLineString>待分割的线
segmentLengthnumber每个段的长度
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(...);