Module: ADIWG::Mdtranslator::Readers::MdJson::GeorectifiedRepresentation

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

Class Method Summary collapse

Class Method Details

.unpack(hGeoRec, 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_georectifiedRepresentation.rb', line 18

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

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

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

   # instance classes needed in script
   intMetadataClass = .new
   intGeoRec = intMetadataClass.newGeorectifiedInfo

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

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

   # georectified representation - check point availability (required)
   if hGeoRec.has_key?('checkPointAvailable')
      if hGeoRec['checkPointAvailable'] === true
         intGeoRec[:checkPointAvailable] = hGeoRec['checkPointAvailable']
      end
   end

   # georectified representation - check point description
   if hGeoRec.has_key?('checkPointDescription')
      if hGeoRec['checkPointDescription'] != ''
         intGeoRec[:checkPointDescription] = hGeoRec['checkPointDescription']
      end
   end

   # georectified representation - corner points [2 or 4] (required)
   if hGeoRec.has_key?('cornerPoints')
      unless hGeoRec['cornerPoints'].empty?
         intGeoRec[:cornerPoints] = hGeoRec['cornerPoints']
      end
   end
   unless intGeoRec[:cornerPoints].length == 2 || intGeoRec[:cornerPoints].length == 4
      @MessagePath.issueError(402, responseObj, inContext)
   end

   # georectified representation - center points
   if hGeoRec.has_key?('centerPoint')
      unless hGeoRec['centerPoint'].empty?
         intGeoRec[:centerPoint] = hGeoRec['centerPoint']
      end
      unless intGeoRec[:centerPoint].length == 2
         @MessagePath.issueError(403, responseObj, inContext)
      end
   end

   # georectified representation - point in pixel (required)
   if hGeoRec.has_key?('pointInPixel')
      if hGeoRec['pointInPixel'] != ''
         intGeoRec[:pointInPixel] = hGeoRec['pointInPixel']
      end
   end
   if intGeoRec[:pointInPixel].nil?
      @MessagePath.issueError(404, responseObj, inContext)
   end

   # georectified representation - transformation dimension description
   if hGeoRec.has_key?('transformationDimensionDescription')
      if hGeoRec['transformationDimensionDescription'] != ''
         intGeoRec[:transformationDimensionDescription] = hGeoRec['transformationDimensionDescription']
      end
   end

   # georectified representation - transformation dimension mapping
   if hGeoRec.has_key?('transformationDimensionMapping')
      if hGeoRec['transformationDimensionMapping'] != ''
         intGeoRec[:transformationDimensionMapping] = hGeoRec['transformationDimensionMapping']
      end
   end

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

   return intGeoRec

end