Skip to main content
Version: 7.2.0

lineSlice

描述

¥Description

获取一个 line、一个起始点 和一个终止点,并返回这些点之间的一段线。起点和终点不必恰好位于直线上。

¥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坐标系起始点
stopPt坐标系终止点
line特性<LineString> | LineString要切片的线

返回

¥Returns

特性<LineString> 切片线

¥Feature<LineString> sliced line

示例

¥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(...);