Sha256: 941c60e3b31c854a17e485040d6404bd3cb5250b55c7566d7f1a5607b2d7cb94
Contents?: true
Size: 926 Bytes
Versions: 1
Compression:
Stored size: 926 Bytes
Contents
require 'rgeo' require 'mongoid_geospatial/ext/rgeo_spherical_point_impl' module Mongoid module Geospatial # Wrapper to Rgeo's Point class Point def to_rgeo RGeo::Geographic.spherical_factory.point x, y end def rgeo_distance(other) to_rgeo.distance other.to_rgeo end end # Rgeo's GeometryField concept class GeometryField private def points map do |pair| RGeo::Geographic.spherical_factory.point(*pair) end end end # Wrapper to Rgeo's Line class Line < GeometryField def to_rgeo RGeo::Geographic.spherical_factory.line_string points end end # Wrapper to Rgeo's Polygon class Polygon < GeometryField def to_rgeo ring = RGeo::Geographic.spherical_factory.linear_ring points RGeo::Geographic.spherical_factory.polygon ring end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mongoid-geospatial-3.9.0 | lib/mongoid/geospatial/wrappers/rgeo.rb |