Skip to main content
Version: 7.2.0

lineSegment

描述

¥Description

根据 (多个)LineString(多个)多边形 创建由 2 个顶点和 LineString 线段组成的 FeatureCollection

¥Creates a FeatureCollection of 2-vertex LineString segments from a (Multi)LineString or (Multi)Polygon.

参数

¥Parameters

名称类型描述
geojsonGeoJSONGeoJSON 多边形或线串

返回

¥Returns

FeatureCollection<LineString> 2 顶点线段

¥FeatureCollection<LineString> 2-vertex line segments

示例

¥Examples

var polygon = turf.polygon([
[
[-50, 5],
[-40, -10],
[-50, -10],
[-40, 5],
[-50, 5],
],
]);
var segments = turf.lineSegment(polygon);

安装

¥Installation

$ npm install @turf/line-segment

import { lineSegment } from "@turf/line-segment";
const result = lineSegment(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.lineSegment(...);