findSegment
描述
¥Description
Finds a particular 2-vertex LineString Segment from a GeoJSON using @turf/meta
indexes.
允许使用负索引。Point & MultiPoint will always return null.
¥Negative indexes are permitted. Point & MultiPoint will always return null.
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
geojson | FeatureCollection | 特性 | 几何图形 | Any GeoJSON Feature or Geometry |
options? | 对象 | 可选参数(默认 ) |
options.featureIndex? | number | 要素索引(默认 0) |
options.multiFeatureIndex? | number | 多要素索引(默认值为 0) |
options.geometryIndex? | number | 几何体索引(默认 0) |
options.segmentIndex? | number | 段索引(默认 0) |
options.properties? | 对象 | Translate Properties to output LineString (default ) |
options.bbox? | BBox | Translate BBox to output LineString (default ) |
options.id? | number | string | Translate Id to output LineString (default ) |
返回
¥Returns
特性<LineString> 2-vertex GeoJSON Feature LineString
¥Feature<LineString> 2-vertex GeoJSON Feature LineString
示例
¥Examples
var multiLine = turf.multiLineString([
[
[10, 10],
[50, 30],
[30, 40],
],
[
[-10, -10],
[-50, -30],
[-30, -40],
],
]);
// First Segment (defaults are 0)
turf.findSegment(multiLine);
// => Feature<LineString<[[10, 10], [50, 30]]>>
// First Segment of 2nd Multi Feature
turf.findSegment(multiLine, { multiFeatureIndex: 1 });
// => Feature<LineString<[[-10, -10], [-50, -30]]>>
// Last Segment of Last Multi Feature
turf.findSegment(multiLine, { multiFeatureIndex: -1, segmentIndex: -1 });
// => Feature<LineString<[[-50, -30], [-30, -40]]>>
安装
¥Installation
$ npm install @turf/meta
import { findSegment } from "@turf/meta";
const result = findSegment(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.findSegment(...);