lib/rgeo/geo_json/coder.rb
def _encode_geometry(object) # :nodoc:
        need_reverse =  (@reverse_coordinates && object.coordinates.flatten.present?)
        case object
        when RGeo::Feature::Point
          coordinates = need_reverse ? object.coordinates.reverse : object.coordinates
          {
            "type" => "Point",
            "coordinates" => coordinates
          }
        when RGeo::Feature::LineString
          coordinates = need_reverse ? object.coordinates.map(&:reverse) : object.coordinates
          {
            "type" => "LineString",
            "coordinates" => coordinates
          }
        when RGeo::Feature::Polygon
          coordinates = need_reverse ? object.coordinates.map {|x| x.map(&:reverse)} : object.coordinates
          {
            "type" => "Polygon",
            "coordinates" => coordinates
          }
        when RGeo::Feature::MultiPoint
          coordinates = need_reverse ? object.coordinates.map(&:reverse) : object.coordinates
          {
            "type" => "MultiPoint",
            "coordinates" => coordinates
          }
        when RGeo::Feature::MultiLineString
          coordinates = need_reverse ? object.coordinates.map { |x| x.map(&:reverse) } : object.coordinates
          {
            "type" => "MultiLineString",
            "coordinates" => coordinates
          }
        when RGeo::Feature::MultiPolygon
          coordinates = need_reverse ? object.coordinates.map {|x| x.map {|x| x.map(&:reverse) }} : object.coordinates
          {
            "type" => "MultiPolygon",
            "coordinates" => coordinates
          }
        when RGeo::Feature::GeometryCollection
          {
            "type" => "GeometryCollection",
            "geometries" => object.map { |geom| _encode_geometry(geom) }
          }
        else
          nil
        end
      end
# Create a new coder settings object. The geo factory is passed as
# a required argument.
#
# Options include:
#
# [<tt>:geo_factory</tt>]
#   Specifies the geo factory to use to create geometry objects.
#   Defaults to the preferred cartesian factory.
# [<tt>:entity_factory</tt>]
#   Specifies an entity factory, which lets you override the types
#   of GeoJSON entities that are created. It defaults to the default
#   RGeo::GeoJSON::EntityFactory, which generates objects of type
#   RGeo::GeoJSON::Feature or RGeo::GeoJSON::FeatureCollection.
#   See RGeo::GeoJSON::EntityFactory for more information.
# [<tt>:json_parser</tt>]
#   Specifies a JSON parser to use when decoding a String or IO
#   object. The value may be a Proc object taking the string as the
#   sole argument and returning the JSON hash, or it may be one of
#   the special values <tt>:json</tt>, <tt>:yajl</tt>, or
#   <tt>:active_support</tt>. Setting one of those special values
#   will require the corresponding library to be available. Note
#   that the <tt>:json</tt> library is present in the standard
#   library in Ruby 1.9.
#   If a parser is not specified, then the decode method will not
#   accept a String or IO object; it will require a Hash.
Create a new coder settings object. The geo factory is passed as
a required argument.

Options include.

[:geo_factory]
Specifies the geo factory to use to create geometry objects.
Defaults to the preferred cartesian factory.
[:entity_factory]
Specifies an entity factory, which lets you override the types
of GeoJSON entities that are created.
Create a new coder settings object . The geo factory is passed as a required argument . Options include . [ : geo_factory ] Specifies the geo factory to use to create geometry objects . Defaults to the preferred cartesian factory . [ : entity_factory ] Specifies an entity factory which lets you override the types of GeoJSON entities that are created .
def _encode_geometry(object) 
        need_reverse =  (@reverse_coordinates && object.coordinates.flatten.present?)
        case object
        when RGeo::Feature::Point
          coordinates = need_reverse ? object.coordinates.reverse : object.coordinates
          {
            "type" => "Point",
            "coordinates" => coordinates
          }
        when RGeo::Feature::LineString
          coordinates = need_reverse ? object.coordinates.map(&:reverse) : object.coordinates
          {
            "type" => "LineString",
            "coordinates" => coordinates
          }
        when RGeo::Feature::Polygon
          coordinates = need_reverse ? object.coordinates.map {|x| x.map(&:reverse)} : object.coordinates
          {
            "type" => "Polygon",
            "coordinates" => coordinates
          }
        when RGeo::Feature::MultiPoint
          coordinates = need_reverse ? object.coordinates.map(&:reverse) : object.coordinates
          {
            "type" => "MultiPoint",
            "coordinates" => coordinates
          }
        when RGeo::Feature::MultiLineString
          coordinates = need_reverse ? object.coordinates.map { |x| x.map(&:reverse) } : object.coordinates
          {
            "type" => "MultiLineString",
            "coordinates" => coordinates
          }
        when RGeo::Feature::MultiPolygon
          coordinates = need_reverse ? object.coordinates.map {|x| x.map {|x| x.map(&:reverse) }} : object.coordinates
          {
            "type" => "MultiPolygon",
            "coordinates" => coordinates
          }
        when RGeo::Feature::GeometryCollection
          {
            "type" => "GeometryCollection",
            "geometries" => object.map { |geom| _encode_geometry(geom) }
          }
        else
          nil
        end
      end
def _encode_geometry ( object ) need_reverse = ( @reverse_coordinates && object . coordinates . flatten . present? ) case object when RGeo :: Feature :: Point coordinates = need_reverse ? object . coordinates . reverse : object . coordinates { "type" => "Point" , "coordinates" => coordinates } when RGeo :: Feature :: LineString coordinates = need_reverse ? object . coordinates . map ( & :reverse ) : object . coordinates { "type" => "LineString" , "coordinates" => coordinates } when RGeo :: Feature :: Polygon coordinates = need_reverse ? object . coordinates . map { | x | x . map ( & :reverse ) } : object . coordinates { "type" => "Polygon" , "coordinates" => coordinates } when RGeo :: Feature :: MultiPoint coordinates = need_reverse ? object . coordinates . map ( & :reverse ) : object . coordinates { "type" => "MultiPoint" , "coordinates" => coordinates } when RGeo :: Feature :: MultiLineString coordinates = need_reverse ? object . coordinates . map { | x | x . map ( & :reverse ) } : object . coordinates { "type" => "MultiLineString" , "coordinates" => coordinates } when RGeo :: Feature :: MultiPolygon coordinates = need_reverse ? object . coordinates . map { | x | x . map { | x | x . map ( & :reverse ) } } : object . coordinates { "type" => "MultiPolygon" , "coordinates" => coordinates } when RGeo :: Feature :: GeometryCollection { "type" => "GeometryCollection" , "geometries" => object . map { | geom | _encode_geometry ( geom ) } } else nil end end
Create a new coder settings object.
Create a new coder settings object .
# :nodoc:
object