Skip to content

描述 ​

从 (Multi)LineString 或 (Multi)Polygon 创建 2 顶点 LineString 线段的 FeatureCollection。

参数 ​

名称类型描述
geojsonGeoJSONGeoJSON Polygon 或 LineString

返回值 ​

FeatureCollection<LineString> 2 顶点线段

示例 ​

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

安装 ​

javascript
$ npm install @turf/line-segment

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

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