Class: ADIWG::Mdtranslator::Writers::Fgdc::SpatialOrganization

Inherits:
Object
  • Object
show all
Defined in:
lib/adiwg/mdtranslator/writers/fgdc/classes/class_spatialOrganization.rb

Instance Method Summary collapse

Constructor Details

#initialize(xml, hResponseObj) ⇒ SpatialOrganization

Returns a new instance of SpatialOrganization.



17
18
19
20
21
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_spatialOrganization.rb', line 17

def initialize(xml, hResponseObj)
   @xml = xml
   @hResponseObj = hResponseObj
   @NameSpace = ADIWG::Mdtranslator::Writers::Fgdc
end

Instance Method Details

#writeXML(hResourceInfo) ⇒ Object



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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/adiwg/mdtranslator/writers/fgdc/classes/class_spatialOrganization.rb', line 23

def writeXML(hResourceInfo)

   # spatial organization 3.1 (indspref) - Indirect Spatial Reference
   # <- hResourceInfo.spatialReferenceSystems.systemIdentifier (first)
   haveIndirect = false
   hResourceInfo[:spatialReferenceSystems].each do |hSystem|
      unless hSystem[:systemIdentifier].nil? || hSystem[:systemIdentifier].empty?
         unless hSystem[:systemIdentifier][:description].nil? || hSystem[:systemIdentifier][:description].empty?
            @xml.tag!('indspref', hSystem[:systemIdentifier][:description])
            haveIndirect = true
            break
         end
      end
   end
   if !haveIndirect && @hResponseObj[:writerShowTags]
      @xml.tag!('indspref')
   end

   # spatial organization 3.2 (direct) - Direct Spatial Reference Method
   # <- resourceInfo.spatialRepresentationTypes
   # take first to match ['point' | 'vector' | 'grid']
   direct = nil
   hResourceInfo[:spatialRepresentationTypes].each do |type|
      direct = 'Point' if type == 'point'
      direct = 'Vector' if type == 'vector'
      direct = 'Raster' if type == 'grid'
     unless direct.nil?
        @xml.tag!('direct', direct)
        break
     end
   end
   if direct.nil? && @hResponseObj[:writerShowTags]
      @xml.tag!('direct')
   end

   # spatial organization 3.3 (ptvctinf) - point and vector object information
   # <- resourceInfo.spatialRepresentations.vectorRepresentation (first)
   hResourceInfo[:spatialRepresentations].each do |hSpaceRep|
      unless hSpaceRep[:vectorRepresentation].empty?
         hVectorRep = hSpaceRep[:vectorRepresentation]
         unless hVectorRep.empty?
            @xml.tag!('ptvctinf') do
               if hVectorRep[:topologyLevel].nil?

                  # spatial organization point and vector object 3.3.1 (sdtsterm) - SDTS term []
                  hVectorRep[:vectorObject].each do |hVecObj|
                     @xml.tag!('sdtsterm') do

                        # spatial organization point and vector object 3.3.1.1 (sdtstype) - SDTS object type (requied)
                        @xml.tag!('sdtstype', hVecObj[:objectType])

                        # spatial organization point and vector object 3.3.1.2 (ptvctcnt) - SDTS count
                        unless hVecObj[:objectCount].nil?
                           @xml.tag!('ptvctcnt', hVecObj[:objectCount])
                        end
                        if hVecObj[:objectCount].nil?
                           @xml.tag!('ptvctcnt')
                        end

                     end
                  end

               else

                  # point and vector object 3.3.2 (vpfterm) - VPF terms description
                  @xml.tag!('vpfterm') do

                     # VPF term 3.3.2.1 (vpflevel) - VPF topology level
                     @xml.tag!('vpflevel', hVectorRep[:topologyLevel])

                     # VPF term 3.3.2.2 (vpfinfo) - VPF point and vector object information []
                     hVectorRep[:vectorObject].each do |hVecObj|
                        @xml.tag!('vpfinfo') do

                           # spatial organization point and vector object 3.3.2.2.1 (vpftype) - VPF object type (requied)
                           @xml.tag!('vpftype', hVecObj[:objectType])

                           # spatial organization point and vector object 3.3.2.2.2 (ptvctcnt) - VPF object type
                           unless hVecObj[:objectCount].nil?
                              @xml.tag!('ptvctcnt', hVecObj[:objectCount])
                           end
                           if hVecObj[:objectCount].nil?
                              @xml.tag!('ptvctcnt')
                           end

                        end
                     end

                  end

               end
            end
            break
         end

      end
   end

   # spatial organization 3.4 (rastinfo) - point and vector object information
   # <- resourceInfo.spatialRepresentations.gridRepresentation (first)
   hResourceInfo[:spatialRepresentations].each do |hSpaceRep|
      unless hSpaceRep[:gridRepresentation].empty?
         hGridRep = hSpaceRep[:gridRepresentation]
         @xml.tag!('rastinfo') do

            # spatial organization raster 3.4.1 (rasttype) - raster type (required)
            unless hGridRep[:cellGeometry].empty?
               @xml.tag!('rasttype', hGridRep[:cellGeometry])
            end
            if hGridRep[:cellGeometry].empty?
               @NameSpace.issueWarning(380, 'rasttype')
            end

            # spatial organization raster 3.4.2 (rowcount) - row count
            hGridRep[:dimension].each do |hDimension|
               if hDimension[:dimensionType] == 'row'
                  unless hDimension[:dimensionSize].nil?
                     @xml.tag!('rowcount', hDimension[:dimensionSize])
                  end
               end
            end

            # spatial organization raster 3.4.2 (colcount) - column count
            hGridRep[:dimension].each do |hDimension|
               if hDimension[:dimensionType] == 'column'
                  unless hDimension[:dimensionSize].nil?
                     @xml.tag!('colcount', hDimension[:dimensionSize])
                  end
               end
            end

            # spatial organization raster 3.4.2 (vrtcount) - depth count
            hGridRep[:dimension].each do |hDimension|
               if hDimension[:dimensionType] == 'vertical'
                  unless hDimension[:dimensionSize].nil?
                     @xml.tag!('vrtcount', hDimension[:dimensionSize])
                  end
               end
            end

         end
         break
      end
   end

end