module Mongoid::Geospatial
Main Geospatial
module
include Mongoid::Geospatial
Mongoid
Geospatial
version
Wrappers for GeoRuby github.com/nofxx/georuby
Wrappers for RGeo
github.com/rgeo/rgeo
Constants
- EARTH_RADIUS
Earth radius in multiple units
- EARTH_RADIUS_KM
For distance spherical calculations
- LAT_SYMBOLS
Symbols accepted as 'latitude', 'y'…
- LNG_SYMBOLS
Symbols accepted as 'longitude', 'x'…
- RAD_PER_DEG
- VERSION
Public Class Methods
config()
click to toggle source
# File lib/mongoid/geospatial/config.rb, line 24 def config Config end
configure() { |Config| ... }
click to toggle source
# File lib/mongoid/geospatial/config.rb, line 20 def configure block_given? ? yield(Config) : Config end
with_georuby!()
click to toggle source
# File lib/mongoid/geospatial.rb, line 68 def self.with_georuby! require 'mongoid/geospatial/wrappers/georuby' end
with_rgeo!()
click to toggle source
# File lib/mongoid/geospatial.rb, line 64 def self.with_rgeo! require 'mongoid/geospatial/wrappers/rgeo' end
Public Instance Methods
geo_distance(other)
click to toggle source
With GeoRuby support
@return (Float)
# File lib/mongoid/geospatial/wrappers/georuby.rb, line 27 def geo_distance(other) to_geo.spherical_distance(other.to_geo) end
points()
click to toggle source
# File lib/mongoid/geospatial/wrappers/rgeo.rb, line 31 def points map do |pair| RGeo::Geographic.spherical_factory.point(*pair) end end
rgeo_distance(other)
click to toggle source
Distance with RGeo
@return (Float)
# File lib/mongoid/geospatial/wrappers/rgeo.rb, line 24 def rgeo_distance(other) to_rgeo.distance other.to_rgeo end
to_geo()
click to toggle source
With GeoRuby support
@return (GeoRuby::SimpleFeatures::Point)
# File lib/mongoid/geospatial/wrappers/georuby.rb, line 17 def to_geo return unless valid? GeoRuby::SimpleFeatures::Point.xy(x, y) end
to_rgeo()
click to toggle source
With RGeo
support
@return (RGeo::SphericalFactory::Point)
# File lib/mongoid/geospatial/wrappers/rgeo.rb, line 16 def to_rgeo RGeo::Geographic.spherical_factory.point x, y end