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
|
# File 'lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryCollection.rb', line 19
def self.unpack(hGeoCol, responseObj)
@MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
if hGeoCol.empty?
@MessagePath.issueWarning(360, responseObj)
return nil
end
intMetadataClass = InternalMetadata.new
intGeoCol = intMetadataClass.newGeometryCollection
if hGeoCol.has_key?('type')
if hGeoCol['type'] != ''
if hGeoCol['type'] == 'GeometryCollection'
intGeoCol[:type] = hGeoCol['type']
else
@MessagePath.issueError(361, responseObj)
end
end
end
if intGeoCol[:type].nil? || intGeoCol[:type] == ''
@MessagePath.issueError(362, responseObj)
end
if hGeoCol.has_key?('bbox')
unless hGeoCol['bbox'].empty?
intGeoCol[:bbox] = hGeoCol['bbox']
end
end
if hGeoCol.has_key?('geometries')
hGeoCol['geometries'].each do |hGeometry|
hReturn = GeoJson.unpack(hGeometry, responseObj)
unless hReturn.nil?
intGeoCol[:geometryObjects] << hReturn
end
end
else
@MessagePath.issueError(363, responseObj)
end
unless intGeoCol[:geometryObjects].empty?
intGeoCol[:computedBbox] = AdiwgCoordinates.computeBbox(intGeoCol[:geometryObjects])
end
intGeoCol[:nativeGeoJson] = hGeoCol
return intGeoCol
end
|