flattenEach
描述
🌐 Description
遍历任何 GeoJSON 对象中的扁平化特性,类似于 Array.forEach。
🌐 Iterate over flattened features in any GeoJSON object, similar to Array.forEach.
参数
🌐 Parameters
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | FeatureCollection | Feature | GeometryObject | GeometryCollection | Feature<GeometryCollection> | 任何 GeoJSON 对象 |
| callback | flattenEachCallback | 一个接收 (currentFeature, featureIndex, multiFeatureIndex) 的方法 |
返回
🌐 Returns
void
示例
🌐 Examples
var features = turf.featureCollection([
turf.point([26, 37], { foo: "bar" }),
turf.multiPoint(
[
[40, 30],
[36, 53],
],
{ hello: "world" },
),
]);
turf.flattenEach(
features,
function (currentFeature, featureIndex, multiFeatureIndex) {
//=currentFeature
//=featureIndex
//=multiFeatureIndex
},
);
安装
🌐 Installation
$ npm install @turf/meta
import { flattenEach } from "@turf/meta";
const result = flattenEach(...);
$ npm install @turf/turf
import * as turf from "@turf/turf";
const result = turf.flattenEach(...);