lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialResolution.rb in adiwg-mdtranslator-2.9.2 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialResolution.rb in adiwg-mdtranslator-2.10.0
- old
+ new
@@ -1,9 +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 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
@@ -25,33 +26,29 @@
def self.unpack(hResolution, responseObj)
# return nil object if input is empty
if hResolution.empty?
- responseObj[:readerExecutionMessages] << 'Spatial Resolution object is empty'
- responseObj[:readerExecutionPass] = false
+ responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: spatial resolution object is empty'
return nil
end
# instance classes needed in script
intMetadataClass = InternalMetadata.new
intResolution = intMetadataClass.newSpatialResolution
- foundOne = false
haveOne = false
# spatial resolution - scale factor (required if not others)
if hResolution.has_key?('scaleFactor')
- foundOne = true
- if hResolution['scaleFactor'] != ''
+ unless hResolution['scaleFactor'] == ''
intResolution[:scaleFactor] = hResolution['scaleFactor']
haveOne = true
end
end
# spatial resolution - measure (required if not others)
if hResolution.has_key?('measure')
- foundOne = true
hMeasure = hResolution['measure']
unless hMeasure.empty?
hObject = Measure.unpack(hMeasure, responseObj)
unless hObject.nil?
intResolution[:measure] = hObject
@@ -60,11 +57,10 @@
end
end
# spatial resolution - coordinate resolution (required if not others)
if hResolution.has_key?('coordinateResolution')
- foundOne = true
hCoordRes = hResolution['coordinateResolution']
unless hCoordRes.empty?
hReturn = CoordinateResolution.unpack(hCoordRes, responseObj)
unless hReturn.nil?
intResolution[:coordinateResolution] = hReturn
@@ -73,11 +69,10 @@
end
end
# spatial resolution - bearing distance resolution (required if not others)
if hResolution.has_key?('bearingDistanceResolution')
- foundOne = true
hBearRes = hResolution['bearingDistanceResolution']
unless hBearRes.empty?
hReturn = BearingDistanceResolution.unpack(hBearRes, responseObj)
unless hReturn.nil?
intResolution[:bearingDistanceResolution] = hReturn
@@ -86,11 +81,10 @@
end
end
# spatial resolution - geographic resolution (required if not others)
if hResolution.has_key?('geographicResolution')
- foundOne = true
hGeoRes = hResolution['geographicResolution']
unless hGeoRes.empty?
hReturn = GeographicResolution.unpack(hGeoRes, responseObj)
unless hReturn.nil?
intResolution[:geographicResolution] = hReturn
@@ -99,23 +93,23 @@
end
end
# spatial resolution - level of detail (required if not others)
if hResolution.has_key?('levelOfDetail')
- foundOne = true
- if hResolution['levelOfDetail'] != ''
+ unless hResolution['levelOfDetail'] == ''
intResolution[:levelOfDetail] = hResolution['levelOfDetail']
haveOne = true
end
end
- unless foundOne
- responseObj[:readerExecutionMessages] << 'Spatial Resolution did not have an object of supported type'
+ # error messages
+ unless haveOne
+ responseObj[:readerExecutionMessages] <<
+ 'ERROR: mdJson reader: spatial resolution did not have an object of supported type'
responseObj[:readerExecutionPass] = false
return nil
end
- return nil unless haveOne
return intResolution
end
end