lib/rgeo/geo_json/coder.rb
# Encode the given object as GeoJSON. The object may be one of the
# geometry objects specified in RGeo::Feature, or an appropriate
# GeoJSON wrapper entity supported by this coder's entity factory.
#
# This method returns a JSON object (i.e. a hash). In order to
# generate a string suitable for transmitting to a service, you
# will need to JSON-encode it. This is usually accomplished by
# calling <tt>to_json</tt> on the hash object, if you have the
# appropriate JSON library installed.
#
# Returns nil if nil is passed in as the object.
Encode the given object as GeoJSON. The object may be one of the
geometry objects specified in RGeo::Feature, or an appropriate
GeoJSON wrapper entity supported by this coder's entity factory.

This method returns a JSON object . In order to
generate a string suitable for transmitting to a service, you
will need to JSON-encode it. This is usually accomplished by
calling to_json on the hash object, if you have the
appropriate JSON library installed.

Returns nil if nil is passed in as the object.
Encode the given object as GeoJSON . The object may be one of the geometry objects specified in RGeo :: Feature or an appropriate GeoJSON wrapper entity supported by this coder ' s entity factory . This method returns a JSON object . In order to generate a string suitable for transmitting to a service you will need to JSON - encode it . This is usually accomplished by calling to_json on the hash object if you have the appropriate JSON library installed . Returns nil if nil is passed in as the object .
def encode(object)
        if @entity_factory.is_feature_collection?(object)
          {
            "type" => "FeatureCollection",
            "features" => @entity_factory.map_feature_collection(object) { |f| encode_feature(f) },
          }
        elsif @entity_factory.is_feature?(object)
          encode_feature(object)
        elsif object.nil?
          nil
        else
          encode_geometry(object)
        end
      end
def encode ( object ) if @entity_factory . is_feature_collection? ( object ) { "type" => "FeatureCollection" , "features" => @entity_factory . map_feature_collection ( object ) { | f | encode_feature ( f ) } , } elsif @entity_factory . is_feature? ( object ) encode_feature ( object ) elsif object . nil? nil else encode_geometry ( object ) end end
Encode the given object as GeoJSON.
Encode the given object as GeoJSON .
object
<not_specific>