geomEach
描述
¥Description
迭代任意 GeoJSON 对象中的每个几何体,类似于 Array.forEach()
¥Iterate over each geometry in any GeoJSON object, similar to Array.forEach()
参数
¥Parameters
名称 | 类型 | 描述 |
---|---|---|
geojson | FeatureCollection | 特性 | 几何图形 | GeometryObject | 特性<GeometryCollection> | 任意 GeoJSON 对象 |
callback | geomEachCallback | 一个接收 (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) 的方法 |
返回
¥Returns
void
示例
¥Examples
var features = turf.featureCollection([
turf.point([26, 37], { foo: "bar" }),
turf.point([36, 53], { hello: "world" }),
]);
turf.geomEach(
features,
function (
currentGeometry,
featureIndex,
featureProperties,
featureBBox,
featureId,
) {
//=currentGeometry
//=featureIndex
//=featureProperties
//=featureBBox
//=featureId
},
);
安装
¥Installation
$ npm install @turf/meta
import { geomEach } from "@turf/meta";
const result = geomEach(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.geomEach(...);