Module: ADIWG::Mdtranslator::Readers::MdJson::SpatialResolution

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

Class Method Summary collapse

Class Method Details

.unpack(hResolution, responseObj, inContext = nil) ⇒ 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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialResolution.rb', line 27

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

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

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

   # instance classes needed in script
   intMetadataClass = .new
   intResolution = intMetadataClass.newSpatialResolution

   outContext = 'spatial resolution'
   outContext = inContext + ' > ' + outContext unless inContext.nil?

   haveOne = false

   # spatial resolution - scale factor (required if not others)
   if hResolution.has_key?('scaleFactor')
      unless hResolution['scaleFactor'] == ''
         intResolution[:scaleFactor] = hResolution['scaleFactor']
         haveOne = true
      end
   end

   # spatial resolution - measure (required if not others)
   if hResolution.has_key?('measure')
      hMeasure = hResolution['measure']
      unless hMeasure.empty?
         hObject = Measure.unpack(hMeasure, responseObj, outContext)
         unless hObject.nil?
            intResolution[:measure] = hObject
            haveOne = true
         end
      end
   end

   # spatial resolution - coordinate resolution (required if not others)
   if hResolution.has_key?('coordinateResolution')
      hCoordRes = hResolution['coordinateResolution']
      unless hCoordRes.empty?
         hReturn = CoordinateResolution.unpack(hCoordRes, responseObj, outContext)
         unless hReturn.nil?
            intResolution[:coordinateResolution] = hReturn
            haveOne = true
         end
      end
   end

   # spatial resolution - bearing distance resolution (required if not others)
   if hResolution.has_key?('bearingDistanceResolution')
      hBearRes = hResolution['bearingDistanceResolution']
      unless hBearRes.empty?
         hReturn = BearingDistanceResolution.unpack(hBearRes, responseObj, outContext)
         unless hReturn.nil?
            intResolution[:bearingDistanceResolution] = hReturn
            haveOne = true
         end
      end
   end

   # spatial resolution - geographic resolution (required if not others)
   if hResolution.has_key?('geographicResolution')
      hGeoRes = hResolution['geographicResolution']
      unless hGeoRes.empty?
         hReturn = GeographicResolution.unpack(hGeoRes, responseObj, outContext)
         unless hReturn.nil?
            intResolution[:geographicResolution] = hReturn
            haveOne = true
         end
      end
   end

   # spatial resolution - level of detail (required if not others)
   if hResolution.has_key?('levelOfDetail')
      unless hResolution['levelOfDetail'] == ''
         intResolution[:levelOfDetail] = hResolution['levelOfDetail']
         haveOne = true
      end
   end

   # error messages
   unless haveOne
      @MessagePath.issueError(801, responseObj, inContext)
   end

   return intResolution

end