Module: RGeo::GeoJSON::ConversionMethods

Included in:
Feature, FeatureCollection
Defined in:
lib/rgeo/geo_json/conversion_methods.rb

Overview

This module serves to provide handy methods when using GeoJSON. The methods provided eases the passage between entities and GeoJSON String/Hash.

Instance Method Summary collapse

Instance Method Details

#as_geojsonObject Also known as: as_json

Convert a geometry to a GeoJSON Hash



8
9
10
# File 'lib/rgeo/geo_json/conversion_methods.rb', line 8

def as_geojson
  GeoJSON.encode(self)
end

#to_geojsonObject Also known as: to_json

Convert a geometry to a GeoJSON String



14
15
16
# File 'lib/rgeo/geo_json/conversion_methods.rb', line 14

def to_geojson
  ::MultiJson.dump(as_geojson)
end