Module: ADIWG::Mdtranslator::Readers::MdJson::Extent

Defined in:
lib/adiwg/mdtranslator/readers/mdJson/modules/module_extent.rb

Class Method Summary collapse

Class Method Details

.unpack(hExtent, responseObj, inContext = nil) ⇒ Object



19
20
21
22
23
24
25
26
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_extent.rb', line 19

def self.unpack(hExtent, responseObj, inContext = nil)

   @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson

   # return nil object if input is empty
   if hExtent.empty?
      @MessagePath.issueWarning(270, responseObj, inContext)
      return nil
   end

   # instance classes needed in script
   intMetadataClass = .new
   intExtent = intMetadataClass.newExtent

   outContext = 'extent'
   outContext = inContext + ' > ' + outContext unless inContext.nil?

   haveExtent = false

   # extent - description
   if hExtent.has_key?('description')
      unless hExtent['description'] == ''
         intExtent[:description] = hExtent['description']
         haveExtent = true
      end
   end

   # extent - geographicExtent
   if hExtent.has_key?('geographicExtent')
      hExtent['geographicExtent'].each do |item|
         unless item.empty?
            hReturn = GeographicExtent.unpack(item, responseObj, outContext)
            unless hReturn.nil?
               intExtent[:geographicExtents] << hReturn
               haveExtent = true
            end
         end
      end
   end

   # extent - temporalExtent
   if hExtent.has_key?('temporalExtent')
      hExtent['temporalExtent'].each do |item|
         unless item.empty?
            hReturn = TemporalExtent.unpack(item, responseObj, outContext)
            unless hReturn.nil?
               intExtent[:temporalExtents] << hReturn
               haveExtent = true
            end
         end
      end
   end

   # extent - verticalExtent
   if hExtent.has_key?('verticalExtent')
      hExtent['verticalExtent'].each do |item|
         unless item.empty?
            hReturn = VerticalExtent.unpack(item, responseObj, outContext)
            unless hReturn.nil?
               intExtent[:verticalExtents] << hReturn
               haveExtent = true
            end
         end
      end
   end

   # error messages
   unless haveExtent
      @MessagePath.issueError(271, responseObj, inContext)
   end

   return intExtent

end