Sha256: 18107e9d966ed216b776f917be5714e403cae7fd7caddb8070b326768305f414

Contents?: true

Size: 824 Bytes

Versions: 1

Compression:

Stored size: 824 Bytes

Contents

# Sample spec class
class River
  include Mongoid::Document
  include Mongoid::Geospatial

  field :name,        type: String
  field :length,      type: Integer
  field :discharge,   type: Integer
  field :course,      type: LineString,      spatial: true
  # set return_array to true if you do not want a hash returned all the time
  field :source,      type: Point,     spatial: true
  field :mouth,       type: Point,    spatial: { lat: 'latitude', lng: 'longitude' }
  field :mouth_array, type: Array,    spatial: { return_array: true }

  # simplified spatial indexing
  # you can only index one field in mongodb < 1.9
  spatial_index :source
  # alternatives
  # index [[ :spatial, Mongo::GEO2D ]], {min:-400, max:400}
  # index [[ :spatial, Mongo::GEO2D ]], {bit:32}
  # index [[ :spatial, Mongo::GEO2D ],:name]
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mongoid-geospatial-4.0.1 spec/models/river.rb