Module: ADIWG::Mdtranslator::Readers::MdJson::GridRepresentation

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

Class Method Summary collapse

Class Method Details

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



18
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
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_gridRepresentation.rb', line 18

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

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

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

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   intGrid = intMetadataClass.newGridInfo

   outContext = 'grid representation'
   outContext = inContext + ' > ' + outContext unless inContext.nil?

   # grid representation - number of dimensions (required)
   if hGrid.has_key?('numberOfDimensions')
      unless hGrid['numberOfDimensions'] == ''
         intGrid[:numberOfDimensions] = hGrid['numberOfDimensions']
      end
   end
   if intGrid[:numberOfDimensions].nil?
      @MessagePath.issueError(441, responseObj, inContext)
   end

   # grid representation - dimensions [] (required)
   if hGrid.has_key?('dimension')
      hGrid['dimension'].each do |item|
         hDim = Dimension.unpack(item, responseObj, outContext)
         unless hDim.nil?
            intGrid[:dimension] << hDim
         end
      end
   end
   if intGrid[:dimension].empty?
      @MessagePath.issueError(442, responseObj, inContext)
   end

   # grid representation - cell geometry (required)
   if hGrid.has_key?('cellGeometry')
      unless hGrid['cellGeometry'] == ''
         intGrid[:cellGeometry] = hGrid['cellGeometry']
      end
   end
   if intGrid[:cellGeometry].nil?
      @MessagePath.issueError(443, responseObj, inContext)
   end

   # grid representation - transformation parameter available {Boolean} (required)
   if hGrid.has_key?('transformationParameterAvailable')
      if hGrid['transformationParameterAvailable'] === true
         intGrid[:transformationParameterAvailable] = hGrid['transformationParameterAvailable']
      end
   end

   if hGrid.has_key?('scope')
      hGrid['scope'].each do |item|
         scope = Scope.unpack(item, responseObj, outContext)
         unless scope.nil?
            intGrid[:scope] << scope
         end
      end
   end

   return intGrid

end