Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Help using near with maxDistance in a model. Mongo::OperationFailure: geo values have to be numbers:
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
NickW  
View profile  
 More options Apr 5 2012, 11:05 am
From: NickW <nickw...@gmail.com>
Date: Thu, 5 Apr 2012 08:05:48 -0700 (PDT)
Local: Thurs, Apr 5 2012 11:05 am
Subject: Help using near with maxDistance in a model. Mongo::OperationFailure: geo values have to be numbers:

I'm trying to add a model method to abstract radius searches within a
given distance and have them ordered by distance. I must be doing
something silly in my query syntax.

>> Site.nearest([-122.0,44.0],200)
>Mongo::OperationFailure: geo values have to be numbers: {$maxDistance: 200, $near: [ -122.0, 44.0 ] }

class Site
  include MongoMapper::Document

  key :id, Integer
  key :name, String
  key :location, Array
  ensure_index [[:location, '2d']]

  def self.nearest(center_point, range)
    where(:location => {'$near' => center_point, '$maxDistance' =>
range}).all
  end

end


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.