adiwg-mdtranslator 2.9.2 → 2.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +30 -2
  3. data/lib/adiwg/mdtranslator/internal/internal_metadata_obj.rb +8 -8
  4. data/lib/adiwg/mdtranslator/internal/module_dateTimeFun.rb +179 -160
  5. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_albers.rb +1 -2
  6. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_azimuthEquidistant.rb +1 -2
  7. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_equidistantConic.rb +1 -2
  8. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_equirectangular.rb +1 -2
  9. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_generalVertical.rb +1 -2
  10. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_gnomonic.rb +1 -2
  11. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_lambertConic.rb +1 -2
  12. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_lambertEqualArea.rb +1 -2
  13. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_mercator.rb +1 -2
  14. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_millerCylinder.rb +1 -2
  15. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_modifiedAlaska.rb +1 -2
  16. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_obliqueMercator.rb +1 -2
  17. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_orthographic.rb +1 -2
  18. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_polarStereo.rb +1 -2
  19. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_polyconic.rb +1 -2
  20. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_robinson.rb +1 -2
  21. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_sinusoidal.rb +1 -2
  22. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_spaceOblique.rb +1 -2
  23. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_stereographic.rb +1 -2
  24. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_transverseMercator.rb +1 -2
  25. data/lib/adiwg/mdtranslator/readers/fgdc/modules/mapProjections/projection_vanDerGrinten.rb +1 -2
  26. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_attribute.rb +16 -4
  27. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_citation.rb +14 -1
  28. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_codeSet.rb +8 -2
  29. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_contact.rb +36 -8
  30. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_date.rb +2 -2
  31. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_dateTime.rb +2 -2
  32. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_digitalForm.rb +8 -2
  33. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_distribution.rb +8 -2
  34. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entity.rb +12 -3
  35. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityAttribute.rb +5 -0
  36. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_entityOverview.rb +4 -1
  37. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_enumerated.rb +12 -3
  38. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_fgdc.rb +2 -2
  39. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_geodeticReference.rb +13 -4
  40. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_geographicResolution.rb +13 -4
  41. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_geologicAge.rb +6 -0
  42. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_horizontalReference.rb +3 -3
  43. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_identification.rb +58 -12
  44. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_keyword.rb +36 -0
  45. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_lineage.rb +8 -2
  46. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_localSystem.rb +1 -1
  47. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_mapCoordinateInfo.rb +51 -12
  48. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_mapGridSystem.rb +46 -9
  49. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_mapLocalPlanar.rb +8 -2
  50. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_mapProjection.rb +4 -1
  51. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_metadataInfo.rb +10 -4
  52. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_methodology.rb +4 -1
  53. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_offlineOption.rb +16 -4
  54. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_onlineOption.rb +13 -4
  55. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_orderProcess.rb +9 -1
  56. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_pointVector.rb +21 -4
  57. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_process.rb +8 -1
  58. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_publication.rb +8 -2
  59. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_quality.rb +14 -3
  60. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_range.rb +8 -2
  61. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_raster.rb +12 -3
  62. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_security.rb +12 -3
  63. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_series.rb +8 -2
  64. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_source.rb +20 -5
  65. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_spatialDomain.rb +32 -8
  66. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonClass.rb +8 -2
  67. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonSystem.rb +20 -5
  68. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_taxonomy.rb +8 -2
  69. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_transferInfo.rb +4 -1
  70. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_verticalAltitude.rb +12 -3
  71. data/lib/adiwg/mdtranslator/readers/fgdc/modules/module_verticalDepth.rb +9 -0
  72. data/lib/adiwg/mdtranslator/readers/fgdc/version.rb +2 -1
  73. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_reader.rb +10 -10
  74. data/lib/adiwg/mdtranslator/readers/mdJson/mdJson_validator.rb +13 -16
  75. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_additionalDocumentation.rb +55 -55
  76. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_address.rb +85 -85
  77. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_allocation.rb +8 -8
  78. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_associatedResource.rb +91 -92
  79. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_attribute.rb +212 -212
  80. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_attributeGroup.rb +43 -43
  81. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_bearingDistanceResolution.rb +8 -8
  82. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_boundingBox.rb +11 -11
  83. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_citation.rb +17 -17
  84. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_constraint.rb +26 -13
  85. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_contact.rb +13 -12
  86. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_coordinateResolution.rb +8 -5
  87. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_coverageDescription.rb +77 -77
  88. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dataDictionary.rb +9 -7
  89. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_date.rb +54 -54
  90. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dateTime.rb +35 -35
  91. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_dimension.rb +70 -70
  92. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_distribution.rb +15 -4
  93. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_distributor.rb +53 -53
  94. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_domain.rb +5 -5
  95. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_domainItem.rb +5 -5
  96. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_duration.rb +92 -91
  97. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entity.rb +10 -10
  98. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityAttribute.rb +28 -18
  99. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityForeignKey.rb +58 -59
  100. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_entityIndex.rb +52 -53
  101. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_extent.rb +70 -56
  102. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_featureCollection.rb +64 -63
  103. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_format.rb +6 -6
  104. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_funding.rb +9 -6
  105. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geoJson.rb +47 -47
  106. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geodetic.rb +7 -7
  107. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geographicExtent.rb +12 -7
  108. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geographicResolution.rb +6 -5
  109. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geologicAge.rb +6 -6
  110. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryCollection.rb +63 -63
  111. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryFeature.rb +84 -84
  112. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryObject.rb +50 -49
  113. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_geometryProperties.rb +57 -57
  114. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_georectifiedRepresentation.rb +115 -100
  115. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_georeferenceableRepresentation.rb +85 -82
  116. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_gmlIdentifier.rb +46 -46
  117. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_graphic.rb +78 -78
  118. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_gridRepresentation.rb +61 -56
  119. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_identifier.rb +72 -72
  120. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_imageDescription.rb +106 -107
  121. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_keyword.rb +4 -4
  122. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_keywordObject.rb +46 -46
  123. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_legalConstraint.rb +55 -51
  124. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_lineage.rb +87 -83
  125. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_locale.rb +46 -46
  126. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_maintenance.rb +73 -74
  127. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_mdJson.rb +11 -5
  128. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_measure.rb +56 -55
  129. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_medium.rb +88 -88
  130. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadata.rb +106 -105
  131. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadataInfo.rb +4 -3
  132. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_metadataRepository.rb +4 -4
  133. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_obliqueLinePoint.rb +7 -4
  134. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_onlineResource.rb +60 -61
  135. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_orderProcess.rb +47 -47
  136. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_party.rb +57 -57
  137. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_phone.rb +49 -51
  138. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_processStep.rb +6 -6
  139. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_projectionParameters.rb +31 -30
  140. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_referenceSystemParameters.rb +16 -2
  141. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_releasability.rb +53 -47
  142. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceInfo.rb +15 -13
  143. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceType.rb +46 -46
  144. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_resourceUsage.rb +95 -95
  145. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_responsibleParty.rb +67 -67
  146. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_schema.rb +47 -46
  147. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_scope.rb +47 -47
  148. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_scopeDescription.rb +68 -63
  149. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_securityConstraint.rb +50 -50
  150. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_series.rb +38 -38
  151. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_source.rb +8 -8
  152. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialReference.rb +6 -5
  153. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialRepresentation.rb +77 -75
  154. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialResolution.rb +8 -14
  155. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_taxonomicClassification.rb +71 -72
  156. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_taxonomicSystem.rb +46 -45
  157. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_taxonomy.rb +118 -116
  158. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_temporalExtent.rb +48 -46
  159. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timeInstant.rb +8 -8
  160. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timeInterval.rb +50 -50
  161. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_timePeriod.rb +21 -14
  162. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_transferOption.rb +86 -75
  163. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_valueRange.rb +4 -4
  164. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_vectorObject.rb +45 -45
  165. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_vectorRepresentation.rb +45 -33
  166. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_verticalDatum.rb +28 -6
  167. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_verticalExtent.rb +59 -59
  168. data/lib/adiwg/mdtranslator/readers/mdJson/modules/module_voucher.rb +43 -43
  169. data/lib/adiwg/mdtranslator/readers/mdReaders.rb +6 -2
  170. data/lib/adiwg/mdtranslator/version.rb +9 -1
  171. data/lib/adiwg/mdtranslator/writers/html/sections/html_entityAttribute.rb +3 -3
  172. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_featureConstraint.rb +50 -46
  173. data/lib/adiwg/mdtranslator/writers/iso19110/classes/class_multiplicity.rb +53 -43
  174. data/lib/adiwg/mdtranslator/writers/iso19110/version.rb +3 -1
  175. data/lib/adiwg/mdtranslator/writers/mdJson/sections/mdJson_entityAttribute.rb +1 -1
  176. data/lib/adiwg/mdtranslator/writers/mdWriters.rb +58 -58
  177. data/lib/adiwg/mdtranslator.rb +177 -165
  178. data/lib/adiwg/mdtranslator_cli.rb +8 -3
  179. metadata +2 -2
@@ -2,6 +2,7 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
+ # Stan Smith 2018-02-18 refactored error and warning messaging
5
6
  # Stan Smith 2017-08-30 refactored for mdJson schema 2.3
6
7
  # Stan Smith 2016-10-30 original script
7
8
 
@@ -19,8 +20,7 @@ module ADIWG
19
20
 
20
21
  # return nil object if input is empty
21
22
  if hFunding.empty?
22
- responseObj[:readerExecutionMessages] << 'Funding object is empty'
23
- responseObj[:readerExecutionPass] = false
23
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: funding object is empty'
24
24
  return nil
25
25
  end
26
26
 
@@ -30,10 +30,12 @@ module ADIWG
30
30
 
31
31
  # funding - description
32
32
  if hFunding.has_key?('description')
33
- intFunding[:description] = hFunding['description']
33
+ unless hFunding['description'] == ''
34
+ intFunding[:description] = hFunding['description']
35
+ end
34
36
  end
35
37
 
36
- # funding - timePeriod
38
+ # funding - timePeriod (required if)
37
39
  if hFunding.has_key?('timePeriod')
38
40
  hObject = hFunding['timePeriod']
39
41
  unless hObject.empty?
@@ -44,7 +46,7 @@ module ADIWG
44
46
  end
45
47
  end
46
48
 
47
- # funding - allocation []
49
+ # funding - allocation [] (required if)
48
50
  if hFunding.has_key?('allocation')
49
51
  aItems = hFunding['allocation']
50
52
  aItems.each do |item|
@@ -55,8 +57,9 @@ module ADIWG
55
57
  end
56
58
  end
57
59
 
60
+ # error messages
58
61
  if intFunding[:allocations].empty? && intFunding[:timePeriod].empty?
59
- responseObj[:readerExecutionMessages] << 'Funding must have either an allocation or timePeriod'
62
+ responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: funding must have either allocation or timePeriod'
60
63
  responseObj[:readerExecutionPass] = false
61
64
  return nil
62
65
  end
@@ -2,7 +2,8 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-10-25 original script
5
+ # Stan Smith 2018-02-18 refactored error and warning messaging
6
+ # Stan Smith 2016-10-25 original script
6
7
 
7
8
  require_relative 'module_geometryObject'
8
9
  require_relative 'module_geometryCollection'
@@ -10,61 +11,60 @@ require_relative 'module_geometryFeature'
10
11
  require_relative 'module_featureCollection'
11
12
 
12
13
  module ADIWG
13
- module Mdtranslator
14
- module Readers
15
- module MdJson
14
+ module Mdtranslator
15
+ module Readers
16
+ module MdJson
16
17
 
17
- module GeoJson
18
+ module GeoJson
18
19
 
19
- def self.unpack(hGeoJson, responseObj)
20
+ def self.unpack(hGeoJson, responseObj)
20
21
 
21
- # return nil object if input is empty
22
- if hGeoJson.empty?
23
- responseObj[:readerExecutionMessages] << 'GeoJson object is empty'
24
- responseObj[:readerExecutionPass] = false
25
- return nil
26
- end
27
-
28
- intGeoEle = {}
22
+ # return nil object if input is empty
23
+ if hGeoJson.empty?
24
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: GeoJSON object is empty'
25
+ return nil
26
+ end
29
27
 
30
- if hGeoJson.has_key?('type')
31
- if hGeoJson['type'] != ''
32
- type = hGeoJson['type']
33
- if %w{ Point LineString Polygon MultiPoint MultiLineString MultiPolygon }.one? { |word| word == type }
34
- hReturn = GeometryObject.unpack(hGeoJson, responseObj)
35
- unless hReturn.nil?
36
- intGeoEle = hReturn
37
- end
38
- end
39
- if type == 'GeometryCollection'
40
- hReturn = GeometryCollection.unpack(hGeoJson, responseObj)
41
- unless hReturn.nil?
42
- intGeoEle = hReturn
43
- end
44
- end
45
- if type == 'Feature'
46
- hReturn = GeometryFeature.unpack(hGeoJson, responseObj)
47
- unless hReturn.nil?
48
- intGeoEle = hReturn
49
- end
50
- end
51
- if type == 'FeatureCollection'
52
- hReturn = FeatureCollection.unpack(hGeoJson, responseObj)
53
- unless hReturn.nil?
54
- intGeoEle = hReturn
55
- end
56
- end
28
+ intGeoEle = {}
57
29
 
58
- end
30
+ if hGeoJson.has_key?('type')
31
+ if hGeoJson['type'] != ''
32
+ type = hGeoJson['type']
33
+ if %w{ Point LineString Polygon MultiPoint MultiLineString MultiPolygon }.one? {|word| word == type}
34
+ hReturn = GeometryObject.unpack(hGeoJson, responseObj)
35
+ unless hReturn.nil?
36
+ intGeoEle = hReturn
37
+ end
38
+ end
39
+ if type == 'GeometryCollection'
40
+ hReturn = GeometryCollection.unpack(hGeoJson, responseObj)
41
+ unless hReturn.nil?
42
+ intGeoEle = hReturn
43
+ end
44
+ end
45
+ if type == 'Feature'
46
+ hReturn = GeometryFeature.unpack(hGeoJson, responseObj)
47
+ unless hReturn.nil?
48
+ intGeoEle = hReturn
49
+ end
50
+ end
51
+ if type == 'FeatureCollection'
52
+ hReturn = FeatureCollection.unpack(hGeoJson, responseObj)
53
+ unless hReturn.nil?
54
+ intGeoEle = hReturn
55
+ end
59
56
  end
60
57
 
61
- return intGeoEle
58
+ end
59
+ end
62
60
 
63
- end
61
+ return intGeoEle
64
62
 
65
- end
63
+ end
66
64
 
67
65
  end
68
- end
69
- end
66
+
67
+ end
68
+ end
69
+ end
70
70
  end
@@ -2,6 +2,7 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
+ # Stan Smith 2018-02-18 refactored error and warning messaging
5
6
  # Stan Smith 2017-10-23 original script
6
7
 
7
8
  require_relative 'module_identifier'
@@ -17,8 +18,7 @@ module ADIWG
17
18
 
18
19
  # return nil object if input is empty
19
20
  if hGeodetic.empty?
20
- responseObj[:readerExecutionMessages] << 'Geodetic object is empty'
21
- responseObj[:readerExecutionPass] = false
21
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: spatial reference geodetic object is empty'
22
22
  return nil
23
23
  end
24
24
 
@@ -38,7 +38,7 @@ module ADIWG
38
38
 
39
39
  # geodetic - datum name
40
40
  if hGeodetic.has_key?('datumName')
41
- if hGeodetic['datumName'] != ''
41
+ unless hGeodetic['datumName'] == ''
42
42
  intGeodetic[:datumName] = hGeodetic['datumName']
43
43
  end
44
44
  end
@@ -58,28 +58,28 @@ module ADIWG
58
58
  intGeodetic[:ellipsoidName] = hGeodetic['ellipsoidName']
59
59
  end
60
60
  if intGeodetic[:ellipsoidName].nil? || intGeodetic[:ellipsoidName] == ''
61
- responseObj[:readerExecutionMessages] << 'Ellipsoid name is missing'
61
+ responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: spatial reference geodetic ellipsoid name is missing'
62
62
  responseObj[:readerExecutionPass] = false
63
63
  return nil
64
64
  end
65
65
 
66
66
  # geodetic - semi-major axis
67
67
  if hGeodetic.has_key?('semiMajorAxis')
68
- if hGeodetic['semiMajorAxis'] != ''
68
+ unless hGeodetic['semiMajorAxis'] == ''
69
69
  intGeodetic[:semiMajorAxis] = hGeodetic['semiMajorAxis']
70
70
  end
71
71
  end
72
72
 
73
73
  # geodetic - axis units
74
74
  if hGeodetic.has_key?('axisUnits')
75
- if hGeodetic['axisUnits'] != ''
75
+ unless['axisUnits'] == ''
76
76
  intGeodetic[:axisUnits] = hGeodetic['axisUnits']
77
77
  end
78
78
  end
79
79
 
80
80
  # geodetic - denominator of flattening ratio
81
81
  if hGeodetic.has_key?('denominatorOfFlatteningRatio')
82
- if hGeodetic['denominatorOfFlatteningRatio'] != ''
82
+ unless hGeodetic['denominatorOfFlatteningRatio'] == ''
83
83
  intGeodetic[:denominatorOfFlatteningRatio] = hGeodetic['denominatorOfFlatteningRatio']
84
84
  end
85
85
  end
@@ -1,7 +1,9 @@
1
+ # Stan Smith 2018-02-18 refactored error and warning messaging
1
2
  # unpack geoJson
2
3
  # Reader - ADIwg JSON to internal data structure
3
4
 
4
5
  # History:
6
+ # Stan Smith 2018-02-18 refactored error and warning messaging
5
7
  # Stan Smith 2017-09-28 added description element to support fgdc
6
8
  # Stan Smith 2016-12-01 original script
7
9
 
@@ -20,8 +22,7 @@ module ADIWG
20
22
 
21
23
  # return nil object if input is empty
22
24
  if hGeoExt.empty?
23
- responseObj[:readerExecutionMessages] << 'geographicExtent object is empty'
24
- responseObj[:readerExecutionPass] = false
25
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: geographic extent object is empty'
25
26
  return nil
26
27
  end
27
28
 
@@ -29,10 +30,13 @@ module ADIWG
29
30
  intMetadataClass = InternalMetadata.new
30
31
  intGeoExt = intMetadataClass.newGeographicExtent
31
32
 
33
+ haveGExtent = false
34
+
32
35
  # geographic extent - description
33
36
  if hGeoExt.has_key?('description')
34
37
  if hGeoExt['description'] != ''
35
38
  intGeoExt[:description] = hGeoExt['description']
39
+ haveGExtent = true
36
40
  end
37
41
  end
38
42
 
@@ -50,6 +54,7 @@ module ADIWG
50
54
  unless hReturn.nil?
51
55
  intGeoExt[:identifier] = hReturn
52
56
  end
57
+ haveGExtent = true
53
58
  end
54
59
  end
55
60
 
@@ -59,6 +64,7 @@ module ADIWG
59
64
  hReturn = BoundingBox.unpack(hGeoExt['boundingBox'], responseObj)
60
65
  unless hReturn.nil?
61
66
  intGeoExt[:boundingBox] = hReturn
67
+ haveGExtent = true
62
68
  end
63
69
  end
64
70
  end
@@ -69,6 +75,7 @@ module ADIWG
69
75
  hReturn = GeoJson.unpack(hElement, responseObj)
70
76
  unless hReturn.nil?
71
77
  intGeoExt[:geographicElements] << hReturn
78
+ haveGExtent = true
72
79
  end
73
80
  end
74
81
  end
@@ -85,12 +92,10 @@ module ADIWG
85
92
  intGeoExt[:computedBbox] = AdiwgCoordinates.computeBbox(intGeoExt[:geographicElements])
86
93
  end
87
94
 
88
- # test for completeness
89
- if intGeoExt[:identifier].empty? &&
90
- intGeoExt[:boundingBox].empty? &&
91
- intGeoExt[:geographicElements].empty?
95
+ # error messages
96
+ unless haveGExtent
92
97
  responseObj[:readerExecutionMessages] <<
93
- 'geographicExtent must have at least one identifier, boundingBox, or geographic element'
98
+ 'ERROR: mdJson reader: geographic extent must have at least one description, identifier, bounding box, or geographic element'
94
99
  responseObj[:readerExecutionPass] = false
95
100
  return nil
96
101
  end
@@ -2,6 +2,7 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
+ # Stan Smith 2018-02-18 refactored error and warning messaging
5
6
  # Stan Smith 2017-10-19 original script
6
7
 
7
8
  module ADIWG
@@ -15,8 +16,7 @@ module ADIWG
15
16
 
16
17
  # return nil object if input is empty
17
18
  if hGeoRes.empty?
18
- responseObj[:readerExecutionMessages] << 'Geographic Resolution object is empty'
19
- responseObj[:readerExecutionPass] = false
19
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: geographic spatial resolution object is empty'
20
20
  return nil
21
21
  end
22
22
 
@@ -29,7 +29,8 @@ module ADIWG
29
29
  intGeoRes[:latitudeResolution] = hGeoRes['latitudeResolution']
30
30
  end
31
31
  if intGeoRes[:latitudeResolution].nil? || intGeoRes[:latitudeResolution] == ''
32
- responseObj[:readerExecutionMessages] << 'Geographic Resolution is missing latitude resolution'
32
+ responseObj[:readerExecutionMessages] <<
33
+ 'WARNING: mdJson reader: geographic spatial resolution latitude resolution is missing'
33
34
  responseObj[:readerExecutionPass] = false
34
35
  return nil
35
36
  end
@@ -39,7 +40,7 @@ module ADIWG
39
40
  intGeoRes[:longitudeResolution] = hGeoRes['longitudeResolution']
40
41
  end
41
42
  if intGeoRes[:longitudeResolution].nil? || intGeoRes[:longitudeResolution] == ''
42
- responseObj[:readerExecutionMessages] << 'Geographic Resolution is missing longitude resolution'
43
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: geographic spatial resolution longitude resolution is missing'
43
44
  responseObj[:readerExecutionPass] = false
44
45
  return nil
45
46
  end
@@ -49,7 +50,7 @@ module ADIWG
49
50
  intGeoRes[:unitOfMeasure] = hGeoRes['unitOfMeasure']
50
51
  end
51
52
  if intGeoRes[:unitOfMeasure].nil? || intGeoRes[:unitOfMeasure] == ''
52
- responseObj[:readerExecutionMessages] << 'Geographic resolution is missing unit of measure'
53
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: geographic spatial resolution units are missing'
53
54
  responseObj[:readerExecutionPass] = false
54
55
  return nil
55
56
  end
@@ -2,6 +2,7 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
+ # Stan Smith 2018-02-18 refactored error and warning messaging
5
6
  # Stan Smith 2017-11-07 original script
6
7
 
7
8
  require_relative 'module_citation'
@@ -17,8 +18,7 @@ module ADIWG
17
18
 
18
19
  # return nil object if input is empty
19
20
  if hGeoAge.empty?
20
- responseObj[:readerExecutionMessages] << 'Geologic Age object is empty'
21
- responseObj[:readerExecutionPass] = false
21
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: geologic age object is empty'
22
22
  return nil
23
23
  end
24
24
 
@@ -31,7 +31,7 @@ module ADIWG
31
31
  intGeoAge[:ageTimeScale] = hGeoAge['ageTimeScale']
32
32
  end
33
33
  if intGeoAge[:ageTimeScale].nil? || intGeoAge[:ageTimeScale] == ''
34
- responseObj[:readerExecutionMessages] << 'Geologic Age is missing time scale'
34
+ responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: geologic age time scale is missing'
35
35
  responseObj[:readerExecutionPass] = false
36
36
  return nil
37
37
  end
@@ -41,21 +41,21 @@ module ADIWG
41
41
  intGeoAge[:ageEstimate] = hGeoAge['ageEstimate']
42
42
  end
43
43
  if intGeoAge[:ageEstimate].nil? || intGeoAge[:ageEstimate] == ''
44
- responseObj[:readerExecutionMessages] << 'Geologic Age is missing age estimate'
44
+ responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: geologic age age-estimate is missing'
45
45
  responseObj[:readerExecutionPass] = false
46
46
  return nil
47
47
  end
48
48
 
49
49
  # geologic age - age uncertainty
50
50
  if hGeoAge.has_key?('ageUncertainty')
51
- if hGeoAge['ageUncertainty'] != ''
51
+ unless hGeoAge['ageUncertainty'] == ''
52
52
  intGeoAge[:ageUncertainty] = hGeoAge['ageUncertainty']
53
53
  end
54
54
  end
55
55
 
56
56
  # geologic age - age explanation
57
57
  if hGeoAge.has_key?('ageExplanation')
58
- if hGeoAge['ageExplanation'] != ''
58
+ unless hGeoAge['ageExplanation'] == ''
59
59
  intGeoAge[:ageExplanation] = hGeoAge['ageExplanation']
60
60
  end
61
61
  end
@@ -2,86 +2,86 @@
2
2
  # Reader - ADIwg JSON to internal data structure
3
3
 
4
4
  # History:
5
- # Stan Smith 2016-11-11 added computedBbox computation
6
- # Stan Smith 2016-10-25 original script
5
+ # Stan Smith 2018-02-18 refactored error and warning messaging
6
+ # Stan Smith 2016-11-11 added computedBbox computation
7
+ # Stan Smith 2016-10-25 original script
7
8
 
8
9
  require_relative 'module_geoJson'
9
10
  require 'adiwg/mdtranslator/internal/module_coordinates'
10
11
 
11
12
  module ADIWG
12
- module Mdtranslator
13
- module Readers
14
- module MdJson
13
+ module Mdtranslator
14
+ module Readers
15
+ module MdJson
15
16
 
16
- module GeometryCollection
17
+ module GeometryCollection
17
18
 
18
- def self.unpack(hGeoCol, responseObj)
19
+ def self.unpack(hGeoCol, responseObj)
19
20
 
20
- # return nil object if input is empty
21
- if hGeoCol.empty?
22
- responseObj[:readerExecutionMessages] << 'Geometry Collection object is empty'
23
- responseObj[:readerExecutionPass] = false
24
- return nil
25
- end
21
+ # return nil object if input is empty
22
+ if hGeoCol.empty?
23
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: GeoJSON geometry collection object is empty'
24
+ return nil
25
+ end
26
26
 
27
- # instance classes needed in script
28
- intMetadataClass = InternalMetadata.new
29
- intGeoCol = intMetadataClass.newGeometryCollection
30
-
31
- # geometry collection - type (required)
32
- if hGeoCol.has_key?('type')
33
- if hGeoCol['type'] != ''
34
- if hGeoCol['type'] == 'GeometryCollection'
35
- intGeoCol[:type] = hGeoCol['type']
36
- else
37
- responseObj[:readerExecutionMessages] << 'Geometry Collection type must be GeometryCollection'
38
- responseObj[:readerExecutionPass] = false
39
- return nil
40
- end
41
- end
42
- end
43
- if intGeoCol[:type].nil? || intGeoCol[:type] == ''
44
- responseObj[:readerExecutionMessages] << 'Geometry Collection is missing type'
45
- responseObj[:readerExecutionPass] = false
46
- return nil
47
- end
27
+ # instance classes needed in script
28
+ intMetadataClass = InternalMetadata.new
29
+ intGeoCol = intMetadataClass.newGeometryCollection
48
30
 
49
- # geometry collection - bounding box
50
- if hGeoCol.has_key?('bbox')
51
- unless hGeoCol['bbox'].empty?
52
- intGeoCol[:bbox] = hGeoCol['bbox']
53
- end
54
- end
55
-
56
- # geometry collection - geometries (required, but can be empty)
57
- if hGeoCol.has_key?('geometries')
58
- hGeoCol['geometries'].each do |hGeometry|
59
- hReturn = GeoJson.unpack(hGeometry, responseObj)
60
- unless hReturn.nil?
61
- intGeoCol[:geometryObjects] << hReturn
62
- end
63
- end
31
+ # geometry collection - type (required)
32
+ if hGeoCol.has_key?('type')
33
+ if hGeoCol['type'] != ''
34
+ if hGeoCol['type'] == 'GeometryCollection'
35
+ intGeoCol[:type] = hGeoCol['type']
64
36
  else
65
- responseObj[:readerExecutionMessages] << 'Geometry Collection is missing geometries'
66
- responseObj[:readerExecutionPass] = false
67
- return nil
37
+ responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: GeoJSON geometry collection type must be GeometryCollection'
38
+ responseObj[:readerExecutionPass] = false
39
+ return nil
68
40
  end
69
-
70
- # geometry collection - compute bbox for geometry collection
71
- unless intGeoCol[:geometryObjects].empty?
72
- intGeoCol[:computedBbox] = AdiwgCoordinates.computeBbox(intGeoCol[:geometryObjects])
41
+ end
42
+ end
43
+ if intGeoCol[:type].nil? || intGeoCol[:type] == ''
44
+ responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: GeoJSON geometry collection type is missing'
45
+ responseObj[:readerExecutionPass] = false
46
+ return nil
47
+ end
48
+
49
+ # geometry collection - bounding box
50
+ if hGeoCol.has_key?('bbox')
51
+ unless hGeoCol['bbox'].empty?
52
+ intGeoCol[:bbox] = hGeoCol['bbox']
53
+ end
54
+ end
55
+
56
+ # geometry collection - geometries (required, but can be empty)
57
+ if hGeoCol.has_key?('geometries')
58
+ hGeoCol['geometries'].each do |hGeometry|
59
+ hReturn = GeoJson.unpack(hGeometry, responseObj)
60
+ unless hReturn.nil?
61
+ intGeoCol[:geometryObjects] << hReturn
73
62
  end
63
+ end
64
+ else
65
+ responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: GeoJSON geometry collection geometries are missing'
66
+ responseObj[:readerExecutionPass] = false
67
+ return nil
68
+ end
74
69
 
75
- # geometry collection - save GeoJSON for the collection
76
- intGeoCol[:nativeGeoJson] = hGeoCol
70
+ # geometry collection - compute bbox for geometry collection
71
+ unless intGeoCol[:geometryObjects].empty?
72
+ intGeoCol[:computedBbox] = AdiwgCoordinates.computeBbox(intGeoCol[:geometryObjects])
73
+ end
77
74
 
78
- return intGeoCol
75
+ # geometry collection - save GeoJSON for the collection
76
+ intGeoCol[:nativeGeoJson] = hGeoCol
79
77
 
80
- end
78
+ return intGeoCol
81
79
 
82
- end
80
+ end
83
81
 
84
82
  end
85
- end
86
- end
83
+
84
+ end
85
+ end
86
+ end
87
87
  end