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,61 @@
1
+ # ISO <<Class>> CI_Series
2
+ # 19115-1 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-04-16 original script
6
+
7
+ require_relative 'class_gridRepresentation'
8
+ require_relative 'class_vectorRepresentation'
9
+ require_relative 'class_georectified'
10
+ require_relative 'class_georeferenceable'
11
+
12
+ module ADIWG
13
+ module Mdtranslator
14
+ module Writers
15
+ module Iso19115_1
16
+
17
+ class SpatialRepresentation
18
+
19
+ def initialize(xml, hResponseObj)
20
+ @xml = xml
21
+ @hResponseObj = hResponseObj
22
+ end
23
+
24
+ def writeXML(hRepresentation, inContext = nil)
25
+
26
+ # classes used
27
+ gridClass = MD_GridSpatialRepresentation.new(@xml, @hResponseObj)
28
+ vectorClass = MD_VectorSpatialRepresentation.new(@xml, @hResponseObj)
29
+ rectifiedClass = MD_Georectified.new(@xml, @hResponseObj)
30
+ referenceClass = MD_Georeferenceable.new(@xml, @hResponseObj)
31
+
32
+ outContext = 'spatial representation'
33
+ outContext = inContext + ' spatial representation' unless inContext.nil?
34
+
35
+ # spatial representation - grid
36
+ unless hRepresentation[:gridRepresentation].empty?
37
+ gridClass.writeXML(hRepresentation[:gridRepresentation], outContext)
38
+ end
39
+
40
+ # spatial representation - vector
41
+ unless hRepresentation[:vectorRepresentation].empty?
42
+ vectorClass.writeXML(hRepresentation[:vectorRepresentation], outContext)
43
+ end
44
+
45
+ # spatial representation - georectified
46
+ unless hRepresentation[:georectifiedRepresentation].empty?
47
+ rectifiedClass.writeXML(hRepresentation[:georectifiedRepresentation], outContext)
48
+ end
49
+
50
+ # spatial representation - georeferenceable
51
+ unless hRepresentation[:georeferenceableRepresentation].empty?
52
+ referenceClass.writeXML(hRepresentation[:georeferenceableRepresentation], outContext)
53
+ end
54
+
55
+ end # writeXML
56
+ end # SpatialRepresentation class
57
+
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,53 @@
1
+ # ISO <<Class>> EX_TemporalExtent
2
+ # 19115-1 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-03-19 original script
6
+
7
+ require_relative 'class_timeInstant'
8
+ require_relative 'class_timePeriod'
9
+
10
+ module ADIWG
11
+ module Mdtranslator
12
+ module Writers
13
+ module Iso19115_1
14
+
15
+ class EX_TemporalExtent
16
+
17
+ def initialize(xml, hResponseObj)
18
+ @xml = xml
19
+ @hResponseObj = hResponseObj
20
+ end
21
+
22
+ def writeXML(hTempEle)
23
+
24
+ # classes used
25
+ timeInstClass = TimeInstant.new(@xml, @hResponseObj)
26
+ timePeriodClass = TimePeriod.new(@xml, @hResponseObj)
27
+
28
+ @xml.tag!('gex:EX_TemporalExtent') do
29
+
30
+ # temporal extent - time instant
31
+ hTimeInst = hTempEle[:timeInstant]
32
+ unless hTimeInst.empty?
33
+ @xml.tag!('gex:extent') do
34
+ timeInstClass.writeXML(hTimeInst)
35
+ end
36
+ end
37
+
38
+ # temporal extent - time period
39
+ hTimePeriod = hTempEle[:timePeriod]
40
+ unless hTimePeriod.empty?
41
+ @xml.tag!('gex:extent') do
42
+ timePeriodClass.writeXML(hTimePeriod)
43
+ end
44
+ end
45
+
46
+ end # EX_TemporalExtent tag
47
+ end # writeXML
48
+ end # EX_TemporalExtent class
49
+
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,80 @@
1
+ # ISO <<Class>> TimeInstant
2
+ # 19115-1 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-03-19 original script.
6
+
7
+ require_relative 'class_gmlIdentifier'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Writers
12
+ module Iso19115_1
13
+
14
+ class TimeInstant
15
+
16
+ def initialize(xml, hResponseObj)
17
+ @xml = xml
18
+ @hResponseObj = hResponseObj
19
+ end
20
+
21
+ def writeXML(hInstant)
22
+
23
+ # classes used
24
+ gmlClass = GMLIdentifier.new(@xml, @hResponseObj)
25
+
26
+ # TimeInstant requires a unique ID
27
+ timeID = hInstant[:timeId]
28
+ if timeID.nil?
29
+ @hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ
30
+ timeID = 'timeInstant' + @hResponseObj[:writerMissingIdCount]
31
+ else
32
+ timeID.gsub!(/[^0-9a-zA-Z]/, '')
33
+ end
34
+
35
+ @xml.tag!('gml:TimeInstant', {'gml:id' => timeID}) do
36
+
37
+ # time instant - description
38
+ unless hInstant[:description].nil?
39
+ @xml.tag!('gml:description', hInstant[:description])
40
+ end
41
+ if hInstant[:description].nil? && @hResponseObj[:writerShowTags]
42
+ @xml.tag!('gml:description')
43
+ end
44
+
45
+ # time instant - identifier {gmlIdentifier}
46
+ hGMLid = hInstant[:identifier]
47
+ unless hGMLid.empty?
48
+ gmlClass.writeXML(hGMLid)
49
+ end
50
+ if hGMLid.empty? && @hResponseObj[:writerShowTags]
51
+ @xml.tag!('gml:identifier', {'codeSpace' => ''})
52
+ end
53
+
54
+ # time instant - names []
55
+ aNames = hInstant[:instantNames]
56
+ aNames.each do |name|
57
+ @xml.tag!('gml:name', name)
58
+ end
59
+ if aNames.empty? && @hResponseObj[:writerShowTags]
60
+ @xml.tag!('gml:name')
61
+ end
62
+
63
+ # time instant - related Time [] { TmeInstant | TimePeriod}
64
+ # not implemented
65
+
66
+ # time instant - time position
67
+ hDateTime = hInstant[:timeInstant]
68
+ timeInstant = hDateTime[:dateTime]
69
+ timeResolution = hDateTime[:dateResolution]
70
+ dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(timeInstant, timeResolution)
71
+ @xml.tag!('gml:timePosition', dateStr)
72
+
73
+ end # TimeInstant tag
74
+ end # writeXML
75
+ end # TimeInstant class
76
+
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,113 @@
1
+ # ISO <<Class>> TimePeriod
2
+ # 19115-1 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-03-19 original script.
6
+
7
+ require_relative 'class_gmlIdentifier'
8
+
9
+ module ADIWG
10
+ module Mdtranslator
11
+ module Writers
12
+ module Iso19115_1
13
+
14
+ class TimePeriod
15
+
16
+ def initialize(xml, hResponseObj)
17
+ @xml = xml
18
+ @hResponseObj = hResponseObj
19
+ end
20
+
21
+ def writeXML(hPeriod)
22
+
23
+ # classes used
24
+ gmlClass = GMLIdentifier.new(@xml, @hResponseObj)
25
+
26
+ # TimePeriod must have a uniqueID
27
+ timeID = hPeriod[:timeId]
28
+ if timeID.nil?
29
+ @hResponseObj[:writerMissingIdCount] = @hResponseObj[:writerMissingIdCount].succ
30
+ timeID = 'timePeriod' + @hResponseObj[:writerMissingIdCount]
31
+ else
32
+ timeID.gsub!(/[^0-9a-zA-Z]/, '')
33
+ end
34
+
35
+ @xml.tag!('gml:TimePeriod', {'gml:id' => timeID}) do
36
+
37
+ # time period - description
38
+ unless hPeriod[:description].nil?
39
+ @xml.tag!('gml:description', hPeriod[:description])
40
+ end
41
+ if hPeriod[:description].nil? && @hResponseObj[:writerShowTags]
42
+ @xml.tag!('gml:description')
43
+ end
44
+
45
+ # time period - identifier {gmlIdentifier}
46
+ hGMLid = hPeriod[:identifier]
47
+ unless hGMLid.empty?
48
+ gmlClass.writeXML(hGMLid)
49
+ end
50
+ if hGMLid.empty? && @hResponseObj[:writerShowTags]
51
+ @xml.tag!('gml:identifier', {'codeSpace' => ''})
52
+ end
53
+
54
+ # time period - names []
55
+ aNames = hPeriod[:periodNames]
56
+ aNames.each do |name|
57
+ @xml.tag!('gml:name', name)
58
+ end
59
+ if aNames.empty? && @hResponseObj[:writerShowTags]
60
+ @xml.tag!('gml:name')
61
+ end
62
+
63
+ # time period - begin position
64
+ # tag always required, however value may be empty
65
+ # if empty add indeterminatePosition="unknown"
66
+ unless hPeriod[:startDateTime].empty?
67
+ hDateTime = hPeriod[:startDateTime]
68
+ dateTime = hDateTime[:dateTime]
69
+ timeResolution = hDateTime[:dateResolution]
70
+ dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(dateTime, timeResolution)
71
+ @xml.tag!('gml:beginPosition', dateStr)
72
+ end
73
+ if hPeriod[:startDateTime].empty?
74
+ @xml.tag!('gml:beginPosition', {indeterminatePosition: 'unknown'})
75
+ end
76
+
77
+ # time period - begin position
78
+ # tag always required, however value may be empty
79
+ # if empty add indeterminatePosition="unknown"
80
+ unless hPeriod[:endDateTime].empty?
81
+ hDateTime = hPeriod[:endDateTime]
82
+ dateTime = hDateTime[:dateTime]
83
+ timeResolution = hDateTime[:dateResolution]
84
+ dateStr = AdiwgDateTimeFun.stringDateTimeFromDateTime(dateTime, timeResolution)
85
+ @xml.tag!('gml:endPosition', dateStr)
86
+ end
87
+ if hPeriod[:endDateTime].empty?
88
+ @xml.tag!('gml:endPosition', {indeterminatePosition: 'unknown'})
89
+ end
90
+
91
+ # time period - time interval
92
+ hInterval = hPeriod[:timeInterval]
93
+ unless hInterval.empty?
94
+ units = hInterval[:units]
95
+ interval = hInterval[:interval]
96
+ @xml.tag!('gml:timeInterval', {'unit' => units}, interval)
97
+ end
98
+
99
+ # time period - duration (do not output if have time interval)
100
+ hDuration = hPeriod[:duration]
101
+ if hInterval.empty? && !hDuration.empty?
102
+ duration = AdiwgDateTimeFun.writeDuration(hDuration)
103
+ @xml.tag!('gml:duration', duration)
104
+ end
105
+
106
+ end # TimePeriod tag
107
+ end # writeXML
108
+ end # TimePeriod class
109
+
110
+ end
111
+ end
112
+ end
113
+ end
@@ -0,0 +1,107 @@
1
+ # ISO <<Class>> MD_DigitalTransferOptions
2
+ # 19115-1 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-04-10 original script
6
+
7
+ require_relative 'class_onlineResource'
8
+ require_relative 'class_medium'
9
+ require_relative 'class_format'
10
+
11
+ module ADIWG
12
+ module Mdtranslator
13
+ module Writers
14
+ module Iso19115_1
15
+
16
+ class MD_DigitalTransferOptions
17
+
18
+ def initialize(xml, hResponseObj)
19
+ @xml = xml
20
+ @hResponseObj = hResponseObj
21
+ end
22
+
23
+ def writeXML(hOption, inContext = nil)
24
+
25
+ # classes used
26
+ olResClass = CI_OnlineResource.new(@xml, @hResponseObj)
27
+ mediumClass = MD_Medium.new(@xml, @hResponseObj)
28
+ formatClass = MD_Format.new(@xml, @hResponseObj)
29
+
30
+ outContext = 'transfer option'
31
+ outContext = inContext + ' transfer option' unless inContext.nil?
32
+
33
+ @xml.tag!('mrd:MD_DigitalTransferOptions') do
34
+
35
+ # digital transfer options - units of distribution
36
+ unless hOption[:unitsOfDistribution].nil?
37
+ @xml.tag!('mrd:unitsOfDistribution') do
38
+ @xml.tag!('gco:CharacterString', hOption[:unitsOfDistribution])
39
+ end
40
+ end
41
+ if hOption[:unitsOfDistribution].nil? && @hResponseObj[:writerShowTags]
42
+ @xml.tag!('mrd:unitsOfDistribution')
43
+ end
44
+
45
+ # digital transfer options - transfer size {MB}
46
+ unless hOption[:transferSize].nil?
47
+ @xml.tag!('mrd:transferSize') do
48
+ @xml.tag!('gco:Real', hOption[:transferSize].to_s)
49
+ end
50
+ end
51
+ if hOption[:transferSize].nil? && @hResponseObj[:writerShowTags]
52
+ @xml.tag!('mrd:transferSize')
53
+ end
54
+
55
+ # digital transfer options - online [] {CI_OnlineResource}
56
+ aOnlineOps = hOption[:onlineOptions]
57
+ aOnlineOps.each do |hOlOption|
58
+ @xml.tag!('mrd:onLine') do
59
+ olResClass.writeXML(hOlOption, outContext)
60
+ end
61
+ end
62
+ if aOnlineOps.empty? && @hResponseObj[:writerShowTags]
63
+ @xml.tag!('mrd:onLine')
64
+ end
65
+
66
+ # digital transfer options - offline [] {MD_Medium}
67
+ aOfflineOps = hOption[:offlineOptions]
68
+ aOfflineOps.each do |hOffline|
69
+ @xml.tag!('mrd:offLine') do
70
+ mediumClass.writeXML(hOffline)
71
+ end
72
+ end
73
+ if aOfflineOps.empty? && @hResponseObj[:writerShowTags]
74
+ @xml.tag!('mrd:offLine')
75
+ end
76
+
77
+ # digital transfer options - transfer frequency {TM_PeriodDuration}
78
+ hDuration = hOption[:transferFrequency]
79
+ unless hDuration.empty?
80
+ duration = AdiwgDateTimeFun.writeDuration(hDuration)
81
+ @xml.tag!('mrd:transferFrequency') do
82
+ @xml.tag!('gco:TM_PeriodDuration', duration)
83
+ end
84
+ end
85
+ if hDuration.empty? && @hResponseObj[:writerShowTags]
86
+ @xml.tag!('mrd:transferFrequency')
87
+ end
88
+
89
+ # digital transfer options - distribution format [] {MD_Format}
90
+ aFormats = hOption[:distributionFormats]
91
+ aFormats.each do |hFormat|
92
+ @xml.tag!('mrd:distributionFormat') do
93
+ formatClass.writeXML(hFormat)
94
+ end
95
+ end
96
+ if aFormats.empty? && @hResponseObj[:writerShowTags]
97
+ @xml.tag!('mrd:distributionFormat')
98
+ end
99
+
100
+ end # mrd:MD_DigitalTransferOptions tag
101
+ end # writeXML
102
+ end # MD_DigitalTransferOptions class
103
+
104
+ end
105
+ end
106
+ end
107
+ end
@@ -0,0 +1,258 @@
1
+ # ISO <<Class>> UnitsOfMeasure
2
+ # 19115-1 writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2019-04-08 copied from 19115_2 writer
6
+
7
+ require_relative 'class_baseUnit'
8
+ require_relative 'class_conventionalUnit'
9
+ require_relative 'class_derivedUnit'
10
+ require_relative 'class_definitionUnit'
11
+
12
+ module ADIWG
13
+ module Mdtranslator
14
+ module Writers
15
+ module Iso19115_1
16
+
17
+ class UnitsOfMeasure
18
+
19
+ def initialize(xml, hResponseObj)
20
+ @xml = xml
21
+ @hResponseObj = hResponseObj
22
+ end
23
+
24
+ def writeUnits(unit)
25
+
26
+ # define empty containers here to save lines of code
27
+ # for base units
28
+ hBase = {}
29
+ hBase[:identifier] = ''
30
+ hBase[:codeSpace] = 'http://www.bipm.org/en/si/'
31
+ hBase[:name] = ''
32
+ hBase[:catalogSymbol] = ''
33
+ hBase[:unitsSystem] = 'base unit'
34
+
35
+ # for conventional units
36
+ hConvent = {}
37
+ hConvent[:identifier] = ''
38
+ hConvent[:codeSpace] = 'http://www.bipm.org/en/si/'
39
+ hConvent[:name] = ''
40
+ hConvent[:catalogSymbol] = ''
41
+ hConvent[:preferredUnit] = ''
42
+ hConvent[:factor] = nil
43
+ hConvent[:a] = nil
44
+ hConvent[:b] = nil
45
+ hConvent[:c] = nil
46
+ hConvent[:d] = nil
47
+
48
+ # for derived units
49
+ hDerived = {}
50
+ hDerived[:identifier] = ''
51
+ hDerived[:codeSpace] = ''
52
+ hDerived[:name] = ''
53
+ hDerived[:remarks] = ''
54
+ hDerived[:catalogSymbol] = ''
55
+ hDerived[:derivationUnitTerm] = nil
56
+
57
+ # find matching units of measure
58
+ case unit
59
+
60
+ # angular degrees
61
+ when 'deg', 'degree', 'degrees'
62
+ hBase[:identifier] = 'degree'
63
+ hBase[:codeSpace] = 'urn:ogc:def:uom:1.0'
64
+ hBase[:name] = 'degree of arc'
65
+ hBase[:catalogSymbol] = 'deg'
66
+ hBase[:unitsSystem] = 'http://www.opengis.net/def/uom/OGC/1.0/degree'
67
+
68
+ baseClass = BaseUnit.new(@xml, @hResponseObj)
69
+ baseClass.writeXML(hBase)
70
+
71
+ when 'm', 'meter', 'meters', 'metre'
72
+ hBase[:identifier] = 'meter'
73
+ hBase[:name] = 'meter'
74
+ hBase[:catalogSymbol] = 'm'
75
+
76
+ baseClass = BaseUnit.new(@xml, @hResponseObj)
77
+ baseClass.writeXML(hBase)
78
+
79
+ when 'kg', 'kilogram', 'kilograms'
80
+ hBase[:identifier] = 'kilogram'
81
+ hBase[:name] = 'kilogram'
82
+ hBase[:catalogSymbol] = 'kg'
83
+
84
+ baseClass = BaseUnit.new(@xml, @hResponseObj)
85
+ baseClass.writeXML(hBase)
86
+
87
+ when 's', 'second', 'seconds'
88
+ hBase[:identifier] = 'second'
89
+ hBase[:name] = 'second'
90
+ hBase[:catalogSymbol] = 'd'
91
+
92
+ baseClass = BaseUnit.new(@xml, @hResponseObj)
93
+ baseClass.writeXML(hBase)
94
+
95
+ when 'A', 'ampere', 'amperes'
96
+ hBase[:identifier] = 'ampere'
97
+ hBase[:name] = 'ampere'
98
+ hBase[:catalogSymbol] = 'A'
99
+
100
+ baseClass = BaseUnit.new(@xml, @hResponseObj)
101
+ baseClass.writeXML(hBase)
102
+
103
+ when 'K', 'kelvin'
104
+ hBase[:identifier] = 'kelvin'
105
+ hBase[:name] = 'kelvin'
106
+ hBase[:catalogSymbol] = 'K'
107
+
108
+ baseClass = BaseUnit.new(@xml, @hResponseObj)
109
+ baseClass.writeXML(hBase)
110
+
111
+ when 'mol', 'mole', 'moles'
112
+ hBase[:identifier] = 'mole'
113
+ hBase[:name] = 'mole'
114
+ hBase[:catalogSymbol] = 'mol'
115
+
116
+ baseClass = BaseUnit.new(@xml, @hResponseObj)
117
+ baseClass.writeXML(hBase)
118
+
119
+ when 'cd', 'candela', 'candelas'
120
+ hBase[:identifier] = 'candela'
121
+ hBase[:name] = 'candela'
122
+ hBase[:catalogSymbol] = 'cd'
123
+
124
+ baseClass = BaseUnit.new(@xml, @hResponseObj)
125
+ baseClass.writeXML(hBase)
126
+
127
+ when 'ft', 'foot', 'feet'
128
+ hConvent[:identifier] = 'meter'
129
+ hConvent[:name] = 'foot'
130
+ hConvent[:catalogSymbol] = 'ft'
131
+ hConvent[:preferredUnit] = 'meter'
132
+ hConvent[:factor] = 3.280839
133
+
134
+ convClass = ConventionalUnit.new(@xml, @hResponseObj)
135
+ convClass.writeXML(hConvent)
136
+
137
+ when 'in', 'inch', 'inches'
138
+ hConvent[:identifier] = 'meter'
139
+ hConvent[:name] = 'inch'
140
+ hConvent[:catalogSymbol] = 'in'
141
+ hConvent[:preferredUnit] = 'meter'
142
+ hConvent[:factor] = 0.0254
143
+
144
+ convClass = ConventionalUnit.new(@xml, @hResponseObj)
145
+ convClass.writeXML(hConvent)
146
+
147
+ when 'mm', 'millimeter', 'millimeters'
148
+ hConvent[:identifier] = 'meter'
149
+ hConvent[:name] = 'millimeter'
150
+ hConvent[:catalogSymbol] = 'mm'
151
+ hConvent[:preferredUnit] = 'meter'
152
+ hConvent[:factor] = 0.001
153
+
154
+ convClass = ConventionalUnit.new(@xml, @hResponseObj)
155
+ convClass.writeXML(hConvent)
156
+
157
+ when 'micrometer', 'micrometers'
158
+ micro = "\u00b5"
159
+ s = micro.encode('utf-8')
160
+ s += 'm'
161
+ hConvent[:identifier] = 'meter'
162
+ hConvent[:name] = 'micrometer'
163
+ hConvent[:catalogSymbol] = s
164
+ hConvent[:preferredUnit] = 'meter'
165
+ hConvent[:factor] = 0.000001
166
+
167
+ convClass = ConventionalUnit.new(@xml, @hResponseObj)
168
+ convClass.writeXML(hConvent)
169
+
170
+ when 'nm', 'nanometer', 'nanometers'
171
+ hConvent[:identifier] = 'meter'
172
+ hConvent[:name] = 'nanometer'
173
+ hConvent[:catalogSymbol] = 'nm'
174
+ hConvent[:preferredUnit] = 'meter'
175
+ hConvent[:factor] = 0.000000001
176
+
177
+ convClass = ConventionalUnit.new(@xml, @hResponseObj)
178
+ convClass.writeXML(hConvent)
179
+
180
+ when 'degC', 'centigrade', 'degreesC', 'Celsius'
181
+ hConvent[:identifier] = 'kelvin'
182
+ hConvent[:name] = 'degree Celsius'
183
+ hConvent[:catalogSymbol] = 'degC'
184
+ hConvent[:preferredUnit] = 'kelvin'
185
+ hConvent[:a] = 273.16
186
+ hConvent[:b] = 1
187
+ hConvent[:c] = 1
188
+ hConvent[:d] = 0
189
+
190
+ convClass = ConventionalUnit.new(@xml, @hResponseObj)
191
+ convClass.writeXML(hConvent)
192
+
193
+ when 'degF', 'degreesF', 'Fahrenheit'
194
+ hConvent[:identifier] = 'kelvin'
195
+ hConvent[:name] = 'degree Fahrenheit'
196
+ hConvent[:catalogSymbol] = 'degF'
197
+ hConvent[:preferredUnit] = 'kelvin'
198
+ hConvent[:a] = 2298.44
199
+ hConvent[:b] = 5
200
+ hConvent[:c] = 9
201
+ hConvent[:d] = 0
202
+
203
+ convClass = ConventionalUnit.new(@xml, @hResponseObj)
204
+ convClass.writeXML(hConvent)
205
+
206
+ when 'mph', 'miles per hour'
207
+ hConvent[:identifier] = 'mi/h'
208
+ hConvent[:name] = 'miles per hour'
209
+ hConvent[:catalogSymbol] = 'mph'
210
+ hConvent[:preferredUnit] = 'm/s'
211
+ hConvent[:a] = 0
212
+ hConvent[:b] = 1609.344
213
+ hConvent[:c] = 0
214
+ hConvent[:d] = 3600.0
215
+
216
+ convClass = ConventionalUnit.new(@xml, @hResponseObj)
217
+ convClass.writeXML(hConvent)
218
+
219
+ when 'kph', 'kilometers per hour'
220
+ hConvent[:identifier] = 'k/h'
221
+ hConvent[:name] = 'kilometers per hour'
222
+ hConvent[:catalogSymbol] = 'kph'
223
+ hConvent[:preferredUnit] = 'm/s'
224
+ hConvent[:a] = 0
225
+ hConvent[:b] = 1000
226
+ hConvent[:c] = 0
227
+ hConvent[:d] = 3600
228
+
229
+ convClass = ConventionalUnit.new(@xml, @hResponseObj)
230
+ convClass.writeXML(hConvent)
231
+
232
+ when 'density'
233
+ hDerived = {}
234
+ hDerived[:identifier] = 'kg/m^3'
235
+ hDerived[:name] = 'kilograms per cubic meter'
236
+ hDerived[:remarks] = 'volumetric mass density'
237
+ hDerived[:catalogSymbol] = 'p'
238
+ unitTerms = []
239
+ unitTerms << {'uom' => 'kg', 'exponent' => '1'}
240
+ unitTerms << {'uom' => 'm', 'exponent' => '-3'}
241
+ hDerived[:derivationUnitTerm] = unitTerms
242
+
243
+ dervClass = DerivedUnit.new(@xml, @hResponseObj)
244
+ dervClass.writeXML(hDerived)
245
+
246
+ else
247
+ defnClass = UnitDefinition.new(@xml, @hResponseObj)
248
+ defnClass.writeXML(unit)
249
+
250
+ end
251
+ end
252
+
253
+ end
254
+
255
+ end
256
+ end
257
+ end
258
+ end