lineSlice
描述
🌐 Description
接受一条line、一个起始Point和一个停止点,并返回位于这些点之间的线段子部分。起点和终点不需要恰好位于直线上。
🌐 Takes a line, a start Point, and a stop point and returns a subsection of the line in-between those points. The start & stop points don't need to fall exactly on the line.
这对于仅提取航点之间的部分路线非常有用。
🌐 This can be useful for extracting only the part of a route between waypoints.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| startPt | Coord | 起点 |
| stopPt | Coord | 停车点 |
| line | Feature<LineString> | LineString | 切线 |
返回
🌐 Returns
Feature<LineString> 切片线
示例
🌐 Examples
var line = turf.lineString([
[-77.031669, 38.878605],
[-77.029609, 38.881946],
[-77.020339, 38.884084],
[-77.025661, 38.885821],
[-77.021884, 38.889563],
[-77.019824, 38.892368],
]);
var start = turf.point([-77.029609, 38.881946]);
var stop = turf.point([-77.021884, 38.889563]);
var sliced = turf.lineSlice(start, stop, line);
安装
🌐 Installation
$ npm install @turf/line-slice
import { lineSlice } from "@turf/line-slice";
const result = lineSlice(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.lineSlice(...);