Module: ADIWG::Mdtranslator::Readers::Fgdc::Source

Defined in:
lib/adiwg/mdtranslator/readers/fgdc/modules/module_source.rb

Class Method Summary collapse

Class Method Details

.unpack(xSource, hResponseObj) ⇒ Object



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
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_source.rb', line 19

def self.unpack(xSource, hResponseObj)

   # instance classes needed in script
   intMetadataClass = .new
   hSource = intMetadataClass.newDataSource

   # source 2.5.1.1 (srccite) - source citation {citation} (required)
   xCitation = xSource.xpath('./srccite')
   unless xCitation.empty?
      hCitation = Citation.unpack(xCitation, hResponseObj)
      hSource[:sourceCitation] = hCitation
   end
   if xCitation.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: lineage source citation is missing'
   end

   # source 2.5.1.2 (srcscale) - source scale denominator
   scale = xSource.xpath('./srcscale').text
   unless scale.empty?
      hResolution = intMetadataClass.newSpatialResolution
      hResolution[:scaleFactor] = scale.to_i
      hSource[:spatialResolution] = hResolution
   end

   # source 2.5.1.3 (typesrc) - type of source media (required)
   type = xSource.xpath('./typesrc').text
   unless type.empty?
      hSource[:description] = type
   end
   if type.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: lineage source media type is missing'
   end

   # source 2.5.1.4 (srctime) - source time period {scope < temporalExtent} (required)
   xTimePeriod = xSource.xpath('./srctime')
   unless xTimePeriod.empty?
      hTimePeriod = TimePeriod.unpack(xTimePeriod, hResponseObj)
      unless hTimePeriod.nil?
         hScope = intMetadataClass.newScope
         hExtent = intMetadataClass.newExtent
         hTempExtent = intMetadataClass.newTemporalExtent
         hTempExtent[:timePeriod] = hTimePeriod
         hExtent[:temporalExtents] << hTempExtent
         hScope[:scopeCode] = 'dataset'
         hScope[:extents] << hExtent
         hSource[:scope] = hScope
      end
   end
   if xTimePeriod.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: lineage source time period is missing'
   end

   # source 2.5.1.5 (srccitea) - source citation abbreviation (required)
   sourceAbb = xSource.xpath('./srccitea').text
   unless sourceAbb.empty?
      hSource[:sourceId] = sourceAbb
   end
   if sourceAbb.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: lineage source citation abbreviation is missing'
   end

   # source 2.5.1.6 (srccontr) - source contribution (required)
   contribution = xSource.xpath('./srccontr').text
   unless contribution.empty?
      hSource[:description] = contribution
   end
   if contribution.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: lineage source contribution is missing'
   end

   return hSource

end