Sha256: 1441d3979e5d3bfc0a4e971c9ad4c6f2eeb5a1e11ecfa3b2247bb07feeb672b2
Contents?: true
Size: 858 Bytes
Versions: 1
Compression:
Stored size: 858 Bytes
Contents
require 'geo_ruby' module Mongoid module Geospatial # Wrapper to GeoRuby's Point Point.class_eval do # delegate :distance, to: :to_geo # # With GeoRuby support # # @return (GeoRuby::SimpleFeatures::Point) def to_geo return unless valid? GeoRuby::SimpleFeatures::Point.xy(x, y) end # # With GeoRuby support # # @return (Float) def geo_distance(other) to_geo.spherical_distance(other.to_geo) end end # Wrapper to GeoRuby's LineString LineString.class_eval do def to_geo GeoRuby::SimpleFeatures::LineString.from_coordinates(self) end end # Wrapper to GeoRuby's Polygon Polygon.class_eval do def to_geo GeoRuby::SimpleFeatures::Polygon.from_coordinates(self) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-geospatial-4.0.1 | lib/mongoid/geospatial/wrappers/georuby.rb |