Module: ADIWG::Mdtranslator::Readers::Fgdc::MapProjection

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

Class Method Summary collapse

Class Method Details

.unpack(xMapProjection, hResponseObj) ⇒ Object



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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_mapProjection.rb', line 40

def self.unpack(xMapProjection, hResponseObj)

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   hProjection = intMetadataClass.newProjection
   hIdentifier = intMetadataClass.newIdentifier
   hProjection[:projectionIdentifier] = hIdentifier

   # map projection 4.1.2.1.1 (mapprojn) - map projection name (required)
   # -> ReferenceSystemParameters.projection.projectionIdentifier.identifier
   name = xMapProjection.xpath('./mapprojn').text
   unless name.empty?
      hIdentifier[:name] = name
   end
   if name.empty?
      hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: map projection name is missing'
   end

   # map projection 4.1.2.1.2 (albers) - Albers Conical Equal Area
   xAlbers = xMapProjection.xpath('./albers')
   unless xAlbers.empty?
      hIdentifier[:identifier] = 'albers'
      hIdentifier[:name] = 'Albers Conical Equal Area' if name.empty?
      return AlbersProjection.unpack(xAlbers, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.3 (azimequi) - Azimuthal Equidistant
   xAzimequi = xMapProjection.xpath('./azimequi')
   unless xAzimequi.empty?
      hIdentifier[:identifier] = 'azimuthalEquidistant'
      hIdentifier[:name] = 'Azimuthal Equidistant' if name.empty?
      return AzimuthEquidistantProjection.unpack(xAzimequi, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.4 (equicon) - Equidistant Conic
   xEquiCon = xMapProjection.xpath('./equicon')
   unless xEquiCon.empty?
      hIdentifier[:identifier] = 'equidistantConic'
      hIdentifier[:name] = 'Equidistant Conic' if name.empty?
      return EquidistantConicProjection.unpack(xEquiCon, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.5 (equirect) - Equirectangular
   xEquirec = xMapProjection.xpath('./equirect')
   unless xEquirec.empty?
      hIdentifier[:identifier] = 'equirectangular'
      hIdentifier[:name] = 'Equirectangular' if name.empty?
      return EquirectangularProjection.unpack(xEquirec, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.6 (gvnsp) - General Vertical Near-sided Perspective
   xGenVert = xMapProjection.xpath('./gvnsp')
   unless xGenVert.empty?
      hIdentifier[:identifier] = 'generalVertical'
      hIdentifier[:name] = 'General Vertical Near-sided Perspective' if name.empty?
      return GeneralVerticalProjection.unpack(xGenVert, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.7 (gnomonic) - Gnomonic
   xGeomonic = xMapProjection.xpath('./gnomonic')
   unless xGeomonic.empty?
      hIdentifier[:identifier] = 'gnomonic'
      hIdentifier[:name] = 'Gnomonic' if name.empty?
      return GnomonicProjection.unpack(xGeomonic, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.8 (lamberta) - Lambert Azimuthal Equal Area
   xLambertA = xMapProjection.xpath('./lamberta')
   unless xLambertA.empty?
      hIdentifier[:identifier] = 'lambertEqualArea'
      hIdentifier[:name] = 'Lambert Azimuthal Equal Area' if name.empty?
      return LambertEqualAreaProjection.unpack(xLambertA, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.9 (lambertc) - Lambert Conformal Conic
   xLambertC = xMapProjection.xpath('./lambertc')
   unless xLambertC.empty?
      hIdentifier[:identifier] = 'lambertConic'
      hIdentifier[:name] = 'Lambert Conformal Conic' if name.empty?
      return LambertConicProjection.unpack(xLambertC, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.10 (mercator) - Mercator
   xMercator = xMapProjection.xpath('./mercator')
   unless xMercator.empty?
      hIdentifier[:identifier] = 'mercator'
      hIdentifier[:name] = 'Mercator' if name.empty?
      return MercatorProjection.unpack(xMercator, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.11 (modsak) - Modified Stereographic for Alaska
   xAlaska = xMapProjection.xpath('./modsak')
   unless xAlaska.empty?
      hIdentifier[:identifier] = 'alaska'
      hIdentifier[:name] = 'Modified Stereographic for Alaska' if name.empty?
      return ModifiedAlaskaProjection.unpack(xAlaska, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.12 (miller) - Miller Cylindrical
   xMiller = xMapProjection.xpath('./miller')
   unless xMiller.empty?
      hIdentifier[:identifier] = 'miller'
      hIdentifier[:name] = 'Miller Cylindrical' if name.empty?
      return MillerCylinderProjection.unpack(xMiller, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.13 (obqmerc) - Oblique Mercator
   xObliqueM = xMapProjection.xpath('./obqmerc')
   unless xObliqueM.empty?
      hIdentifier[:identifier] = 'obliqueMercator'
      hIdentifier[:name] = 'Oblique Mercator' if name.empty?
      return ObliqueMercatorProjection.unpack(xObliqueM, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.14 (orthogr) - Orthographic
   xOrtho = xMapProjection.xpath('./orthogr')
   unless xOrtho.empty?
      hIdentifier[:identifier] = 'orthographic'
      hIdentifier[:name] = 'Orthographic' if name.empty?
      return OrthographicProjection.unpack(xOrtho, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.15 (polarst) - Polar Stereographic
   xPolarStereo = xMapProjection.xpath('./polarst')
   unless xPolarStereo.empty?
      hIdentifier[:identifier] = 'polarStereo'
      hIdentifier[:name] = 'Polar Stereographic' if name.empty?
      return PolarStereoProjection.unpack(xPolarStereo, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.16 (polycon) - Polyconic
   xPolycon = xMapProjection.xpath('./polycon')
   unless xPolycon.empty?
      hIdentifier[:identifier] = 'polyconic'
      hIdentifier[:name] = 'Polyconic' if name.empty?
      return PolyconicProjection.unpack(xPolycon, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.17 (robinson) - Robinson
   xRobin = xMapProjection.xpath('./robinson')
   unless xRobin.empty?
      hIdentifier[:identifier] = 'robinson'
      hIdentifier[:name] = 'Robinson' if name.empty?
      return RobinsonProjection.unpack(xRobin, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.18 (sinusoid) - Sinusoidal
   xSinu = xMapProjection.xpath('./sinusoid')
   unless xSinu.empty?
      hIdentifier[:identifier] = 'sinusoidal'
      hIdentifier[:name] = 'Sinusoidal' if name.empty?
      return SinusoidalProjection.unpack(xSinu, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.19 (spaceobq) - Space Oblique Mercator (Landsat)
   xSpaceO = xMapProjection.xpath('./spaceobq')
   unless xSpaceO.empty?
      hIdentifier[:identifier] = 'spaceOblique'
      hIdentifier[:name] = 'Space Oblique Mercator (Landsat)' if name.empty?
      return SpaceObliqueProjection.unpack(xSpaceO, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.20 (stereo) - Stereographic
   xStereo = xMapProjection.xpath('./stereo')
   unless xStereo.empty?
      hIdentifier[:identifier] = 'stereographic'
      hIdentifier[:name] = 'Stereographic' if name.empty?
      return StereographicProjection.unpack(xStereo, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.21 (transmer) - Transverse Mercator
   xTransMer = xMapProjection.xpath('./transmer')
   unless xTransMer.empty?
      hIdentifier[:identifier] = 'transverseMercator'
      hIdentifier[:name] = 'Transverse Mercator' if name.empty?
      return TransverseMercatorProjection.unpack(xTransMer, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.22 (vdgrin) - van der Grinten
   xVanDerG = xMapProjection.xpath('./vdgrin')
   unless xVanDerG.empty?
      hIdentifier[:identifier] = 'grinten'
      hIdentifier[:name] = 'Van Der Grinten' if name.empty?
      return VanDerGrintenProjection.unpack(xVanDerG, hProjection, hResponseObj)
   end

   # map projection 4.1.2.1.23 (mapprojp) - projection parameter set
   xParamSet = xMapProjection.xpath('./mapprojp')
   unless xParamSet.empty?
      hIdentifier[:identifier] = 'parameters'
      hIdentifier[:name] = 'Projection Parameters' if name.empty?
      return ProjectionParameters.unpack(xParamSet, hProjection, hResponseObj)
   end

   return nil

end