lib/turf/meta.rb
def flatten_each(geojson)
    geom_each(geojson) do |geometry, feature_index, properties, bbox, id|
      if geometry.nil?
        next yield(
          feature(nil, properties: properties, bbox: bbox, id: id),
          feature_index,
          0
        )
      end

      case geometry[:type]
      when "Point", "LineString", "Polygon"
        yield(
          feature(geometry, properties: properties, bbox: bbox, id: id),
          feature_index,
          0
        )
      when "MultiPoint", "MultiLineString", "MultiPolygon"
        geom_type = geometry[:type].sub(/^Multi/, "")
        geometry[:coordinates].each_with_index do |coordinate, multi_feature_index|
          geom = {
            type: geom_type,
            coordinates: coordinate
          }
          yield(
            feature(geom, properties: properties),
            feature_index,
            multi_feature_index
          )
        end
      end
    end
  end
# Iterate over flattened features in any GeoJSON object, similar to Array.forEach.
# @see https://turfjs.org/docs/#flattenEach
# @param geojson [FeatureCollection|Feature|Geometry] any GeoJSON object
# @yieldparam feature [Feature<any>] The current Feature being processed.
# @yieldparam feature_index [number] The current index of the Feature being processed.
# @yieldparam multi_feature_index [number] The current index of the Feature in the multi-Feature
Iterate over flattened features in any GeoJSON object, similar to Array.forEach.
Iterate over flattened features in any GeoJSON object similar to Array . forEach .
def flatten_each(geojson)
    geom_each(geojson) do |geometry, feature_index, properties, bbox, id|
      if geometry.nil?
        next yield(
          feature(nil, properties: properties, bbox: bbox, id: id),
          feature_index,
          0
        )
      end
      case geometry[:type]
      when "Point", "LineString", "Polygon"
        yield(
          feature(geometry, properties: properties, bbox: bbox, id: id),
          feature_index,
          0
        )
      when "MultiPoint", "MultiLineString", "MultiPolygon"
        geom_type = geometry[:type].sub(/^Multi/, "")
        geometry[:coordinates].each_with_index do |coordinate, multi_feature_index|
          geom = {
            type: geom_type,
            coordinates: coordinate
          }
          yield(
            feature(geom, properties: properties),
            feature_index,
            multi_feature_index
          )
        end
      end
    end
  end
def flatten_each ( geojson ) geom_each ( geojson ) do | geometry , feature_index , properties , bbox , id | if geometry . nil? next yield ( feature ( nil , properties : properties , bbox : bbox , id : id ) , feature_index , 0 ) end case geometry [ :type ] when "Point" , "LineString" , "Polygon" yield ( feature ( geometry , properties : properties , bbox : bbox , id : id ) , feature_index , 0 ) when "MultiPoint" , "MultiLineString" , "MultiPolygon" geom_type = geometry [ :type ] . sub ( / ^Multi / , "" ) geometry [ :coordinates ] . each_with_index do | coordinate , multi_feature_index | geom = { type : geom_type , coordinates : coordinate } yield ( feature ( geom , properties : properties ) , feature_index , multi_feature_index ) end end end end
Iterate over flattened features in any GeoJSON object, similar to Array.forEach.
Iterate over flattened features in any GeoJSON object similar to Array . forEach .
geojson
any GeoJSON object
any GeoJSON object
feature
The current Feature being processed.
The current Feature being processed .
feature_index
The current index of the Feature being processed.
The current index of the Feature being processed .
multi_feature_index
The current index of the Feature in the multi-Feature
The current index of the Feature in the multi - Feature
see
None