Module: Adiwg_ResourceInfo

Defined in:
lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_resourceInfo.rb

Class Method Summary collapse

Class Method Details

.unpack(hResourceInfo) ⇒ Object



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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
# File 'lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_resourceInfo.rb', line 38

def self.unpack(hResourceInfo)

  # instance classes needed in script
  intMetadataClass = .new
  intResInfo = intMetadataClass.newResourceInfo

  # resource information - resource type
  if hResourceInfo.has_key?('resourceType')
    s = hResourceInfo['resourceType']
    if s != ''
      intResInfo[:resourceType] = s
    end
  end

  # resource information - citation
  if hResourceInfo.has_key?('citation')
    hCitation = hResourceInfo['citation']
    unless hCitation.empty?
      intResInfo[:citation] = Adiwg_Citation.unpack(hCitation)
    end
  end

  # resource information - resource time period
  if hResourceInfo.has_key?('resourceTimePeriod')
    hResPeriod = hResourceInfo['resourceTimePeriod']
    unless hResPeriod.empty?
      intResInfo[:timePeriod] = Adiwg_TimePeriod.unpack(hResPeriod)
    end
  end

  # resource information - point of contact
  if hResourceInfo.has_key?('pointOfContact')
    aPOC = hResourceInfo['pointOfContact']
    unless aPOC.empty?
      aPOC.each do |rParty|
        intResInfo[:pointsOfContact] << Adiwg_ResponsibleParty.unpack(rParty)
      end
    end
  end

  # resource information - abstract
  if hResourceInfo.has_key?('abstract')
    s = hResourceInfo['abstract']
    if s != ''
      intResInfo[:abstract] = s
    end
  end

  # resource information - short abstract
  if hResourceInfo.has_key?('shortAbstract')
    s = hResourceInfo['shortAbstract']
    if s != ''
      intResInfo[:shortAbstract] = s
    end
  end

  # resource information - status
  if hResourceInfo.has_key?('status')
    s = hResourceInfo['status']
    if s != ''
      intResInfo[:status] = s
    end
  end

  # resource information - has mappable location
  if hResourceInfo.has_key?('hasMapLocation')
    s = hResourceInfo['hasMapLocation']
    if s != ''
      intResInfo[:hasMapLocation?] = s
    end
  end

  # resource information - has data available
  if hResourceInfo.has_key?('hasDataAvailable')
    s = hResourceInfo['hasDataAvailable']
    if s != ''
      intResInfo[:hasDataAvailable?] = s
    end
  end

  # resource information - language
  if hResourceInfo.has_key?('language')
    aLanguage = hResourceInfo['language']
    unless aLanguage.empty?
      aLanguage.each do |language|
        intResInfo[:resourceLanguages] << language
      end
    end
  end

  # resource information - purpose
  if hResourceInfo.has_key?('purpose')
    s = hResourceInfo['purpose']
    if s != ''
      intResInfo[:purpose] = s
    end
  end

  # resource information - credit
  if hResourceInfo.has_key?('credit')
    aCredits = hResourceInfo['credit']
    unless aCredits.empty?
      aCredits.each do |credit|
        intResInfo[:credits] << credit
      end
    end
  end

  # resource information - topic category
  if hResourceInfo.has_key?('topicCategory')
    aTopics = hResourceInfo['topicCategory']
    unless aTopics.empty?
      aTopics.each do |topic|
        intResInfo[:topicCategories] << topic
      end
    end
  end

  # resource information - environment description
  if hResourceInfo.has_key?('environmentDescription')
    s = hResourceInfo['environmentDescription']
    if s != ''
      intResInfo[:environmentDescription] = s
    end
  end

  # resource information - resource format
  if hResourceInfo.has_key?('resourceNativeFormat')
    aResFormat = hResourceInfo['resourceNativeFormat']
    unless aResFormat.empty?
      aResFormat.each do |hResFormat|
        intResInfo[:resourceFormats] << Adiwg_ResourceFormat.unpack(hResFormat)
      end
    end
  end

  # resource information - descriptive keywords
  if hResourceInfo.has_key?('keyword')
    aDesKeywords = hResourceInfo['keyword']
    unless aDesKeywords.empty?
      aDesKeywords.each do |hDesKeyword|
        intResInfo[:descriptiveKeywords] << Adiwg_DescriptiveKeyword.unpack(hDesKeyword)
      end
    end
  end

  # resource information - resource maintenance
  if hResourceInfo.has_key?('resourceMaintenance')
    aResMaint = hResourceInfo['resourceMaintenance']
    unless aResMaint.empty?
      aResMaint.each do |hResource|
        intResInfo[:resourceMaint] << Adiwg_ResourceMaintenance.unpack(hResource)
      end
    end
  end

  # resource information - resource specific usage
  if hResourceInfo.has_key?('resourceSpecificUsage')
    aResUses = hResourceInfo['resourceSpecificUsage']
    unless aResUses.empty?
      aResUses.each do |hUsage|
        intResInfo[:resourceUses] << Adiwg_ResourceSpecificUsage.unpack(hUsage)
      end
    end
  end

  # resource information - graphic overview
  if hResourceInfo.has_key?('graphicOverview')
    aBrowseGraph = hResourceInfo['graphicOverview']
    unless aBrowseGraph.empty?
      aBrowseGraph.each do |hBGraphic|
        intResInfo[:graphicOverview] << Adiwg_BrowseGraphic.unpack(hBGraphic)
      end
    end
  end

  # resource information - use constraints
  if hResourceInfo.has_key?('constraint')
    hConstraint = hResourceInfo['constraint']

    # resource information - resource constraints - use
    if hConstraint.has_key?('useLimitation')
      aUseLimits = hConstraint['useLimitation']
      unless aUseLimits.empty?
        aUseLimits.each do |useLimit|
          intResInfo[:useConstraints] << useLimit
        end
      end
    end

    # resource information - resource constraints - legal
    if hConstraint.has_key?('legalConstraint')
      aLegalCons = hConstraint['legalConstraint']
      unless aLegalCons.empty?
        aLegalCons.each do |hLegalCon|
          intResInfo[:legalConstraints] << Adiwg_LegalConstraints.unpack(hLegalCon)
        end
      end
    end

    # resource information - resource constraints - security
    if hConstraint.has_key?('securityConstraint')
      aSecurityCons = hConstraint['securityConstraint']
      unless aSecurityCons.empty?
        aSecurityCons.each do |hSecurityCon|
          intResInfo[:securityConstraints] << Adiwg_SecurityConstraints.unpack(hSecurityCon)
        end
      end
    end

  end

  # resource information - taxonomy
  if hResourceInfo.has_key?('taxonomy')
    hTaxonomy = hResourceInfo['taxonomy']
    unless hTaxonomy.empty?
      intResInfo[:taxonomy] = Adiwg_Taxonomy.unpack(hTaxonomy)
    end
  end

  # resource information - spatial reference systems
  if hResourceInfo.has_key?('spatialReferenceSystem')
    hSpatialRef = hResourceInfo['spatialReferenceSystem']
    unless hSpatialRef.empty?
      intResInfo[:spatialReferenceSystem] = Adiwg_SpatialReferenceSystem.unpack(hSpatialRef)
    end
  end

  # resource information - spatial representation type
  if hResourceInfo.has_key?('spatialRepresentation')
    aSpatialType = hResourceInfo['spatialRepresentation']
    unless aSpatialType.empty?
      aSpatialType.each do |spType|
        intResInfo[:spatialRepresentationTypes] << spType
      end
    end
  end

  # resource information - spatial resolution
  if hResourceInfo.has_key?('spatialResolution')
    aSpRes = hResourceInfo['spatialResolution']
    unless aSpRes.empty?
      aSpRes.each do |hResolution|
        intResInfo[:spatialResolutions] << Adiwg_Resolution.unpack(hResolution)
      end
    end
  end

  # resource information - extent
  if hResourceInfo.has_key?('extent')
    aExtents = hResourceInfo['extent']
    unless aExtents.empty?
      aExtents.each do |hExtent|
        intResInfo[:extents] << Adiwg_Extent.unpack(hExtent)
      end
    end
  end

  # resource information - data quality information
  if hResourceInfo.has_key?('dataQualityInfo')
    aDataQual = hResourceInfo['dataQualityInfo']
    unless aDataQual.empty?
      aDataQual.each do |hDQ|
        intResInfo[:dataQualityInfo] << Adiwg_DataQuality.unpack(hDQ)
      end
    end
  end

  # resource information - supplemental info
  if hResourceInfo.has_key?('supplementalInfo')
    s = hResourceInfo['supplementalInfo']
    if s != ''
      intResInfo[:supplementalInfo] = s
    end
  end

  return intResInfo
end