adiwg-mdtranslator 1.3.0 → 1.4.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.jsbeautifyrc +8 -0
- data/Rakefile +1 -3
- data/adiwg-mdtranslator.gemspec +2 -0
- data/bin/mdtranslator +2 -2
- data/lib/adiwg/mdtranslator.rb +2 -0
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +6 -3
- data/lib/adiwg/mdtranslator/internal/module_geoFormat.rb +183 -190
- data/lib/adiwg/mdtranslator/internal/module_lineString.rb +18 -0
- data/lib/adiwg/mdtranslator/internal/module_point.rb +18 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_v1/module_contacts.rb +3 -1
- data/lib/adiwg/mdtranslator/readers/mdJson/modules_v1/module_geographicElement.rb +18 -10
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_additionalDocumentation.rb +52 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_boundingBox.rb +54 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_browseGraphic.rb +66 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_citation.rb +125 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_contacts.rb +144 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_dateTime.rb +31 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_distributionInfo.rb +64 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_extent.rb +61 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geoCoordSystem.rb +50 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geoProperties.rb +91 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_geographicElement.rb +161 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_metadata.rb +70 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_metadataInfo.rb +131 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_onlineResource.rb +71 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_resourceIdentifier.rb +73 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_resourceInfo.rb +437 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_responsibleParty.rb +53 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/module_sbJson.rb +52 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/modules_v0/version.rb +12 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/readme.md +12 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_reader.rb +205 -0
- data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_validator.rb +44 -0
- data/lib/adiwg/mdtranslator/version.rb +1 -2
- data/lib/adiwg/mdtranslator/writers/html/sections/html_browseGraphic.rb +2 -1
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiGeometry.rb +5 -5
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_responsibleParty.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/mdJson/mdJson_writer.rb +42 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/readme.md +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_additionalDoc.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_address.rb +22 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_associatedResource.rb +22 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_attribute.rb +27 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_base.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_citation.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_constraint.rb +28 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_contact.rb +31 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageInfo.rb +30 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_coverageItem.rb +44 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dataQuality.rb +32 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dateTime.rb +18 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dictionary.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_distributionInfo.rb +31 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_domain.rb +25 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entity.rb +37 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_extent.rb +26 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_format.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_geographicElement.rb +81 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_graphicOverview.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_gridInfo.rb +27 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_imageInfo.rb +28 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_keyword.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_locale.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadata.rb +30 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_metadataInfo.rb +36 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_onlineResource.rb +21 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_phone.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processStep.rb +25 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceIdentifier.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceInfo.rb +69 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceMaintenance.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_responsibleParty.rb +18 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_spatialreference.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_taxon.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_taxonomy.rb +32 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_temporalElement.rb +38 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_timePeriod.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_transferOption.rb +33 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_usage.rb +23 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_verticalElement.rb +20 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/version.rb +13 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/readme.md +12 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sbJson_writer.rb +126 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_base.rb +19 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_contact.rb +42 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_identifier.rb +22 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb +49 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/version.rb +13 -0
- data/test/readers/mdJson/v1/tc_reader_mdjson_translation.rb +83 -0
- data/test/readers/sbJson/v0/tc_reader_sbjson_translation.rb +79 -0
- data/test/readers/sbJson/v0/test.json +431 -0
- data/test/readers/sbJson/v0/test1.json +383 -0
- data/test/writers/mdJson/v1/tc_writer_mdJson.rb +60 -0
- data/test/writers/sbJson/v0/tc_writer_sbJson.rb +60 -0
- metadata +121 -7
- data/test/readers/mdJson/v1/tc_translation_19115_2.rb +0 -67
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'adiwg/mdtranslator/internal/module_dateTimeFun'
|
2
|
+
|
3
|
+
module ADIWG
|
4
|
+
module Mdtranslator
|
5
|
+
module Readers
|
6
|
+
module SbJson
|
7
|
+
|
8
|
+
module DateTime
|
9
|
+
|
10
|
+
def self.unpack(sDateTime, responseObj)
|
11
|
+
|
12
|
+
# instance classes needed in script
|
13
|
+
intMetadataClass = InternalMetadata.new
|
14
|
+
|
15
|
+
# dateTime
|
16
|
+
intDateTime = intMetadataClass.newDateTime
|
17
|
+
|
18
|
+
aDateTimeReturn = AdiwgDateTimeFun.dateTimeFromString(sDateTime)
|
19
|
+
intDateTime[:dateTime] = aDateTimeReturn[0]
|
20
|
+
intDateTime[:dateResolution] = aDateTimeReturn[1]
|
21
|
+
|
22
|
+
return intDateTime
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_responsibleParty')
|
3
|
+
|
4
|
+
module ADIWG
|
5
|
+
module Mdtranslator
|
6
|
+
module Readers
|
7
|
+
module SbJson
|
8
|
+
module DistributionInfo
|
9
|
+
def self.unpack(hDistributor, responseObj, intObj)
|
10
|
+
# instance classes needed in script
|
11
|
+
intMetadataClass = InternalMetadata.new
|
12
|
+
intDistributor = intMetadataClass.newDistributor
|
13
|
+
|
14
|
+
# distributor - distribution contact - required
|
15
|
+
# We're just injecting the first SB contact here
|
16
|
+
# with a a role of "distributor", if none just use
|
17
|
+
# the default SB contact
|
18
|
+
aCust = {}
|
19
|
+
dist = intObj[:contacts].find { |c| c[:sbType] == 'Distributor' }
|
20
|
+
|
21
|
+
unless dist.nil?
|
22
|
+
aCust['contactId'] = dist[:contactId]
|
23
|
+
aCust['role'] = 'distributor'
|
24
|
+
else
|
25
|
+
aCust['contactId'] = 'SB'
|
26
|
+
aCust['role'] = 'distributor'
|
27
|
+
end
|
28
|
+
intDistributor[:distContact] = ResponsibleParty.unpack(aCust, responseObj)
|
29
|
+
|
30
|
+
# distributor - distribution order process
|
31
|
+
if hDistributor.key?('materialRequestInstructions')
|
32
|
+
aDistOrder = hDistributor['materialRequestInstructions']
|
33
|
+
unless aDistOrder.empty?
|
34
|
+
intDistOrder = intMetadataClass.newDistOrder
|
35
|
+
intDistOrder[:orderInstructions] = hDistributor['materialRequestInstructions']
|
36
|
+
intDistributor[:distOrderProcs] << intDistOrder
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# distributor - distribution transfer options
|
41
|
+
if hDistributor.key?('distributionLinks')
|
42
|
+
aDistTransOpt = hDistributor['distributionLinks']
|
43
|
+
unless aDistTransOpt.empty?
|
44
|
+
options = intMetadataClass.newDigitalTransOption
|
45
|
+
aDistTransOpt.each do |opt|
|
46
|
+
aOpt = intMetadataClass.newOnlineResource
|
47
|
+
aOpt[:olResURI] = opt['uri']
|
48
|
+
aOpt[:olResProtocol] = URI.parse(opt['uri']).scheme
|
49
|
+
aOpt[:olResName] = opt['title']
|
50
|
+
aOpt[:olResDesc] = opt['typeLabel']
|
51
|
+
aOpt[:olResFunction] = 'information'
|
52
|
+
options[:online] << aOpt
|
53
|
+
end
|
54
|
+
intDistributor[:distTransOptions] << options
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
intDistributor
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_geographicElement')
|
2
|
+
#require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_temporalElement')
|
3
|
+
#require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_verticalElement')
|
4
|
+
|
5
|
+
module ADIWG
|
6
|
+
module Mdtranslator
|
7
|
+
module Readers
|
8
|
+
module SbJson
|
9
|
+
|
10
|
+
module Extent
|
11
|
+
|
12
|
+
def self.unpack(hExtent, responseObj)
|
13
|
+
|
14
|
+
# instance classes needed in script
|
15
|
+
intMetadataClass = InternalMetadata.new
|
16
|
+
intExtent = intMetadataClass.newExtent
|
17
|
+
|
18
|
+
# extent - description
|
19
|
+
if hExtent.has_key?('description')
|
20
|
+
s = hExtent['description']
|
21
|
+
if s != ''
|
22
|
+
intExtent[:extDesc] = s
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# extent - geographic elements
|
27
|
+
if hExtent.has_key?('geographicElement')
|
28
|
+
aGeoElements = hExtent['geographicElement']
|
29
|
+
unless aGeoElements.empty?
|
30
|
+
intExtent[:extGeoElements] = GeographicElement.unpack(aGeoElements, responseObj)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# extent - temporal elements
|
35
|
+
# if hExtent.has_key?('temporalElement')
|
36
|
+
# hTempElement = hExtent['temporalElement']
|
37
|
+
# unless hTempElement.empty?
|
38
|
+
# intExtent[:extTempElements] = TemporalElement.unpack(hTempElement, responseObj)
|
39
|
+
# end
|
40
|
+
# end
|
41
|
+
#
|
42
|
+
# # extent - vertical elements
|
43
|
+
# if hExtent.has_key?('verticalElement')
|
44
|
+
# aVertElements = hExtent['verticalElement']
|
45
|
+
# unless aVertElements.empty?
|
46
|
+
# aVertElements.each do |hVertElement|
|
47
|
+
# intExtent[:extVertElements] << VerticalElement.unpack(hVertElement, responseObj)
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
# end
|
51
|
+
|
52
|
+
return intExtent
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module ADIWG
|
2
|
+
module Mdtranslator
|
3
|
+
module Readers
|
4
|
+
module SbJson
|
5
|
+
|
6
|
+
module GeoCoordSystem
|
7
|
+
|
8
|
+
def self.unpack(hGeoCrs, intElement, responseObj)
|
9
|
+
|
10
|
+
intMetadataClass = InternalMetadata.new
|
11
|
+
intSRS = intMetadataClass.newSRS
|
12
|
+
|
13
|
+
# get coordinate reference system
|
14
|
+
# null crs will default to CRS84 in writer
|
15
|
+
if hGeoCrs.has_key?('properties')
|
16
|
+
hCRSProp = hGeoCrs['properties']
|
17
|
+
|
18
|
+
if hCRSProp.has_key?('name')
|
19
|
+
s = hCRSProp['name']
|
20
|
+
if s != ''
|
21
|
+
intSRS[:srsName] = s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if hCRSProp.has_key?('href')
|
26
|
+
s = hCRSProp['href']
|
27
|
+
if s != ''
|
28
|
+
intSRS[:srsHref] = s
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if hCRSProp.has_key?('type')
|
33
|
+
s = hCRSProp['type']
|
34
|
+
if s != ''
|
35
|
+
intSRS[:srsType] = s
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
intElement[:elementSrs] = intSRS
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
#require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_temporalElement')
|
2
|
+
#require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_verticalElement')
|
3
|
+
#require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_resourceIdentifier')
|
4
|
+
|
5
|
+
module ADIWG
|
6
|
+
module Mdtranslator
|
7
|
+
module Readers
|
8
|
+
module SbJson
|
9
|
+
|
10
|
+
module GeoProperties
|
11
|
+
|
12
|
+
def self.unpack(hGeoProps, intElement, responseObj)
|
13
|
+
|
14
|
+
# set element extent - (default true)
|
15
|
+
intElement[:elementIncludeData] = true
|
16
|
+
if hGeoProps.has_key?('includesData')
|
17
|
+
if !hGeoProps['includesData']
|
18
|
+
intElement[:elementIncludeData] = false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# set element feature name
|
23
|
+
if hGeoProps.has_key?('featureName')
|
24
|
+
s = hGeoProps['featureName']
|
25
|
+
if s != ''
|
26
|
+
intElement[:elementName] = s
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
# set element description
|
31
|
+
if hGeoProps.has_key?('description')
|
32
|
+
s = hGeoProps['description']
|
33
|
+
if s != ''
|
34
|
+
intElement[:elementDescription] = s
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# # set temporal information
|
39
|
+
# if hGeoProps.has_key?('temporalElement')
|
40
|
+
# hTempEle = hGeoProps['temporalElement']
|
41
|
+
# unless hTempEle.empty?
|
42
|
+
# intElement[:temporalElements] = TemporalElement.unpack(hTempEle, responseObj)
|
43
|
+
# end
|
44
|
+
# end
|
45
|
+
#
|
46
|
+
# # set vertical information
|
47
|
+
# if hGeoProps.has_key?('verticalElement')
|
48
|
+
# aVertEle = hGeoProps['verticalElement']
|
49
|
+
# unless aVertEle.empty?
|
50
|
+
# aVertEle.each do |hVertEle|
|
51
|
+
# intElement[:verticalElements] << VerticalElement.unpack(hVertEle, responseObj)
|
52
|
+
# end
|
53
|
+
# end
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# # set other assigned IDs
|
57
|
+
# if hGeoProps.has_key?('identifier')
|
58
|
+
# aResIds = hGeoProps['identifier']
|
59
|
+
# unless aResIds.empty?
|
60
|
+
# aResIds.each do |hIdentifier|
|
61
|
+
# intElement[:elementIdentifiers] << ResourceIdentifier.unpack(hIdentifier, responseObj)
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
# end
|
65
|
+
#
|
66
|
+
# # set feature scope
|
67
|
+
# if hGeoProps.has_key?('featureScope')
|
68
|
+
# s = hGeoProps['featureScope']
|
69
|
+
# if s != ''
|
70
|
+
# intElement[:elementScope] = s
|
71
|
+
# end
|
72
|
+
# end
|
73
|
+
#
|
74
|
+
# # set feature acquisition methodology
|
75
|
+
# if hGeoProps.has_key?('featureAcquisitionMethod')
|
76
|
+
# s = hGeoProps['featureAcquisitionMethod']
|
77
|
+
# if s != ''
|
78
|
+
# intElement[:elementAcquisition] = s
|
79
|
+
# end
|
80
|
+
# end
|
81
|
+
|
82
|
+
return intElement
|
83
|
+
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_geoCoordSystem')
|
2
|
+
require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_geoProperties')
|
3
|
+
require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_boundingBox')
|
4
|
+
#require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_point')
|
5
|
+
#require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_lineString')
|
6
|
+
#require ADIWG::Mdtranslator::Readers::SbJson.readerModule('module_polygon')
|
7
|
+
|
8
|
+
module ADIWG
|
9
|
+
module Mdtranslator
|
10
|
+
module Readers
|
11
|
+
module SbJson
|
12
|
+
|
13
|
+
module GeographicElement
|
14
|
+
|
15
|
+
def self.unpack(aGeoElements, responseObj)
|
16
|
+
|
17
|
+
# only one geometry is allowed per geographic element.
|
18
|
+
# ... in GeoJSON each geometry is allowed a bounding box;
|
19
|
+
# ... This code splits bounding boxes to separate elements
|
20
|
+
|
21
|
+
# instance classes needed in script
|
22
|
+
aIntGeoEle = Array.new
|
23
|
+
|
24
|
+
aGeoElements.each do |hGeoJsonElement|
|
25
|
+
|
26
|
+
# instance classes needed in script
|
27
|
+
intMetadataClass = InternalMetadata.new
|
28
|
+
hGeoElement = intMetadataClass.newGeoElement
|
29
|
+
|
30
|
+
# find geographic element type
|
31
|
+
if hGeoJsonElement.has_key?('type')
|
32
|
+
elementType = hGeoJsonElement['type']
|
33
|
+
else
|
34
|
+
# invalid geographic element
|
35
|
+
return nil
|
36
|
+
end
|
37
|
+
|
38
|
+
# set geographic element id
|
39
|
+
if hGeoJsonElement.has_key?('id')
|
40
|
+
s = hGeoJsonElement['id']
|
41
|
+
if s != ''
|
42
|
+
hGeoElement[:elementId] = s
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
# set geographic element coordinate reference system - CRS
|
47
|
+
if hGeoJsonElement.has_key?('crs')
|
48
|
+
hGeoCrs = hGeoJsonElement['crs']
|
49
|
+
GeoCoordSystem.unpack(hGeoCrs, hGeoElement, responseObj)
|
50
|
+
end
|
51
|
+
|
52
|
+
# set geographic element properties
|
53
|
+
if hGeoJsonElement.has_key?('properties')
|
54
|
+
hGeoProps = hGeoJsonElement['properties']
|
55
|
+
GeoProperties.unpack(hGeoProps, hGeoElement, responseObj)
|
56
|
+
end
|
57
|
+
|
58
|
+
# process geographic element bounding box
|
59
|
+
# the bounding box must be represented as a separate geographic element for ISO
|
60
|
+
# need to make a deep copy of current state of geographic element for bounding box
|
61
|
+
if hGeoJsonElement.has_key?('bbox')
|
62
|
+
if hGeoJsonElement['bbox'].length == 4
|
63
|
+
aBBox = hGeoJsonElement['bbox']
|
64
|
+
|
65
|
+
boxElement = Marshal.load(Marshal.dump(hGeoElement))
|
66
|
+
boxElement[:elementGeometry] = BoundingBox.unpack(aBBox, responseObj)
|
67
|
+
|
68
|
+
aIntGeoEle << boxElement
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
# unpack geographic element
|
73
|
+
case elementType
|
74
|
+
|
75
|
+
# GeoJSON Features
|
76
|
+
when 'Feature'
|
77
|
+
if hGeoJsonElement.has_key?('geometry')
|
78
|
+
hGeometry = hGeoJsonElement['geometry']
|
79
|
+
|
80
|
+
# geoJSON requires geometry to be 'null' when geometry is bounding box only
|
81
|
+
# JSON null converts in parsing to ruby nil
|
82
|
+
unless hGeometry.nil?
|
83
|
+
unless hGeometry.empty?
|
84
|
+
if hGeometry.has_key?('type')
|
85
|
+
geometryType = hGeometry['type']
|
86
|
+
aCoordinates = hGeometry['coordinates']
|
87
|
+
unless aCoordinates.empty?
|
88
|
+
case geometryType
|
89
|
+
when 'Point', 'MultiPoint'
|
90
|
+
hGeoElement[:elementGeometry] = ADIWG::Mdtranslator::Point.unpack(aCoordinates, geometryType, responseObj)
|
91
|
+
when 'LineString', 'MultiLineString'
|
92
|
+
hGeoElement[:elementGeometry] = ADIWG::Mdtranslator::LineString.unpack(aCoordinates, geometryType, responseObj)
|
93
|
+
when 'Polygon', 'MultiPolygon'
|
94
|
+
hGeoElement[:elementGeometry] = Polygon.unpack(aCoordinates, geometryType, responseObj)
|
95
|
+
else
|
96
|
+
# log - the GeoJSON geometry type is not supported
|
97
|
+
end
|
98
|
+
aIntGeoEle << hGeoElement
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
# GeoJSON Feature Collection
|
107
|
+
when 'FeatureCollection'
|
108
|
+
if hGeoJsonElement.has_key?('features')
|
109
|
+
aFeatures = hGeoJsonElement['features']
|
110
|
+
unless aFeatures.empty?
|
111
|
+
intGeometry = intMetadataClass.newGeometry
|
112
|
+
intGeometry[:geoType] = 'MultiGeometry'
|
113
|
+
intGeometry[:geometry] = GeographicElement.unpack(aFeatures, responseObj)
|
114
|
+
hGeoElement[:elementGeometry] = intGeometry
|
115
|
+
aIntGeoEle << hGeoElement
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# GeoJSON Geometries
|
120
|
+
when 'Point', 'MultiPoint'
|
121
|
+
aCoordinates = hGeoJsonElement['coordinates']
|
122
|
+
hGeoElement[:elementGeometry] = ADIWG::Mdtranslator::Point.unpack(aCoordinates, elementType, responseObj)
|
123
|
+
aIntGeoEle << hGeoElement
|
124
|
+
|
125
|
+
when 'LineString', 'MultiLineString'
|
126
|
+
aCoordinates = hGeoJsonElement['coordinates']
|
127
|
+
hGeoElement[:elementGeometry] = ADIWG::Mdtranslator::LineString.unpack(aCoordinates, elementType, responseObj)
|
128
|
+
aIntGeoEle << hGeoElement
|
129
|
+
|
130
|
+
when 'Polygon', 'MultiPolygon'
|
131
|
+
aCoordinates = hGeoJsonElement['coordinates']
|
132
|
+
hGeoElement[:elementGeometry] = Polygon.unpack(aCoordinates, elementType, responseObj)
|
133
|
+
aIntGeoEle << hGeoElement
|
134
|
+
|
135
|
+
# GeoJSON Geometry Collection
|
136
|
+
when 'GeometryCollection'
|
137
|
+
if hGeoJsonElement.has_key?('geometries')
|
138
|
+
aGeometries = hGeoJsonElement['geometries']
|
139
|
+
unless aGeometries.empty?
|
140
|
+
intGeometry = intMetadataClass.newGeometry
|
141
|
+
intGeometry[:geoType] = 'MultiGeometry'
|
142
|
+
intGeometry[:geometry] = GeographicElement.unpack(aGeometries, responseObj)
|
143
|
+
hGeoElement[:elementGeometry] = intGeometry
|
144
|
+
aIntGeoEle << hGeoElement
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
end
|
151
|
+
|
152
|
+
return aIntGeoEle
|
153
|
+
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|