Sha256: a4ddc2f60aa1954e4fd852481738de29a28d500b7cb3ad4cbe8786473b0df5cc

Contents?: true

Size: 776 Bytes

Versions: 3

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: Array,    spatial: true
  # set return_array to true if you do not want a hash returned all the time
  field :mouth,             type: Array,    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

3 entries across 3 versions & 1 rubygems

Version Path
mongoid_geospatial-1.0.0 spec/models/river.rb
mongoid_geospatial-1.0.0rc1 spec/models/river.rb
mongoid_geospatial-1.0.0rc0 spec/models/river.rb