module ADIWG::Mdtranslator::Readers::MdJson::GeoJson

Public Class Methods

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

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

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

   intGeoEle = {}

   if hGeoJson.has_key?('type')
      if hGeoJson['type'] != ''
         type = hGeoJson['type']
         if %w{ Point LineString Polygon MultiPoint MultiLineString MultiPolygon }.one? {|word| word == type}
            hReturn = GeometryObject.unpack(hGeoJson, responseObj)
            unless hReturn.nil?
               intGeoEle = hReturn
            end
         end
         if type == 'GeometryCollection'
            hReturn = GeometryCollection.unpack(hGeoJson, responseObj)
            unless hReturn.nil?
               intGeoEle = hReturn
            end
         end
         if type == 'Feature'
            hReturn = GeometryFeature.unpack(hGeoJson, responseObj)
            unless hReturn.nil?
               intGeoEle = hReturn
            end
         end
         if type == 'FeatureCollection'
            hReturn = FeatureCollection.unpack(hGeoJson, responseObj)
            unless hReturn.nil?
               intGeoEle = hReturn
            end
         end
         if intGeoEle.empty?
            @MessagePath.issueError(341, responseObj, inContext)
         end

      end
   end

   return intGeoEle

end