Sha256: 15da844a7fe67909ec4ae9fe944ce8fa751700e9cc0df5f0da093d4cbbffd571

Contents?: true

Size: 669 Bytes

Versions: 1

Compression:

Stored size: 669 Bytes

Contents

require 'rgeo'
require 'mongoid_geospatial/extensions/rgeo_spherical_point_impl'

module Mongoid
  module Geospatial

    class Point
      def to_geo
        RGeo::Geographic.spherical_factory.point x, y
      end
    end


    class LineString < GeometryField
      def to_geo
        RGeo::Geographic.spherical_factory.line_string self
      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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid_geospatial-2.2.0 lib/mongoid_geospatial/wrappers/rgeo.rb