flattenEach function

void flattenEach(
  1. GeoJSONObject geoJSON,
  2. FlattenEachCallback callback
)

Iterates over flattened features in any geoJSONObject, similar to Iterate.forEach, calling callback on each flattened feature

flattenEach(featureCollection, (currentFeature, featureIndex, multiFeatureIndex) {
  someOperationOnEachFeature(currentFeature);
});

Implementation

void flattenEach(GeoJSONObject geoJSON, FlattenEachCallback callback) {
  try {
    geomEach(geoJSON, (GeometryType? currentGeomObject, featureIndex,
        featureProperties, featureBBox, featureId) {
      if (currentGeomObject == null ||
          currentGeomObject is Point ||
          currentGeomObject is LineString ||
          currentGeomObject is Polygon) {
        _callFlattenEachCallback(callback, currentGeomObject as GeometryType,
            featureProperties, featureIndex, 0);
      } else {
        _forEachFeatureOfMultiFeature(
            currentGeomObject, callback, featureProperties, featureIndex);
      }
    });
  } on ShortCircuit {
    return;
  }
}