findPoint
描述
🌐 Description
使用 @turf/meta 索引从 GeoJSON 中查找特定点。
🌐 Finds a particular Point from a GeoJSON using @turf/meta indexes.
允许使用负索引。
🌐 Negative indexes are permitted.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | FeatureCollection | Feature | Geometry | 任何 GeoJSON 要素或几何体 |
| options? | Object | 可选参数 (默认 {}) |
| options.featureIndex? | number | 功能索引 (默认 0) |
| options.multiFeatureIndex? | number | 多特性索引 (默认 0) |
| options.geometryIndex? | number | 几何索引 (默认 0) |
| options.coordIndex? | number | 坐标索引 (默认 0) |
| options.properties? | Object | 将属性转换为输出点 (默认 {}) |
| options.bbox? | BBox | 将 BBox 转换为输出点 (默认 {}) |
| options.id? | number | string | 将 Id 翻译为输出点 (默认 {}) |
返回
🌐 Returns
Feature<Point> 2顶点 GeoJSON 特性点
示例
🌐 Examples
var multiLine = turf.multiLineString([
[
[10, 10],
[50, 30],
[30, 40],
],
[
[-10, -10],
[-50, -30],
[-30, -40],
],
]);
// First Segment (defaults are 0)
turf.findPoint(multiLine);
// => Feature<Point<[10, 10]>>
// First Segment of the 2nd Multi-Feature
turf.findPoint(multiLine, { multiFeatureIndex: 1 });
// => Feature<Point<[-10, -10]>>
// Last Segment of last Multi-Feature
turf.findPoint(multiLine, { multiFeatureIndex: -1, coordIndex: -1 });
// => Feature<Point<[-30, -40]>>
安装
🌐 Installation
$ npm install @turf/meta
import { findPoint } from "@turf/meta";
const result = findPoint(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.findPoint(...);