Module: RGeo::GeoJSON
- Defined in:
- lib/rgeo/geo_json/coder.rb,
lib/rgeo/geo_json/version.rb,
lib/rgeo/geo_json/interface.rb,
lib/rgeo/geo_json/entities.rb
Defined Under Namespace
Modules: CollectionMethods, ConversionMethods, DelegateToGeometry Classes: Coder, EntityFactory, Feature, FeatureCollection
Constant Summary collapse
- VERSION =
"2.2.0"
Class Method Summary collapse
-
.coder(opts = {}) ⇒ Object
Creates and returns a coder object of type RGeo::GeoJSON::Coder that encapsulates encoding and decoding settings (principally the RGeo::Feature::Factory and the RGeo::GeoJSON::EntityFactory to be used).
-
.decode(input, opts = {}) ⇒ Object
High-level convenience routine for decoding an object from GeoJSON.
-
.encode(object, opts = {}) ⇒ Object
High-level convenience routine for encoding an object as GeoJSON.
Class Method Details
.coder(opts = {}) ⇒ Object
Creates and returns a coder object of type RGeo::GeoJSON::Coder that encapsulates encoding and decoding settings (principally the RGeo::Feature::Factory and the RGeo::GeoJSON::EntityFactory to be used).
The geo factory is a required argument. Other 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. 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.
55 56 57 |
# File 'lib/rgeo/geo_json/interface.rb', line 55 def coder(opts = {}) Coder.new(opts) end |
.decode(input, opts = {}) ⇒ Object
High-level convenience routine for decoding an object from GeoJSON. The input may be a JSON hash, a String, or an IO object from which to read the JSON string.
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. 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.
35 36 37 |
# File 'lib/rgeo/geo_json/interface.rb', line 35 def decode(input, opts = {}) coder(opts).decode(input) end |
.encode(object, opts = {}) ⇒ Object
High-level convenience routine for encoding an object as GeoJSON. Pass the object, which may one of the geometry objects specified in RGeo::Feature, or an appropriate GeoJSON wrapper entity such as RGeo::GeoJSON::Feature or RGeo::GeoJSON::FeatureCollection.
The only option supported is :entity_factory
, which lets you override the types of GeoJSON entities supported. See RGeo::GeoJSON::EntityFactory for more information. By default, encode supports objects of type RGeo::GeoJSON::Feature and RGeo::GeoJSON::FeatureCollection.
16 17 18 |
# File 'lib/rgeo/geo_json/interface.rb', line 16 def encode(object, opts = {}) coder(opts).encode(object) end |