Module: ADIWG::Mdtranslator::Readers::Fgdc::SpatialOrganization

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

Class Method Summary collapse

Class Method Details

.unpack(xSpatialOrg, hResourceInfo, 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
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialOrganization.rb', line 19

def self.unpack(xSpatialOrg, hResourceInfo, hResponseObj)

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new

   # spatial organization 3.1 (indspref) - indirect spatial reference
   # -> resourceInfo.spatialReferenceSystems.systemIdentifier.identifier per NOAA
   # -> however definitions are not close
   indirect = xSpatialOrg.xpath('./indspref').text
   unless indirect.empty?
      hSystem = intMetadataClass.newSpatialReferenceSystem
      hIdentifier = intMetadataClass.newIdentifier
      hIdentifier[:identifier] = 'indirect'
      hIdentifier[:namespace] = 'FGDC'
      hIdentifier[:description] = indirect
      hSystem[:systemIdentifier] = hIdentifier
      hResourceInfo[:spatialReferenceSystems] << hSystem
   end

   # spatial organization 3.2 (direct) - direct spatial reference method
   # -> resourceInfo.spatialRepresentationTypes, translate FGDC to ISO as:
   # -> point = vector do 3.3
   # -> vector = vector do 3.3
   # -> raster = grid do 3.4
   direct = xSpatialOrg.xpath('./direct').text
   unless direct.empty?
      type = 'point' if direct == 'Point'
      type = 'vector' if direct == 'Vector'
      type = 'grid' if direct == 'Raster'
      hResourceInfo[:spatialRepresentationTypes] << type

      # spatial organization 3.3 (ptvctinfo) - point and vector object
      if type == 'vector' || type == 'point'
         xPtVec = xSpatialOrg.xpath('./ptvctinf')
         unless xPtVec.empty?
            PointVector.unpack(xPtVec, hResourceInfo, hResponseObj)
         end
      end

      # spatial organization 3.4 (rastinfo) - raster object
      if type == 'grid'
         xRaster = xSpatialOrg.xpath('./rastinfo')
         unless xRaster.empty?
            Raster.unpack(xRaster, hResourceInfo, hResponseObj)
         end
      end

   end

   return hResourceInfo

end