module ADIWG::Mdtranslator::Writers::SbJson::GeographicExtent

Public Class Methods

build(aExtents) click to toggle source
# File lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_geographicExtent.rb, line 27
def self.build(aExtents)

   aFeatureCollection = []

   # gather geographicExtents geoJson blocks
   aExtents.each do |hExtent|
      hExtent[:geographicExtents].each do |hGeoExtent|

         collection = new_collection()
         hGeoExtent[:nativeGeoJson].each do |hGeoObj|

            case hGeoObj['type']
               when 'Point', 'LineString', 'Polygon', 'MultiPoint', 'MultiLineString', 'MultiPolygon'
                  feature = new_feature()
                  feature['geometry'] = hGeoObj
                  collection['features'] << feature

               when 'GeometryCollection'
                  geoCollection = new_collection()
                  hGeoObj['geometries'].each do |hGeometry|
                     feature = new_feature()
                     feature['geometry'] = hGeometry
                     geoCollection['features'] << feature
                  end
                  aFeatureCollection << geoCollection

               when 'Feature'
                  collection['features'] << hGeoObj

               when 'FeatureCollection'
                  aFeatureCollection << hGeoObj
            end

         end

         unless collection['features'].empty?
            aFeatureCollection << collection
         end

      end
   end

   aFeatureCollection

end
new_collection() click to toggle source
# File lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_geographicExtent.rb, line 13
def self.new_collection
   {
      'type' => 'FeatureCollection',
      'features' => []
   }
end
new_feature() click to toggle source
# File lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_geographicExtent.rb, line 20
def self.new_feature
   {
      'type' => 'Feature',
      'geometry' => {}
   }
end