lib/rgeo/geo_json/coder.rb
# 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.
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)
        case object
        when RGeo::Feature::Point
          {
            "type" => "Point",
            "coordinates" => object.coordinates
          }
        when RGeo::Feature::LineString
          {
            "type" => "LineString",
            "coordinates" => object.coordinates
          }
        when RGeo::Feature::Polygon
          {
            "type" => "Polygon",
            "coordinates" => object.coordinates
          }
        when RGeo::Feature::MultiPoint
          {
            "type" => "MultiPoint",
            "coordinates" => object.coordinates
          }
        when RGeo::Feature::MultiLineString
          {
            "type" => "MultiLineString",
            "coordinates" => object.coordinates
          }
        when RGeo::Feature::MultiPolygon
          {
            "type" => "MultiPolygon",
            "coordinates" => object.coordinates
          }
        when RGeo::Feature::GeometryCollection
          {
            "type" => "GeometryCollection",
            "geometries" => object.map { |geom| encode_geometry(geom) }
          }
        else
          nil
        end
      end
def encode_geometry ( object ) case object when RGeo :: Feature :: Point { "type" => "Point" , "coordinates" => object . coordinates } when RGeo :: Feature :: LineString { "type" => "LineString" , "coordinates" => object . coordinates } when RGeo :: Feature :: Polygon { "type" => "Polygon" , "coordinates" => object . coordinates } when RGeo :: Feature :: MultiPoint { "type" => "MultiPoint" , "coordinates" => object . coordinates } when RGeo :: Feature :: MultiLineString { "type" => "MultiLineString" , "coordinates" => object . coordinates } when RGeo :: Feature :: MultiPolygon { "type" => "MultiPolygon" , "coordinates" => object . 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 .
object
<not_specific>