adiwg-mdtranslator 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -0
- data/adiwg-mdtranslator.gemspec +1 -0
- data/lib/adiwg/mdtranslator/internal/module_coordinates.rb +13 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb +49 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_citation.rb +144 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_date.rb +57 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dateTime.rb +108 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_distribution.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityAttribute.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +193 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +136 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_metadataInfo.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_onlineResource.rb +35 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_publication.rb +63 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_quality.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_responsibility.rb +46 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_series.rb +44 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb +184 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialOrganization.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialReference.rb +28 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timeInstant.rb +40 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_timePeriod.rb +88 -0
- data/lib/adiwg/mdtranslator/readers/fgdc/readme.md +18 -0
- data/lib/adiwg/mdtranslator/readers/{fgcd → fgdc}/version.rb +0 -0
- data/lib/adiwg/mdtranslator/readers/mdJson/readme.md +1 -1
- data/lib/adiwg/mdtranslator/readers/mdJson/version.rb +2 -1
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_browseCategory.rb +5 -5
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_relatedItem.rb +4 -10
- data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_sbJson.rb +1 -1
- data/lib/adiwg/mdtranslator/readers/sbJson/readme.md +1 -1
- data/lib/adiwg/mdtranslator/readers/sbJson/sbJson_reader.rb +2 -2
- data/lib/adiwg/mdtranslator/readers/sbJson/version.rb +1 -1
- data/lib/adiwg/mdtranslator/version.rb +1 -1
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_resourceType.rb +1 -0
- metadata +37 -3
@@ -0,0 +1,136 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc metadata identification
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-15 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
require_relative 'module_citation'
|
10
|
+
require_relative 'module_timePeriod'
|
11
|
+
require_relative 'module_timeInstant'
|
12
|
+
require_relative 'module_spatialDomain'
|
13
|
+
|
14
|
+
module ADIWG
|
15
|
+
module Mdtranslator
|
16
|
+
module Readers
|
17
|
+
module Fgdc
|
18
|
+
|
19
|
+
module Identification
|
20
|
+
|
21
|
+
def self.unpack(xIdInfo, intObj, hResponseObj)
|
22
|
+
|
23
|
+
# instance classes needed in script
|
24
|
+
intMetadataClass = InternalMetadata.new
|
25
|
+
|
26
|
+
# useful parts
|
27
|
+
hMetadata = intObj[:metadata]
|
28
|
+
hMetadataInfo = hMetadata[:metadataInfo]
|
29
|
+
hResourceInfo = hMetadata[:resourceInfo]
|
30
|
+
|
31
|
+
# identification information 1.1 (citation) - citation (required)
|
32
|
+
xCitation = xIdInfo.xpath('./citation')
|
33
|
+
unless xCitation.empty?
|
34
|
+
hCitation = Citation.unpack(xCitation, hResponseObj)
|
35
|
+
unless hCitation.nil?
|
36
|
+
hResourceInfo[:citation] = hCitation
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# identification information 1.2 (descript) - description (required)
|
41
|
+
xDescription = xIdInfo.xpath('./descript')
|
42
|
+
unless xDescription.empty?
|
43
|
+
|
44
|
+
# description 1.2.1 (abstract) - abstract
|
45
|
+
abstract = xDescription.xpath('./abstract').text
|
46
|
+
unless abstract.empty?
|
47
|
+
hResourceInfo[:abstract] = abstract
|
48
|
+
end
|
49
|
+
|
50
|
+
# description 1.2.2 (purpose) - purpose
|
51
|
+
purpose = xDescription.xpath('./purpose').text
|
52
|
+
unless purpose.empty?
|
53
|
+
hResourceInfo[:purpose] = purpose
|
54
|
+
end
|
55
|
+
|
56
|
+
# description 1.2.3 (supplinf) - supplemental information
|
57
|
+
supplemental = xDescription.xpath('./supplinf').text
|
58
|
+
unless supplemental.empty?
|
59
|
+
hResourceInfo[:supplementalInfo] = supplemental
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
# identification information 1.3 (timeperd) - time period of content
|
65
|
+
xTimePeriod = xIdInfo.xpath('./timeperd')
|
66
|
+
unless xTimePeriod.empty?
|
67
|
+
|
68
|
+
# time period for single date and date range
|
69
|
+
hTimePeriod = TimePeriod.unpack(xTimePeriod, hResponseObj)
|
70
|
+
unless hTimePeriod.nil?
|
71
|
+
hResourceInfo[:timePeriod] = hTimePeriod
|
72
|
+
end
|
73
|
+
|
74
|
+
# time period multiple date time pairs 9.1.2 (mdattim)
|
75
|
+
axMultiple = xTimePeriod.xpath('./timeinfo/mdattim/sngdate')
|
76
|
+
unless axMultiple.empty?
|
77
|
+
current = xTimePeriod.xpath('./current').text
|
78
|
+
hExtent = intMetadataClass.newExtent
|
79
|
+
hExtent[:description] = 'FGDC resource time period multiple date/times'
|
80
|
+
axMultiple.each do |xDateTime|
|
81
|
+
date = xDateTime.xpath('./caldate').text
|
82
|
+
time = xDateTime.xpath('./time').text
|
83
|
+
hInstant = TimeInstant.unpack(date, time, hResponseObj)
|
84
|
+
unless hInstant.nil?
|
85
|
+
hTempExtent = intMetadataClass.newTemporalExtent
|
86
|
+
hInstant[:description] = current
|
87
|
+
hTempExtent[:timeInstant] = hInstant
|
88
|
+
hExtent[:temporalExtents] << hTempExtent
|
89
|
+
end
|
90
|
+
end
|
91
|
+
unless hExtent[:temporalExtents].empty?
|
92
|
+
hResourceInfo[:extents] << hExtent
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
# identification information 1.4 (status) - status and maintenance
|
99
|
+
xStatus = xIdInfo.xpath('./status')
|
100
|
+
unless xStatus.empty?
|
101
|
+
|
102
|
+
# status 1.4.1 (progress) - state of resource
|
103
|
+
progress = xStatus.xpath('./progress').text
|
104
|
+
unless progress.empty?
|
105
|
+
hResourceInfo[:status] << progress
|
106
|
+
end
|
107
|
+
|
108
|
+
# status 1.4.2 (update) - maintenance frequency
|
109
|
+
update = xStatus.xpath('./update').text
|
110
|
+
unless update.empty?
|
111
|
+
hMaintenance = intMetadataClass.newMaintenance
|
112
|
+
hMaintenance[:frequency] = update
|
113
|
+
hResourceInfo[:resourceMaintenance] << hMaintenance
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
# identification information 1.5 (spdom) - spatial domain
|
119
|
+
xDomain = xIdInfo.xpath('./spdom')
|
120
|
+
unless xDomain.empty?
|
121
|
+
hExtent = SpatialDomain.unpack(xDomain, hResponseObj)
|
122
|
+
unless hExtent.nil?
|
123
|
+
hResourceInfo[:extents] << hExtent
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
# identification information 1.6 (keywords) - keywords
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc metadata information
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-15 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
|
10
|
+
module ADIWG
|
11
|
+
module Mdtranslator
|
12
|
+
module Readers
|
13
|
+
module Fgdc
|
14
|
+
|
15
|
+
module MetadataInformation
|
16
|
+
|
17
|
+
def self.unpack(xMetaInfo, hResponseObj)
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc online resource
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-17 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
|
10
|
+
module ADIWG
|
11
|
+
module Mdtranslator
|
12
|
+
module Readers
|
13
|
+
module Fgdc
|
14
|
+
|
15
|
+
module OnlineResource
|
16
|
+
|
17
|
+
def self.unpack(onLink, description, hResponseObj)
|
18
|
+
|
19
|
+
# instance classes needed in script
|
20
|
+
intMetadataClass = InternalMetadata.new
|
21
|
+
hURI = intMetadataClass.newOnlineResource
|
22
|
+
|
23
|
+
hURI[:olResURI] = onLink
|
24
|
+
hURI[:olResDesc] = description
|
25
|
+
|
26
|
+
return hURI
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc publication
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-17 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
require_relative 'module_fgdc'
|
10
|
+
|
11
|
+
module ADIWG
|
12
|
+
module Mdtranslator
|
13
|
+
module Readers
|
14
|
+
module Fgdc
|
15
|
+
|
16
|
+
module Publication
|
17
|
+
|
18
|
+
def self.unpack(xPublication, hResponseObj)
|
19
|
+
|
20
|
+
# instance classes needed in script
|
21
|
+
intMetadataClass = InternalMetadata.new
|
22
|
+
hResponsibility = nil
|
23
|
+
contactId = nil
|
24
|
+
|
25
|
+
# publication information 8.2 (publish) - publisher {contact}
|
26
|
+
publisher = xPublication.xpath('./publish').text
|
27
|
+
unless publisher.empty?
|
28
|
+
contactId = Fgdc.find_contact_by_name(publisher)
|
29
|
+
if contactId.nil?
|
30
|
+
contactId = Fgdc.add_contact(publisher, true)
|
31
|
+
end
|
32
|
+
hResponsibility = Responsibility.unpack([contactId], 'publisher', hResponseObj)
|
33
|
+
end
|
34
|
+
|
35
|
+
# publication information 8.1 (pubplace) - place of publication
|
36
|
+
place = xPublication.xpath('./pubplace').text
|
37
|
+
unless place.empty?
|
38
|
+
unless contactId.nil?
|
39
|
+
hContact = Fgdc.get_contact_by_id(contactId)
|
40
|
+
unless hContact.nil?
|
41
|
+
if hContact[:addresses].empty?
|
42
|
+
hAddress = intMetadataClass.newAddress
|
43
|
+
hContact[:addresses] << hAddress
|
44
|
+
else
|
45
|
+
hAddress = hContact[:addresses][0]
|
46
|
+
end
|
47
|
+
hAddress[:addressTypes] << 'mailing'
|
48
|
+
hAddress[:description] = place
|
49
|
+
Fgdc.set_contact(hContact)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
return hResponsibility
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc data quality
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-15 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
|
10
|
+
module ADIWG
|
11
|
+
module Mdtranslator
|
12
|
+
module Readers
|
13
|
+
module Fgdc
|
14
|
+
|
15
|
+
module Quality
|
16
|
+
|
17
|
+
def self.unpack(xDataQual, hResponseObj)
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc metadata responsibility
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-18 original script
|
6
|
+
|
7
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
8
|
+
require_relative 'module_fgdc'
|
9
|
+
|
10
|
+
module ADIWG
|
11
|
+
module Mdtranslator
|
12
|
+
module Readers
|
13
|
+
module Fgdc
|
14
|
+
|
15
|
+
module Responsibility
|
16
|
+
|
17
|
+
def self.unpack(aContacts, role, hResponseObj)
|
18
|
+
|
19
|
+
# instance classes needed in script
|
20
|
+
intMetadataClass = InternalMetadata.new
|
21
|
+
hResponsibility = intMetadataClass.newResponsibility
|
22
|
+
|
23
|
+
hResponsibility[:roleName] = role
|
24
|
+
|
25
|
+
# add contacts to responsibility party []
|
26
|
+
aContacts.each do |contactId|
|
27
|
+
hContactInfo = Fgdc.find_contact_by_id(contactId)
|
28
|
+
unless hContactInfo[0].nil?
|
29
|
+
hParty = intMetadataClass.newParty
|
30
|
+
hParty[:contactId] = contactId
|
31
|
+
hParty[:contactIndex] = hContactInfo[0]
|
32
|
+
hParty[:contactType] = hContactInfo[1]
|
33
|
+
hResponsibility[:parties] << hParty
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
return hResponsibility
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc series
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-17 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
|
10
|
+
module ADIWG
|
11
|
+
module Mdtranslator
|
12
|
+
module Readers
|
13
|
+
module Fgdc
|
14
|
+
|
15
|
+
module Series
|
16
|
+
|
17
|
+
def self.unpack(xSerInfo, hResponseObj)
|
18
|
+
|
19
|
+
# instance classes needed in script
|
20
|
+
intMetadataClass = InternalMetadata.new
|
21
|
+
hSeries = intMetadataClass.newSeries
|
22
|
+
|
23
|
+
# series 8.7.1 (sername) - series name
|
24
|
+
name = xSerInfo.xpath('./sername').text
|
25
|
+
unless name.empty?
|
26
|
+
hSeries[:seriesName] = name
|
27
|
+
end
|
28
|
+
|
29
|
+
# series 8.7.2 (issue) - series issue
|
30
|
+
issue = xSerInfo.xpath('./issue').text
|
31
|
+
unless issue.empty?
|
32
|
+
hSeries[:seriesIssue] = issue
|
33
|
+
end
|
34
|
+
|
35
|
+
return hSeries
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc spatial domain
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-22 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'json'
|
9
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
10
|
+
require 'adiwg/mdtranslator/internal/module_coordinates'
|
11
|
+
|
12
|
+
module ADIWG
|
13
|
+
module Mdtranslator
|
14
|
+
module Readers
|
15
|
+
module Fgdc
|
16
|
+
|
17
|
+
module SpatialDomain
|
18
|
+
|
19
|
+
def self.process_polygon(xPolygon)
|
20
|
+
aCoords = []
|
21
|
+
|
22
|
+
# polygon coordinates (grngpoin) - g ring points []
|
23
|
+
axPoints = xPolygon.xpath('./grngpoin')
|
24
|
+
unless axPoints.empty?
|
25
|
+
aCoords = coords_from_points(axPoints)
|
26
|
+
end
|
27
|
+
|
28
|
+
# polygon coordinates (gring) - g ring
|
29
|
+
xRing = xPolygon.xpath('./gring')
|
30
|
+
unless xRing.empty?
|
31
|
+
aCoords = coords_from_ring(xRing)
|
32
|
+
end
|
33
|
+
|
34
|
+
return aCoords
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.coords_from_points(axPoints)
|
38
|
+
aCoords = []
|
39
|
+
axPoints.each do |xPoint|
|
40
|
+
lon = xPoint.xpath('./grnglon').text.to_f
|
41
|
+
lat = xPoint.xpath('./grnglat').text.to_f
|
42
|
+
aCoords << [lon, lat]
|
43
|
+
end
|
44
|
+
return aCoords
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.coords_from_ring(xRing)
|
48
|
+
aCoords = []
|
49
|
+
sRing = xRing.text
|
50
|
+
aPoints = sRing.split(', ')
|
51
|
+
aPoints.each do |point|
|
52
|
+
aCoord = point.split(' ')
|
53
|
+
aCoords << [aCoord[0].to_f, aCoord[1].to_f]
|
54
|
+
end
|
55
|
+
return aCoords
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.unpack(xDomain, hResponseObj)
|
59
|
+
|
60
|
+
# instance classes needed in script
|
61
|
+
intMetadataClass = InternalMetadata.new
|
62
|
+
hExtent = intMetadataClass.newExtent
|
63
|
+
hGeoExtent = intMetadataClass.newGeographicExtent
|
64
|
+
|
65
|
+
# spatial domain 1.5.1 (bounding) - bounding box
|
66
|
+
xBbox = xDomain.xpath('./bounding')
|
67
|
+
unless xBbox.empty?
|
68
|
+
hBbox = intMetadataClass.newBoundingBox
|
69
|
+
|
70
|
+
# bounding box 1.5.1.1 (westbc) - west coordinate
|
71
|
+
hBbox[:westLongitude] = xBbox.xpath('./westbc').text.to_f
|
72
|
+
|
73
|
+
# bounding box 1.5.1.2 (eastbc) - east coordinate
|
74
|
+
hBbox[:eastLongitude] = xBbox.xpath('./eastbc').text.to_f
|
75
|
+
|
76
|
+
# bounding box 1.5.1.3 (northbc) - north coordinate
|
77
|
+
hBbox[:northLatitude] = xBbox.xpath('./northbc').text.to_f
|
78
|
+
|
79
|
+
# bounding box 1.5.1.4 (southbc) - south coordinate
|
80
|
+
hBbox[:southLatitude] = xBbox.xpath('./southbc').text.to_f
|
81
|
+
|
82
|
+
hGeoExtent[:boundingBox] = hBbox
|
83
|
+
end
|
84
|
+
|
85
|
+
# spatial domain 1.5.2 (dsgpoly) - data set geographic polygon
|
86
|
+
xPoly = xDomain.xpath('./dsgpoly')
|
87
|
+
unless xPoly.empty?
|
88
|
+
|
89
|
+
polygon = []
|
90
|
+
|
91
|
+
# polygon 1.5.2.1 (dsgpolyo) - polygon outer ring
|
92
|
+
xOring = xPoly.xpath('./dsgpolyo')
|
93
|
+
unless xOring.empty?
|
94
|
+
|
95
|
+
# outer ring 1.5.2.1.1 (grngpoin) - g ring point
|
96
|
+
# outer ring 1.5.2.1.2 (gring) - g ring
|
97
|
+
# outer ring must be counterclockwise
|
98
|
+
aOutCoords = process_polygon(xOring)
|
99
|
+
unless aOutCoords.empty?
|
100
|
+
if AdiwgCoordinates.is_polygon_clockwise(aOutCoords)
|
101
|
+
aOutCoords.reverse!
|
102
|
+
end
|
103
|
+
polygon << aOutCoords
|
104
|
+
end
|
105
|
+
|
106
|
+
# first ring must be outer
|
107
|
+
# only process if already have outer ring
|
108
|
+
# polygon 1.5.2.2 (dsgpolyx) - polygon exclusion ring []
|
109
|
+
axXring = xPoly.xpath('./dsgpolyx')
|
110
|
+
axXring.each do |xRing|
|
111
|
+
|
112
|
+
# exclusion ring 1.5.2.2.1 (grngpoin) - g ring point
|
113
|
+
# exclusion ring 1.5.2.2.2 (gring) - g ring
|
114
|
+
# exclusion ring must be clockwise
|
115
|
+
aInCoords = process_polygon(xRing)
|
116
|
+
unless aInCoords.empty?
|
117
|
+
unless AdiwgCoordinates.is_polygon_clockwise(aInCoords)
|
118
|
+
aInCoords.reverse!
|
119
|
+
end
|
120
|
+
polygon << aInCoords
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
unless polygon.empty?
|
127
|
+
|
128
|
+
# make geoJson FeatureCollection from polygon
|
129
|
+
hGeometry = {
|
130
|
+
type: 'Polygon',
|
131
|
+
coordinates: polygon
|
132
|
+
}
|
133
|
+
hFeature = {
|
134
|
+
type: 'Feature',
|
135
|
+
geometry: hGeometry,
|
136
|
+
properties: {
|
137
|
+
description: 'FGDC bounding polygon'
|
138
|
+
}
|
139
|
+
}
|
140
|
+
hCollection = {
|
141
|
+
type: 'FeatureCollection',
|
142
|
+
features: [hFeature]
|
143
|
+
}
|
144
|
+
geoJson = hCollection.to_json
|
145
|
+
|
146
|
+
# make internal geometries from polygon
|
147
|
+
hIntGeo = intMetadataClass.newGeometryObject
|
148
|
+
hIntGeo[:type] = 'Polygon'
|
149
|
+
hIntGeo[:coordinates] = polygon
|
150
|
+
hIntGeo[:nativeGeoJson] = hGeometry.to_json
|
151
|
+
|
152
|
+
hIntProps = intMetadataClass.newGeometryProperties
|
153
|
+
hIntProps[:description] = 'FGDC bounding polygon'
|
154
|
+
|
155
|
+
hIntFeature = intMetadataClass.newGeometryFeature
|
156
|
+
hIntFeature[:type] = 'Feature'
|
157
|
+
hIntFeature[:geometryObject] = hIntGeo
|
158
|
+
hIntFeature[:nativeGeoJson] = hFeature.to_json
|
159
|
+
hIntFeature[:properties] = hIntProps
|
160
|
+
|
161
|
+
hIntCollect = intMetadataClass.newFeatureCollection
|
162
|
+
hIntCollect[:type] = 'FeatureCollection'
|
163
|
+
hIntCollect[:features] << hIntFeature
|
164
|
+
hIntCollect[:nativeGeoJson] = hCollection.to_json
|
165
|
+
|
166
|
+
hGeoExtent[:geographicElements] << hIntCollect
|
167
|
+
hGeoExtent[:nativeGeoJson] = geoJson
|
168
|
+
|
169
|
+
hExtent[:geographicExtents] << hGeoExtent
|
170
|
+
hExtent[:description] = 'FGDC spatial domain'
|
171
|
+
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
return hExtent
|
176
|
+
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc spatial data organization
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-15 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
|
10
|
+
module ADIWG
|
11
|
+
module Mdtranslator
|
12
|
+
module Readers
|
13
|
+
module Fgdc
|
14
|
+
|
15
|
+
module SpatialOrganization
|
16
|
+
|
17
|
+
def self.unpack(xSpatialOrg, hResponseObj)
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc spatial data reference
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-15 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
|
10
|
+
module ADIWG
|
11
|
+
module Mdtranslator
|
12
|
+
module Readers
|
13
|
+
module Fgdc
|
14
|
+
|
15
|
+
module SpatialReference
|
16
|
+
|
17
|
+
def self.unpack(xSpatialRef, hResponseObj)
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Reader - fgdc to internal data structure
|
2
|
+
# unpack fgdc time instant
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2017-08-21 original script
|
6
|
+
|
7
|
+
require 'nokogiri'
|
8
|
+
require 'adiwg/mdtranslator/internal/internal_metadata_obj'
|
9
|
+
require_relative 'module_dateTime'
|
10
|
+
|
11
|
+
module ADIWG
|
12
|
+
module Mdtranslator
|
13
|
+
module Readers
|
14
|
+
module Fgdc
|
15
|
+
|
16
|
+
module TimeInstant
|
17
|
+
|
18
|
+
def self.unpack(date, time, hResponseObj)
|
19
|
+
|
20
|
+
# instance classes needed in script
|
21
|
+
intMetadataClass = InternalMetadata.new
|
22
|
+
hTimeInstant = intMetadataClass.newTimeInstant
|
23
|
+
|
24
|
+
# time instant
|
25
|
+
hDateTime = DateTime.unpack(date, time, hResponseObj)
|
26
|
+
unless hDateTime.nil?
|
27
|
+
hTimeInstant[:timeInstant] = hDateTime
|
28
|
+
return hTimeInstant
|
29
|
+
end
|
30
|
+
|
31
|
+
return nil
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|