adiwg-mdtranslator 2.0.0rc5 → 2.0.0rc6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/adiwg/mdtranslator/internal/module_coordinates.rb +184 -158
- data/lib/adiwg/mdtranslator/internal/module_dateTimeFun.rb +19 -0
- data/lib/adiwg/mdtranslator/version.rb +3 -1
- data/lib/adiwg/mdtranslator/writers/html/sections/html_resourceType.rb +6 -1
- data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureType.rb +2 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_gcoDateTime.rb +40 -40
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_geometryCollection.rb +2 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_lineString.rb +2 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiLine.rb +2 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiPoint.rb +2 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_multiPolygon.rb +2 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_point.rb +63 -61
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_polygon.rb +2 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_timeInstant.rb +2 -0
- data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_timePeriod.rb +2 -0
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_date.rb +1 -14
- data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_dateTime.rb +1 -14
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_citation.rb +17 -18
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_provenance.rb +39 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_rights.rb +41 -0
- data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb +12 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63347888ab794a1ee8a6def46c8dbf979c55ee47
|
4
|
+
data.tar.gz: bbe3e51b5cfedd30c354d31277f9e4c98b477d3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 289cf433acd5d2c3fb71f6e010d2bab975ad3b6c85b57ddf54b1b44a6bcbfac21491272f34569642090e5f50c4ba6f8676a661caa753b10771bfb5e3b5af1d89
|
7
|
+
data.tar.gz: 2110820a54149d78f9a244de1d927090111f1408366e961b9ff8b7535eed597f189adf2ce77c481dbe810bdc123079506db49f99112951eea6da6240b1487744
|
@@ -1,171 +1,197 @@
|
|
1
1
|
# repack coordinates
|
2
2
|
|
3
3
|
# History:
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
4
|
+
# Stan Smith 2017-05-24 added checkGeometry method to move objects to real world
|
5
|
+
# Stan Smith 2016-11-10 added computedBbox computation
|
6
|
+
# Stan Smith 2015-07-16 moved module_coordinates from mdJson reader to internal
|
7
|
+
# Stan Smith 2015-07-14 refactored to remove global namespace constants
|
8
|
+
# Stan Smith 2015-06-22 replace global ($response) with passed in object (responseObj)
|
9
|
+
# Stan Smith 2014-12-15 refactored to handle namespacing readers and writers
|
10
|
+
# Stan Smith 2014-05-23 added getLevels
|
10
11
|
# Stan Smith 2013-11-13 added getDimension
|
11
12
|
# Stan Smith 2013-11-07 original script
|
12
13
|
|
13
14
|
module AdiwgCoordinates
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
s = s + ' '
|
16
|
+
# repack coordinate array into single string for ISO
|
17
|
+
def self.stringifyCoords(aCoords, responseObj)
|
18
|
+
|
19
|
+
s = ''
|
20
|
+
i = 0
|
21
|
+
coordCount = aCoords.length
|
22
|
+
aCoords.each do |coord|
|
23
|
+
if coord.kind_of?(Array)
|
24
|
+
s = s + unpack(coord, responseObj)
|
25
|
+
else
|
26
|
+
i += 1
|
27
|
+
s = s + coord.to_s
|
28
|
+
if i < coordCount
|
29
|
+
s = s + ','
|
31
30
|
end
|
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
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
31
|
+
s = s + ' '
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
return s
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
# get the number of dimensions in a coordinate array
|
40
|
+
def self.getDimension(aCoords)
|
41
|
+
|
42
|
+
if aCoords[0].kind_of?(Array)
|
43
|
+
coordDim = getDimension(aCoords[0])
|
44
|
+
else
|
45
|
+
coordDim = aCoords.length
|
46
|
+
end
|
47
|
+
|
48
|
+
return coordDim
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
# get the number of levels in the coordinate array
|
53
|
+
def self.getLevels(aCoords)
|
54
|
+
|
55
|
+
i = 1
|
56
|
+
if aCoords[0].kind_of?(Array)
|
57
|
+
i = i + getLevels(aCoords[0])
|
58
|
+
end
|
59
|
+
return i
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
# compute bounding box
|
64
|
+
def self.computeBbox(aGeo)
|
65
|
+
|
66
|
+
# find all the eastings (x) and northings (y) in the GeoJSON object
|
67
|
+
aNorthings = []
|
68
|
+
aEastings = []
|
69
|
+
aGeo.each do |hGeo|
|
70
|
+
unpackGeometry(hGeo, aNorthings, aEastings)
|
71
|
+
end
|
72
|
+
|
73
|
+
# find most north/south points
|
74
|
+
north = aNorthings.max
|
75
|
+
south = aNorthings.min
|
76
|
+
|
77
|
+
# find most east/west spanning the meridian
|
78
|
+
eastM = aEastings.max
|
79
|
+
westM = aEastings.min
|
80
|
+
|
81
|
+
# find most east/west spanning the anti-meridian
|
82
|
+
aPositiveEast = []
|
83
|
+
aNegativeEast = []
|
84
|
+
aEastings.each do |east|
|
85
|
+
aNegativeEast << east if east < 0.0
|
86
|
+
aPositiveEast << east if east >= 0.0
|
87
|
+
end
|
88
|
+
aNegativeEast.uniq!
|
89
|
+
aPositiveEast.uniq!
|
90
|
+
|
91
|
+
eastAM = aNegativeEast.max
|
92
|
+
westAM = aPositiveEast.min
|
93
|
+
|
94
|
+
# if eastings are all positive or all negative hemisphere is decided
|
95
|
+
if aPositiveEast.empty? || aNegativeEast.empty?
|
96
|
+
east = eastM
|
97
|
+
west = westM
|
98
|
+
else
|
99
|
+
# choose which meridian to span based on smaller edge-to-edge distance
|
100
|
+
distanceM = eastM - westM
|
101
|
+
distanceAM = (180 + eastAM) + (180 - westAM)
|
102
|
+
if distanceM.abs <= distanceAM.abs
|
103
|
+
# this spanned to meridian
|
92
104
|
east = eastM
|
93
105
|
west = westM
|
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
|
-
|
106
|
+
else
|
107
|
+
# this spanned tne anti-meridian
|
108
|
+
east = eastAM
|
109
|
+
west = westAM
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
bBox = {}
|
114
|
+
bBox[:westLongitude] = west
|
115
|
+
bBox[:eastLongitude] = east
|
116
|
+
bBox[:southLatitude] = south
|
117
|
+
bBox[:northLatitude] = north
|
118
|
+
|
119
|
+
return bBox
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
# compute bounding box
|
124
|
+
def self.unpackGeometry(hGeo, aNorthings, aEastings)
|
125
|
+
|
126
|
+
# geometry objects
|
127
|
+
type = hGeo[:type]
|
128
|
+
if %w{ Point LineString Polygon MultiPoint MultiLineString MultiPolygon }.one? {|word| word == type}
|
129
|
+
checkGeometry(hGeo[:coordinates], aNorthings, aEastings)
|
130
|
+
end
|
131
|
+
|
132
|
+
# geometry collections
|
133
|
+
if hGeo[:type] == 'GeometryCollection'
|
134
|
+
hGeo[:geometryObjects].each do |aGeoObj|
|
135
|
+
checkGeometry(aGeoObj[:coordinates], aNorthings, aEastings)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# features
|
140
|
+
if hGeo[:type] == 'Feature'
|
141
|
+
featureType = hGeo[:geometryObject][:type]
|
142
|
+
if featureType == 'GeometryCollection'
|
143
|
+
unpackGeometry(hGeo[:geometryObject], aNorthings, aEastings)
|
144
|
+
else
|
145
|
+
checkGeometry(hGeo[:geometryObject][:coordinates], aNorthings, aEastings)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# feature collections
|
150
|
+
if hGeo[:type] == 'FeatureCollection'
|
151
|
+
hGeo[:features].each do |hFeature|
|
152
|
+
unpackGeometry(hFeature, aNorthings, aEastings)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
# move geometry to real world if necessary
|
159
|
+
def self.checkGeometry(aCoords, aNorthings, aEastings)
|
160
|
+
|
161
|
+
aGeoNorthings = []
|
162
|
+
aGeoEastings = []
|
163
|
+
|
164
|
+
unpackCoords(aCoords, aGeoNorthings, aGeoEastings)
|
165
|
+
|
166
|
+
minEast = aGeoEastings.min
|
167
|
+
maxEast = aGeoEastings.max
|
168
|
+
if maxEast < -180
|
169
|
+
aGeoEastings.collect! { |x| x + 360 }
|
170
|
+
end
|
171
|
+
if minEast > 180
|
172
|
+
aGeoEastings.collect! { |x| x - 360 }
|
173
|
+
end
|
174
|
+
|
175
|
+
aEastings.concat(aGeoEastings)
|
176
|
+
aNorthings.concat(aGeoNorthings)
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
# unpack coordinate arrays
|
181
|
+
def self.unpackCoords(aCoords, aNorthings, aEastings)
|
182
|
+
if aCoords[0].kind_of?(Array)
|
183
|
+
aCoords.each do |aTuple|
|
184
|
+
unpackCoords(aTuple, aNorthings, aEastings)
|
185
|
+
end
|
186
|
+
else
|
187
|
+
addPoint(aCoords, aNorthings, aEastings)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# add to tuple to an array
|
192
|
+
def self.addPoint(aPoint, aNorthings, aEastings)
|
193
|
+
aEastings << aPoint[0]
|
194
|
+
aNorthings << aPoint[1]
|
195
|
+
end
|
170
196
|
|
171
197
|
end
|
@@ -140,4 +140,23 @@ module AdiwgDateTimeFun
|
|
140
140
|
return sDuration
|
141
141
|
end
|
142
142
|
|
143
|
+
def self.stringFromDateObject(obj)
|
144
|
+
|
145
|
+
date = obj[:date]
|
146
|
+
if date.nil?
|
147
|
+
date = obj[:dateTime]
|
148
|
+
end
|
149
|
+
dateRes = obj[:dateResolution]
|
150
|
+
unless date.nil?
|
151
|
+
case dateRes
|
152
|
+
when 'Y', 'YM', 'YMD'
|
153
|
+
dateStr = stringDateFromDateTime(date, dateRes)
|
154
|
+
else
|
155
|
+
dateStr = stringDateTimeFromDateTime(date, dateRes)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
return dateStr
|
160
|
+
end
|
161
|
+
|
143
162
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
# adiwg mdTranslator
|
2
2
|
|
3
3
|
# version 2 history
|
4
|
+
# 2.0.0rc6 2017-05-24 move geometries to real world if in -1 or +1 world
|
5
|
+
# --- removed special characters from ids for gml:id= in iso writers
|
4
6
|
# 2.0.0rc5 2017-05-20 Fixed bug with no writer provided
|
5
7
|
# 2.0.0rc4 2017-05-19 bump mdJson schema version to 2.1.2
|
6
8
|
# 2.0.0rc3 2017-05-16 removed topicCategory from schema and manage as keyword
|
@@ -11,7 +13,7 @@
|
|
11
13
|
module ADIWG
|
12
14
|
module Mdtranslator
|
13
15
|
# current mdtranslator version
|
14
|
-
VERSION = "2.0.
|
16
|
+
VERSION = "2.0.0rc6"
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# resource type
|
3
3
|
|
4
4
|
# History:
|
5
|
+
# Stan Smith 2017-05-24 Fixed problem with nil name
|
5
6
|
# Stan Smith 2015-03-25 original script
|
6
7
|
|
7
8
|
module ADIWG
|
@@ -19,7 +20,11 @@ module ADIWG
|
|
19
20
|
|
20
21
|
# resource type
|
21
22
|
@html.em('Resource Type: ')
|
22
|
-
@html.text!(hType[:type]
|
23
|
+
@html.text!(hType[:type])
|
24
|
+
unless hType[:name].nil?
|
25
|
+
@html.em(' Name: ')
|
26
|
+
@html.text!(hType[:name])
|
27
|
+
end
|
23
28
|
@html.br
|
24
29
|
|
25
30
|
end # writeHtml
|
@@ -36,6 +36,8 @@ module ADIWG
|
|
36
36
|
if entityId.nil?
|
37
37
|
@hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ
|
38
38
|
entityId = 'entity' + @hResponseObj[:writerMissingIdCount]
|
39
|
+
else
|
40
|
+
entityId.gsub!(/[^0-9a-zA-Z]/,'')
|
39
41
|
end
|
40
42
|
|
41
43
|
@xml.tag!('gfc:FC_FeatureType', {'id' => entityId}) do
|
@@ -5,44 +5,44 @@
|
|
5
5
|
# Stan Smith 2017-02-10 original script
|
6
6
|
|
7
7
|
module ADIWG
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
-
|
8
|
+
module Mdtranslator
|
9
|
+
module Writers
|
10
|
+
module Iso19115_2
|
11
|
+
|
12
|
+
class GcoDateTime
|
13
|
+
|
14
|
+
def initialize(xml, hResponseObj)
|
15
|
+
@xml = xml
|
16
|
+
@hResponseObj = hResponseObj
|
17
|
+
end
|
18
|
+
|
19
|
+
def writeXML(hDate)
|
20
|
+
|
21
|
+
date = hDate[:date]
|
22
|
+
dateRes = hDate[:dateResolution]
|
23
|
+
|
24
|
+
# date - date (required)
|
25
|
+
unless date.nil?
|
26
|
+
case dateRes
|
27
|
+
when 'Y', 'YM', 'YMD'
|
28
|
+
dateStr = AdiwgDateTimeFun.stringDateFromDateTime(date, dateRes)
|
29
|
+
@xml.tag!('gco:Date', dateStr)
|
30
|
+
when 'YMDh', 'YMDhm', 'YMDhms'
|
31
|
+
dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, 'YMDhms')
|
32
|
+
@xml.tag!('gco:DateTime', dateStr)
|
33
|
+
when 'YMDhZ', 'YMDhmZ', 'YMDhmsZ'
|
34
|
+
dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, 'YMDhmsZ')
|
35
|
+
@xml.tag!('gco:DateTime', dateStr)
|
36
|
+
else
|
37
|
+
dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, dateRes)
|
38
|
+
@xml.tag!('gco:DateTime', dateStr)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end # write XML
|
43
|
+
end # Date class
|
44
|
+
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
48
|
end
|
@@ -42,6 +42,8 @@ module ADIWG
|
|
42
42
|
if objId.nil?
|
43
43
|
@hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ
|
44
44
|
objId = 'geometryCollection' + @hResponseObj[:writerMissingIdCount]
|
45
|
+
else
|
46
|
+
objId.gsub!(/[^0-9a-zA-Z]/,'')
|
45
47
|
end
|
46
48
|
attributes['gml:id'] = objId
|
47
49
|
|
@@ -35,6 +35,8 @@ module ADIWG
|
|
35
35
|
if objId.nil?
|
36
36
|
@hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ
|
37
37
|
objId = 'multiPoint' + @hResponseObj[:writerMissingIdCount]
|
38
|
+
else
|
39
|
+
objId.gsub!(/[^0-9a-zA-Z]/,'')
|
38
40
|
end
|
39
41
|
attributes['gml:id'] = objId
|
40
42
|
|
@@ -35,6 +35,8 @@ module ADIWG
|
|
35
35
|
if objId.nil?
|
36
36
|
@hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ
|
37
37
|
objId = 'multiPolygon' + @hResponseObj[:writerMissingIdCount]
|
38
|
+
else
|
39
|
+
objId.gsub!(/[^0-9a-zA-Z]/,'')
|
38
40
|
end
|
39
41
|
attributes['gml:id'] = objId
|
40
42
|
|
@@ -16,68 +16,70 @@ require 'adiwg/mdtranslator/internal/module_coordinates'
|
|
16
16
|
require_relative 'class_featureProperties'
|
17
17
|
|
18
18
|
module ADIWG
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
19
|
+
module Mdtranslator
|
20
|
+
module Writers
|
21
|
+
module Iso19115_2
|
22
|
+
|
23
|
+
class Point
|
24
|
+
|
25
|
+
def initialize(xml, hResponseObj)
|
26
|
+
@xml = xml
|
27
|
+
@hResponseObj = hResponseObj
|
28
|
+
end
|
29
|
+
|
30
|
+
def writeXML(hGeoObject, hProperties, objId)
|
31
|
+
|
32
|
+
# classes used
|
33
|
+
geoPropClass = FeatureProperties.new(@xml, @hResponseObj)
|
34
|
+
|
35
|
+
# Point attributes
|
36
|
+
attributes = {}
|
37
|
+
|
38
|
+
# Point attributes - gml:id (required)
|
39
|
+
if objId.nil?
|
40
|
+
@hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ
|
41
|
+
objId = 'point' + @hResponseObj[:writerMissingIdCount]
|
42
|
+
else
|
43
|
+
objId.gsub!(/[^0-9a-zA-Z]/,'')
|
44
|
+
end
|
45
|
+
attributes['gml:id'] = objId
|
46
|
+
|
47
|
+
# Point attributes - srsDimension
|
48
|
+
s = AdiwgCoordinates.getDimension(hGeoObject[:coordinates])
|
49
|
+
if !s.nil?
|
50
|
+
attributes[:srsDimension] = s
|
51
|
+
end
|
52
|
+
|
53
|
+
# Point attributes - srsName (GeoJSON is WGS84)
|
54
|
+
attributes[:srsName] = 'WGS84'
|
55
|
+
|
56
|
+
@xml.tag!('gml:Point', attributes) do
|
57
|
+
|
58
|
+
# point - properties for Feature
|
59
|
+
unless hProperties.empty?
|
60
|
+
geoPropClass.writeXML(hProperties)
|
61
|
+
end
|
62
|
+
if hProperties.empty? && @hResponseObj[:writerShowTags]
|
63
|
+
@xml.tag!('gml:description')
|
64
|
+
@xml.tag!('gml:identifier', {'codeSpace' => ''})
|
65
|
+
@xml.tag!('gml:name')
|
66
|
+
end
|
67
|
+
|
68
|
+
# point - pos (required)
|
69
|
+
s = ''
|
70
|
+
unless hGeoObject[:coordinates].empty?
|
71
|
+
hGeoObject[:coordinates].each do |coord|
|
72
|
+
s += coord.to_s + ' '
|
42
73
|
end
|
43
|
-
|
74
|
+
s = s.strip
|
75
|
+
end
|
76
|
+
@xml.tag!('gml:pos', s)
|
44
77
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
attributes[:srsDimension] = s
|
49
|
-
end
|
78
|
+
end # gml:Point tag
|
79
|
+
end # writeXML
|
80
|
+
end # Point class
|
50
81
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
@xml.tag!('gml:Point', attributes) do
|
55
|
-
|
56
|
-
# point - properties for Feature
|
57
|
-
unless hProperties.empty?
|
58
|
-
geoPropClass.writeXML(hProperties)
|
59
|
-
end
|
60
|
-
if hProperties.empty? && @hResponseObj[:writerShowTags]
|
61
|
-
@xml.tag!('gml:description')
|
62
|
-
@xml.tag!('gml:identifier', {'codeSpace'=>''})
|
63
|
-
@xml.tag!('gml:name')
|
64
|
-
end
|
65
|
-
|
66
|
-
# point - pos (required)
|
67
|
-
s = ''
|
68
|
-
unless hGeoObject[:coordinates].empty?
|
69
|
-
hGeoObject[:coordinates].each do |coord|
|
70
|
-
s += coord.to_s + ' '
|
71
|
-
end
|
72
|
-
s = s.strip
|
73
|
-
end
|
74
|
-
@xml.tag!('gml:pos', s)
|
75
|
-
|
76
|
-
end # gml:Point tag
|
77
|
-
end # writeXML
|
78
|
-
end # Point class
|
79
|
-
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
83
85
|
end
|
@@ -33,6 +33,8 @@ module ADIWG
|
|
33
33
|
if timeID.nil?
|
34
34
|
@hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ
|
35
35
|
timeID = 'timeInstant' + @hResponseObj[:writerMissingIdCount]
|
36
|
+
else
|
37
|
+
timeID.gsub!(/[^0-9a-zA-Z]/,'')
|
36
38
|
end
|
37
39
|
|
38
40
|
@xml.tag!('gml:TimeInstant', {'gml:id' => timeID}) do
|
@@ -34,6 +34,8 @@ module ADIWG
|
|
34
34
|
if timeID.nil?
|
35
35
|
@hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ
|
36
36
|
timeID = 'timePeriod' + @hResponseObj[:writerMissingIdCount]
|
37
|
+
else
|
38
|
+
timeID.gsub!(/[^0-9a-zA-Z]/,'')
|
37
39
|
end
|
38
40
|
|
39
41
|
@xml.tag!('gml:TimePeriod', {'gml:id' => timeID}) do
|
@@ -15,21 +15,8 @@ module ADIWG
|
|
15
15
|
|
16
16
|
def self.build(hDate)
|
17
17
|
|
18
|
-
date = hDate[:date]
|
19
|
-
dateRes = hDate[:dateResolution]
|
20
|
-
dateStr = ''
|
21
|
-
|
22
|
-
unless date.nil?
|
23
|
-
case dateRes
|
24
|
-
when 'Y', 'YM', 'YMD'
|
25
|
-
dateStr = AdiwgDateTimeFun.stringDateFromDateTime(date, dateRes)
|
26
|
-
else
|
27
|
-
dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, dateRes)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
18
|
Jbuilder.new do |json|
|
32
|
-
json.date(
|
19
|
+
json.date(AdiwgDateTimeFun.stringFromDateObject(hDate))
|
33
20
|
json.dateType hDate[:dateType]
|
34
21
|
end
|
35
22
|
|
@@ -14,20 +14,7 @@ module ADIWG
|
|
14
14
|
|
15
15
|
def self.build(hDateTime)
|
16
16
|
|
17
|
-
|
18
|
-
dateRes = hDateTime[:dateResolution]
|
19
|
-
dateStr = ''
|
20
|
-
|
21
|
-
unless date.nil?
|
22
|
-
case dateRes
|
23
|
-
when 'Y', 'YM', 'YMD'
|
24
|
-
dateStr = AdiwgDateTimeFun.stringDateFromDateTime(date, dateRes)
|
25
|
-
else
|
26
|
-
dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, dateRes)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
return dateStr
|
17
|
+
return AdiwgDateTimeFun.stringFromDateObject(hDateTime)
|
31
18
|
|
32
19
|
end # build
|
33
20
|
end # DateTime
|
@@ -18,40 +18,39 @@ module ADIWG
|
|
18
18
|
def self.build(hCitation)
|
19
19
|
|
20
20
|
citation = ''
|
21
|
+
role = ''
|
21
22
|
|
22
23
|
# names
|
23
|
-
|
24
|
+
aIndexes = []
|
24
25
|
hCitation[:responsibleParties].each do |hResponsibility|
|
26
|
+
role = hResponsibility[:roleName]
|
25
27
|
hResponsibility[:parties].each do |hParty|
|
26
|
-
|
28
|
+
party = {}
|
29
|
+
party[:role] = role
|
30
|
+
party[:index] = hParty[:contactIndex]
|
31
|
+
aIndexes << party
|
27
32
|
hParty[:organizationMembers].each do |hMember|
|
28
|
-
|
33
|
+
party = {}
|
34
|
+
party[:role] = role
|
35
|
+
party[:index] = hMember[:contactIndex]
|
36
|
+
aIndexes << party
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|
32
|
-
|
33
|
-
|
34
|
-
hContact = ADIWG::Mdtranslator::Writers::SbJson.getContact(index)
|
40
|
+
aIndexes.uniq!
|
41
|
+
aIndexes.each do |hIndex|
|
42
|
+
hContact = ADIWG::Mdtranslator::Writers::SbJson.getContact(hIndex[:index])
|
35
43
|
unless hContact.empty?
|
36
44
|
unless hContact[:name].nil?
|
37
|
-
citation += hContact[:name] + ', '
|
45
|
+
citation += hContact[:name] + '(' + hIndex[:role] + '), '
|
38
46
|
end
|
39
47
|
end
|
40
48
|
end
|
41
49
|
|
42
50
|
# dates
|
43
51
|
hCitation[:dates].each do |hDate|
|
44
|
-
|
45
|
-
|
46
|
-
unless date.nil?
|
47
|
-
case dateRes
|
48
|
-
when 'Y', 'YM', 'YMD'
|
49
|
-
dateStr = AdiwgDateTimeFun.stringDateFromDateTime(date, dateRes)
|
50
|
-
else
|
51
|
-
dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(date, dateRes)
|
52
|
-
end
|
53
|
-
citation += dateStr.to_s + '(' + hDate[:dateType] + '), '
|
54
|
-
end
|
52
|
+
dateStr = AdiwgDateTimeFun.stringFromDateObject(hDate)
|
53
|
+
citation += dateStr + '(' + hDate[:dateType] + '), '
|
55
54
|
end
|
56
55
|
|
57
56
|
# title
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# sbJson 1.0 writer
|
2
|
+
|
3
|
+
# History:
|
4
|
+
# Stan Smith 2017-05-23 original script
|
5
|
+
|
6
|
+
module ADIWG
|
7
|
+
module Mdtranslator
|
8
|
+
module Writers
|
9
|
+
module SbJson
|
10
|
+
|
11
|
+
module Provenance
|
12
|
+
|
13
|
+
def self.build(hMetadataInfo)
|
14
|
+
|
15
|
+
aContacts = hMetadataInfo[:metadataContacts]
|
16
|
+
aDates = hMetadataInfo[:metadataDates]
|
17
|
+
|
18
|
+
hProvenance = {}
|
19
|
+
hProvenance[:dataSource] = 'generated using ADIwg mdTranslator ' + ADIWG::Mdtranslator::VERSION
|
20
|
+
|
21
|
+
aDates.each do |hDate|
|
22
|
+
if hDate[:dateType] == 'creation'
|
23
|
+
hProvenance[:dateCreated] = AdiwgDateTimeFun.stringFromDateObject(hDate)
|
24
|
+
end
|
25
|
+
if hDate[:dateType] == 'lastUpdate'
|
26
|
+
hProvenance[:lastUpdated] = AdiwgDateTimeFun.stringFromDateObject(hDate)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
hProvenance
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# sbJson 1.0 writer
|
2
|
+
|
3
|
+
# History:
|
4
|
+
# Stan Smith 2017-05-22 original script
|
5
|
+
|
6
|
+
module ADIWG
|
7
|
+
module Mdtranslator
|
8
|
+
module Writers
|
9
|
+
module SbJson
|
10
|
+
|
11
|
+
module Rights
|
12
|
+
|
13
|
+
def self.build(aConstraints)
|
14
|
+
|
15
|
+
rights = ''
|
16
|
+
|
17
|
+
aConstraints.each do |hConstraint|
|
18
|
+
if hConstraint[:type] = 'legal'
|
19
|
+
unless hConstraint[:legalConstraint].empty?
|
20
|
+
hConstraint[:legalConstraint][:otherCons].each do |con|
|
21
|
+
rights += con + '; '
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# clean off last semicolon
|
28
|
+
if rights.length > 2
|
29
|
+
rights = rights[0...-2]
|
30
|
+
end
|
31
|
+
|
32
|
+
rights
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -8,6 +8,8 @@ require 'jbuilder'
|
|
8
8
|
require_relative 'sbJson_id'
|
9
9
|
require_relative 'sbJson_citation'
|
10
10
|
require_relative 'sbJson_identifier'
|
11
|
+
require_relative 'sbJson_rights'
|
12
|
+
require_relative 'sbJson_provenance'
|
11
13
|
|
12
14
|
module ADIWG
|
13
15
|
module Mdtranslator
|
@@ -16,6 +18,7 @@ module ADIWG
|
|
16
18
|
|
17
19
|
def self.build(intObj, responseObj)
|
18
20
|
|
21
|
+
metadataInfo = intObj[:metadata][:metadataInfo]
|
19
22
|
resourceInfo = intObj[:metadata][:resourceInfo]
|
20
23
|
hCitation = resourceInfo[:citation]
|
21
24
|
|
@@ -46,6 +49,15 @@ module ADIWG
|
|
46
49
|
json.purpose resourceInfo[:purpose]
|
47
50
|
|
48
51
|
# rights
|
52
|
+
unless resourceInfo[:constraints].empty?
|
53
|
+
json.rights Rights.build(resourceInfo[:constraints])
|
54
|
+
end
|
55
|
+
|
56
|
+
# provenance
|
57
|
+
json.provenance Provenance.build(metadataInfo)
|
58
|
+
|
59
|
+
# material requisition instructions
|
60
|
+
json.materialRequisitionInstructions
|
49
61
|
|
50
62
|
end
|
51
63
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: adiwg-mdtranslator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.0rc6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stan Smith
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-05-
|
12
|
+
date: 2017-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -586,6 +586,8 @@ files:
|
|
586
586
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_facet.rb
|
587
587
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_id.rb
|
588
588
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_identifier.rb
|
589
|
+
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_provenance.rb
|
590
|
+
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_rights.rb
|
589
591
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_sbJson.rb
|
590
592
|
- lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_spatial.rb
|
591
593
|
- lib/adiwg/mdtranslator/writers/sbJson/version.rb
|
@@ -610,7 +612,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
610
612
|
version: 1.3.1
|
611
613
|
requirements: []
|
612
614
|
rubyforge_project:
|
613
|
-
rubygems_version: 2.
|
615
|
+
rubygems_version: 2.5.2
|
614
616
|
signing_key:
|
615
617
|
specification_version: 4
|
616
618
|
summary: The mdtranslator (metadata translator) is a tool for translating metadata
|