lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialResolution.rb in adiwg-mdtranslator-2.13.0 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialResolution.rb in adiwg-mdtranslator-2.13.1
- old
+ new
@@ -1,10 +1,10 @@
# unpack spatial resolution
# Reader - ADIwg JSON to internal data structure
# History:
-# Stan Smith 2018-02-19 refactored error and warning messaging
+# Stan Smith 2018-06-25 refactored error and warning messaging
# Stan Smith 2017-10-19 add geographic resolution
# Stan Smith 2017-10-19 add bearingDistance resolution
# Stan Smith 2017-10-19 add coordinate resolution
# Stan Smith 2016-10-17 refactored for mdJson 2.0
# Stan Smith 2015-07-14 refactored to remove global namespace constants
@@ -22,21 +22,27 @@
module Readers
module MdJson
module SpatialResolution
- def self.unpack(hResolution, responseObj)
+ def self.unpack(hResolution, responseObj, inContext = nil)
+ @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson
+
# return nil object if input is empty
if hResolution.empty?
- responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: spatial resolution object is empty'
+ @MessagePath.issueWarning(800, responseObj, inContext)
return nil
end
# instance classes needed in script
intMetadataClass = InternalMetadata.new
intResolution = intMetadataClass.newSpatialResolution
+
+ outContext = 'spatial resolution'
+ outContext = inContext + ' > ' + outContext unless inContext.nil?
+
haveOne = false
# spatial resolution - scale factor (required if not others)
if hResolution.has_key?('scaleFactor')
unless hResolution['scaleFactor'] == ''
@@ -47,11 +53,11 @@
# spatial resolution - measure (required if not others)
if hResolution.has_key?('measure')
hMeasure = hResolution['measure']
unless hMeasure.empty?
- hObject = Measure.unpack(hMeasure, responseObj)
+ hObject = Measure.unpack(hMeasure, responseObj, outContext)
unless hObject.nil?
intResolution[:measure] = hObject
haveOne = true
end
end
@@ -59,11 +65,11 @@
# spatial resolution - coordinate resolution (required if not others)
if hResolution.has_key?('coordinateResolution')
hCoordRes = hResolution['coordinateResolution']
unless hCoordRes.empty?
- hReturn = CoordinateResolution.unpack(hCoordRes, responseObj)
+ hReturn = CoordinateResolution.unpack(hCoordRes, responseObj, outContext)
unless hReturn.nil?
intResolution[:coordinateResolution] = hReturn
haveOne = true
end
end
@@ -71,11 +77,11 @@
# spatial resolution - bearing distance resolution (required if not others)
if hResolution.has_key?('bearingDistanceResolution')
hBearRes = hResolution['bearingDistanceResolution']
unless hBearRes.empty?
- hReturn = BearingDistanceResolution.unpack(hBearRes, responseObj)
+ hReturn = BearingDistanceResolution.unpack(hBearRes, responseObj, outContext)
unless hReturn.nil?
intResolution[:bearingDistanceResolution] = hReturn
haveOne = true
end
end
@@ -83,11 +89,11 @@
# spatial resolution - geographic resolution (required if not others)
if hResolution.has_key?('geographicResolution')
hGeoRes = hResolution['geographicResolution']
unless hGeoRes.empty?
- hReturn = GeographicResolution.unpack(hGeoRes, responseObj)
+ hReturn = GeographicResolution.unpack(hGeoRes, responseObj, outContext)
unless hReturn.nil?
intResolution[:geographicResolution] = hReturn
haveOne = true
end
end
@@ -101,12 +107,10 @@
end
end
# error messages
unless haveOne
- responseObj[:readerExecutionMessages] <<
- 'WARNING: mdJson reader: spatial resolution did not have an object of supported type'
- return nil
+ @MessagePath.issueError(801, responseObj, inContext)
end
return intResolution
end