adiwg-mdtranslator 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/adiwg/mdtranslator.rb +40 -1
- data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +6 -23
- data/lib/adiwg/mdtranslator/internal/module_geoFormat.rb +226 -0
- data/lib/adiwg/mdtranslator/version.rb +2 -1
- data/lib/adiwg/mdtranslator/writers/html/html_writer.rb +0 -2
- data/lib/adiwg/mdtranslator/writers/html/md_html_writer.rb +34 -3
- data/lib/adiwg/mdtranslator/writers/html/readme.md +6 -2
- data/lib/adiwg/mdtranslator/writers/html/sections/html_body.rb +321 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_bodyScript.js +111 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_browseGraphic.rb +58 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_citation.rb +91 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_contact.rb +132 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_dataDictionary.rb +110 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_dataLineage.rb +67 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_dataSource.rb +66 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_dateTime.rb +41 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_domain.rb +80 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_domainMember.rb +52 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_entity.rb +137 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_entityAttribute.rb +107 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_entityIndex.rb +50 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_extent.rb +107 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_format.rb +39 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_geographicElement.rb +211 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_head.rb +53 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_headScript.js +18 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_inlineCss.css +223 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_keyword.rb +59 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_legalConstraint.rb +56 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_medium.rb +51 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_metadataInfo.rb +119 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_onlineResource.rb +63 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_orderProcess.rb +63 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_processStep.rb +74 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_resolution.rb +46 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_resourceContact.rb +36 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_resourceFormat.rb +39 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_resourceGeneral.rb +106 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_resourceId.rb +50 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_resourceInfo.rb +261 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_resourceMaint.rb +55 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_resourceOther.rb +87 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_resourceUsage.rb +55 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_responsibleParty.rb +38 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_securityConstraint.rb +55 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_spatialReferenceSystem.rb +58 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_taxonomy.rb +108 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_taxonomyClass.rb +62 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_temporalElement.rb +60 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_timeInstant.rb +55 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_timePeriod.rb +59 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_transferOption.rb +51 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/html_verticalElement.rb +59 -0
- data/lib/adiwg/mdtranslator/writers/html/sections/logo150.txt +25 -0
- data/lib/adiwg/mdtranslator/writers/iso/classes/class_geographicDescription.rb +12 -12
- metadata +50 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c9190f59cb06120337f450218450d6fd3768ae8
|
4
|
+
data.tar.gz: 0697e17ef822693beec73ed375f46f8327b1a2fb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06dee876009cdae0ec4271d91b5e8d92471486ca00e5953bc20367532536fb1dd0f939247c8a2682438531a5ec273f8c33467947a342bd36fac5ec7b7f453aca
|
7
|
+
data.tar.gz: b68e266cf5606a7ed236b24bd94c0d485b3a585e49c5d767f0019f4b93de5693927c573d4475d347636e63ca5a5b65b9b964acef8533e4c7b90f4a96a460ec52
|
data/lib/adiwg/mdtranslator.rb
CHANGED
@@ -55,7 +55,46 @@ module ADIWG
|
|
55
55
|
|
56
56
|
$showAllTags = showAllTags
|
57
57
|
|
58
|
-
#
|
58
|
+
# the reader and writer specified in the translate parameter string should load and
|
59
|
+
# return this hash ...
|
60
|
+
# ---------------------------
|
61
|
+
# readerFormat: the anticipated format of the input file, parsing by the reader will
|
62
|
+
# proceed assuming this format, set by reader
|
63
|
+
# readerStructurePass: 'true' if input file structure is determined to be valid.
|
64
|
+
# Set by the reader.
|
65
|
+
# readerStructureMessages: an array of quoted string messages. If readerStructurePass
|
66
|
+
# is false, set one or more messages to assist the user in fixing file structure
|
67
|
+
# problems. Set by reader.
|
68
|
+
# readerRequested: name of the reader requested by the user, set from the translate
|
69
|
+
# parameter list
|
70
|
+
# readerFound: name of the reader used by the reader, set by reader. Will be same as
|
71
|
+
# readerRequested if readerRequested name is valid
|
72
|
+
# readerVersionFound: version of the reader requested by the input file, set by reader
|
73
|
+
# readerVersionUsed: version of the reader the reader method decided to use in processing
|
74
|
+
# the input file. Set by the reader. Default 'normal'.
|
75
|
+
# readerValidationLevel: validation level requested to be applied to the input file, set
|
76
|
+
# from the parameter list
|
77
|
+
# readerValidationPass: true if the input file passes the level of validation requested,
|
78
|
+
# set by reader
|
79
|
+
# readerValidationMessages: an array of quoted string messages. If readerValidationPass
|
80
|
+
# is 'false', set one or more messages to assist user fixing file schema validation
|
81
|
+
# problems. Set by reader.
|
82
|
+
# readerExecutionPass: 'true' if the reader completes the import of the input file into
|
83
|
+
# the internal object without errors set by reader
|
84
|
+
# readerExecutionMessages: an array of quoted string messages. If readerExecutionPass is
|
85
|
+
# 'false', set one or more messages to assist user in fixing file data problems.
|
86
|
+
# Set by reader.
|
87
|
+
# writerName: name of the writer requested by the user, set from the translate parameter
|
88
|
+
# list. if nil no write was requested and only validation of the input file will
|
89
|
+
# be performed.
|
90
|
+
# writerVersion: current version of the writer requested, set by writer
|
91
|
+
# writerFormat: format of the output from the writer, set by writer
|
92
|
+
# writerPass: true if the writer completes the creation of the output file without errors,
|
93
|
+
# set by writer
|
94
|
+
# writerMessages: an array of quoted string messages. If writerPass is 'false', set one
|
95
|
+
# or more messages to assist user in fixing file data problems. Set by writer.
|
96
|
+
# writerOutput: output file returned from the writer, set by writer
|
97
|
+
|
59
98
|
$response = {
|
60
99
|
readerFormat: nil,
|
61
100
|
readerStructurePass: nil,
|
@@ -228,17 +228,17 @@ class InternalMetadata
|
|
228
228
|
}
|
229
229
|
end
|
230
230
|
|
231
|
-
def
|
231
|
+
def newLegalConstraint
|
232
232
|
intObj = {
|
233
|
-
|
234
|
-
|
233
|
+
accessCodes: [],
|
234
|
+
useCodes: [],
|
235
235
|
otherCons: []
|
236
236
|
}
|
237
237
|
end
|
238
238
|
|
239
|
-
def
|
239
|
+
def newSecurityConstraint
|
240
240
|
intObj = {
|
241
|
-
|
241
|
+
classCode: nil,
|
242
242
|
userNote: nil,
|
243
243
|
classSystem: nil,
|
244
244
|
handlingDesc: nil
|
@@ -325,7 +325,7 @@ class InternalMetadata
|
|
325
325
|
intObj = {
|
326
326
|
srsName: nil,
|
327
327
|
srsHref: nil,
|
328
|
-
|
328
|
+
srsType: nil
|
329
329
|
}
|
330
330
|
end
|
331
331
|
|
@@ -387,23 +387,6 @@ class InternalMetadata
|
|
387
387
|
}
|
388
388
|
end
|
389
389
|
|
390
|
-
def newLegalConstraint
|
391
|
-
intObj = {
|
392
|
-
accessCodes: [],
|
393
|
-
useCodes: [],
|
394
|
-
otherCons: []
|
395
|
-
}
|
396
|
-
end
|
397
|
-
|
398
|
-
def newSecurityConstraint
|
399
|
-
intObj = {
|
400
|
-
classCode: nil,
|
401
|
-
userNote: nil,
|
402
|
-
classSystem: nil,
|
403
|
-
handlingDesc: nil
|
404
|
-
}
|
405
|
-
end
|
406
|
-
|
407
390
|
def newDataUsage
|
408
391
|
intObj = {
|
409
392
|
specificUsage: nil,
|
@@ -0,0 +1,226 @@
|
|
1
|
+
# methods for converting geographic formats
|
2
|
+
# for ADIwg readers and writers
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2015-04-01 original script
|
6
|
+
# Stan Smith 2015-04-10 mapped bounding box as geojson feature and wkt polygon
|
7
|
+
|
8
|
+
module AdiwgGeoFormat
|
9
|
+
|
10
|
+
def self.internal_to_geoJson(hGeoEle)
|
11
|
+
|
12
|
+
geoType = hGeoEle[:elementGeometry][:geoType]
|
13
|
+
hGeometry = hGeoEle[:elementGeometry][:geometry]
|
14
|
+
hSRS = hGeoEle[:elementSrs]
|
15
|
+
|
16
|
+
# GeoJson structure as hash
|
17
|
+
hGeoJson = Hash.new()
|
18
|
+
|
19
|
+
# add type
|
20
|
+
hGeoJson[:type] = geoType
|
21
|
+
|
22
|
+
# add bounding box
|
23
|
+
if geoType == 'BoundingBox'
|
24
|
+
hGeoJson[:type] = 'Feature'
|
25
|
+
hGeoJson[:bbox] = [hGeometry[:westLong],hGeometry[:southLat],
|
26
|
+
hGeometry[:eastLong],hGeometry[:northLat]]
|
27
|
+
hGeoJson[:geometry] = nil
|
28
|
+
hGeoJson[:properties] = nil
|
29
|
+
end
|
30
|
+
|
31
|
+
# add point, multi-point, linestring, multi-linestring
|
32
|
+
if geoType == 'Point' ||
|
33
|
+
geoType == 'MultiPoint' ||
|
34
|
+
geoType == 'LineString' ||
|
35
|
+
geoType == 'MultiLineString'
|
36
|
+
hGeoJson[:coordinates] = hGeometry
|
37
|
+
end
|
38
|
+
|
39
|
+
# add polygon
|
40
|
+
if geoType == 'Polygon'
|
41
|
+
hGeoJson[:coordinates] = polygon_to_coords(hGeometry)
|
42
|
+
end
|
43
|
+
|
44
|
+
# add multi-polygon
|
45
|
+
if geoType == 'MultiPolygon'
|
46
|
+
hGeoJson[:coordinates] = []
|
47
|
+
hGeometry.each do |hPolygon|
|
48
|
+
hGeoJson[:coordinates] << polygon_to_coords(hPolygon)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# add coordinate reference system
|
53
|
+
if !hSRS.empty?
|
54
|
+
hGeoJson[:crs] = {}
|
55
|
+
|
56
|
+
# if srs name is provided use crs name format
|
57
|
+
sName = hSRS[:srsName]
|
58
|
+
sLink = hSRS[:srsHref]
|
59
|
+
if !sName.nil?
|
60
|
+
hGeoJson[:crs][:type] = 'name'
|
61
|
+
hGeoJson[:crs][:properties]= {}
|
62
|
+
hGeoJson[:crs][:properties][:name] = sName
|
63
|
+
elsif !sLink.nil?
|
64
|
+
hGeoJson[:crs][:type] = 'link'
|
65
|
+
hGeoJson[:crs][:properties]= {}
|
66
|
+
hGeoJson[:crs][:properties][:href] = sLink
|
67
|
+
sType = hSRS[:srsType]
|
68
|
+
if !sType.nil?
|
69
|
+
hGeoJson[:crs][:properties][:type] = sType
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
# convert internal object polygon format to coordinates
|
76
|
+
def self.polygon_to_coords(hPolygon)
|
77
|
+
aCoordinates = []
|
78
|
+
|
79
|
+
# add exterior ring
|
80
|
+
aCoordinates << hPolygon[:exteriorRing]
|
81
|
+
|
82
|
+
# add exclusion rings
|
83
|
+
hPolygon[:exclusionRings].each do |aExRing|
|
84
|
+
aCoordinates << aExRing
|
85
|
+
end
|
86
|
+
|
87
|
+
return aCoordinates
|
88
|
+
end
|
89
|
+
|
90
|
+
# return GeoJSON
|
91
|
+
return hGeoJson.to_json
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.internal_to_wkt(hGeoEle)
|
96
|
+
geoType = hGeoEle[:geoType]
|
97
|
+
hGeometry = hGeoEle[:geometry]
|
98
|
+
dimension = hGeoEle[:dimension]
|
99
|
+
wktString = ''
|
100
|
+
|
101
|
+
if geoType == 'BoundingBox'
|
102
|
+
wktString = 'POLYGON ('
|
103
|
+
wktString += '(' + hGeometry[:westLong].to_s + ' ' + hGeometry[:northLat].to_s + '), '
|
104
|
+
wktString += '(' + hGeometry[:eastLong].to_s + ' ' + hGeometry[:northLat].to_s + '), '
|
105
|
+
wktString += '(' + hGeometry[:eastLong].to_s + ' ' + hGeometry[:southLat].to_s + '), '
|
106
|
+
wktString += '(' + hGeometry[:westLong].to_s + ' ' + hGeometry[:southLat].to_s + '), '
|
107
|
+
wktString += '(' + hGeometry[:westLong].to_s + ' ' + hGeometry[:northLat].to_s + ')'
|
108
|
+
wktString += ')'
|
109
|
+
end
|
110
|
+
|
111
|
+
if geoType == 'Point'
|
112
|
+
wktString = 'POINT ' + wkt_dimension(dimension) + '('
|
113
|
+
wktString += point_string(hGeometry)
|
114
|
+
wktString += ')'
|
115
|
+
end
|
116
|
+
|
117
|
+
if geoType == 'LineString'
|
118
|
+
wktString = 'LINESTRING ' + wkt_dimension(dimension) + '('
|
119
|
+
hGeometry.each do |point|
|
120
|
+
wktString += point_string(point) + ', '
|
121
|
+
end
|
122
|
+
wktString.chomp!(', ')
|
123
|
+
wktString += ')'
|
124
|
+
end
|
125
|
+
|
126
|
+
if geoType == 'Polygon'
|
127
|
+
wktString = 'POLYGON ' + wkt_dimension(dimension) + '('
|
128
|
+
|
129
|
+
# add exterior ring - required
|
130
|
+
wktString += '('
|
131
|
+
aExtRing = hGeometry[:exteriorRing]
|
132
|
+
aExtRing.each do |point|
|
133
|
+
wktString += point_string(point) + ', '
|
134
|
+
end
|
135
|
+
wktString.chomp!(', ')
|
136
|
+
wktString += ')'
|
137
|
+
|
138
|
+
# add any exclusion rings
|
139
|
+
aExcRings = hGeometry[:exclusionRings]
|
140
|
+
aExcRings.each do |excPolygon|
|
141
|
+
wktString += ', ('
|
142
|
+
excPolygon.each do |point|
|
143
|
+
wktString += point_string(point) + ', '
|
144
|
+
end
|
145
|
+
wktString.chomp!(', ')
|
146
|
+
wktString += ')'
|
147
|
+
end
|
148
|
+
|
149
|
+
wktString += ')'
|
150
|
+
end
|
151
|
+
|
152
|
+
if geoType == 'MultiPoint'
|
153
|
+
wktString = 'MULTIPOINT ' + wkt_dimension(dimension) + '('
|
154
|
+
hGeometry.each do |point|
|
155
|
+
wktString += '('
|
156
|
+
wktString += point_string(point) + '), '
|
157
|
+
end
|
158
|
+
wktString.chomp!(', ')
|
159
|
+
wktString += ')'
|
160
|
+
end
|
161
|
+
|
162
|
+
if geoType == 'MultiLineString'
|
163
|
+
wktString = 'MULTILINESTRING ' + wkt_dimension(dimension) + '('
|
164
|
+
hGeometry.each do |line|
|
165
|
+
wktString += '('
|
166
|
+
line.each do |point|
|
167
|
+
wktString += point_string(point) + ', '
|
168
|
+
end
|
169
|
+
wktString.chomp!(', ')
|
170
|
+
wktString += '), '
|
171
|
+
end
|
172
|
+
wktString.chomp!(', ')
|
173
|
+
wktString += ')'
|
174
|
+
end
|
175
|
+
|
176
|
+
if geoType == 'MultiPolygon'
|
177
|
+
wktString = 'MULTIPOLYGON ' + wkt_dimension(dimension) + '('
|
178
|
+
hGeometry.each do |polygon|
|
179
|
+
wktString += '('
|
180
|
+
|
181
|
+
# add exterior ring - required
|
182
|
+
wktString += '('
|
183
|
+
aExtRing = polygon[:exteriorRing]
|
184
|
+
aExtRing.each do |point|
|
185
|
+
wktString += point_string(point) + ', '
|
186
|
+
end
|
187
|
+
wktString.chomp!(', ')
|
188
|
+
wktString += ')'
|
189
|
+
|
190
|
+
# add any exclusion rings
|
191
|
+
aExcRings = polygon[:exclusionRings]
|
192
|
+
aExcRings.each do |excPolygon|
|
193
|
+
wktString += ', ('
|
194
|
+
excPolygon.each do |point|
|
195
|
+
wktString += point_string(point) + ', '
|
196
|
+
end
|
197
|
+
wktString.chomp!(', ')
|
198
|
+
wktString += ')'
|
199
|
+
end
|
200
|
+
|
201
|
+
wktString += '), '
|
202
|
+
end
|
203
|
+
wktString.chomp!(', ')
|
204
|
+
wktString += ')'
|
205
|
+
end
|
206
|
+
|
207
|
+
def self.point_string(aTuple)
|
208
|
+
sTuple = ''
|
209
|
+
aTuple.each do |element|
|
210
|
+
sTuple += element.to_s + ' '
|
211
|
+
end
|
212
|
+
return sTuple.chomp(' ')
|
213
|
+
end
|
214
|
+
|
215
|
+
def self.wkt_dimension(dim)
|
216
|
+
sDim = ''
|
217
|
+
sDim += 'Z ' if dim == 3
|
218
|
+
sDim += 'ZM ' if dim == 4
|
219
|
+
return sDim
|
220
|
+
end
|
221
|
+
|
222
|
+
return wktString
|
223
|
+
|
224
|
+
end
|
225
|
+
|
226
|
+
end
|
@@ -37,11 +37,12 @@
|
|
37
37
|
# ... added alias to entity and attribute
|
38
38
|
# ... added local names to iso 19110 writer
|
39
39
|
# 1.0.0rc1 2015-02-27 schema 1.0 support
|
40
|
+
# 1.1.0 2015-04-13 added html writer
|
40
41
|
|
41
42
|
module ADIWG
|
42
43
|
module Mdtranslator
|
43
44
|
# current mdtranslator version
|
44
|
-
VERSION = "1.
|
45
|
+
VERSION = "1.1.0"
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
@@ -1,5 +1,15 @@
|
|
1
|
+
# HTML writer
|
1
2
|
|
2
|
-
|
3
|
+
# History:
|
4
|
+
# Stan Smith 2015-03-23 original script
|
5
|
+
# Stan Smith 2015-04-07 replaced instruct! with declare! and html to
|
6
|
+
# ... conform with w3 html encoding declarations
|
7
|
+
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), './sections'))
|
10
|
+
|
11
|
+
require 'html_head'
|
12
|
+
require 'html_body'
|
3
13
|
|
4
14
|
module ADIWG
|
5
15
|
module Mdtranslator
|
@@ -13,8 +23,29 @@ module ADIWG
|
|
13
23
|
|
14
24
|
def writeHtml(intObj)
|
15
25
|
|
16
|
-
# set
|
17
|
-
$
|
26
|
+
# set html section namespace
|
27
|
+
$HtmlNS = ADIWG::Mdtranslator::Writers::Html
|
28
|
+
|
29
|
+
# set contact array in a global
|
30
|
+
$aContacts = intObj[:contacts]
|
31
|
+
|
32
|
+
# classes used
|
33
|
+
htmlHead = $HtmlNS::MdHtmlHead.new(@html)
|
34
|
+
htmlBody = $HtmlNS::MdHtmlBody.new(@html)
|
35
|
+
|
36
|
+
# page
|
37
|
+
metadata = @html.declare! :DOCTYPE, :html
|
38
|
+
@html.html(:lang=>'en') do
|
39
|
+
@html.comment!('Report from mdTranslator HTML writer v1.0')
|
40
|
+
|
41
|
+
# head
|
42
|
+
htmlHead.writeHtml()
|
43
|
+
|
44
|
+
# body
|
45
|
+
htmlBody.writeHtml(intObj)
|
46
|
+
end
|
47
|
+
|
48
|
+
return metadata
|
18
49
|
|
19
50
|
end
|
20
51
|
end
|
@@ -1,10 +1,14 @@
|
|
1
1
|
|
2
2
|
## html
|
3
3
|
|
4
|
-
### Writer for HTML 'human-readable'
|
4
|
+
### Writer for HTML 'human-readable' output of metadata
|
5
5
|
|
6
6
|
The HTML version of metadata is intended to be a human readable
|
7
7
|
version of the metadata content. The HTML output does not mimic
|
8
8
|
any established metadata standard but remains agnostic in its
|
9
9
|
presentation. The HTML metadata version will present the entire
|
10
|
-
content of the metadata
|
10
|
+
content of the metadata provided to the mdTranslator reader.
|
11
|
+
|
12
|
+
The HTML writer can be use to allow users to conveniently scan
|
13
|
+
metadata prior to downloading a data file or to generate a printed
|
14
|
+
version of metadata to accompany a report.
|
@@ -0,0 +1,321 @@
|
|
1
|
+
# HTML writer
|
2
|
+
# html body
|
3
|
+
|
4
|
+
# History:
|
5
|
+
# Stan Smith 2015-03-23 original script
|
6
|
+
# Stan Smith 2014-04-10 add open and close buttons
|
7
|
+
|
8
|
+
require 'html_metadataInfo'
|
9
|
+
require 'html_resourceInfo'
|
10
|
+
require 'html_dataDictionary'
|
11
|
+
require 'html_citation'
|
12
|
+
require 'html_responsibleParty'
|
13
|
+
require 'html_orderProcess'
|
14
|
+
require 'html_format'
|
15
|
+
require 'html_transferOption'
|
16
|
+
|
17
|
+
module ADIWG
|
18
|
+
module Mdtranslator
|
19
|
+
module Writers
|
20
|
+
module Html
|
21
|
+
|
22
|
+
class MdHtmlBody
|
23
|
+
def initialize(html)
|
24
|
+
@html = html
|
25
|
+
end
|
26
|
+
|
27
|
+
def writeHtml(intObj)
|
28
|
+
@html.body do
|
29
|
+
|
30
|
+
# classes used
|
31
|
+
htmlMetaInfo = $HtmlNS::MdHtmlMetadataInfo.new(@html)
|
32
|
+
htmlResInfo = $HtmlNS::MdHtmlResourceInfo.new(@html)
|
33
|
+
htmlDataD = $HtmlNS::MdHtmlDataDictionary.new(@html)
|
34
|
+
htmlCitation = $HtmlNS::MdHtmlCitation.new(@html)
|
35
|
+
htmlResParty = $HtmlNS::MdHtmlResponsibleParty.new(@html)
|
36
|
+
htmlOrderProc = $HtmlNS::MdHtmlOrderProcess.new(@html)
|
37
|
+
htmlFormat = $HtmlNS::MdHtmlFormat.new(@html)
|
38
|
+
htmlTranOpt = $HtmlNS::MdHtmlTransferOption.new(@html)
|
39
|
+
|
40
|
+
# make sections of the internal data store more accessible
|
41
|
+
hMetadata = intObj[:metadata]
|
42
|
+
aDataDict = intObj[:dataDictionary]
|
43
|
+
aDistributor = intObj[:metadata][:distributorInfo]
|
44
|
+
aAssRes = intObj[:metadata][:associatedResources]
|
45
|
+
aAddDocs = intObj[:metadata][:additionalDocuments]
|
46
|
+
|
47
|
+
# set page title with logo
|
48
|
+
# read logo from file
|
49
|
+
path = File.join(File.dirname(__FILE__), 'logo150.txt')
|
50
|
+
file = File.open(path, 'r')
|
51
|
+
logo = file.read
|
52
|
+
file.close
|
53
|
+
|
54
|
+
# add top anchor and button
|
55
|
+
@html.a(' Top', {'href'=>'#', 'class'=>'btn icon-caret-up', 'style'=>'position:fixed; bottom:6em; right:1em'})
|
56
|
+
|
57
|
+
# add open and close buttons
|
58
|
+
@html.span(' Open',{'class'=>'btn icon-caret-down', 'style'=>'position:fixed; bottom:1em; right:1em', 'onclick'=>'openAllDetails();'})
|
59
|
+
@html.span(' Close',{'class'=>'btn icon-caret-right', 'style'=>'position:fixed; bottom:3.5em; right:1em', 'onclick'=>'closeAllDetails();'})
|
60
|
+
|
61
|
+
# main header
|
62
|
+
@html.h2('id'=>'mainHeader') do
|
63
|
+
@html.img('width'=>'150', 'height'=>'39', 'title'=>'', 'alt'=>'', 'src'=>logo)
|
64
|
+
@html.span('Metadata Report')
|
65
|
+
@html.span('HTML','class'=>'version')
|
66
|
+
end
|
67
|
+
|
68
|
+
# report title
|
69
|
+
@html.h1('mdTranslator Metadata Report', 'id'=>'mdtranslator-metadata-report')
|
70
|
+
|
71
|
+
# section index
|
72
|
+
@html.section(:class=>'block') do
|
73
|
+
@html.h3('Page Index')
|
74
|
+
@html.a('Metadata Information Section','href'=>'#metadataInfo')
|
75
|
+
@html.section(:class=>'block') do
|
76
|
+
@html.a('Metadata Identifier', 'href'=>'#metadata-identifier')
|
77
|
+
@html.br
|
78
|
+
@html.a('Metadata Record Information', 'href'=>'#metadata-recordInfo')
|
79
|
+
@html.br
|
80
|
+
@html.a('Parent Metadata Citation', 'href'=>'#metadata-parentInfo')
|
81
|
+
end
|
82
|
+
@html.br
|
83
|
+
@html.a('Resource Information Section','href'=>'#resourceInfo')
|
84
|
+
@html.section(:class=>'block') do
|
85
|
+
@html.a('Resource Identification', 'href'=>'#resourceInfo-general')
|
86
|
+
@html.br
|
87
|
+
@html.a('Contacts', 'href'=>'#resourceInfo-contacts')
|
88
|
+
@html.br
|
89
|
+
@html.a('Keywords', 'href'=>'#resourceInfo-keywords')
|
90
|
+
@html.br
|
91
|
+
@html.a('Taxonomy', 'href'=>'#resourceInfo-taxonomy')
|
92
|
+
@html.br
|
93
|
+
@html.a('Spatial Reference', 'href'=>'#resourceInfo-spatialRef')
|
94
|
+
@html.br
|
95
|
+
@html.a('Extents (Geographic, Temporal, & Vertical Space)', 'href'=>'#resourceInfo-extents')
|
96
|
+
@html.br
|
97
|
+
@html.a('Data Quality', 'href'=>'#resourceInfo-dataQuality')
|
98
|
+
@html.br
|
99
|
+
@html.a('Constraints', 'href'=>'#resourceInfo-constraints')
|
100
|
+
@html.br
|
101
|
+
@html.a('Maintenance Information', 'href'=>'#resourceInfo-maintInfo')
|
102
|
+
@html.br
|
103
|
+
@html.a('Other Resource Information', 'href'=>'#resourceInfo-other')
|
104
|
+
end
|
105
|
+
@html.br
|
106
|
+
@html.a('Data Dictionary Section','href'=>'#dataDictionary')
|
107
|
+
@html.br
|
108
|
+
@html.a('Resource Distribution Section','href'=>'#resourceDistribution')
|
109
|
+
@html.br
|
110
|
+
@html.a('Associated Resources Section','href'=>'#associatedResource')
|
111
|
+
@html.br
|
112
|
+
@html.a('Additional Documentation Section','href'=>'#additionalDocuments')
|
113
|
+
end
|
114
|
+
@html.hr
|
115
|
+
|
116
|
+
# metadata source
|
117
|
+
@html.h2('Metadata Source', 'id'=>'metadata-source')
|
118
|
+
@html.section(:class=>'block') do
|
119
|
+
@html.em('Metadata schema:')
|
120
|
+
@html.text!(intObj[:schema][:name])
|
121
|
+
@html.br
|
122
|
+
|
123
|
+
@html.em('Schema version:')
|
124
|
+
@html.text!(intObj[:schema][:version])
|
125
|
+
end
|
126
|
+
@html.hr
|
127
|
+
|
128
|
+
# metadata information section
|
129
|
+
@html.h2('Metadata Information', 'id'=>'metadataInfo')
|
130
|
+
@html.section(:class=>'block') do
|
131
|
+
htmlMetaInfo.writeHtml(hMetadata[:metadataInfo])
|
132
|
+
end
|
133
|
+
@html.hr
|
134
|
+
|
135
|
+
# resource information section
|
136
|
+
@html.h2('Resource Information', 'id'=>'resourceInfo')
|
137
|
+
@html.section(:class=>'block') do
|
138
|
+
htmlResInfo.writeHtml(hMetadata[:resourceInfo])
|
139
|
+
end
|
140
|
+
@html.hr
|
141
|
+
|
142
|
+
# data dictionary section
|
143
|
+
@html.h2('Data Dictionary', 'id'=>'dataDictionary')
|
144
|
+
aDataDict.each do |hDictionary|
|
145
|
+
@html.section(:class=>'block') do
|
146
|
+
|
147
|
+
# get dictionary title from the citation
|
148
|
+
sTitle = hDictionary[:dictionaryInfo][:dictCitation][:citTitle]
|
149
|
+
@html.details do
|
150
|
+
@html.summary(sTitle, {'class'=>'h3'})
|
151
|
+
@html.section(:class=>'block') do
|
152
|
+
htmlDataD.writeHtml(hDictionary)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
end
|
158
|
+
@html.hr
|
159
|
+
|
160
|
+
# resource distribution section
|
161
|
+
@html.h2('Resource Distribution', 'id'=>'resourceDistribution')
|
162
|
+
aDistributor.each do |hDistributor|
|
163
|
+
@html.section(:class=>'block') do
|
164
|
+
@html.details do
|
165
|
+
@html.summary('Distributor', {'class'=>'h4'})
|
166
|
+
@html.section(:class=>'block') do
|
167
|
+
|
168
|
+
# resource distribution - distributor - required
|
169
|
+
@html.em('Distributor contact: ')
|
170
|
+
hResParty = hDistributor[:distContact]
|
171
|
+
@html.section(:class=>'block') do
|
172
|
+
htmlResParty.writeHtml(hResParty)
|
173
|
+
end
|
174
|
+
|
175
|
+
# resource distribution - order process
|
176
|
+
hDistributor[:distOrderProc].each do |hOrder|
|
177
|
+
@html.em('Order Process: ')
|
178
|
+
@html.section(:class=>'block') do
|
179
|
+
htmlOrderProc.writeHtml(hOrder)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# resource distribution - resource format
|
184
|
+
hDistributor[:distFormat].each do |hFormat|
|
185
|
+
htmlFormat.writeHtml(hFormat)
|
186
|
+
end
|
187
|
+
|
188
|
+
# resource distribution - transfer options
|
189
|
+
hDistributor[:distTransOption].each do |hTransOption|
|
190
|
+
htmlTranOpt.writeHtml(hTransOption)
|
191
|
+
end
|
192
|
+
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
@html.hr
|
198
|
+
|
199
|
+
# associated resource section
|
200
|
+
@html.h2('Associated Resources', 'id'=>'associatedResource')
|
201
|
+
aAssRes.each do |hAssRes|
|
202
|
+
@html.section(:class=>'block') do
|
203
|
+
|
204
|
+
# get document title from the citation
|
205
|
+
hCitation = hAssRes[:resourceCitation]
|
206
|
+
if !hCitation.empty?
|
207
|
+
sTitle = hCitation[:citTitle]
|
208
|
+
else
|
209
|
+
sTitle = 'Resource'
|
210
|
+
end
|
211
|
+
|
212
|
+
@html.details do
|
213
|
+
@html.summary(sTitle, {'class'=>'h4'})
|
214
|
+
@html.section(:class=>'block') do
|
215
|
+
|
216
|
+
# associated resource - resource type
|
217
|
+
s = hAssRes[:resourceType]
|
218
|
+
if !s.nil?
|
219
|
+
@html.em('Resource type: ')
|
220
|
+
@html.text!(s)
|
221
|
+
@html.br
|
222
|
+
end
|
223
|
+
|
224
|
+
# associated resource - association type
|
225
|
+
s = hAssRes[:associationType]
|
226
|
+
if !s.nil?
|
227
|
+
@html.em('Association type: ')
|
228
|
+
@html.text!(s)
|
229
|
+
@html.br
|
230
|
+
end
|
231
|
+
|
232
|
+
# associated resource - initiative type
|
233
|
+
s = hAssRes[:initiativeType]
|
234
|
+
if !s.nil?
|
235
|
+
@html.em('Initiative type: ')
|
236
|
+
@html.text!(s)
|
237
|
+
@html.br
|
238
|
+
end
|
239
|
+
|
240
|
+
# associated resource - citation
|
241
|
+
if !hCitation.empty?
|
242
|
+
@html.em('Resource citation: ')
|
243
|
+
@html.section(:class=>'block') do
|
244
|
+
htmlCitation.writeHtml(hCitation)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
# associated resource - metadata citation
|
249
|
+
hCitation = hAssRes[:metadataCitation]
|
250
|
+
if !hCitation.empty?
|
251
|
+
@html.em('Metadata citation: ')
|
252
|
+
@html.section(:class=>'block') do
|
253
|
+
htmlCitation.writeHtml(hCitation)
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
end
|
259
|
+
|
260
|
+
end
|
261
|
+
end
|
262
|
+
@html.hr
|
263
|
+
|
264
|
+
# additional documentation section
|
265
|
+
@html.h2('Additional Documentation', 'id'=>'additionalDocuments')
|
266
|
+
aAddDocs.each do |hAddDoc|
|
267
|
+
@html.section(:class=>'block') do
|
268
|
+
|
269
|
+
# get document title from the citation
|
270
|
+
sTitle = hAddDoc[:citation][:citTitle]
|
271
|
+
@html.details do
|
272
|
+
@html.summary(sTitle, {'class'=>'h4'})
|
273
|
+
@html.section(:class=>'block') do
|
274
|
+
|
275
|
+
# additional documentation - resource type
|
276
|
+
s = hAddDoc[:resourceType]
|
277
|
+
if !s.nil?
|
278
|
+
@html.em('Resource type: ')
|
279
|
+
@html.text!(s)
|
280
|
+
@html.br
|
281
|
+
end
|
282
|
+
|
283
|
+
# additional documentation - citation
|
284
|
+
hCitation = hAddDoc[:citation]
|
285
|
+
if !hCitation.empty?
|
286
|
+
@html.em('Citation: ')
|
287
|
+
@html.section(:class=>'block') do
|
288
|
+
htmlCitation.writeHtml(hCitation)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
end
|
297
|
+
@html.hr
|
298
|
+
|
299
|
+
#Load leaflet
|
300
|
+
@html.link( :rel => 'stylesheet', :href => 'http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css')
|
301
|
+
@html.script('', :src => 'http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js')
|
302
|
+
|
303
|
+
# add inline javascript
|
304
|
+
# read javascript from file
|
305
|
+
path = File.join(File.dirname(__FILE__), 'html_bodyScript.js')
|
306
|
+
file = File.open(path, 'r')
|
307
|
+
js = file.read
|
308
|
+
file.close
|
309
|
+
|
310
|
+
@html.script('type'=>'text/javascript') do
|
311
|
+
@html << js
|
312
|
+
end
|
313
|
+
|
314
|
+
end # body
|
315
|
+
end # def writeHtml
|
316
|
+
end # class
|
317
|
+
|
318
|
+
end
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|