Module: ADIWG::Mdtranslator::Readers::Fgdc::GeographicResolution

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

Class Method Summary collapse

Class Method Details

.unpack(xGeographic, hResponseObj) ⇒ Object



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

def self.unpack(xGeographic, hResponseObj)

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new

   hResolution = intMetadataClass.newSpatialResolution
   hGeoResolution = intMetadataClass.newGeographicResolution

   # geographic reference 4.1.1.1 (latres) - latitude resolution (required)
   # -> spatialResolution.geographicResolution.latitudeResolution
   latResolution = xGeographic.xpath('./latres').text
   unless latResolution.empty?
      hGeoResolution[:latitudeResolution] = latResolution.to_f
   end
   if latResolution.empty?
      hResponseObj[:readerExecutionMessages] <<
         'WARNING: FGDC reader: geographic latitude resolution is missing'
   end

   # geographic reference 4.1.1.2 (longres) - longitude resolution (required)
   # -> spatialResolution.geographicResolution.longitudeResolution
   longResolution = xGeographic.xpath('./longres').text
   unless longResolution.empty?
      hGeoResolution[:longitudeResolution] = longResolution.to_f
   end
   if longResolution.empty?
      hResponseObj[:readerExecutionMessages] <<
         'WARNING: FGDC reader: geographic longitude resolution is missing'
   end

   # geographic reference 4.1.1.3 (geogunit) - latitude/longitude units (required)
   # -> spatialResolution.geographicResolution.unitOfMeasure
   unitMeasure = xGeographic.xpath('./geogunit').text
   unless unitMeasure.empty?
      hGeoResolution[:unitOfMeasure] = unitMeasure
   end
   if unitMeasure.empty?
      hResponseObj[:readerExecutionMessages] <<
         'WARNING: FGDC reader: geographic latitude/longitude units are missing'
   end

   hResolution[:geographicResolution] = hGeoResolution

   return hResolution

end