coordEach function

void coordEach(
  1. GeoJSONObject geoJSON,
  2. Function callback, [
  3. bool excludeWrapCoord = false
])

Iterates over coordinates in any geoJSONObject, similar to Iterable.forEach example:

var features = FeatureCollection(features: [
  Feature(geometry: Point(coordinates: Position.of([26, 37])), properties: {'foo': 'bar'}),
  Feature(geometry: Point(coordinates: Position.of([36, 53])), properties: {'foo': 'bar'})
]);

coordEach(features, (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {
 //=currentCoord
 //=coordIndex
 //=featureIndex
 //=multiFeatureIndex
 //=geometryIndex
});

Implementation

void coordEach(GeoJSONObject geoJSON, Function callback,
    [bool excludeWrapCoord = false]) {
  _IndexCounter indexCounter = _IndexCounter();
  try {
    geomEach(
      geoJSON,
      (
        GeometryType? currentGeometry,
        int? featureIndex,
        featureProperties,
        featureBBox,
        featureId,
      ) {
        if (currentGeometry == null) return;

        indexCounter.featureIndex = featureIndex ?? 0;

        _forEachCoordInGeometryObject(
            currentGeometry, callback, excludeWrapCoord, indexCounter);
      },
    );
  } on ShortCircuit {
    return;
  }
}