Sha256: a8e22fdb866e977f77621ea60c3bc6684b2b02c4916813f41473a7ec18b315c5

Contents?: true

Size: 776 Bytes

Versions: 8

Compression:

Stored size: 776 Bytes

Contents

class River
  include Mongoid::Document
  include Mongoid::Geospatial

  field :name,              type: String
  field :length,            type: Integer
  field :average_discharge, type: Integer
  field :source,            type: Line,     spatial: true
  # set return_array to true if you do not want a hash returned all the time
  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

8 entries across 8 versions & 1 rubygems

Version Path
mongoid_geospatial-2.8.1 spec/models/river.rb
mongoid_geospatial-2.8.0 spec/models/river.rb
mongoid_geospatial-2.7.2 spec/models/river.rb
mongoid_geospatial-2.7.1 spec/models/river.rb
mongoid_geospatial-2.7.0 spec/models/river.rb
mongoid_geospatial-2.5.1 spec/models/river.rb
mongoid_geospatial-2.5.0 spec/models/river.rb
mongoid_geospatial-2.3.0 spec/models/river.rb