adiwg-mdtranslator 2.14.2 → 2.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -1
  3. data/CHANGELOG.md +20 -5
  4. data/Rakefile +2 -0
  5. data/adiwg-mdtranslator.gemspec +2 -1
  6. data/lib/adiwg/mdtranslator.rb +1 -0
  7. data/lib/adiwg/mdtranslator/internal/module_codelistFun.rb +26 -0
  8. data/lib/adiwg/mdtranslator/internal/module_coordinates.rb +3 -0
  9. data/lib/adiwg/mdtranslator/internal/module_dateTimeFun.rb +1 -1
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_date.rb +0 -1
  11. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dateTime.rb +0 -1
  12. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_keyword.rb +1 -1
  13. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonSystem.rb +2 -4
  14. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_contact.rb +0 -1
  15. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_date.rb +0 -2
  16. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dateTime.rb +0 -2
  17. data/lib/adiwg/mdtranslator/readers/sbJson/modules/module_provenance.rb +0 -1
  18. data/lib/adiwg/mdtranslator/version.rb +3 -2
  19. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_attribute.rb +0 -1
  20. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_citation.rb +0 -1
  21. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateRange.rb +0 -1
  22. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_dateSingle.rb +0 -1
  23. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_method.rb +1 -1
  24. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_methodKeywords.rb +1 -1
  25. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_process.rb +0 -1
  26. data/lib/adiwg/mdtranslator/writers/fgdc/classes/class_transferInfo.rb +0 -1
  27. data/lib/adiwg/mdtranslator/writers/html/sections/html_taxonomy.rb +1 -3
  28. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_additionalDocument.rb +48 -0
  29. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_address.rb +90 -0
  30. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_associatedResource.rb +84 -0
  31. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_attribute.rb +107 -0
  32. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_attributeGroup.rb +69 -0
  33. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_baseUnit.rb +38 -0
  34. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_boundingBox.rb +70 -0
  35. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_browseGraphic.rb +95 -0
  36. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_citation.rb +205 -0
  37. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_codelist.rb +50 -0
  38. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_constraint.rb +51 -0
  39. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_constraintCommon.rb +104 -0
  40. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_contact.rb +119 -0
  41. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_conventionalUnit.rb +64 -0
  42. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_coverageDescription.rb +84 -0
  43. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_dataIdentification.rb +347 -0
  44. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_date.rb +62 -0
  45. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_definitionUnit.rb +35 -0
  46. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_derivedUnit.rb +42 -0
  47. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_dimension.rb +72 -0
  48. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_distribution.rb +62 -0
  49. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_distributor.rb +77 -0
  50. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_email.rb +44 -0
  51. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_extent.rb +85 -0
  52. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_feature.rb +71 -0
  53. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_featureCollection.rb +56 -0
  54. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_featureProperties.rb +64 -0
  55. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_format.rb +74 -0
  56. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_fraction.rb +46 -0
  57. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_gcoDateTime.rb +45 -0
  58. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_geographicElement.rb +77 -0
  59. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_geographicExtent.rb +96 -0
  60. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_geometricObjects.rb +60 -0
  61. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_geometryCollection.rb +97 -0
  62. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_georectified.rb +121 -0
  63. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_georeferenceable.rb +87 -0
  64. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_gmlIdentifier.rb +32 -0
  65. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_grid.rb +71 -0
  66. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_gridRepresentation.rb +36 -0
  67. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_identifier.rb +95 -0
  68. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_imageDescription.rb +175 -0
  69. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_individual.rb +85 -0
  70. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_keyword.rb +78 -0
  71. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_legalConstraints.rb +87 -0
  72. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_lineString.rb +76 -0
  73. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_lineage.rb +97 -0
  74. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_locale.rb +67 -0
  75. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_maintenance.rb +101 -0
  76. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_mdBand.rb +82 -0
  77. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_mdMetadata.rb +372 -0
  78. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_measure.rb +71 -0
  79. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_medium.rb +113 -0
  80. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_miBand.rb +90 -0
  81. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_multiLine.rb +84 -0
  82. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_multiPoint.rb +84 -0
  83. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_multiPolygon.rb +84 -0
  84. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_onlineResource.rb +91 -0
  85. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_orderProcess.rb +79 -0
  86. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_organization.rb +106 -0
  87. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_phone.rb +81 -0
  88. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_point.rb +77 -0
  89. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_polygon.rb +95 -0
  90. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_processStep.rb +130 -0
  91. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_rangeDimension.rb +94 -0
  92. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_referenceSystem.rb +92 -0
  93. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_releasability.rb +71 -0
  94. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_resolution.rb +97 -0
  95. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_responsibility.rb +91 -0
  96. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_sampleDimension.rb +127 -0
  97. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_scope.rb +75 -0
  98. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_scopeDescription.rb +75 -0
  99. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_securityConstraints.rb +97 -0
  100. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_series.rb +63 -0
  101. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_source.rb +125 -0
  102. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_spatialRepresentation.rb +61 -0
  103. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_temporalExtent.rb +53 -0
  104. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_timeInstant.rb +80 -0
  105. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_timePeriod.rb +113 -0
  106. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_transferOptions.rb +107 -0
  107. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_unitsOfMeasure.rb +258 -0
  108. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_usage.rb +134 -0
  109. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_useConstraints.rb +41 -0
  110. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_vectorRepresentation.rb +61 -0
  111. data/lib/adiwg/mdtranslator/writers/iso19115_1/classes/class_verticalExtent.rb +70 -0
  112. data/lib/adiwg/mdtranslator/writers/iso19115_1/iso19115_1_writer.rb +105 -0
  113. data/lib/adiwg/mdtranslator/writers/iso19115_1/iso19115_1_writer_messages_eng.yml +132 -0
  114. data/lib/adiwg/mdtranslator/writers/iso19115_1/readme.md +12 -0
  115. data/lib/adiwg/mdtranslator/writers/iso19115_1/version.rb +15 -0
  116. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_citation.rb +3 -2
  117. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataIdentification.rb +42 -39
  118. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_dataQuality.rb +2 -2
  119. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_distributor.rb +3 -1
  120. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_extension.rb +12 -7
  121. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_miMetadata.rb +2 -3
  122. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_referenceSystem.rb +1 -1
  123. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_resolution.rb +1 -1
  124. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_responsibleParty.rb +42 -35
  125. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_spatialRepresentation.rb +4 -10
  126. data/lib/adiwg/mdtranslator/writers/iso19115_2/classes/class_useConstraints.rb +1 -1
  127. data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer_messages_eng.yml +5 -0
  128. data/lib/adiwg/mdtranslator/writers/iso19115_2/readme.md +2 -2
  129. data/lib/adiwg/mdtranslator/writers/iso19115_2/version.rb +1 -1
  130. data/lib/adiwg/mdtranslator/writers/mdWriters.rb +7 -7
  131. data/lib/adiwg/mdtranslator/writers/sbJson/sections/sbJson_citation.rb +0 -1
  132. data/lib/adiwg/mdtranslator_cli.rb +2 -1
  133. metadata +93 -5
  134. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_gmlIdentifier.rb +0 -55
@@ -0,0 +1,372 @@
1
+ # ISO 19115-1 <<Class>> MD_Metadata
2
+ # 19115-1 writer output in XML.
3
+
4
+ # History:
5
+ # Stan Smith 2019-03-12 original script
6
+
7
+ require 'uuidtools'
8
+ require 'adiwg/mdtranslator/internal/internal_metadata_obj'
9
+ require_relative '../iso19115_1_writer'
10
+ require_relative 'class_codelist'
11
+ require_relative 'class_identifier'
12
+ require_relative 'class_citation'
13
+ require_relative 'class_responsibility'
14
+ require_relative 'class_date'
15
+ require_relative 'class_locale'
16
+ require_relative 'class_onlineResource'
17
+ require_relative 'class_coverageDescription'
18
+ require_relative 'class_imageDescription'
19
+ require_relative 'class_distribution'
20
+ require_relative 'class_lineage'
21
+ require_relative 'class_constraint'
22
+ require_relative 'class_dataIdentification'
23
+ require_relative 'class_maintenance'
24
+ require_relative 'class_spatialRepresentation'
25
+ require_relative 'class_referenceSystem'
26
+
27
+ module ADIWG
28
+ module Mdtranslator
29
+ module Writers
30
+ module Iso19115_1
31
+
32
+ class MD_Metadata
33
+
34
+ def initialize(xml, hResponseObj)
35
+ @xml = xml
36
+ @hResponseObj = hResponseObj
37
+ @NameSpace = ADIWG::Mdtranslator::Writers::Iso19115_1
38
+ end
39
+
40
+ def writeXML(intObj)
41
+
42
+ # classes used
43
+ intMetadataClass = InternalMetadata.new
44
+ codelistClass = MD_Codelist.new(@xml, @hResponseObj)
45
+ identifierClass = MD_Identifier.new(@xml, @hResponseObj)
46
+ citationClass = CI_Citation.new(@xml, @hResponseObj)
47
+ responsibilityClass = CI_Responsibility.new(@xml, @hResponseObj)
48
+ dateClass = CI_Date.new(@xml, @hResponseObj)
49
+ localeClass = PT_Locale.new(@xml, @hResponseObj)
50
+ onlineClass = CI_OnlineResource.new(@xml, @hResponseObj)
51
+ dataIdClass = MD_DataIdentification.new(@xml, @hResponseObj)
52
+ coverageClass = MD_CoverageDescription.new(@xml, @hResponseObj)
53
+ imageClass = MD_ImageDescription.new(@xml, @hResponseObj)
54
+ distributionClass = MD_Distribution.new(@xml, @hResponseObj)
55
+ lineageClass = LI_Lineage.new(@xml, @hResponseObj)
56
+ constraintClass = Constraint.new(@xml, @hResponseObj)
57
+ maintenanceClass = MD_MaintenanceInformation.new(@xml, @hResponseObj)
58
+ representationClass = SpatialRepresentation.new(@xml, @hResponseObj)
59
+ referenceSystemClass = MD_ReferenceSystem.new(@xml, @hResponseObj)
60
+
61
+ # create shortcuts to sections of internal object
62
+ hMetadata = intObj[:metadata]
63
+ hMetaInfo = hMetadata[:metadataInfo]
64
+ hResInfo = hMetadata[:resourceInfo]
65
+ aDistributions = hMetadata[:distributorInfo]
66
+ aLineage = hMetadata[:lineageInfo]
67
+ version = @hResponseObj[:translatorVersion]
68
+
69
+ # document head
70
+ metadata = @xml.instruct! :xml, encoding: 'UTF-8'
71
+ @xml.comment!('ISO 19115-1 METADATA')
72
+ @xml.comment!('The following metadata file was constructed using the ADIwg mdTranslator, http://mdtranslator.adiwg.org')
73
+ @xml.comment!('mdTranslator software is an open-source project of the Alaska Data Integration working group (ADIwg)')
74
+ @xml.comment!('mdTranslator and other metadata tools are available at https://github.com/adiwg')
75
+ @xml.comment!('ADIwg is not responsible for the content of this metadata record')
76
+ @xml.comment!('This metadata record was generated by mdTranslator ' + version + ' at ' + Time.now.to_s)
77
+
78
+ # schema locations
79
+ # set to 'remoteSchema' before publishing
80
+ localSchema = 'C:\Users\StanSmith\Projects\ISO\19115\-3\mdt\1.0\mdt.xsd'
81
+ remoteSchema = 'http://standards.iso.org/iso/19115/-3/mdt/2.0/mdt.xsd'
82
+
83
+ # MD_Metadata
84
+ @xml.tag!('mdb:MD_Metadata',
85
+ {
86
+ 'xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
87
+ 'xmlns:xlink' => 'http://www.w3.org/1999/xlink',
88
+ 'xmlns:gml' => 'http://www.opengis.net/gml/3.2',
89
+
90
+ 'xmlns:cat' => 'http://standards.iso.org/iso/19115/-3/cat/1.0',
91
+ 'xmlns:gco' => 'http://standards.iso.org/iso/19115/-3/gco/1.0',
92
+ 'xmlns:gcx' => 'http://standards.iso.org/iso/19115/-3/gcx/1.0',
93
+ 'xmlns:gex' => 'http://standards.iso.org/iso/19115/-3/gex/1.0',
94
+ 'xmlns:lan' => 'http://standards.iso.org/iso/19115/-3/lan/1.0',
95
+ 'xmlns:mas' => 'http://standards.iso.org/iso/19115/-3/mas/1.0',
96
+ 'xmlns:mcc' => 'http://standards.iso.org/iso/19115/-3/mcc/1.0',
97
+ 'xmlns:mco' => 'http://standards.iso.org/iso/19115/-3/mco/1.0',
98
+ 'xmlns:mda' => 'http://standards.iso.org/iso/19115/-3/mda/1.0',
99
+ 'xmlns:mdq' => 'http://standards.iso.org/iso/19157/-2/mdq/1.0',
100
+ 'xmlns:mex' => 'http://standards.iso.org/iso/19157/-2/mex/1.0',
101
+ 'xmlns:mmi' => 'http://standards.iso.org/iso/19115/-3/mmi/1.0',
102
+ 'xmlns:mpc' => 'http://standards.iso.org/iso/19115/-3/mpc/1.0',
103
+ 'xmlns:mrd' => 'http://standards.iso.org/iso/19115/-3/mrd/1.0',
104
+ 'xmlns:mri' => 'http://standards.iso.org/iso/19115/-3/mri/1.0',
105
+ 'xmlns:mrs' => 'http://standards.iso.org/iso/19115/-3/mrs/1.0',
106
+
107
+ 'xmlns:cit' => 'http://standards.iso.org/iso/19115/-3/cit/2.0',
108
+ 'xmlns:mac' => 'http://standards.iso.org/iso/19115/-3/mac/2.0',
109
+ 'xmlns:mdb' => 'http://standards.iso.org/iso/19115/-3/mdb/2.0',
110
+ 'xmlns:mds' => 'http://standards.iso.org/iso/19115/-3/mds/2.0',
111
+ 'xmlns:mdt' => 'http://standards.iso.org/iso/19115/-3/mdt/2.0',
112
+ 'xmlns:mrl' => 'http://standards.iso.org/iso/19115/-3/mrl/2.0',
113
+ 'xmlns:mrc' => 'http://standards.iso.org/iso/19115/-3/mrc/2.0',
114
+ 'xmlns:msr' => 'http://standards.iso.org/iso/19115/-3/msr/2.0',
115
+ 'xmlns:srv' => 'http://standards.iso.org/iso/19115/-3/srv/2.0',
116
+
117
+ 'xmlns:fcc' => 'http://standards.iso.org/iso/19110/fcc/1.0',
118
+ 'xmlns:gfc' => 'http://standards.iso.org/iso/19110/gfc/1.1',
119
+
120
+ 'xsi:schemaLocation' => "http://standards.iso.org/iso/19115/-3/mdt/2.0 #{remoteSchema}"
121
+ }) do
122
+
123
+ # metadata information - metadata identifier {MD_Identifier} (default: UUID)
124
+ hMetadataId = hMetaInfo[:metadataIdentifier]
125
+ if hMetadataId.empty?
126
+ hMetadataId = intMetadataClass.newIdentifier
127
+ hMetadataId[:identifier] = UUIDTools::UUID.random_create.to_s
128
+ hMetadataId[:namespace] = 'UUID'
129
+ end
130
+ @xml.tag!('mdb:metadataIdentifier') do
131
+ identifierClass.writeXML(hMetadataId, 'metadata identifier')
132
+ end
133
+
134
+ # metadata information - default locale {PT_Locale} (default: USA, English, UTF-8)
135
+ hDefLocale = hMetaInfo[:defaultMetadataLocale]
136
+ if hDefLocale.empty?
137
+ hDefLocale = intMetadataClass.newLocale
138
+ hDefLocale[:languageCode] = 'eng'
139
+ hDefLocale[:countryCode] = 'USA'
140
+ hDefLocale[:characterEncoding] = 'UTF-8'
141
+ end
142
+ @xml.tag!('mdb:defaultLocale') do
143
+ localeClass.writeXML(hDefLocale, 'metadata default locale')
144
+ end
145
+
146
+ # metadata information - parent metadata {CI_Citation}
147
+ unless hMetaInfo[:parentMetadata].empty?
148
+ @xml.tag!('mdb:parentMetadata') do
149
+ citationClass.writeXML(hMetaInfo[:parentMetadata], 'metadata information')
150
+ end
151
+ end
152
+ if hMetaInfo[:parentMetadata].empty? && @hResponseObj[:writerShowTags]
153
+ @xml.tag!('mdb:parentMetadata')
154
+ end
155
+
156
+ # metadata information - metadata scope [] {MD_MetadataScope}
157
+ aScope = hResInfo[:resourceTypes]
158
+ aScope.each do |hScope|
159
+ unless hScope[:type].nil?
160
+ @xml.tag!('mdb:metadataScope') do
161
+ @xml.tag!('mdb:MD_MetadataScope') do
162
+ @xml.tag!('mdb:resourceScope') do
163
+ codelistClass.writeXML('mcc', 'iso_scope', hScope[:type])
164
+ end
165
+ end
166
+ end
167
+ end
168
+ if hScope[:type].nil?
169
+ @NameSpace.issueWarning(390, 'mdb:metadataScope', 'resource information')
170
+ end
171
+ end
172
+ if aScope.empty? && @hResponseObj[:writerShowTags]
173
+ @xml.tag!('mdb:metadataScope')
174
+ end
175
+
176
+ # metadata information - contact [] {CI_ResponsibleParty} (required)
177
+ aContacts = hMetaInfo[:metadataContacts]
178
+ aContacts.each do |hContact|
179
+ unless hContact.empty?
180
+ @xml.tag!('mdb:contact') do
181
+ responsibilityClass.writeXML(hContact, 'metadata information')
182
+ end
183
+ end
184
+ end
185
+ if aContacts.empty?
186
+ @NameSpace.issueWarning(240, 'mdb:contact', 'metadata information')
187
+ end
188
+
189
+ # metadata information - date info [] {CI_Date} (required)
190
+ # 'creation' date is required - default: now()
191
+ aDates = hMetaInfo[:metadataDates]
192
+ haveCreation = false
193
+ aDates.each do |hDate|
194
+ if hDate[:dateType] == 'creation'
195
+ haveCreation = true
196
+ end
197
+ end
198
+ unless haveCreation
199
+ hCreateDate = {}
200
+ hCreateDate[:date] = DateTime.now
201
+ hCreateDate[:dateResolution] = 'YMD'
202
+ aDates.insert(0, hCreateDate)
203
+ end
204
+ aDates.each do |hDate|
205
+ @xml.tag!('mdb:dateInfo') do
206
+ dateClass.writeXML(hDate, 'metadata information')
207
+ end
208
+ end
209
+
210
+ # metadata information - metadata standard [] {CI_Citation} (auto fill)
211
+ hStandard = intMetadataClass.newCitation
212
+ hStandard[:title] = 'ISO 19115-3'
213
+ @xml.tag!('mdb:metadataStandard') do
214
+ citationClass.writeXML(hStandard, 'metadata standard')
215
+ end
216
+
217
+ # metadata information - metadata profile [] {CI_Citation} (auto fill)
218
+ hProfile = intMetadataClass.newCitation
219
+ hProfile[:title] = 'ISO 19115-1:2014-04-01'
220
+ @xml.tag!('mdb:metadataStandard') do
221
+ citationClass.writeXML(hProfile, 'metadata profile')
222
+ end
223
+
224
+ # metadata information - alternate metadata reference [] {CI_Citation}
225
+ aAlternates = hMetaInfo[:alternateMetadataReferences]
226
+ aAlternates.each do |hAlternate|
227
+ @xml.tag!('mdb:alternativeMetadataReference') do
228
+ citationClass.writeXML(hAlternate, 'metadata alternate')
229
+ end
230
+ end
231
+ if aAlternates.empty? && @hResponseObj[:writerShowTags]
232
+ @xml.tag!('mdb:alternativeMetadataReference')
233
+ end
234
+
235
+ # metadata information - other locale [] {PT_Locale}
236
+ aLocales = hMetaInfo[:otherMetadataLocales]
237
+ aLocales.each do |hLocale|
238
+ @xml.tag!('mdb:otherLocale') do
239
+ localeClass.writeXML(hLocale, 'other metadata locale')
240
+ end
241
+ end
242
+ if aLocales.empty? && @hResponseObj[:writerShowTags]
243
+ @xml.tag!('mdb:otherLocale')
244
+ end
245
+
246
+ # metadata information - metadata linkage [] {CI_OnlineResource}
247
+ aLinks = hMetaInfo[:metadataLinkages]
248
+ aLinks.each do |hLink|
249
+ @xml.tag!('mdb:metadataLinkage') do
250
+ onlineClass.writeXML(hLink, 'metadata online resource')
251
+ end
252
+ end
253
+ if aLinks.empty? && @hResponseObj[:writerShowTags]
254
+ @xml.tag!('mdb:metadataLinkage')
255
+ end
256
+
257
+ # metadata information - spatial representation []
258
+ # {MD_GridSpatialRepresentation | MD_VectorSpatialRepresentation}
259
+ # {MD_Georeferenceable | MD_Georectified }
260
+ aRepresentations = hResInfo[:spatialRepresentations]
261
+ aRepresentations.each do |hRepresentation|
262
+ unless hRepresentation.empty?
263
+ @xml.tag!('mdb:spatialRepresentationInfo') do
264
+ representationClass.writeXML(hRepresentation, 'resource spatial representation')
265
+ end
266
+ end
267
+ end
268
+ if aRepresentations.empty? && @hResponseObj[:writerShowTags]
269
+ @xml.tag!('mdb:spatialRepresentationInfo')
270
+ end
271
+
272
+ # metadata information - reference system info [] {MD_ReferenceSystem}
273
+ aReferenceSystems = hResInfo[:spatialReferenceSystems]
274
+ aReferenceSystems.each do |hSystem|
275
+ unless hSystem.empty?
276
+ @xml.tag!('mdb:referenceSystemInfo') do
277
+ referenceSystemClass.writeXML(hSystem, 'resource spatial reference system')
278
+ end
279
+ end
280
+ end
281
+ if aReferenceSystems.empty? && @hResponseObj[:writerShowTags]
282
+ @xml.tag!('mdb:referenceSystemInfo')
283
+ end
284
+
285
+ # ###################### Begin Data Identification #####################
286
+
287
+ # metadata information - data identification info - required
288
+ unless hResInfo.empty?
289
+ @xml.tag!('mdb:identificationInfo') do
290
+ dataIdClass.writeXML(hMetadata)
291
+ end
292
+ end
293
+ if hResInfo.empty?
294
+ @NameSpace.issueWarning(241, 'mdb:identificationInfo')
295
+ end
296
+
297
+ # ###################### End Data Identification #######################
298
+
299
+ # metadata information - content information []
300
+ # FC_FeatureCatalogue not implemented
301
+ aCoverages = hResInfo[:coverageDescriptions]
302
+ aCoverages.each do |hCoverage|
303
+ unless hCoverage.empty?
304
+ @xml.tag!('mdb:contentInfo') do
305
+ haveImage = !hCoverage[:imageDescription].empty?
306
+ if haveImage
307
+ imageClass.writeXML(hCoverage)
308
+ else
309
+ coverageClass.writeXML(hCoverage)
310
+ end
311
+ end
312
+ end
313
+ end
314
+ if aCoverages.empty? && @hResponseObj[:writerShowTags]
315
+ @xml.tag!('mdb:contentInfo')
316
+ end
317
+
318
+ # metadata information - distribution info [] {MD_Distribution}
319
+ aDistributions.each do |hDistribution|
320
+ unless hDistribution.empty?
321
+ @xml.tag!('mdb:distributionInfo') do
322
+ distributionClass.writeXML(hDistribution)
323
+ end
324
+ end
325
+ end
326
+ if aDistributions.empty? && @hResponseObj[:writerShowTags]
327
+ @xml.tag!('mdb:distributionInfo')
328
+ end
329
+
330
+ # metadata information - resource lineage [] {LI_Lineage}
331
+ aLineage.each do |hLineage|
332
+ @xml.tag!('mdb:resourceLineage') do
333
+ lineageClass.writeXML(hLineage)
334
+ end
335
+ end
336
+ if aLineage.empty? && @hResponseObj[:writerShowTags]
337
+ @xml.tag!('mdb:resourceLineage')
338
+ end
339
+
340
+ # metadata information - metadata constraints {}
341
+ aConstraint = hMetaInfo[:metadataConstraints]
342
+ aConstraint.each do |hCon|
343
+ @xml.tag!('mdb:metadataConstraints') do
344
+ constraintClass.writeXML(hCon, 'metadata information')
345
+ end
346
+ end
347
+ if aConstraint.empty? && @hResponseObj[:writerShowTags]
348
+ @xml.tag!('mdb:metadataConstraints')
349
+ end
350
+
351
+ # metadata information - metadata maintenance
352
+ hMaintenance = hMetaInfo[:metadataMaintenance]
353
+ unless hMaintenance.empty?
354
+ @xml.tag!('mdb:metadataMaintenance') do
355
+ maintenanceClass.writeXML(hMaintenance, 'metadata maintenance')
356
+ end
357
+ end
358
+ if hMaintenance.empty? && @hResponseObj[:writerShowTags]
359
+ @xml.tag!('mdb:metadataMaintenance')
360
+ end
361
+
362
+ end # mdb:MD_Metadata tag
363
+
364
+ return metadata
365
+
366
+ end # writeXML
367
+ end # MI_Metadata class
368
+
369
+ end
370
+ end
371
+ end
372
+ end
@@ -0,0 +1,71 @@
1
+ # ISO <<Class>> Measure
2
+ # 19115-1 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-03-21 original script.
6
+
7
+ require_relative '../iso19115_1_writer'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Writers
12
+ module Iso19115_1
13
+
14
+ class Measure
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(hMeasure, inContext = nil)
23
+
24
+ outContext = 'measure'
25
+ outContext = inContext + ' measure' unless inContext.nil?
26
+
27
+ # measure
28
+ type = hMeasure[:type]
29
+ value = hMeasure[:value]
30
+ uom = hMeasure[:unitOfMeasure]
31
+
32
+ # ISO 19115-2 will not accept spaces in uom
33
+ uom.gsub!(/\s+/, '')
34
+
35
+ haveType = false
36
+ if type == 'distance'
37
+ @xml.tag!('gco:Distance', {'uom' => uom}, value)
38
+ haveType = true
39
+ end
40
+ if type == 'vertical'
41
+ @xml.tag!('gco:Distance', {'uom' => uom}, value)
42
+ haveType = true
43
+ end
44
+ if type == 'length'
45
+ @xml.tag!('gco:Length', {'uom' => uom}, value)
46
+ haveType = true
47
+ end
48
+ if type == 'angle'
49
+ @xml.tag!('gco:Angle', {'uom' => uom}, value)
50
+ haveType = true
51
+ end
52
+ if type == 'measure'
53
+ @xml.tag!('gco:Measure', {'uom' => uom}, value)
54
+ haveType = true
55
+ end
56
+ if type == 'scale'
57
+ @xml.tag!('gco:Scale', {'uom' => uom}, value)
58
+ haveType = true
59
+ end
60
+
61
+ unless haveType
62
+ @NameSpace.issueWarning(360, nil, outContext)
63
+ end
64
+
65
+ end # write XML
66
+ end # CI_Telephone class
67
+
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,113 @@
1
+ # ISO <<Class>> MD_Medium
2
+ # 19115-1 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-04-10 original script.
6
+
7
+ require_relative 'class_citation'
8
+ require_relative 'class_identifier'
9
+ require_relative 'class_codelist'
10
+
11
+ module ADIWG
12
+ module Mdtranslator
13
+ module Writers
14
+ module Iso19115_1
15
+
16
+ class MD_Medium
17
+
18
+ def initialize(xml, hResponseObj)
19
+ @xml = xml
20
+ @hResponseObj = hResponseObj
21
+ end
22
+
23
+ def writeXML(hMedium, inContext = nil)
24
+
25
+ # classes used
26
+ codelistClass = MD_Codelist.new(@xml, @hResponseObj)
27
+ citationClass = CI_Citation.new(@xml, @hResponseObj)
28
+ identifierClass = MD_Identifier.new(@xml, @hResponseObj)
29
+
30
+ outContext = 'medium'
31
+ outContext = inContext + ' medium' unless inContext.nil?
32
+
33
+ @xml.tag!('mrd:MD_Medium') do
34
+
35
+ # medium - name {CI_Citation}
36
+ unless hMedium[:mediumSpecification].empty?
37
+ @xml.tag!('mrd:name') do
38
+ citationClass.writeXML(hMedium[:mediumSpecification], outContext)
39
+ end
40
+ end
41
+ if hMedium[:mediumSpecification].empty? && @hResponseObj[:writerShowTags]
42
+ @xml.tag!('mrd:name')
43
+ end
44
+
45
+ # medium - density {Real}
46
+ unless hMedium[:density].nil?
47
+ @xml.tag!('mrd:density') do
48
+ @xml.tag!('gco:Real', hMedium[:density].to_s)
49
+ end
50
+ end
51
+ if hMedium[:density].nil? && @hResponseObj[:writerShowTags]
52
+ @xml.tag!('mrd:density')
53
+ end
54
+
55
+ # medium density units
56
+ unless hMedium[:units].nil?
57
+ @xml.tag!('mrd:densityUnits') do
58
+ @xml.tag!('gco:CharacterString', hMedium[:units].downcase)
59
+ end
60
+ end
61
+ if hMedium[:units].nil? && @hResponseObj[:writerShowTags]
62
+ @xml.tag!('mrd:densityUnits')
63
+ end
64
+
65
+ # medium - volumes {Integer}
66
+ unless hMedium[:numberOfVolumes].nil?
67
+ @xml.tag!('mrd:volumes') do
68
+ @xml.tag!('gco:Integer', hMedium[:numberOfVolumes].to_s)
69
+ end
70
+ end
71
+ if hMedium[:numberOfVolumes].nil? && @hResponseObj[:writerShowTags]
72
+ @xml.tag!('mrd:volumes')
73
+ end
74
+
75
+ # medium - medium format code [] {MD_MediumFormatCode}
76
+ aCode = hMedium[:mediumFormat]
77
+ aCode.each do |code|
78
+ @xml.tag!('mrd:mediumFormat') do
79
+ codelistClass.writeXML('mrd', 'iso_mediumFormat', code)
80
+ end
81
+ end
82
+ if aCode.empty? && @hResponseObj[:writerShowTags]
83
+ @xml.tag!('mrd:mediumFormat')
84
+ end
85
+
86
+ # medium - note
87
+ unless hMedium[:note].nil?
88
+ @xml.tag!('mrd:mediumNote') do
89
+ @xml.tag!('gco:CharacterString', hMedium[:note])
90
+ end
91
+ end
92
+ if hMedium[:note].nil? && @hResponseObj[:writerShowTags]
93
+ @xml.tag!('mrd:mediumNote')
94
+ end
95
+
96
+ # medium - identifier {MD_Identifier}
97
+ unless hMedium[:identifier].empty?
98
+ @xml.tag!('mrd:identifier') do
99
+ identifierClass.writeXML(hMedium[:identifier], outContext)
100
+ end
101
+ end
102
+ if hMedium[:identifier].empty? && @hResponseObj[:writerShowTags]
103
+ @xml.tag!('mrd:identifier')
104
+ end
105
+
106
+ end # mrd:MD_Medium
107
+ end # writeXML
108
+ end # MD_Medium class
109
+
110
+ end
111
+ end
112
+ end
113
+ end