How should nearby queries be done on millions of geocoded items?
-
We're launching MyFavorites in the coming weeks at SXSW. The idea is that people favorite anything (i.e. "Joe Stump is my favorite Speaker at SXSW" or "Stubb's is my favorite BBQ in Austin" or "Foursquare Party is a favorite SXSW 2011 Party of mine"). On our iphone/android app, we have a "nearby" button, which of course loads all the favorites nearby you. I'm now realizing why Twitter doesn't have a "nearby" button on their mobile app. Currently we have a database of cities with a lat/long. We can take a lat/long from a mobile device and determine which city in our database they are closest too, and specify the user is currently in that city. The problem we have now is, how do we display favorites in a 10-mile range of the user? A thought is to query on every city and see what other cities are within 10-miles, then store an array of those cityIDs with each city. When we determine a user is in 'Austin, TX' from their lat/long, then we query all favorites in all the cities that are 10-miles from Austin, TX. We are thinking of not doing radius queries, and instead stick to squares, to reduce the calculus equations. The queries get more complex as the user filters more -- such as specifying a category of 'band' and then seeing just favorites by people they follow, rather than 'everyone'. 'Austin, TX' is a fairly large city (guessing 20-mile+ radius), whereas 'Buffalo, NY' isn't. 'Buffalo, NY' has about 25 cities within a 15-mile radius. A lat/long in North Austin, might be 20-miles from downtown, but in my stated example, would show 'nearby' to a person located in downtown Austin. This is the same problem Twitter would have. Foursquare has a 'nearby' feature when you click 'tips'. But Foursquare can likely determine that within a mile of where your lat/long is, there are 50 places, so they pull the tips from those places, according to distance from the user. This sounds like the same type of problem, but with more distinct lat/long points (places) that (maybe) are pre-determined to know what other places are nearby? How would you solve this problem? What DB/backend architecture would you use?
-
Answer:
We really like Factual, and we use them through SimpleGeo for now. They've got a great database and allow for lots of queries.
Amber Case at Quora Visit the source
Other answers
Have a look at GeoXP API http://sites.google.com/a/geoxp.com/api, or Location Labs' storage service (http://www.locationlabs.com/products/spatial-storage/) or SimpleGeo private beta storage (http://simplegeo.com/products/storage/) Stick to lat/lon, the city adds no real value in your problem, besides maybe determining the optimal search zone around a user. But your fastest pick would be to not think too much about geo search and let one of the three pros mentioned above handle it for you.
Mathias Herberts
This is exactly what SimpleGeo Storage was built to do. EDIT: Additionally, we are no longer in private beta. You can signup and kick the tires now.
Joe Stump
Just in case the recommended sites aren't of particular use to you, I'll throwin my .05 cents worth. It sounds like your problem is granularity, or in the GIS business we call it precision as opposed to accuracy. (as it relates to resolution) I have no idea what your data set looks like or how you are handling it programatically for your application, but from what you described you don't want to hand your user a duplo block when they want a lego right? Use a Degree Minute Second (DMS) to Decimal Degree (DD) translator to make the math easier for your calculations. Austin is 30 16' 0" N / 97 44' 34" E which would translate to 30.266667 97.742778 the numbers of places right of the zero determines precision and eliminates the potential of identifying someone 20 miles away as "nearby". One Arc Second in DMS is = to .000278. Programatically it is easier to set up a bounding box to search for returns by boolean querry from a table than it is to calculate acceptable values inside a radius and pull all the qualified "lego pieces". hope that helps
Jason Feser
you can also consider DeCarta, they have a lot of experience in this area, and been around a while.
Rama Aysola
Related Q & A:
- How to do SQL inner queries through SQLAlchemy?Best solution by Stack Overflow
- How much does it cost for me to put some items on eBay?Best solution by pages.ebay.com
- How do I get a job after school is done?Best solution by wikihow.com
- How should i motivate myself to get my hw done?Best solution by Yahoo! Answers
- How to tell if a turkey is done?Best solution by ChaCha
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.