module ADIWG::Mdtranslator::Readers::MdJson::SpatialReferenceSystem

Public Class Methods

unpack(hSpatialRef, responseObj, inContext = nil) click to toggle source
# File lib/adiwg/mdtranslator/readers/mdJson/modules/module_spatialReference.rb, line 24
def self.unpack(hSpatialRef, responseObj, inContext = nil)

   @MessagePath = ADIWG::Mdtranslator::Readers::MdJson::MdJson

   # return nil object if input is empty
   if hSpatialRef.empty?
      @MessagePath.issueWarning(780, responseObj, inContext)
      return nil
   end

   # instance classes needed in script
   intMetadataClass = InternalMetadata.new
   intSpatialRef = intMetadataClass.newSpatialReferenceSystem

   outContext = 'spatial reference system'

   haveSystem = false

   # spatial reference system - type
   if hSpatialRef.has_key?('referenceSystemType')
      unless hSpatialRef['referenceSystemType'] == ''
         intSpatialRef[:systemType] = hSpatialRef['referenceSystemType']
         haveSystem = true
      end
   end

   # spatial reference system - reference system {identifier}
   if hSpatialRef.has_key?('referenceSystemIdentifier')
      hObject = hSpatialRef['referenceSystemIdentifier']
      unless hObject.empty?
         hReturn = Identifier.unpack(hObject, responseObj, outContext)
         unless hReturn.nil?
            intSpatialRef[:systemIdentifier] = hReturn
            haveSystem = true
         end
      end
   end

   # spatial reference system - wkt
   if hSpatialRef.has_key?('referenceSystemWKT')
      unless hSpatialRef['referenceSystemWKT'] == ''
         intSpatialRef[:systemWKT] = hSpatialRef['referenceSystemWKT']
         haveSystem = true
      end
   end

   # spatial reference system - reference system parameters {referenceSystemParameterSet}
   if hSpatialRef.has_key?('referenceSystemParameterSet')
      hObject = hSpatialRef['referenceSystemParameterSet']
      unless hObject.empty?
         hReturn = ReferenceSystemParameters.unpack(hObject, responseObj, outContext)
         unless hReturn.nil?
            intSpatialRef[:systemParameterSet] = hReturn
            haveSystem = true
         end
      end
   end

   unless haveSystem
      @MessagePath.issueError(781, responseObj, inContext)
   end

   return intSpatialRef
end