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
237
|
# File 'lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb', line 59
def self.unpack(xDomain, hResponseObj)
intMetadataClass = InternalMetadata.new
hIntExtent = intMetadataClass.newExtent
hIntGeoExtent = intMetadataClass.newGeographicExtent
hIntExtent[:geographicExtents] << hIntGeoExtent
hIntExtent[:description] = 'FGDC spatial domain'
description = xDomain.xpath('./descgeog').text
unless description.empty?
hIntGeoExtent[:description] = description
end
if description.empty?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: BIO geographic description is missing'
end
xBbox = xDomain.xpath('./bounding')
unless xBbox.empty?
hBbox = intMetadataClass.newBoundingBox
hBbox[:westLongitude] = xBbox.xpath('./westbc').text.to_f
if hBbox[:westLongitude].nil?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: bounding box west boundary is missing'
end
hBbox[:eastLongitude] = xBbox.xpath('./eastbc').text.to_f
if hBbox[:eastLongitude].nil?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: bounding box east boundary is missing'
end
hBbox[:northLatitude] = xBbox.xpath('./northbc').text.to_f
if hBbox[:northLatitude].nil?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: bounding box north boundary is missing'
end
hBbox[:southLatitude] = xBbox.xpath('./southbc').text.to_f
if hBbox[:southLatitude].nil?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: bounding box south boundary is missing'
end
xAltitude = xBbox.xpath('./boundalt')
unless xAltitude.empty?
hBbox[:minimumAltitude] = xAltitude.xpath('./altmin').text.to_f
if hBbox[:minimumAltitude].nil?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: BIO bounding box minimum altitude is missing'
end
hBbox[:maximumAltitude] = xAltitude.xpath('./altmax').text.to_f
if hBbox[:maximumAltitude].nil?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: BIO bounding box maximum altitude is missing'
end
hBbox[:unitsOfAltitude] = xAltitude.xpath('./altunits').text
end
hIntGeoExtent[:boundingBox] = hBbox
end
if xBbox.empty?
hResponseObj[:readerExecutionMessages] << 'WARNING: FGDC reader: bounding box is missing'
end
axPoly = xDomain.xpath('//dsgpoly')
unless axPoly.empty?
hIntCollect = intMetadataClass.newFeatureCollection
hIntCollect[:type] = 'FeatureCollection'
hCollection = {
'type' => 'FeatureCollection',
'features' => []
}
axPoly.each do |xPoly|
polygon = []
xOring = xPoly.xpath('./dsgpolyo')
unless xOring.empty?
aOutCoords = process_polygon(xOring)
unless aOutCoords.empty?
if AdiwgCoordinates.is_polygon_clockwise(aOutCoords)
aOutCoords.reverse!
end
polygon << aOutCoords
end
axXring = xPoly.xpath('./dsgpolyx')
unless axXring.empty?
axXring.each do |xRing|
aInCoords = process_polygon(xRing)
unless aInCoords.empty?
unless AdiwgCoordinates.is_polygon_clockwise(aInCoords)
aInCoords.reverse!
end
polygon << aInCoords
end
end
end
end
unless polygon.empty?
hGeometry = {
'type' => 'Polygon',
'coordinates' => polygon
}
hFeature = {
'type' => 'Feature',
'geometry' => hGeometry,
'properties' => {
'description' => 'FGDC bounding polygon'
}
}
hCollection['features'] << hFeature
hIntGeo = intMetadataClass.newGeometryObject
hIntGeo[:type] = 'Polygon'
hIntGeo[:coordinates] = polygon
hIntGeo[:nativeGeoJson] = hGeometry
hIntFeature = intMetadataClass.newGeometryFeature
hIntFeature[:type] = 'Feature'
hIntFeature[:geometryObject] = hIntGeo
hIntFeature[:nativeGeoJson] = hFeature
hIntProps = intMetadataClass.newGeometryProperties
hIntProps[:description] = 'FGDC bounding polygon'
hIntFeature[:properties] = hIntProps
hIntCollect[:features] << hIntFeature
hIntCollect[:nativeGeoJson] = hCollection
end
end
hIntGeoExtent[:geographicElements] << hIntCollect
hIntGeoExtent[:nativeGeoJson] << hIntCollect[:nativeGeoJson]
end
return hIntExtent
end
|