Module: ADIWG::Mdtranslator::Writers::SbJson::GeographicExtent

Defined in:
lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_geographicExtent.rb

Class Method Summary collapse

Class Method Details

.build(aExtents) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# 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_collectionObject



13
14
15
16
17
18
# File 'lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_geographicExtent.rb', line 13

def self.new_collection
   {
      'type' => 'FeatureCollection',
      'features' => []
   }
end

.new_featureObject



20
21
22
23
24
25
# File 'lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_geographicExtent.rb', line 20

def self.new_feature
   {
      'type' => 'Feature',
      'geometry' => {}
   }
end