|
module Geospatial |
|
# Wrapper to Rgeo's Point |
|
Point.class_eval do |
|
# |
|
# With RGeo support |
|
# |
|
# @return (RGeo::SphericalFactory::Point) |
|
def to_rgeo |
|
RGeo::Geographic.spherical_factory.point x, y |
|
end |
Here, and everywhere else, the spherical_factory is being used to convert geometries from geospatial Objects into RGeos objects. However, this may not always be the best choice.
The library geo_json already has a solution, that may serve as a guide:
https://github.com/rgeo/rgeo-geojson/blob/6c76aced209969692a51364d6765b45c61eabf08/lib/rgeo/geo_json/coder.rb#L23-L24
mongoid-geospatial/lib/mongoid/geospatial/wrappers/rgeo.rb
Lines 9 to 18 in 9d25a5a
Here, and everywhere else, the spherical_factory is being used to convert geometries from geospatial Objects into RGeos objects. However, this may not always be the best choice.
The library geo_json already has a solution, that may serve as a guide:
https://github.com/rgeo/rgeo-geojson/blob/6c76aced209969692a51364d6765b45c61eabf08/lib/rgeo/geo_json/coder.rb#L23-L24