adiwg-mdtranslator 2.15.0 → 2.16.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. checksums.yaml +5 -5
  2. data/Rakefile +8 -12
  3. data/adiwg-mdtranslator.gemspec +2 -2
  4. data/lib/adiwg/mdtranslator/internal/acquisition.json +108 -0
  5. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +267 -12
  6. data/lib/adiwg/mdtranslator/internal/qualityReport.json +64 -0
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityAttribute.rb +5 -2
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +11 -1
  9. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader_messages_eng.yml +15 -0
  10. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_algorithm.rb +65 -0
  11. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_nominalResolution.rb +78 -0
  12. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_onlineResource.rb +25 -10
  13. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processReport.rb +66 -0
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processStep.rb +46 -9
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processing.rb +104 -0
  16. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_source.rb +27 -2
  17. data/lib/adiwg/mdtranslator/version.rb +4 -1
  18. data/lib/adiwg/mdtranslator/writers/html/sections/html_onlineResource.rb +14 -0
  19. data/lib/adiwg/mdtranslator/writers/html/sections/html_source.rb +2 -2
  20. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_fcFeatureCatalogue.rb +20 -15
  21. data/lib/adiwg/mdtranslator/writers/iso19110/iso19110_writer.rb +4 -4
  22. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_featureCatalog.rb +53 -0
  23. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_mdMetadata.rb +18 -3
  24. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_onlineResource.rb +19 -2
  25. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_source.rb +1 -1
  26. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_onlineResource.rb +26 -20
  27. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_algorithm.rb +31 -0
  28. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_nominalResolution.rb +31 -0
  29. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_onlineResource.rb +6 -3
  30. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processReport.rb +31 -0
  31. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processStep.rb +6 -0
  32. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_processing.rb +37 -0
  33. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_source.rb +7 -2
  34. data/lib/adiwg/mdtranslator_cli.rb +1 -1
  35. metadata +18 -8
@@ -0,0 +1,104 @@
1
+ # unpack processing
2
+ # Reader - ADIwg JSON to internal data structure
3
+
4
+ # History:
5
+ # Stan Smith 2019-09-23 original script
6
+
7
+ require_relative 'module_identifier'
8
+ require_relative 'module_citation'
9
+ require_relative 'module_algorithm'
10
+
11
+ module ADIWG
12
+ module Mdtranslator
13
+ module Readers
14
+ module MdJson
15
+
16
+ module Processing
17
+
18
+ def self.unpack(hProcessing, responseObj, inContext = nil)
19
+
20
+ @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
21
+
22
+ # return nil object if input is empty
23
+ if hProcessing.empty?
24
+ @MessagePath.issueWarning(990, responseObj, inContext)
25
+ return nil
26
+ end
27
+
28
+ # instance classes needed in script
29
+ intMetadataClass = InternalMetadata.new
30
+ intProcessing = intMetadataClass.newProcessing
31
+
32
+ outContext = 'process step report'
33
+ outContext = inContext + ' > ' + outContext unless inContext.nil?
34
+
35
+ # processing - identifier {identifier} (required)
36
+ if hProcessing.has_key?('identifier')
37
+ unless hProcessing['identifier'].empty?
38
+ hReturn = Identifier.unpack(hProcessing['identifier'], responseObj, outContext)
39
+ unless hReturn.nil?
40
+ intProcessing[:identifier] = hReturn
41
+ end
42
+ end
43
+ end
44
+ if intProcessing[:identifier].empty?
45
+ @MessagePath.issueWarning(991, responseObj, inContext)
46
+ end
47
+
48
+ # processing - software reference
49
+ if hProcessing.has_key?('softwareReference')
50
+ aCitation = hProcessing['softwareReference']
51
+ aCitation.each do |item|
52
+ hCitation = Citation.unpack(item, responseObj, outContext)
53
+ unless hCitation.nil?
54
+ intProcessing[:softwareReferences] << hCitation
55
+ end
56
+ end
57
+ end
58
+
59
+ # processing - procedure description
60
+ if hProcessing.has_key?('procedureDescription')
61
+ unless hProcessing['procedureDescription'] == ''
62
+ intProcessing[:procedureDescription] = hProcessing['procedureDescription']
63
+ end
64
+ end
65
+
66
+ # processing - documentation
67
+ if hProcessing.has_key?('documentation')
68
+ aCitation = hProcessing['documentation']
69
+ aCitation.each do |item|
70
+ hCitation = Citation.unpack(item, responseObj, outContext)
71
+ unless hCitation.nil?
72
+ intProcessing[:documentation] << hCitation
73
+ end
74
+ end
75
+ end
76
+
77
+ # processing - runtime parameters
78
+ if hProcessing.has_key?('runtimeParameters')
79
+ unless hProcessing['runtimeParameters'] == ''
80
+ intProcessing[:runtimeParameters] = hProcessing['runtimeParameters']
81
+ end
82
+ end
83
+
84
+ # processing - algorithm
85
+ if hProcessing.has_key?('algorithm')
86
+ aAlgorithm = hProcessing['algorithm']
87
+ aAlgorithm.each do |item|
88
+ hAlgorithm = Algorithm.unpack(item, responseObj, outContext)
89
+ unless hAlgorithm.nil?
90
+ intProcessing[:algorithms] << hAlgorithm
91
+ end
92
+ end
93
+ end
94
+
95
+ return intProcessing
96
+
97
+ end
98
+
99
+ end
100
+
101
+ end
102
+ end
103
+ end
104
+ end
@@ -2,6 +2,7 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
+ # Stan Smith 2019-09-22 add LE_Source elements
5
6
  # Stan Smith 2018-06-25 refactored error and warning messaging
6
7
  # Stan Smith 2016-10-17 refactored for mdJson 2.0
7
8
  # Stan Smith 2015-07-14 refactored to remove global namespace constants
@@ -15,6 +16,8 @@ require_relative 'module_processStep'
15
16
  require_relative 'module_spatialReference'
16
17
  require_relative 'module_scope'
17
18
  require_relative 'module_spatialResolution'
19
+ require_relative 'module_identifier'
20
+ require_relative 'module_nominalResolution'
18
21
 
19
22
  module ADIWG
20
23
  module Mdtranslator
@@ -74,7 +77,7 @@ module ADIWG
74
77
  aCitation.each do |item|
75
78
  hCitation = Citation.unpack(item, responseObj, outContext)
76
79
  unless hCitation.nil?
77
- intSource[:metadataCitation] << hCitation
80
+ intSource[:metadataCitations] << hCitation
78
81
  end
79
82
  end
80
83
  end
@@ -112,7 +115,7 @@ module ADIWG
112
115
  end
113
116
  end
114
117
 
115
- # source - scope {scope}
118
+ # source - scope {scope} (required if)
116
119
  if hSource.has_key?('scope')
117
120
  hObject = hSource['scope']
118
121
  unless hObject.empty?
@@ -124,6 +127,28 @@ module ADIWG
124
127
  end
125
128
  end
126
129
 
130
+ # source - processed level {identifier}
131
+ if hSource.has_key?('processedLevel')
132
+ hObject = hSource['processedLevel']
133
+ unless hObject.empty?
134
+ hReturn = Identifier.unpack(hObject, responseObj, outContext)
135
+ unless hReturn.nil?
136
+ intSource[:processedLevel] = hReturn
137
+ end
138
+ end
139
+ end
140
+
141
+ # source - resolution {nominalResolution}
142
+ if hSource.has_key?('resolution')
143
+ hObject = hSource['resolution']
144
+ unless hObject.empty?
145
+ hReturn = NominalResolution.unpack(hObject, responseObj, outContext)
146
+ unless hReturn.nil?
147
+ intSource[:resolution] = hReturn
148
+ end
149
+ end
150
+ end
151
+
127
152
  unless haveRequired
128
153
  @MessagePath.issueError(771, responseObj, inContext)
129
154
  end
@@ -1,6 +1,9 @@
1
1
  # adiwg mdTranslator
2
2
 
3
3
  # version 2 history
4
+ # 2.16.1 2019-09-19 refactor fgdc reader to output FGDC entityAttribute citation title as dictionary citation title
5
+ # 2.16.1 2019-09-18 add applicationProfile and protocolRequest to onlineResource
6
+ # 2.16.0 2019-09-17 add 19110:2005 dictionary support to 19115-1
4
7
  # 2.15.0 2019-05-15 added ISO 19115-3(1) writer
5
8
  # 2.14.2 2018-11-02 changed keywordType from 'method' to 'methodology' for FGDC reader/writer
6
9
  # 2.14.1 2018-10-31 add fix for empty verticalDatum in fgdc and iso 19115_2 writers
@@ -104,7 +107,7 @@
104
107
  module ADIWG
105
108
  module Mdtranslator
106
109
  # current mdtranslator version
107
- VERSION = "2.15.0"
110
+ VERSION = "2.16.1"
108
111
  end
109
112
  end
110
113
 
@@ -44,6 +44,13 @@ module ADIWG
44
44
  @html.br
45
45
  end
46
46
 
47
+ # online resource - application profile
48
+ unless hOlRes[:olResApplicationProfile].nil?
49
+ @html.em('Application Profile: ')
50
+ @html.text!(hOlRes[:olResApplicationProfile])
51
+ @html.br
52
+ end
53
+
47
54
  # online resource - protocol
48
55
  unless hOlRes[:olResProtocol].nil?
49
56
  @html.em('Protocol: ')
@@ -51,6 +58,13 @@ module ADIWG
51
58
  @html.br
52
59
  end
53
60
 
61
+ # online resource - protocol request
62
+ unless hOlRes[:olResProtocolRequest].nil?
63
+ @html.em('Protocol Request: ')
64
+ @html.text!(hOlRes[:olResProtocolRequest])
65
+ @html.br
66
+ end
67
+
54
68
  end # writeHtml
55
69
  end # Html_OnlineResource
56
70
 
@@ -58,11 +58,11 @@ module ADIWG
58
58
  end
59
59
 
60
60
  # source - metadata citation [] {citation}
61
- unless hSource[:metadataCitation].empty?
61
+ unless hSource[:metadataCitations].empty?
62
62
  @html.details do
63
63
  @html.summary('Metadata Citations', {'class' => 'h5'})
64
64
  @html.section(:class => 'block') do
65
- hSource[:metadataCitation].each do |hCitation|
65
+ hSource[:metadataCitations].each do |hCitation|
66
66
  @html.details do
67
67
  @html.summary(hCitation[:title], {'class' => 'h5'})
68
68
  @html.section(:class => 'block') do
@@ -2,6 +2,7 @@
2
2
  # writer output in XML
3
3
 
4
4
  # History:
5
+ # Stan Smith 2019-09-17 handle namespace setup for dictionary embedded in 19115
5
6
  # Stan Smith 2018-05-03 add variable for changing XSD location
6
7
  # Stan Smith 2018-04-03 refactored error and warning messaging
7
8
  # Stan Smith 2017-01-20 refactored for mdJson/mdTranslator 2.0
@@ -30,14 +31,13 @@ module ADIWG
30
31
  @NameSpace = ADIWG::Mdtranslator::Writers::Iso19110
31
32
  end
32
33
 
33
- def writeXML(intObj)
34
+ def writeXML(hDictionary, embed)
34
35
 
35
36
  # classes used
36
37
  localeClass = PT_Locale.new(@xml, @hResponseObj)
37
38
  rPartyClass = CI_ResponsibleParty.new(@xml, @hResponseObj)
38
39
  featureClass = FC_FeatureType.new(@xml, @hResponseObj)
39
40
 
40
- hDictionary = intObj[:dataDictionaries][0]
41
41
  hCitation = hDictionary[:citation]
42
42
  aEntities = hDictionary[:entities]
43
43
  version = @hResponseObj[:translatorVersion]
@@ -57,19 +57,24 @@ module ADIWG
57
57
  remoteSchema = 'ftp://ftp.ncddc.noaa.gov/pub/Metadata/Online_ISO_Training/Intro_to_ISO/schemas/ISObio/gfc/gfc.xsd'
58
58
 
59
59
  # FC_FeatureCatalogue
60
- @xml.tag!('gfc:FC_FeatureCatalogue',
61
- {'xmlns:gmi' => 'http://www.isotc211.org/2005/gmi',
62
- 'xmlns:gmd' => 'http://www.isotc211.org/2005/gmd',
63
- 'xmlns:gco' => 'http://www.isotc211.org/2005/gco',
64
- 'xmlns:gml' => 'http://www.opengis.net/gml/3.2',
65
- 'xmlns:gsr' => 'http://www.isotc211.org/2005/gsr',
66
- 'xmlns:gss' => 'http://www.isotc211.org/2005/gss',
67
- 'xmlns:gst' => 'http://www.isotc211.org/2005/gst',
68
- 'xmlns:gmx' => 'http://www.isotc211.org/2005/gmx',
69
- 'xmlns:gfc' => 'http://www.isotc211.org/2005/gfc',
70
- 'xmlns:xlink' => 'http://www.w3.org/1999/xlink',
71
- 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
72
- 'xsi:schemaLocation' => "http://www.isotc211.org/2005/gfc #{remoteSchema}"}) do
60
+ if embed
61
+ attributes = {}
62
+ else
63
+ attributes = {'xmlns:gmi' => 'http://www.isotc211.org/2005/gmi',
64
+ 'xmlns:gmd' => 'http://www.isotc211.org/2005/gmd',
65
+ 'xmlns:gco' => 'http://www.isotc211.org/2005/gco',
66
+ 'xmlns:gml' => 'http://www.opengis.net/gml/3.2',
67
+ 'xmlns:gsr' => 'http://www.isotc211.org/2005/gsr',
68
+ 'xmlns:gss' => 'http://www.isotc211.org/2005/gss',
69
+ 'xmlns:gst' => 'http://www.isotc211.org/2005/gst',
70
+ 'xmlns:gmx' => 'http://www.isotc211.org/2005/gmx',
71
+ 'xmlns:gfc' => 'http://www.isotc211.org/2005/gfc',
72
+ 'xmlns:xlink' => 'http://www.w3.org/1999/xlink',
73
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
74
+ 'xsi:schemaLocation' => "http://www.isotc211.org/2005/gfc #{remoteSchema}"}
75
+ end
76
+
77
+ @xml.tag!('gfc:FC_FeatureCatalogue', attributes) do
73
78
 
74
79
  # feature catalogue - name, version, version date are
75
80
  # are taken from citation
@@ -21,7 +21,7 @@ module ADIWG
21
21
  module Writers
22
22
  module Iso19110
23
23
 
24
- def self.startWriter(intObj, hResponseObj, whichDict = 0)
24
+ def self.startWriter(intObj, hResponseObj, whichDict = 0, embed = false)
25
25
 
26
26
  # load error message array
27
27
  file = File.join(File.dirname(__FILE__), 'iso19110_writer_messages_eng') + '.yml'
@@ -41,8 +41,8 @@ module ADIWG
41
41
  issueNotice(111)
42
42
  end
43
43
 
44
- dictionary = intObj[:dataDictionaries][whichDict]
45
- @domains = dictionary[:domains]
44
+ hDictionary = intObj[:dataDictionaries][whichDict]
45
+ @domains = hDictionary[:domains]
46
46
 
47
47
  # set the format of the output file based on the writer specified
48
48
  hResponseObj[:writerOutputFormat] = 'xml'
@@ -53,7 +53,7 @@ module ADIWG
53
53
 
54
54
  # start writing the ISO 19110 XML record
55
55
  metadataWriter = FC_FeatureCatalogue.new(@xml, hResponseObj)
56
- metadata = metadataWriter.writeXML(intObj)
56
+ metadata = metadataWriter.writeXML(hDictionary, embed)
57
57
 
58
58
  return metadata
59
59
 
@@ -0,0 +1,53 @@
1
+ # ISO <<abstract class>> MD_FeatureCatalogue
2
+ # 19115-1 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-08-20 original script.
6
+
7
+ require_relative '../../iso19110/iso19110_writer'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Writers
12
+ module Iso19115_1
13
+
14
+ class MD_FeatureCatalogue
15
+
16
+ def initialize(xml, hResponseObj)
17
+ @xml = xml
18
+ @hResponseObj = hResponseObj
19
+ @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_1
20
+ end
21
+
22
+ def writeXML(intObj,whichDict)
23
+
24
+ # set up iso19110 writer namespace
25
+ nameSpace19110 = ADIWG::Mdtranslator::Writers::Iso19110
26
+
27
+ # write 19110 record
28
+ fcCatalogClass = nameSpace19110.startWriter(intObj, @hResponseObj, whichDict, true)
29
+
30
+ # strip first line
31
+ first_line = fcCatalogClass.index("\n")
32
+ fcCatalogClass.slice!(0, first_line + 1)
33
+
34
+ outContext = 'feature catalog'
35
+
36
+ unless fcCatalogClass.empty?
37
+ @xml.tag!('mrc:MD_FeatureCatalogue') do
38
+ @xml.tag!('mrc:featureCatalogue') do
39
+
40
+ # data dictionary
41
+ @xml << fcCatalogClass
42
+
43
+ end
44
+ end
45
+ end
46
+
47
+ end # writeXML
48
+ end # MD_FeatureCatalogue class
49
+
50
+ end
51
+ end
52
+ end
53
+ end
@@ -3,6 +3,7 @@
3
3
 
4
4
  # History:
5
5
  # Stan Smith 2019-03-12 original script
6
+ # Stan Smith 2019-08-22 add support for data dictionary (feature catalogue)
6
7
 
7
8
  require 'uuidtools'
8
9
  require 'adiwg/mdtranslator/internal/internal_metadata_obj'
@@ -23,6 +24,7 @@ require_relative 'class_dataIdentification'
23
24
  require_relative 'class_maintenance'
24
25
  require_relative 'class_spatialRepresentation'
25
26
  require_relative 'class_referenceSystem'
27
+ require_relative 'class_featureCatalog'
26
28
 
27
29
  module ADIWG
28
30
  module Mdtranslator
@@ -57,6 +59,7 @@ module ADIWG
57
59
  maintenanceClass = MD_MaintenanceInformation.new(@xml, @hResponseObj)
58
60
  representationClass = SpatialRepresentation.new(@xml, @hResponseObj)
59
61
  referenceSystemClass = MD_ReferenceSystem.new(@xml, @hResponseObj)
62
+ mdCatalogClass = MD_FeatureCatalogue.new(@xml, @hResponseObj)
60
63
 
61
64
  # create shortcuts to sections of internal object
62
65
  hMetadata = intObj[:metadata]
@@ -64,6 +67,7 @@ module ADIWG
64
67
  hResInfo = hMetadata[:resourceInfo]
65
68
  aDistributions = hMetadata[:distributorInfo]
66
69
  aLineage = hMetadata[:lineageInfo]
70
+ aDictionaries = intObj[:dataDictionaries]
67
71
  version = @hResponseObj[:translatorVersion]
68
72
 
69
73
  # document head
@@ -116,6 +120,8 @@ module ADIWG
116
120
 
117
121
  'xmlns:fcc' => 'http://standards.iso.org/iso/19110/fcc/1.0',
118
122
  'xmlns:gfc' => 'http://standards.iso.org/iso/19110/gfc/1.1',
123
+ 'xmlns:gmd' => 'http://www.isotc211.org/2005/gmd',
124
+ 'xmlns:gmx' => 'http://www.isotc211.org/2005/gmx',
119
125
 
120
126
  'xsi:schemaLocation' => "http://standards.iso.org/iso/19115/-3/mdt/2.0 #{remoteSchema}"
121
127
  }) do
@@ -296,8 +302,7 @@ module ADIWG
296
302
 
297
303
  # ###################### End Data Identification #######################
298
304
 
299
- # metadata information - content information []
300
- # FC_FeatureCatalogue not implemented
305
+ # metadata information - content information [] {coverage and image description}
301
306
  aCoverages = hResInfo[:coverageDescriptions]
302
307
  aCoverages.each do |hCoverage|
303
308
  unless hCoverage.empty?
@@ -311,7 +316,17 @@ module ADIWG
311
316
  end
312
317
  end
313
318
  end
314
- if aCoverages.empty? && @hResponseObj[:writerShowTags]
319
+
320
+ # metadata information - content information [] {data dictionary}
321
+ aDictionaries.each_with_index do |hDictionary, index|
322
+ unless hDictionary.empty?
323
+ @xml.tag!('mdb:contentInfo') do
324
+ mdCatalogClass.writeXML(intObj, index)
325
+ end
326
+ end
327
+ end
328
+
329
+ if aCoverages.empty? && aDictionaries.empty? && @hResponseObj[:writerShowTags]
315
330
  @xml.tag!('mdb:contentInfo')
316
331
  end
317
332
 
@@ -2,6 +2,7 @@
2
2
  # 19115-1 writer output in XML
3
3
 
4
4
  # History:
5
+ # Stan Smith 2019-09-18 add protocolRequest and applicationProfile
5
6
  # Stan Smith 2019-03-14 original script.
6
7
 
7
8
  require_relative '../iso19115_1_writer'
@@ -47,7 +48,15 @@ module ADIWG
47
48
  @xml.tag!('cit:protocol')
48
49
  end
49
50
 
50
- # online resource - application profile - not implemented
51
+ # online resource - application profile
52
+ unless hOlResource[:olResApplicationProfile].nil?
53
+ @xml.tag!('cit:applicationProfile') do
54
+ @xml.tag!('gco:CharacterString', hOlResource[:olResApplicationProfile])
55
+ end
56
+ end
57
+ if hOlResource[:olResApplicationProfile].nil? && @hResponseObj[:writerShowTags]
58
+ @xml.tag!('cit:applicationProfile')
59
+ end
51
60
 
52
61
  # online resource - link name
53
62
  unless hOlResource[:olResName].nil?
@@ -79,7 +88,15 @@ module ADIWG
79
88
  @xml.tag!('cit:function')
80
89
  end
81
90
 
82
- # online resource - protocol request - not implemented
91
+ # online resource - protocol request
92
+ unless hOlResource[:olResProtocolRequest].nil?
93
+ @xml.tag!('cit:protocolRequest') do
94
+ @xml.tag!('gco:CharacterString', hOlResource[:olResProtocolRequest])
95
+ end
96
+ end
97
+ if hOlResource[:olResProtocolRequest].nil? && @hResponseObj[:writerShowTags]
98
+ @xml.tag!('cit:protocolRequest')
99
+ end
83
100
 
84
101
  end # CI_OnlineResource tag
85
102
  end # write XML