lib/mongoid_geospatial/wrappers/georuby.rb in mongoid_geospatial-2.8.3 vs lib/mongoid_geospatial/wrappers/georuby.rb in mongoid_geospatial-3.0.0
- old
+ new
@@ -1,7 +1,7 @@
require 'geo_ruby'
-# require 'mongoid_geospatial/extensions/georuby'
+require 'mongoid_geospatial/extensions/georuby_point'
module Mongoid
module Geospatial
class Point
@@ -9,37 +9,27 @@
def to_geo
GeoRuby::SimpleFeatures::Point.xy(x, y)
end
- def distance other
+ def geo_distance other
to_geo.spherical_distance(other.to_geo)
end
- def self.mongoize(obj)
- case obj
- when GeoRuby::SimpleFeatures::Point then [obj.x, obj.y]
- when Point then obj.mongoize
- when Array then obj.to_xy
- when Hash then obj.to_xy
- else obj
- end
- end
end
-
class Line < GeometryField
def to_geo
- GeoRuby::SimpleFeatures::LineString.from_coordinates([self])
+ GeoRuby::SimpleFeatures::LineString.from_coordinates(self)
end
end
class Polygon < GeometryField
def to_geo
- GeoRuby::SimpleFeatures::Polygon.from_coordinates([self])
+ GeoRuby::SimpleFeatures::Polygon.from_coordinates(self)
end
end
end
end