lib/mongoid_geospatial/wrappers/rgeo.rb in mongoid_geospatial-2.7.2 vs lib/mongoid_geospatial/wrappers/rgeo.rb in mongoid_geospatial-2.8.0
- old
+ new
@@ -3,11 +3,10 @@
module Mongoid
module Geospatial
class Point
-
def to_geo
RGeo::Geographic.spherical_factory.point x, y
end
def distance other
@@ -23,25 +22,29 @@
else obj
end
end
end
+ class GeometryField
+ private
+ def points
+ self.map do |pair|
+ RGeo::Geographic.spherical_factory.point(*pair)
+ end
+ end
+ end
class Line < GeometryField
def to_geo
- RGeo::Geographic.spherical_factory.line_string self
+ RGeo::Geographic.spherical_factory.line_string points
end
end
class Polygon < GeometryField
def to_geo
- points = self.map do |pair|
- RGeo::Geographic.spherical_factory.point *pair
- end
ring = RGeo::Geographic.spherical_factory.linear_ring points
RGeo::Geographic.spherical_factory.polygon ring
end
-
end
end
end