couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Burgess <timburg...@mac.com>
Subject Retrieving documents that have a latitude and longitude intersection
Date Sun, 14 Jun 2009 08:12:41 GMT
I've run up couchdb and am trying to use it to serve JSON requests  
from a browser javascript application (using google maps).
I've been doing this with MySQL and RoR but the replication and the  
ability to simply add image attachments is very appealing to me.

Essentially the client-side requests points that fall within a given  
latitude and longitude boundary i.e. a southwest lat, long and a  
northeast lat,long.
These are my first steps with map/reduce but I've determined how I can  
use startkey and endkey to pull documents within a latitude. I'm
a bit stumped on a URL query that can do both however.

A simple view such as;

function(doc) {
   if (doc.lat && doc.lng) {
     emit([doc.lat, doc.lng], [doc._id, doc.rating, doc.name,  
doc.description]);
   }
}

I'm fortunate in that I'm only having to deal with an area that  
doesn't cross the equator or prime meridian so essentially I just need  
to query
two floats that fall within ranges provided by startkey and endkey.  
I'd be very grateful if someone had some idea as to how to do this..

Cheers!

Tim Burgess
timburgess@mac.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message