Module: ADIWG::Mdtranslator::Readers::Fgdc::GeodeticReference

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

Class Method Summary collapse

Class Method Details

.unpack(xHorizontalRef, hResponseObj) ⇒ Object



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

def self.unpack(xHorizontalRef, hResponseObj)

   # instance classes needed in script
   intMetadataClass = .new

   hGeodetic = intMetadataClass.newGeodetic
   xGeodetic = xHorizontalRef.xpath('./geodetic')

   # geodetic model 4.1.4.1 (horizdn) - horizontal datum name
   # -> referenceSystemParameters.geodetic.datumIdentifier.identifier
   datumName = xGeodetic.xpath('./horizdn').text
   unless datumName.empty?
      hGeodetic[:datumIdentifier] = intMetadataClass.newIdentifier
      hGeodetic[:datumIdentifier][:identifier] = datumName
      hGeodetic[:datumIdentifier][:name] = datumName
   end

   # geodetic model 4.1.4.2 (ellips) - ellipsoid name (required)
   # -> referenceSystemParameters.geodetic.ellipsoidIdentifier.identifier
   ellipsoidName = xGeodetic.xpath('./ellips').text
   unless ellipsoidName.empty?
      hGeodetic[:ellipsoidIdentifier] = intMetadataClass.newIdentifier
      hGeodetic[:ellipsoidIdentifier][:identifier] = ellipsoidName
      hGeodetic[:ellipsoidIdentifier][:name] = ellipsoidName
   end
   if ellipsoidName.empty?
      hResponseObj[:readerExecutionMessages] <<
         'WARNING: FGDC reader: geodetic reference ellipsoid name is missing'
   end

   # geodetic model 4.1.4.3 (semiaxis) - semi-major axis (required)
   # -> referenceSystemParameters.geodetic.semiMajorAxis
   semiAxis = xGeodetic.xpath('./semiaxis').text
   unless semiAxis.empty?
      hGeodetic[:semiMajorAxis] = semiAxis.to_f
   end
   if semiAxis.empty?
      hResponseObj[:readerExecutionMessages] <<
         'WARNING: FGDC reader: geodetic reference radius of semi-major axis is missing'
   end

   # geodetic model 4.1.2.4.4 (plandu) - distance units
   # take value from the first 'planar' section with 'plandu' specified
   axPlanar = xHorizontalRef.xpath('./planar')
   unless axPlanar.empty?
      axPlanar.each do |xPlanar|
         xPlanCI = xPlanar.xpath('./planci')
         unless xPlanCI.empty?
            units = xPlanCI.xpath('./plandu').text
            unless units.empty?
               hGeodetic[:axisUnits] = units
            end
         end
      end
   end

   # geodetic model 4.1.4.4 (denflat) - denominator of flattening ratio (required)
   # -> referenceSystemParameters.geodetic.denominatorOfFlatteningRatio
   flattening = xGeodetic.xpath('./denflat').text
   unless flattening.empty?
      hGeodetic[:denominatorOfFlatteningRatio] = flattening.to_f
   end
   if flattening.empty?
      hResponseObj[:readerExecutionMessages] <<
         'WARNING: FGDC reader: geodetic reference denominator flattening ratio is missing'
   end

   hReferenceSystem = intMetadataClass.newSpatialReferenceSystem
   hSystemParameters = intMetadataClass.newReferenceSystemParameterSet
   hSystemParameters[:geodetic] = hGeodetic
   hReferenceSystem[:systemParameterSet] = hSystemParameters

   return hReferenceSystem

end