描述
使用 @turf/meta 索引从 GeoJSON 中查找特定 Point。
允许负索引。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | FeatureCollection | Feature | Geometry | 任何 GeoJSON Feature 或 Geometry |
| options? | Object | 可选参数 (默认 {}) |
| options.featureIndex? | number | Feature 索引 (默认 0) |
| options.multiFeatureIndex? | number | Multi-Feature 索引 (默认 0) |
| options.geometryIndex? | number | Geometry 索引 (默认 0) |
| options.coordIndex? | number | Coord 索引 (默认 0) |
| options.properties? | Object | 将属性转换到输出 Point (默认 {}) |
| options.bbox? | BBox | 将 BBox 转换到输出 Point (默认 {}) |
| options.id? | number | string | 将 Id 转换到输出 Point (默认 {}) |
返回值
Feature<Point> 2 顶点 GeoJSON Feature Point
示例
javascript
var multiLine = turf.multiLineString([
[
[10, 10],
[50, 30],
[30, 40],
],
[
[-10, -10],
[-50, -30],
[-30, -40],
],
]);
// 第一个线段(默认值为 0)
turf.findPoint(multiLine);
// => Feature<Point<[10, 10]>>
// 第二个 Multi-Feature 的第一个线段
turf.findPoint(multiLine, { multiFeatureIndex: 1 });
// => Feature<Point<[-10, -10]>>
// 最后一个 Multi-Feature 的最后一个线段
turf.findPoint(multiLine, { multiFeatureIndex: -1, coordIndex: -1 });
// => Feature<Point<[-30, -40]>>安装
javascript
$ npm install @turf/meta
import { findPoint } from "@turf/meta";
const result = findPoint(...);javascript
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.findPoint(...);