Module: ADIWG::Mdtranslator::Readers::MdJson::GeoreferenceableRepresentation

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

Class Method Summary collapse

Class Method Details

.unpack(hGeoRef, 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_georeferenceableRepresentation.rb', line 18

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

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

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

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   intGeoRef = intMetadataClass.newGeoreferenceableInfo

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

   # georeferenceable representation - grid representation (required)
   if hGeoRef.has_key?('gridRepresentation')
      hObject = hGeoRef['gridRepresentation']
      unless hObject.empty?
         hReturn = GridRepresentation.unpack(hObject, responseObj, outContext)
         unless hReturn.nil?
            intGeoRef[:gridRepresentation] = hReturn
         end
      end
   end
   if intGeoRef[:gridRepresentation].empty?
      @MessagePath.issueError(411, responseObj, inContext)
   end

   # georeferenceable representation - control point availability (required)
   if hGeoRef.has_key?('controlPointAvailable')
      if hGeoRef['controlPointAvailable'] === true
         intGeoRef[:controlPointAvailable] = hGeoRef['controlPointAvailable']
      end
   end

   # georeferenceable representation - orientation parameter availability (required)
   if hGeoRef.has_key?('orientationParameterAvailable')
      if hGeoRef['orientationParameterAvailable'] === true
         intGeoRef[:orientationParameterAvailable] = hGeoRef['orientationParameterAvailable']
      end
   end

   # georeferenceable representation - orientation parameter description
   if hGeoRef.has_key?('orientationParameterDescription')
      unless hGeoRef['orientationParameterDescription'] == ''
         intGeoRef[:orientationParameterDescription] = hGeoRef['orientationParameterDescription']
      end
   end

   # georeferenceable representation - georeferenced parameter (required)
   if hGeoRef.has_key?('georeferencedParameter')
      unless hGeoRef['georeferencedParameter'] == ''
         intGeoRef[:georeferencedParameter] = hGeoRef['georeferencedParameter']
      end
   end
   if intGeoRef[:georeferencedParameter].nil?
      @MessagePath.issueError(412, responseObj, inContext)
   end

   # georeferenceable representation - parameter citation [citation]
   if hGeoRef.has_key?('parameterCitation')
      aCitation = hGeoRef['parameterCitation']
      aCitation.each do |item|
         hCitation = Citation.unpack(item, responseObj, outContext)
         unless hCitation.nil?
            intGeoRef[:parameterCitation] << hCitation
         end
      end
   end

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

   return intGeoRef

end