Module: ADIWG::Mdtranslator::Readers::MdJson::SpatialRepresentation

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

Class Method Summary collapse

Class Method Details

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



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

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

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

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

   # instance classes needed in script
   intMetadataClass = .new
   intRepresent = intMetadataClass.newSpatialRepresentation

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

   haveOne = false

   # spatial representation - grid representation (required if not others)
   if hRepresent.has_key?('gridRepresentation')
      hRep = hRepresent['gridRepresentation']
      unless hRep.empty?
         hObject = GridRepresentation.unpack(hRep, responseObj, outContext)
         unless hObject.nil?
            intRepresent[:gridRepresentation] = hObject
            haveOne = true
         end
      end
   end

   # spatial representation - vector representation (required if not others)
   if hRepresent.has_key?('vectorRepresentation')
      hRep = hRepresent['vectorRepresentation']
      unless hRep.empty?
         hObject = VectorRepresentation.unpack(hRep, responseObj, outContext)
         unless hObject.nil?
            intRepresent[:vectorRepresentation] = hObject
            haveOne = true
         end
      end
   end

   # spatial representation - georectified representation (required if not others)
   if hRepresent.has_key?('georectifiedRepresentation')
      hRep = hRepresent['georectifiedRepresentation']
      unless hRep.empty?
         hObject = GeorectifiedRepresentation.unpack(hRep, responseObj, outContext)
         unless hObject.nil?
            intRepresent[:georectifiedRepresentation] = hObject
            haveOne = true
         end
      end
   end

   # spatial representation - georeferenceable representation (required if not others)
   if hRepresent.has_key?('georeferenceableRepresentation')
      hRep = hRepresent['georeferenceableRepresentation']
      unless hRep.empty?
         hObject = GeoreferenceableRepresentation.unpack(hRep, responseObj, outContext)
         unless hObject.nil?
            intRepresent[:georeferenceableRepresentation] = hObject
            haveOne = true
         end
      end
   end

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

   return intRepresent

end