coordEach
描述
¥Description
迭代任意 GeoJSON 对象中的坐标,类似于 Array.forEach()
¥Iterate over coordinates in any GeoJSON object, similar to Array.forEach()
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
geojson | AllGeoJSON | 任意 GeoJSON 对象 |
callback | coordEachCallback | 一个接收 (currentCoord, coordIndex, featureIndex, multiFeatureIndex) 的方法 |
excludeWrapCoord? | boolean | 是否在迭代中包含环绕环的 LinearRings 的最终坐标。(默认 false) |
返回
¥Returns
void
示例
¥Examples
var features = turf.featureCollection([
turf.point([26, 37], { foo: "bar" }),
turf.point([36, 53], { hello: "world" }),
]);
turf.coordEach(
features,
function (
currentCoord,
coordIndex,
featureIndex,
multiFeatureIndex,
geometryIndex,
) {
//=currentCoord
//=coordIndex
//=featureIndex
//=multiFeatureIndex
//=geometryIndex
},
);
安装
¥Installation
$ npm install @turf/meta
import { coordEach } from "@turf/meta";
const result = coordEach(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.coordEach(...);