adiwg-mdtranslator 0.9.0 → 0.10.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -6
  3. data/adiwg-mdtranslator.gemspec +2 -2
  4. data/bin/mdtranslator +10 -10
  5. data/lib/adiwg/mdtranslator.rb +54 -12
  6. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +87 -7
  7. data/lib/adiwg/mdtranslator/readers/{adiwgJson/adiwgJson_reader.rb → mdJson/mdJson_reader.rb} +13 -4
  8. data/lib/adiwg/mdtranslator/readers/{adiwgJson/adiwgJson_validator.rb → mdJson/mdJson_validator.rb} +18 -10
  9. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_additionalDocumentation.rb +2 -2
  10. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_address.rb +1 -1
  11. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_associatedResource.rb +3 -3
  12. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_boundingBox.rb +1 -1
  13. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_browseGraphic.rb +1 -1
  14. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_citation.rb +5 -5
  15. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_contacts.rb +7 -7
  16. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_coordinates.rb +1 -1
  17. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_dataDictionary.rb +53 -0
  18. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_dataQuality.rb +2 -2
  19. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_dateTime.rb +1 -1
  20. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_descriptiveKeyword.rb +2 -2
  21. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_dictionaryInfo.rb +52 -0
  22. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_distributionInfo.rb +4 -4
  23. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_domain.rb +62 -0
  24. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_domainItem.rb +42 -0
  25. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entity.rb +92 -0
  26. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityAttribute.rb +91 -0
  27. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityForeignKey.rb +43 -0
  28. data/lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_entityIndex.rb +42 -0
  29. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_extent.rb +4 -4
  30. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_geoCoordSystem.rb +1 -1
  31. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_geoProperties.rb +4 -4
  32. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_geographicElement.rb +12 -12
  33. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_legalConstraint.rb +1 -1
  34. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_lineString.rb +2 -2
  35. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_lineage.rb +3 -3
  36. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_metadata.rb +6 -6
  37. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_metadataExtension.rb +2 -2
  38. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_metadataInfo.rb +8 -8
  39. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_onlineResource.rb +1 -1
  40. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_phone.rb +1 -1
  41. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_point.rb +2 -2
  42. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_polygon.rb +2 -2
  43. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_processStep.rb +4 -4
  44. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resolution.rb +1 -1
  45. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceFormat.rb +1 -1
  46. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceIdentifier.rb +2 -2
  47. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceInfo.rb +16 -16
  48. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceMaintenance.rb +2 -2
  49. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_resourceSpecificUsage.rb +2 -2
  50. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_responsibleParty.rb +2 -2
  51. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_securityConstraint.rb +1 -1
  52. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_source.rb +3 -3
  53. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_spatialReference.rb +1 -1
  54. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_taxonClass.rb +1 -1
  55. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_taxonomy.rb +5 -5
  56. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_temporalElement.rb +4 -4
  57. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_timeInstant.rb +3 -3
  58. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_timePeriod.rb +4 -4
  59. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_verticalElement.rb +1 -1
  60. data/lib/adiwg/mdtranslator/readers/{adiwgJson → mdJson}/modules_0.9.0/module_voucher.rb +2 -2
  61. data/lib/adiwg/mdtranslator/readers/mdJson/readme.md +19 -0
  62. data/lib/adiwg/mdtranslator/version.rb +5 -1
  63. data/lib/adiwg/mdtranslator/writers/iso/classes/class_FCfeatureCatalogue.rb +171 -0
  64. data/lib/adiwg/mdtranslator/writers/{iso19115_2/classes/class_metadata.rb → iso/classes/class_MImetadata.rb} +3 -3
  65. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_address.rb +0 -0
  66. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_aggregateInformation.rb +0 -0
  67. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_boundingPolygon.rb +0 -0
  68. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_browseGraphic.rb +0 -0
  69. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_citation.rb +3 -3
  70. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_contact.rb +1 -1
  71. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_dataIdentification.rb +0 -0
  72. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_dataQuality.rb +0 -0
  73. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_date.rb +0 -0
  74. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_digitalTransferOptions.rb +0 -0
  75. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_distribution.rb +0 -0
  76. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_distributor.rb +0 -0
  77. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_extent.rb +0 -0
  78. data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureAttribute.rb +114 -0
  79. data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureConstraint.rb +55 -0
  80. data/lib/adiwg/mdtranslator/writers/iso/classes/class_featureType.rb +120 -0
  81. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_format.rb +0 -0
  82. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_genericMetaData.rb +0 -0
  83. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_geographicBoundingBox.rb +0 -0
  84. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_geographicDescription.rb +0 -0
  85. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_geographicElement.rb +0 -0
  86. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_identifier.rb +0 -0
  87. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_keyword.rb +0 -0
  88. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_legalConstraints.rb +0 -0
  89. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_lineString.rb +1 -1
  90. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_lineage.rb +0 -0
  91. data/lib/adiwg/mdtranslator/writers/iso/classes/class_listedValue.rb +68 -0
  92. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_maintenanceInformation.rb +0 -0
  93. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_medium.rb +0 -0
  94. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_metadataExtension.rb +0 -0
  95. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_multiGeometry.rb +3 -3
  96. data/lib/adiwg/mdtranslator/writers/iso/classes/class_multiplicity.rb +44 -0
  97. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_onlineResource.rb +0 -0
  98. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_point.rb +1 -1
  99. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_polygon.rb +2 -2
  100. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_processStep.rb +1 -1
  101. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_referenceIdentifier.rb +0 -0
  102. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_referenceSystem.rb +0 -0
  103. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_resolution.rb +0 -0
  104. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_responsibleParty.rb +1 -1
  105. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_securityConstraints.rb +0 -0
  106. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_source.rb +0 -0
  107. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_standardOrderProcess.rb +0 -0
  108. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_taxonClassification.rb +0 -0
  109. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_taxonSystem.rb +0 -0
  110. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_telephone.rb +0 -0
  111. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_temporalExtent.rb +0 -0
  112. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_timeInstant.rb +1 -1
  113. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_timePeriod.rb +1 -1
  114. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_usage.rb +0 -0
  115. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_useConstraints.rb +0 -0
  116. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_verticalExtent.rb +0 -0
  117. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/classes/class_vouchers.rb +0 -0
  118. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_associationType.rb +0 -0
  119. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_characterSet.rb +0 -0
  120. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_classification.rb +0 -0
  121. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_datatype.rb +0 -0
  122. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_dateType.rb +0 -0
  123. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_initiativeType.rb +0 -0
  124. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_keywordType.rb +0 -0
  125. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_maintenanceFrequency.rb +0 -0
  126. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_mediumFormat.rb +0 -0
  127. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_mediumName.rb +0 -0
  128. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_obligation.rb +0 -0
  129. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_onlineFunction.rb +0 -0
  130. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_presentationForm.rb +0 -0
  131. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_progress.rb +0 -0
  132. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_restriction.rb +0 -0
  133. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_role.rb +0 -0
  134. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_scope.rb +0 -0
  135. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_spatialRepresentationType.rb +0 -0
  136. data/lib/adiwg/mdtranslator/writers/{iso19115_2 → iso}/codelists/code_topicCategory.rb +0 -0
  137. data/lib/adiwg/mdtranslator/writers/iso/units/class_baseUnit.rb +27 -0
  138. data/lib/adiwg/mdtranslator/writers/iso/units/class_conventionalUnit.rb +53 -0
  139. data/lib/adiwg/mdtranslator/writers/iso/units/class_definitionUnit.rb +24 -0
  140. data/lib/adiwg/mdtranslator/writers/iso/units/class_derivedUnit.rb +31 -0
  141. data/lib/adiwg/mdtranslator/writers/iso/units/class_unitsOfMeasure.rb +224 -0
  142. data/lib/adiwg/mdtranslator/writers/iso19110/iso19110_writer.rb +28 -0
  143. data/lib/adiwg/mdtranslator/writers/iso19110/readme.md +13 -0
  144. data/lib/adiwg/mdtranslator/writers/iso19115_2/iso19115_2_writer.rb +1 -1
  145. data/lib/adiwg/mdtranslator/writers/iso19115_2/readme.md +6 -9
  146. data/test/tc_translation.rb +35 -18
  147. metadata +166 -146
  148. data/lib/adiwg/mdtranslator/readers/adiwgJson/readme.md +0 -19
  149. data/mdtranslator.rb +0 -187
@@ -79,7 +79,7 @@ class MultiGeometry
79
79
  aPoints.each do |aCoords|
80
80
  intPoint = intMetadataClass.newGeoElement
81
81
  intPoint[:elementSrs] = hGeoElement[:elementSrs]
82
- intPoint[:elementGeometry] = Adiwg_Point.unpack(aCoords,'Point')
82
+ intPoint[:elementGeometry] = Md_Point.unpack(aCoords,'Point')
83
83
  pointClass.writeXML(intPoint)
84
84
  end
85
85
  end
@@ -91,7 +91,7 @@ class MultiGeometry
91
91
  aLines.each do |aCoords|
92
92
  intLine = intMetadataClass.newGeoElement
93
93
  intLine[:elementSrs] = hGeoElement[:elementSrs]
94
- intLine[:elementGeometry] = Adiwg_LineString.unpack(aCoords,'LineString')
94
+ intLine[:elementGeometry] = Md_LineString.unpack(aCoords,'LineString')
95
95
  lineClass.writeXML(intLine)
96
96
  end
97
97
  end
@@ -103,7 +103,7 @@ class MultiGeometry
103
103
  aPolygons.each do |aCoords|
104
104
  intPolygon = intMetadataClass.newGeoElement
105
105
  intPolygon[:elementSrs] = hGeoElement[:elementSrs]
106
- intPolygon[:elementGeometry] = Adiwg_LineString.unpack(aCoords,'Polygon')
106
+ intPolygon[:elementGeometry] = Md_LineString.unpack(aCoords,'Polygon')
107
107
  polygonClass.writeXML(intPolygon)
108
108
  end
109
109
  end
@@ -0,0 +1,44 @@
1
+ # ISO <<Class>> Multiplicity & MultiplicityRange
2
+ # writer output in XML
3
+ # definition: cardinality (0..1, 0..*, 1..1, 1..*)
4
+ # uncertain how this is used for attributes of relational tables since
5
+ # ... cardinality is defined between tables, not for attributes.
6
+ # ... documentation by NOAA and modelManager suggest best practice for
7
+ # ... propertyType is to default to 1.
8
+ # ... I assume this is using cardinality like optionality.
9
+ # ... therefore ...
10
+ # ... lower = 0 => Null
11
+ # ... lower = 1 => NotNull
12
+ # ... upper not provided a value, but is required to be present
13
+
14
+ # History:
15
+ # Stan Smith 2014-12-02 original script
16
+
17
+ class Multiplicity
18
+
19
+ def initialize(xml)
20
+ @xml = xml
21
+ end
22
+
23
+ def writeXML(allowNull)
24
+
25
+ # xml for iso classes Multiplicity and MultiplicityRange
26
+ @xml.tag!('gco:Multiplicity') do
27
+ @xml.tag!('gco:range') do
28
+ @xml.tag!('gco:MultiplicityRange') do
29
+ @xml.tag!('gco:lower') do
30
+ if !allowNull
31
+ range = 1
32
+ else
33
+ range = 0
34
+ end
35
+ @xml.tag!('gco:Integer',range)
36
+ end
37
+ @xml.tag!('gco:upper')
38
+ end
39
+ end
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -62,7 +62,7 @@ class Point
62
62
  # convert coordinate string from geoJSON to gml
63
63
  s = hGeoElement[:elementGeometry][:geometry]
64
64
  if !s.nil?
65
- s = Adiwg_Coordinates.unpack(s)
65
+ s = Md_Coordinates.unpack(s)
66
66
  @xml.tag!('gml:coordinates',s)
67
67
  else
68
68
  @xml.tag!('gml:coordinates')
@@ -62,7 +62,7 @@ class Polygon
62
62
  # convert coordinate string from geoJSON to gml
63
63
  aCoords = hGeoElement[:elementGeometry][:geometry][:exteriorRing]
64
64
  if !aCoords.empty?
65
- s = Adiwg_Coordinates.unpack(aCoords)
65
+ s = Md_Coordinates.unpack(aCoords)
66
66
  @xml.tag!('gml:exterior') do
67
67
  @xml.tag!('gml:LinearRing') do
68
68
  @xml.tag!('gml:coordinates',s)
@@ -78,7 +78,7 @@ class Polygon
78
78
  aRings = hGeoElement[:elementGeometry][:geometry][:exclusionRings]
79
79
  unless aRings.empty?
80
80
  aRings.each do |aRing|
81
- s = Adiwg_Coordinates.unpack(aRing)
81
+ s = Md_Coordinates.unpack(aRing)
82
82
  @xml.tag!('gml:interior') do
83
83
  @xml.tag!('gml:LinearRing') do
84
84
  @xml.tag!('gml:coordinates', s)
@@ -21,7 +21,7 @@ class LI_ProcessStep
21
21
 
22
22
  # process step - id
23
23
  attributes = {}
24
- s = hProcessStep[:stepID]
24
+ s = hProcessStep[:stepId]
25
25
  unless s.nil?
26
26
  attributes['id' => s]
27
27
  end
@@ -22,7 +22,7 @@ class CI_ResponsibleParty
22
22
  ciRoleCode = CI_RoleCode.new(@xml)
23
23
 
24
24
  # search array of responsible party for matches in contact object
25
- rpID = rParty[:contactID]
25
+ rpID = rParty[:contactId]
26
26
  unless rpID.nil?
27
27
  hContact = ciContactClass.getContact(rpID)
28
28
  unless hContact.empty?
@@ -15,7 +15,7 @@ class TimeInstant
15
15
 
16
16
  def writeXML(hTempI)
17
17
 
18
- timeID = hTempI[:timeID]
18
+ timeID = hTempI[:timeId]
19
19
  if timeID.nil?
20
20
  $idCount = $idCount.succ
21
21
  timeID = 'timeInstant' + $idCount
@@ -15,7 +15,7 @@ class TimePeriod
15
15
 
16
16
  def writeXML(hTempP)
17
17
 
18
- timeID = hTempP[:timeID]
18
+ timeID = hTempP[:timeId]
19
19
  if timeID.nil?
20
20
  $idCount = $idCount.succ
21
21
  timeID = 'timePeriod' + $idCount
@@ -0,0 +1,27 @@
1
+ # ISO <<Class>> BaseUnit
2
+ # writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2014-12-03 original script
6
+
7
+ class BaseUnit
8
+
9
+ def initialize(xml)
10
+ @xml = xml
11
+ end
12
+
13
+ def writeXML(hBase)
14
+
15
+ # create and identity for the unit
16
+ $idCount = $idCount.succ
17
+ unitID = 'unit' + $idCount
18
+ @xml.tag!('gml:BaseUnit', {'gml:id' => unitID}) do
19
+ @xml.tag!('gml:identifier', {'codeSpace' => hBase[:codeSpace]}, hBase[:identifier])
20
+ @xml.tag!('gml:name', hBase[:name])
21
+ @xml.tag!('gml:catalogSymbol', hBase[:catalogSymbol])
22
+ @xml.tag!('gml:unitsSystem', {'xlink:href' => hBase[:unitsSystem]})
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,53 @@
1
+ # ISO <<Class>> ConventionalUnit
2
+ # writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2014-12-03 original script
6
+
7
+ class ConventionalUnit
8
+
9
+ def initialize(xml)
10
+ @xml = xml
11
+ end
12
+
13
+ def writeXML(hConv)
14
+
15
+ # create and identity for the unit
16
+ $idCount = $idCount.succ
17
+ unitID = 'unit' + $idCount
18
+
19
+ @xml.tag!('gml:ConventionalUnit', {'gml:id' => unitID}) do
20
+ @xml.tag!('gml:identifier', {'codeSpace' => hConv[:codeSpace]}, hConv[:identifier])
21
+ @xml.tag!('gml:name', hConv[:name])
22
+ @xml.tag!('gml:catalogSymbol', hConv[:catalogSymbol])
23
+ @xml.tag!('gml:conversionToPreferredUnit', {'uom' => hConv[:preferredUnit]}) do
24
+
25
+ # two methods of conversion are available
26
+ # factor and formula
27
+ if !hConv[:factor].nil?
28
+ # factor:
29
+ # y = factor * x
30
+ # y is in preferred units
31
+ # x is in provided units
32
+ # factor is conversion to preferred units
33
+ @xml.tag!('gml:factor', hConv[:factor])
34
+ else
35
+ # formula:
36
+ # y = (a + bx) / (c + dx)
37
+ # y is in preferred units
38
+ # x is in provided units
39
+ # a,b,c,d are constants to convert to preferred units
40
+ @xml.tag!('gml:formula') do
41
+ @xml.tag!('gml:a', hConv[:a])
42
+ @xml.tag!('gml:b', hConv[:b])
43
+ @xml.tag!('gml:c', hConv[:c])
44
+ @xml.tag!('gml:d', hConv[:d])
45
+ end
46
+ end
47
+
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,24 @@
1
+ # ISO <<Class>> UnitDefinition
2
+ # writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2014-12-03 original script
6
+
7
+ class UnitDefinition
8
+
9
+ def initialize(xml)
10
+ @xml = xml
11
+ end
12
+
13
+ def writeXML(unit)
14
+
15
+ # create and identity for the unit
16
+ $idCount = $idCount.succ
17
+ unitID = 'unit' + $idCount
18
+ @xml.tag!('gml:UnitDefinition', {'gml:id' => unitID}) do
19
+ @xml.tag!('gml:identifier', {'codeSpace' => ''}, unit)
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -0,0 +1,31 @@
1
+ # ISO <<Class>> DerivedUnit
2
+ # writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2014-12-03 original script
6
+
7
+ class DerivedUnit
8
+
9
+ def initialize(xml)
10
+ @xml = xml
11
+ end
12
+
13
+ def writeXML(hDerived)
14
+
15
+ # create and identity for the unit
16
+ $idCount = $idCount.succ
17
+ unitID = 'unit' + $idCount
18
+ @xml.tag!('gml:DerivedUnit', {'gml:id' => unitID}) do
19
+ @xml.tag!('gml:identifier', {'codeSpace' => hDerived[:codeSpace]}, hDerived[:identifier])
20
+ @xml.tag!('gml:name', hDerived[:name])
21
+ @xml.tag!('gml:remarks', hDerived[:remarks])
22
+ @xml.tag!('gml:catalogSymbol', hDerived[:catalogSymbol])
23
+ aTerms = hDerived[:derivationUnitTerm]
24
+ aTerms.each do |term|
25
+ @xml.tag!('gml:derivationUnitTerm',term)
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ end
@@ -0,0 +1,224 @@
1
+ # ISO <<Class>> UnitsOfMeasure
2
+ # writer output in XML
3
+
4
+ # History:
5
+ # Stan Smith 2014-12-03 original script
6
+
7
+ require 'class_baseUnit'
8
+ require 'class_conventionalUnit'
9
+ require 'class_derivedUnit'
10
+ require 'class_definitionUnit'
11
+
12
+ class UnitsOfMeasure
13
+
14
+ def initialize(xml)
15
+ @xml = xml
16
+ end
17
+
18
+ def writeUnits(unit)
19
+
20
+ # define empty containers here to save lines of code
21
+ # for base units
22
+ hBase = {}
23
+ hBase[:identifier] = ''
24
+ hBase[:codeSpace] = 'http://www.bipm.org/en/si/'
25
+ hBase[:name] = ''
26
+ hBase[:catalogSymbol] = ''
27
+ hBase[:unitsSystem] = 'base unit'
28
+
29
+ # for conventional units
30
+ hConvent = {}
31
+ hConvent[:identifier] = ''
32
+ hConvent[:codeSpace] = 'http://www.bipm.org/en/si/'
33
+ hConvent[:name] = ''
34
+ hConvent[:catalogSymbol] = ''
35
+ hConvent[:preferredUnit] = ''
36
+ hConvent[:factor] = nil
37
+ hConvent[:a] = nil
38
+ hConvent[:b] = nil
39
+ hConvent[:c] = nil
40
+ hConvent[:d] = nil
41
+
42
+ # for derived units
43
+ hDerived = {}
44
+ hDerived[:identifier] = ''
45
+ hDerived[:codeSpace] = ''
46
+ hDerived[:name] = ''
47
+ hDerived[:remarks] = ''
48
+ hDerived[:catalogSymbol] = ''
49
+ hDerived[:derivationUnitTerm] = nil
50
+
51
+ # find matching units of measure
52
+ case unit
53
+
54
+ # angular degrees
55
+ when 'deg', 'degree', 'degrees'
56
+ hBase[:identifier] = 'degree'
57
+ hBase[:codeSpace] = 'urn:ogc:def:uom:1.0'
58
+ hBase[:name] = 'degree of arc'
59
+ hBase[:catalogSymbol] = 'deg'
60
+ hBase[:unitsSystem] = 'http://www.opengis.net/def/uom/OGC/1.0/degree'
61
+
62
+ baseClass = BaseUnit.new(@xml)
63
+ baseClass.writeXML(hBase)
64
+
65
+ when 'm', 'meter', 'meters', 'metre'
66
+ hBase[:identifier] = 'meter'
67
+ hBase[:name] = 'meter'
68
+ hBase[:catalogSymbol] = 'm'
69
+
70
+ baseClass = BaseUnit.new(@xml)
71
+ baseClass.writeXML(hBase)
72
+
73
+ when 'kg', 'kilogram', 'kilograms'
74
+ hBase[:identifier] = 'kilogram'
75
+ hBase[:name] = 'kilogram'
76
+ hBase[:catalogSymbol] = 'kg'
77
+
78
+ baseClass = BaseUnit.new(@xml)
79
+ baseClass.writeXML(hBase)
80
+
81
+ when 's', 'second', 'seconds'
82
+ hBase[:identifier] = 'second'
83
+ hBase[:name] = 'second'
84
+ hBase[:catalogSymbol] = 'd'
85
+
86
+ baseClass = BaseUnit.new(@xml)
87
+ baseClass.writeXML(hBase)
88
+
89
+ when 'A', 'ampere', 'amperes'
90
+ hBase[:identifier] = 'ampere'
91
+ hBase[:name] = 'ampere'
92
+ hBase[:catalogSymbol] = 'A'
93
+
94
+ baseClass = BaseUnit.new(@xml)
95
+ baseClass.writeXML(hBase)
96
+
97
+ when 'K', 'kelvin'
98
+ hBase[:identifier] = 'kelvin'
99
+ hBase[:name] = 'kelvin'
100
+ hBase[:catalogSymbol] = 'K'
101
+
102
+ baseClass = BaseUnit.new(@xml)
103
+ baseClass.writeXML(hBase)
104
+
105
+ when 'mol', 'mole', 'moles'
106
+ hBase[:identifier] = 'mole'
107
+ hBase[:name] = 'mole'
108
+ hBase[:catalogSymbol] = 'mol'
109
+
110
+ baseClass = BaseUnit.new(@xml)
111
+ baseClass.writeXML(hBase)
112
+
113
+ when 'cd', 'candela', 'candelas'
114
+ hBase[:identifier] = 'candela'
115
+ hBase[:name] = 'candela'
116
+ hBase[:catalogSymbol] = 'cd'
117
+
118
+ baseClass = BaseUnit.new(@xml)
119
+ baseClass.writeXML(hBase)
120
+
121
+ when 'ft', 'foot', 'feet'
122
+ hConvent[:identifier] = 'meter'
123
+ hConvent[:name] = 'foot'
124
+ hConvent[:catalogSymbol] = 'ft'
125
+ hConvent[:preferredUnit] = 'meter'
126
+ hConvent[:factor] = 3.280839
127
+
128
+ convClass = ConventionalUnit.new(@xml)
129
+ convClass.writeXML(hConvent)
130
+
131
+ when 'in', 'inch', 'inches'
132
+ hConvent[:identifier] = 'meter'
133
+ hConvent[:name] = 'inch'
134
+ hConvent[:catalogSymbol] = 'in'
135
+ hConvent[:preferredUnit] = 'meter'
136
+ hConvent[:factor] = 0.0254
137
+
138
+ convClass = ConventionalUnit.new(@xml)
139
+ convClass.writeXML(hConvent)
140
+
141
+ when 'mm', 'millimeter', 'millimeters'
142
+ hConvent[:identifier] = 'meter'
143
+ hConvent[:name] = 'millimeter'
144
+ hConvent[:catalogSymbol] = 'mm'
145
+ hConvent[:preferredUnit] = 'meter'
146
+ hConvent[:factor] = 0.001
147
+
148
+ convClass = ConventionalUnit.new(@xml)
149
+ convClass.writeXML(hConvent)
150
+
151
+ when 'degC', 'centigrade', 'degreesC', 'Celsius'
152
+ hConvent[:identifier] = 'kelvin'
153
+ hConvent[:name] = 'degree Celsius'
154
+ hConvent[:catalogSymbol] = 'degC'
155
+ hConvent[:preferredUnit] = 'kelvin'
156
+ hConvent[:a] = 273.16
157
+ hConvent[:b] = 1
158
+ hConvent[:c] = 1
159
+ hConvent[:d] = 0
160
+
161
+ convClass = ConventionalUnit.new(@xml)
162
+ convClass.writeXML(hConvent)
163
+
164
+ when 'degF', 'degreesF', 'Fahrenheit'
165
+ hConvent[:identifier] = 'kelvin'
166
+ hConvent[:name] = 'degree Fahrenheit'
167
+ hConvent[:catalogSymbol] = 'degF'
168
+ hConvent[:preferredUnit] = 'kelvin'
169
+ hConvent[:a] = 2298.44
170
+ hConvent[:b] = 5
171
+ hConvent[:c] = 9
172
+ hConvent[:d] = 0
173
+
174
+ convClass = ConventionalUnit.new(@xml)
175
+ convClass.writeXML(hConvent)
176
+
177
+ when 'mph', 'miles per hour'
178
+ hConvent[:identifier] = 'mi/h'
179
+ hConvent[:name] = 'miles per hour'
180
+ hConvent[:catalogSymbol] = 'mph'
181
+ hConvent[:preferredUnit] = 'm/s'
182
+ hConvent[:a] = 0
183
+ hConvent[:b] = 1609.344
184
+ hConvent[:c] = 0
185
+ hConvent[:d] = 3600.0
186
+
187
+ convClass = ConventionalUnit.new(@xml)
188
+ convClass.writeXML(hConvent)
189
+
190
+ when 'kph', 'kilometers per hour'
191
+ hConvent[:identifier] = 'k/h'
192
+ hConvent[:name] = 'kilometers per hour'
193
+ hConvent[:catalogSymbol] = 'kph'
194
+ hConvent[:preferredUnit] = 'm/s'
195
+ hConvent[:a] = 0
196
+ hConvent[:b] = 1000
197
+ hConvent[:c] = 0
198
+ hConvent[:d] = 3600
199
+
200
+ convClass = ConventionalUnit.new(@xml)
201
+ convClass.writeXML(hConvent)
202
+
203
+ when 'density'
204
+ hDerived = {}
205
+ hDerived[:identifier] = 'kg/m^3'
206
+ hDerived[:name] = 'kilograms per cubic meter'
207
+ hDerived[:remarks] = 'volumetric mass density'
208
+ hDerived[:catalogSymbol] = 'p'
209
+ unitTerms = []
210
+ unitTerms << { 'uom' => 'kg', 'exponent' => '1' }
211
+ unitTerms << { 'uom' => 'm', 'exponent' => '-3' }
212
+ hDerived[:derivationUnitTerm] = unitTerms
213
+
214
+ dervClass = DerivedUnit.new(@xml)
215
+ dervClass.writeXML(hDerived)
216
+
217
+ else
218
+ defnClass = UnitDefinition.new(@xml)
219
+ defnClass.writeXML(unit)
220
+
221
+ end
222
+ end
223
+
224
+ end