Class: MD_DataIdentification

Inherits:
Object
  • Object
show all
Defined in:
lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataIdentification.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ MD_DataIdentification

Returns a new instance of MD_DataIdentification.



38
39
40
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataIdentification.rb', line 38

def initialize(xml)
	@xml = xml
end

Instance Method Details

#writeXML(hDataId, aAssocRes) ⇒ Object



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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
# File 'lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataIdentification.rb', line 42

def writeXML(hDataId, aAssocRes)

	# codes used by MD_Metadata
	progressCode = MD_ProgressCode.new(@xml)
	spatialCode = MD_SpatialRepresentationTypeCode.new(@xml)
	topicCode = MD_TopicCategoryCode.new(@xml)

	# classes used by MD_Metadata
	intMetadataClass = InternalMetadata.new
	citationClass = CI_Citation.new(@xml)
	rPartyClass = CI_ResponsibleParty.new(@xml)
	mInfoClass = MD_MaintenanceInformation.new(@xml)
	bGraphicClass = MD_BrowseGraphic.new(@xml)
	rFormatClass = MD_Format.new(@xml)
	keywordClass = MD_Keywords.new(@xml)
	useClass = MD_Usage.new(@xml)
	uConClass = MD_Constraints.new(@xml)
	lConClass = MD_LegalConstraints.new(@xml)
	sConClass = MD_SecurityConstraints.new(@xml)
	aggInfoClass = MD_AggregateInformation.new(@xml)
	taxClass = MD_TaxonSys.new(@xml)
	resolutionClass = MD_Resolution.new(@xml)
	extentClass = EX_Extent.new(@xml)

	# data identification
	@xml.tag!('gmd:MD_DataIdentification') do

		# data identification - citation - required
		hCitation = hDataId[:citation]
		if hCitation.empty?
			@xml.tag!('gmd:citation', {'gco:nilReason' => 'missing'})
		else
			@xml.tag!('gmd:citation') do
				citationClass.writeXML(hCitation)
			end
		end

		# data identification - abstract - required
		s = hDataId[:abstract]
		if s.nil?
			@xml.tag!('gmd:abstract', {'gco:nilReason' => 'missing'})
		else
			@xml.tag!('gmd:abstract') do
				@xml.tag!('gco:CharacterString', s)
			end
		end

		# data identification - purpose
		s = hDataId[:purpose]
		if !s.nil?
			@xml.tag!('gmd:purpose') do
				@xml.tag!('gco:CharacterString', s)
			end
		elsif $showAllTags
			@xml.tag!('gmd:purpose')
		end

		# data identification - credit
		aCredits = hDataId[:credits]
		if !aCredits.empty?
			aCredits.each do |credit|
				@xml.tag!('gmd:credit') do
					@xml.tag!('gco:CharacterString', credit)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:credit')
		end

		# data identification - status - required
		s = hDataId[:status]
		if s.nil?
			@xml.tag!('gmd:status', {'gco:nilReason' => 'missing'})
		else
			@xml.tag!('gmd:status') do
				progressCode.writeXML(s)
			end
		end

		# data identification - point of contact
		aPOCs = hDataId[:pointsOfContact]
		if !aPOCs.empty?
			aPOCs.each do |hPContact|
				@xml.tag!('gmd:pointOfContact') do
					rPartyClass.writeXML(hPContact)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:pointOfContact')
		end

		# data identification - resource maintenance
		aMaintInfo = hDataId[:resourceMaint]
		if !aMaintInfo.empty?
			aMaintInfo.each do |hResMaintInfo|
				@xml.tag!('gmd:resourceMaintenance') do
					mInfoClass.writeXML(hResMaintInfo)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:resourceMaintenance')
		end

		# data identification - graphic overview
		aGOverview = hDataId[:graphicOverview]
		if !aGOverview.empty?
			aGOverview.each do |graphic|
				gLink = graphic[:bGURI]
				attributes = {}
				attributes['xlink:href'] = gLink if gLink
				@xml.tag!('gmd:graphicOverview', attributes) do
					bGraphicClass.writeXML(graphic)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:graphicOverview')
		end

		# data identification - resource format
		aResFormats = hDataId[:resourceFormats]
		if !aResFormats.empty?
			aResFormats.each do |hResFormat|
				@xml.tag!('gmd:resourceFormat') do
					rFormatClass.writeXML(hResFormat)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:resourceFormat')
		end

		# data identification - descriptive keywords
		aDesKeywords = hDataId[:descriptiveKeywords]
		if !aDesKeywords.empty?
			aDesKeywords.each do |hDKeyword|
				@xml.tag!('gmd:descriptiveKeywords') do
					keywordClass.writeXML(hDKeyword)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:descriptiveKeywords')
		end

		# data identification - resource specific usage
		aResUses = hDataId[:resourceUses]
		if !aResUses.empty?
			aResUses.each do |hResUse|
				@xml.tag!('gmd:resourceSpecificUsage') do
					useClass.writeXML(hResUse)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:resourceSpecificUsage')
		end

		# data identification - resource constraints - use constraints
		aUseLimits = hDataId[:useConstraints]
		if !aUseLimits.empty?
			@xml.tag!('gmd:resourceConstraints') do
				uConClass.writeXML(aUseLimits)
			end
		elsif $showAllTags
			@xml.tag!('gmd:resourceConstraints') do
				@xml.tag!('gmd:MD_Constraints')
			end
		end

		# data identification - resource constraints - legal constraints
		aLegalCons = hDataId[:legalConstraints]
		if !aLegalCons.empty?
			aLegalCons.each do |hLegalCon|
				@xml.tag!('gmd:resourceConstraints') do
					lConClass.writeXML(hLegalCon)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:resourceConstraints') do
				@xml.tag!('gmd:MD_LegalConstraints')
			end
		end

		# data identification - resource constraints - security constraints
		# empty tag cannot be shown for security constraints - XSD issue
		aSecurityCons = hDataId[:securityConstraints]
		unless aSecurityCons.empty?
			aSecurityCons.each do |hSecCon|
				@xml.tag!('gmd:resourceConstraints') do
					sConClass.writeXML(hSecCon)
				end
			end
		end

		# data identification - aggregate information
		if !aAssocRes.empty?
			aAssocRes.each do |hAssocRes|
				@xml.tag!('gmd:aggregationInfo') do
					aggInfoClass.writeXML(hAssocRes)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:aggregationInfo')
		end

		# data identification - taxonomy
		hTaxonomy = hDataId[:taxonomy]
		if !hTaxonomy.empty?
			@xml.tag!('gmd:taxonomy') do
				taxClass.writeXML(hTaxonomy)
			end
		elsif $showAllTags
			@xml.tag!('gmd:taxonomy')
		end

		# data identification - spatial representation type
		aSpatialType = hDataId[:spatialRepresentationTypes]
		if !aSpatialType.empty?
			aSpatialType.each do |spType|
				@xml.tag!('gmd:spatialRepresentationType') do
					spatialCode.writeXML(spType)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:spatialRepresentationType')
		end

		# data identification - spatial resolution
		aSpatialRes = hDataId[:spatialResolutions]
		if !aSpatialRes.empty?
			aSpatialRes.each do |hSpRes|
				@xml.tag!('gmd:spatialResolution') do
					resolutionClass.writeXML(hSpRes)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:spatialResolution')
		end

		# data identification - language - required - default of english applied
		aLanguages = hDataId[:resourceLanguages]
		if !aLanguages.empty?
			aLanguages.each do |language|
				@xml.tag!('gmd:language') do
					@xml.tag!('gco:CharacterString', language)
				end
			end
		else
			@xml.tag!('gmd:language') do
				@xml.tag!('gco:CharacterString', 'eng; USA')
			end
		end

		# data identification - topic category
		aTopics = hDataId[:topicCategories]
		if !aTopics.empty?
			aTopics.each do |spType|
				@xml.tag!('gmd:topicCategory') do
					topicCode.writeXML(spType)
				end
			end
		elsif $showAllTags
			@xml.tag!('gmd:topicCategory')
		end

		# data identification - environment description
		s = hDataId[:environmentDescription]
		if !s.nil?
			@xml.tag!('gmd:environmentDescription') do
				@xml.tag!('gco:CharacterString', s)
			end
		elsif $showAllTags
			@xml.tag!('gmd:environmentDescription')
		end

		# data identification - extent
		# if resource time period, represent the time period as
		# a temporal element in the first extent
		needTag = true
		hTimePeriod = hDataId[:timePeriod]
		if !hTimePeriod.empty?
			hTempEle = intMetadataClass.newTemporalElement
			hTempEle[:timePeriod] = hTimePeriod
			hExt = intMetadataClass.newExtent
			hExt[:extDesc] = 'Temporal span of the resource (data or project)'
			hExt[:extTempElements] << hTempEle
			@xml.tag!('gmd:extent') do
				extentClass.writeXML(hExt)
			end
			needTag = false
		end

		# add the remaining geographic, temporal, and veritcal extents
		aExtents = hDataId[:extents]
		if !aExtents.empty?
			aExtents.each do |hExtent|
				@xml.tag!('gmd:extent') do
					extentClass.writeXML(hExtent)
				end
			end
		elsif $showAllTags && needTag
			@xml.tag!('gmd:extent')
		end

		# data identification - supplemental info
		s = hDataId[:supplementalInfo]
		if !s.nil?
			@xml.tag!('gmd:supplementalInformation') do
				@xml.tag!('gco:CharacterString', s)
			end
		elsif $showAllTags
			@xml.tag!('gmd:supplementalInformation')
		end

	end

end