# unpack vertical extent # Reader - ADIwg JSON to internal data structure # History: # Stan Smith 2018-02-19 refactored error and warning messaging # Stan Smith 2016-10-24 original script require_relative 'module_spatialReference' module ADIWG module Mdtranslator module Readers module MdJson module VerticalExtent def self.unpack(hVertical, responseObj) # return nil object if input is empty if hVertical.empty? responseObj[:readerExecutionMessages] << 'WARNING: mdJson reader: vertical extent object is empty' return nil end # instance classes needed in script intMetadataClass = InternalMetadata.new intVertical = intMetadataClass.newVerticalExtent # vertical extent - description if hVertical.has_key?('description') unless hVertical['description'] == '' intVertical[:description] = hVertical['description'] end end # vertical extent - min value (required) if hVertical.has_key?('minValue') intVertical[:minValue] = hVertical['minValue'] end if intVertical[:minValue].nil? || intVertical[:minValue] == '' responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: vertical extent minimum value is missing' responseObj[:readerExecutionPass] = false return nil end # vertical extent - max value (required) if hVertical.has_key?('maxValue') intVertical[:maxValue] = hVertical['maxValue'] end if intVertical[:maxValue].nil? || intVertical[:maxValue] == '' responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: vertical extent maximum value is missing' responseObj[:readerExecutionPass] = false return nil end # vertical extent - crs ID {spatialReference} (required) if hVertical.has_key?('crsId') hObject = hVertical['crsId'] unless hObject.empty? hReturn = SpatialReferenceSystem.unpack(hObject, responseObj) unless hReturn.nil? intVertical[:crsId] = hReturn end end end if intVertical[:crsId].empty? responseObj[:readerExecutionMessages] << 'ERROR: mdJson reader: vertical extent CRS identifier is missing' responseObj[:readerExecutionPass] = false return nil end return intVertical end end end end end end