mongodb - Mongoid geonear query with max distance not working properly -


i confused geonear query mongoid. seems missing , when m trying query points near given coordinates max distance 200 meters form controller following:

     coord.geo_near([params[:lon].to_i,    params[:lat].to_i]).max_distance(200) 

i points available in collection in same order every set of coords provide.

my model:

     class coord      include mongoid::document      include mongoid::geospatial       field :message, :type => string       field :location, type: point, spatial: true      end 

i have created 2dsphere index mongo console:

     db.coords.createindex( { location : "2dsphere" } ) 

i have tried instead of 200 meters provide 0.2/111.2 in case max_distance works degrees in case m not getting results.

use earth radius

to search in 10km radius:

coord.geo_near([params[:lon].to_f, params[:lat].to_f]).max_distance(10.fdiv(6_371))


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -