lib/rgeo/geo_json/coder.rb
# Decode an object from GeoJSON. The input may be a JSON hash, a
# String, or an IO object from which to read the JSON string.
# If an error occurs, nil is returned.
Decode an object from GeoJSON. The input may be a JSON hash, a
String, or an IO object from which to read the JSON string.
If an error occurs, nil is returned.
Decode an object from GeoJSON . The input may be a JSON hash a String or an IO object from which to read the JSON string . If an error occurs nil is returned .
def decode(input)
        if input.is_a?(IO)
          input = input.read rescue nil
        end
        if input.is_a?(String)
          input = MultiJson.load(input)
        end
        return unless input.is_a?(Hash)
        case input["type"]
        when "FeatureCollection"
          features = input["features"]
          features = [] unless features.is_a?(Array)
          decoded_features = []
          features.each do |f|
            if f["type"] == "Feature"
              decoded_features << decode_feature(f)
            end
          end
          @entity_factory.feature_collection(decoded_features)
        when "Feature"
          decode_feature(input)
        else
          decode_geometry(input)
        end
      end
def decode ( input ) if input . is_a? ( IO ) input = input . read rescue nil end if input . is_a? ( String ) input = MultiJson . load ( input ) end return unless input . is_a? ( Hash ) case input [ "type" ] when "FeatureCollection" features = input [ "features" ] features = [ ] unless features . is_a? ( Array ) decoded_features = [ ] features . each do | f | if f [ "type" ] == "Feature" decoded_features << decode_feature ( f ) end end @entity_factory . feature_collection ( decoded_features ) when "Feature" decode_feature ( input ) else decode_geometry ( input ) end end
Decode an object from GeoJSON.
Decode an object from GeoJSON .
input
<not_specific>