Skip to main content
Version: Next

coordEach

描述

¥Description

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

参数

¥Parameters

名称类型描述
geojsonAllGeoJSON任意 GeoJSON 对象
callbackcoordEachCallbacka method that takes (currentCoord, coordIndex, featureIndex, multiFeatureIndex)
excludeWrapCoord?booleanwhether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.(默认 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(...);