Couchbase
  • Why NoSQL?
  • Couchbase Server
  • Download
  • Resources
  • Careers
Home | Forums | SDKs | SDKs

Question regarding geographic queries

1 reply [Last post]
  • Login or register to post comments
Sun, 04/29/2012 - 15:18
ozba
Offline
Joined: 04/29/2012
Groups: None

Hi,
Our team is currently working on some killer ios location app that we fear "explode" in a good way, so we want to put effort thinking about scalability and Availability.

After we read that draw something is based on your no sql, we scanned the couch base api (specifically the .net one) and found solutions to all of our app requirements except one, and we describe the scenario:

1. Let's say we have order of 1,000,000 users around the world, with their location specified by longitude and latitude;
2. We have a user circle range c: it's location (specified by longitude and latitude) and a radius rc
3. We want to efficiently determine which of the users are in the circle.

If we write it in sql server as we did now it's something like this:

CREATE TABLE UserLocations
[UserId] [bigint] NOT NULL,
[CurrentLocation] [geography] NOT NULL

ALTER PROCEDURE sp_GetCurrentUsersInRange
@userPoint geography,
@RangeInMeters int
AS
BEGIN

select UserId from UserLocations
where @userPoint.STDistance(CurrentLocation) <= @RangeInMeters
and UserId <> @userId

END

But this is No SQL, there are only keys (such as longitude key and latitude key), but we can’t fetch all the values and query them all in memory
, can't we?

So the question to you is:
Is there a way you know how to accomplish such thing in couchbase?

Thank you very much,
Oz

p.s. our related question in Stackoverflow: http://stackoverflow.com/questions/10211579/how-to-determine-n-locations...

Top
  • Login or register to post comments
Wed, 05/02/2012 - 03:02
vmx
Offline
Joined: 02/14/2011
Groups: None

Hi Oz,

with Couchbase 2.0 you can create spatial indexes (AFIAK it's not supported by the SDKs yet). There you can make bounding box queries on your lat/lons. You would approximate the circle by a box, and the filter out client-sided the results that are in the bounding box, but not in the radius.

Cheers,
Volker

Top
  • Login or register to post comments
  • Login or register to post comments
  • Login
  • Register

Company

  • About Us
  • Leadership
  • Customers
  • Partners
  • Contact Us

Product

  • Couchbase Server
  • Couchbase SDKs
  • Use Cases
  • Documentation
  • Forums

Open Source

  • Couchbase Project
  • Couchbase vs. CouchDB

Commercial

  • Subscriptions & Support
  • Training & Services

News

  • Blog
  • Newsletter
  • Press Releases
  • Buzz

Follow Us

    
  • Customer Login
  • Terms of Service
  • Privacy Policy
  • Trademark Policy
  • Site Map

© 2013 COUCHBASE All rights reserved.

Sign in to Couchbase Community

close
  • Create new account
  • Request new password
You are logging into the Forums, Wiki and Issue Tracker