Skip to main content
Version: 7.2.0

coordEach

描述

¥Description

迭代任意 GeoJSON 对象中的坐标,类似于 Array.forEach()

¥Iterate over coordinates in any GeoJSON object, similar to Array.forEach()

参数

¥Parameters

名称类型描述
geojsonAllGeoJSON任意 GeoJSON 对象
callbackcoordEachCallback一个接收 (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(...);