lib/turf/area.rb
# Takes one or more features and returns their area in square meters.
# @see https://turfjs.org/docs/#area
# @param geojson [GeoJSON] input GeoJSON feature(s)
# @return [number] aria in square meters
Takes one or more features and returns their area in square meters.
Takes one or more features and returns their area in square meters .
def area_ring_area(coords)
    return 0 if coords.size <= 2
    total = 0
    coords.each_with_index do |_coord, index|
      lower_index, middle_index, upper_index =
        case index
        when coords.size - 2
          [
            coords.size - 2,
            coords.size - 1,
            0,
          ]
        when coords.size - 1
          [
            coords.size - 1,
            0,
            1,
          ]
        else
          [
            index,
            index + 1,
            index + 2,
          ]
        end
      p1 = coords[lower_index]
      p2 = coords[middle_index]
      p3 = coords[upper_index]
      total += (area_rad(p3[0]) - area_rad(p1[0])) * Math.sin(area_rad(p2[1]))
    end
    total * AREA_RADIUS * AREA_RADIUS / 2
  end
def area_ring_area ( coords ) return 0 if coords . size <= 2 total = 0 coords . each_with_index do | _coord , index | lower_index , middle_index , upper_index = case index when coords . size - 2 [ coords . size - 2 , coords . size - 1 , 0 , ] when coords . size - 1 [ coords . size - 1 , 0 , 1 , ] else [ index , index + 1 , index + 2 , ] end p1 = coords [ lower_index ] p2 = coords [ middle_index ] p3 = coords [ upper_index ] total += ( area_rad ( p3 [ 0 ] ) - area_rad ( p1 [ 0 ] ) ) * Math . sin ( area_rad ( p2 [ 1 ] ) ) end total * AREA_RADIUS * AREA_RADIUS / 2 end
Takes one or more features and returns their area in square meters.
Takes one or more features and returns their area in square meters .
aria in square meters
aria in square meters
number
coords
geojson
input GeoJSON feature(s)
input GeoJSON feature ( s )
see
None