Sha256: 03f08df6e34079ddf92944040581d32ad5e8b4de45b3e9242b5be8baaee74cc4

Contents?: true

Size: 511 Bytes

Versions: 3

Compression:

Stored size: 511 Bytes

Contents

module Mongoid
  module Location
    class Polygon
      include Mongoid::Fields::Serializable

      def self.instantiate name, options = {}
        super
      end

      def serialize(object)
        object
      end

      def deserialize(object)
        points = object.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

3 entries across 3 versions & 1 rubygems

Version Path
mongoid_location-0.3.5 lib/mongoid_location/fields/mongoid2/polygon.rb
mongoid_location-0.3.3 lib/mongoid_location/fields/mongoid2/polygon.rb
mongoid_location-0.3.2 lib/mongoid_location/fields/mongoid2/polygon.rb