# lineSegment
Creates a FeatureCollection of 2-vertex LineString segments from a (Multi)LineString or (Multi)Polygon.
从一个(多)LineString
或(多)多Polygon
创建一个2-vertex
线段的FeatureCollection
。
参数
参数 | 类型 | 描述 |
---|---|---|
geojson | (Geometry|FeatureCollection|Feature <(LineString|MultiLineString|MultiPolygon|Polygon)>) | GeoJSON Polygon or LineString |
返回
FeatureCollection <LineString> - 2-vertex line segments
示例
// 注意:polygon首尾坐标要一致
var polygon = turf.polygon([[[-50, 5], [-40, -10], [-50, -10], [-40, 5], [-50, 5]]]);
var segments = turf.lineSegment(polygon);