Module: ADIWG::Mdtranslator::Readers::Fgdc::PointVector

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

Class Method Summary collapse

Class Method Details

.unpack(xPtVec, hResourceInfo, 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
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_pointVector.rb', line 17

def self.unpack(xPtVec, hResourceInfo, hResponseObj)

   # instance classes needed in script
   intMetadataClass = .new

   # point and vector object 3.3.1 (sdtsterm) - SDTS term []
   axSDTSterm = xPtVec.xpath('./sdtsterm')
   unless axSDTSterm.empty?
      hVectorInfo = intMetadataClass.newVectorInfo

      axSDTSterm.each do |xTerm|
         hVectorObj = intMetadataClass.newVectorObject

         # SDTS term 3.3.1.1 (sdtstype) - point and vector object type (required)
         # -> spatialRepresentation.vectorInfo.vectorObject.objectType
         sdtsType = xTerm.xpath('./sdtstype').text
         unless sdtsType.empty?
            hVectorObj[:objectType] = sdtsType
         end
         if sdtsType.empty?
            hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: spatial data SDTS object type is missing'
         end

         # SDTS term 3.3.1.2 (ptvctcnt) - point and vector object count
         # -> spatialRepresentation.vectorInfo.vectorObject.objectCount
         ptvCount = xTerm.xpath('./ptvctcnt').text
         unless ptvCount.empty?
            hVectorObj[:objectCount] = ptvCount.to_i
         end

         hVectorInfo[:vectorObject] << hVectorObj
      end

      hSpatialRepresentation = intMetadataClass.newSpatialRepresentation
      hSpatialRepresentation[:vectorRepresentation] = hVectorInfo
      hResourceInfo[:spatialRepresentations] << hSpatialRepresentation
   end

   # point and vector object 3.3.2 (vpfterm) - VPF terms description
   xVPFterm = xPtVec.xpath('./vpfterm')
   unless xVPFterm.empty?
      hVectorInfo = intMetadataClass.newVectorInfo

      # VPF term 3.3.2.1 (vpflevel) - VPF topology level (required)
      # -> spatialRepresentation.vectorInfo.topologyLevel
      level = xVPFterm.xpath('vpflevel').text
      unless level.empty?
         hVectorInfo[:topologyLevel] = level.to_i
      end
      if level.empty?
         hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: spatial data VPF topology level is missing'
      end

      # VPF term 3.3.2.2 (vpfinfo) - VPF point and vector object information [] (required)
      axVPFInfo = xVPFterm.xpath('./vpfinfo')
      unless axVPFInfo.empty?
         axVPFInfo.each do |xInfo|
            hVectorObj = intMetadataClass.newVectorObject

            # VPF point and object 3.3.2.2.1 (vpftype) - VPF point and vector object type (required)
            # -> spatialRepresentation.vectorInfo.vectorObject.objectType
            vpfType = xInfo.xpath('./vpftype').text
            unless vpfType.empty?
               hVectorObj[:objectType] = vpfType
            end
            if vpfType.empty?
               hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: spatial data VPF object type is missing'
            end

            # VPF point and object 3.3.2.2.2 (ptvctcnt) - VPF point and vector object count
            # -> spatialRepresentation.vectorInfo.vectorObject.objectCount
            vpfCount = xInfo.xpath('./ptvctcnt').text
            unless vpfCount.empty?
               hVectorObj[:objectCount] = vpfCount.to_i
            end

            hVectorInfo[:vectorObject] << hVectorObj
         end

         hSpatialRepresentation = intMetadataClass.newSpatialRepresentation
         hSpatialRepresentation[:vectorRepresentation] = hVectorInfo
         hResourceInfo[:spatialRepresentations] << hSpatialRepresentation
      end
      if axVPFInfo.empty?
         hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: spatial data VPF object information is missing'
      end

   end

   # error message
   if axSDTSterm.empty? && xVPFterm.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: spatial data point-vector terms are missing'
   end

   return hResourceInfo

end