Module: ADIWG::Mdtranslator::Readers::Fgdc::PlanarReference

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

Class Method Summary collapse

Class Method Details

.unpack(xPlanar, hResourceInfo, hResponseObj) ⇒ Object



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

def self.unpack(xPlanar, hResourceInfo, hResponseObj)

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   hReferenceSystem = intMetadataClass.newSpatialReferenceSystem
   hSystemParameters = intMetadataClass.newReferenceSystemParameterSet
   hProjection = {}

   # get distance unit of measure for use in map projections and grid systems
   distanceUnits = nil
   xPlanCI = xPlanar.xpath('./planci')
   unless xPlanCI.empty?
      planDU = xPlanCI.xpath('./plandu').text
      unless planDU.empty?
         distanceUnits = planDU
      end
   end

   # planar reference 4.1.2.1 (mapproj) - map projection
   xMapProjection = xPlanar.xpath('./mapproj')
   unless xMapProjection.empty?
      hProjection = MapProjection.unpack(xMapProjection, hResponseObj)
   end

   # planar reference 4.1.2.2 (gridsys) - grid coordinate system
   xMapGrid = xPlanar.xpath('./gridsys')
   unless xMapGrid.empty?
      hProjection = MapGridSystem.unpack(xMapGrid, hResponseObj)
   end

   # planar reference 4.1.2.3 (localp) - local planar
   xMapLocal = xPlanar.xpath('./localp')
   unless xMapLocal.empty?
      hProjection = MapLocalPlanar.unpack(xMapLocal, hResponseObj)
   end

   # packing
   unless hProjection.nil? || hProjection.empty?
      unless distanceUnits.nil?
         hProjection[:falseEastingNorthingUnits] = distanceUnits
      end
      hSystemParameters[:projection] = hProjection
      hReferenceSystem[:systemParameterSet] = hSystemParameters
      hResourceInfo[:spatialReferenceSystems] << hReferenceSystem
   end

   # planar reference 4.1.2.4 (planci) - planar coordinate information
   xPlanarCI = xPlanar.xpath('./planci')
   unless xPlanarCI.empty?
      PlanarCoordinateInformation.unpack(xPlanarCI, hResourceInfo, hResponseObj)
   end

   return hResourceInfo

end