lib/adiwg/mdtranslator/readers/mdJson/modules/module_geodetic.rb in adiwg-mdtranslator-2.13.0 vs lib/adiwg/mdtranslator/readers/mdJson/modules/module_geodetic.rb in adiwg-mdtranslator-2.13.1

- old
+ new

@@ -1,10 +1,10 @@ # unpack spatial reference system ellipsoid # Reader - ADIwg JSON to internal data structure # History: -# Stan Smith 2018-02-18 refactored error and warning messaging +# Stan Smith 2018-06-19 refactored error and warning messaging # Stan Smith 2017-10-23 original script require_relative 'module_identifier' module ADIWG @@ -12,26 +12,31 @@ module Readers module MdJson module Geodetic - def self.unpack(hGeodetic, responseObj) + def self.unpack(hGeodetic, responseObj, inContext = nil) + @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson + # return nil object if input is empty if hGeodetic.empty? - responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: spatial reference geodetic object is empty' + @MessagePath.issueWarning(310, responseObj, inContext) return nil end # instance classes needed in script intMetadataClass = InternalMetadata.new intGeodetic = intMetadataClass.newGeodetic + outContext = 'geodetic parameters' + outContext = inContext + ' > ' + outContext unless inContext.nil? + # geodetic - datum identifier {identifier} if hGeodetic.has_key?('datumIdentifier') unless hGeodetic['datumIdentifier'].empty? - hReturn = Identifier.unpack(hGeodetic['datumIdentifier'], responseObj) + hReturn = Identifier.unpack(hGeodetic['datumIdentifier'], responseObj, outContext) unless hReturn.nil? intGeodetic[:datumIdentifier] = hReturn end end end @@ -44,11 +49,11 @@ end # geodetic - ellipsoid identifier {identifier} if hGeodetic.has_key?('ellipsoidIdentifier') unless hGeodetic['ellipsoidIdentifier'].empty? - hReturn = Identifier.unpack(hGeodetic['ellipsoidIdentifier'], responseObj) + hReturn = Identifier.unpack(hGeodetic['ellipsoidIdentifier'], responseObj, outContext) unless hReturn.nil? intGeodetic[:ellipsoidIdentifier] = hReturn end end end @@ -56,12 +61,10 @@ # geodetic - ellipsoid name (required) if hGeodetic.has_key?('ellipsoidName') intGeodetic[:ellipsoidName] = hGeodetic['ellipsoidName'] end if intGeodetic[:ellipsoidName].nil? || intGeodetic[:ellipsoidName] == '' - responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: spatial reference geodetic ellipsoid name is missing' - responseObj[:readerExecutionPass] = false - return nil + @MessagePath.issueError(311, responseObj, inContext) end # geodetic - semi-major axis if hGeodetic.has_key?('semiMajorAxis') unless hGeodetic['semiMajorAxis'] == ''