3 ms·
Geohash: http://en.wikipedia.org/wiki/Geohash http://en.wikipedia.org/wiki/Geohash (Edit: to be more specific, you can get a pretty good distance measurement u
by nl 16y ago
Geohash: http://en.wikipedia.org/wiki/Geohash http://en.wikipedia.org/wiki/Geohash
(Edit: to be more specific, you can get a pretty good distance measurement using Geohash and comparing strings. Obviously, indexing strings is something databases do well. The exact distance a single character corresponds to depends on longitude & latitude, but there are lookup tables for that. There are also edge conditions to be aware of which may affect your application)
Or, use Postgres which has geospatial indexes.
- zachster 16y agoThanks for the pointer! This looks interesting. The edge conditions seem like they might pose a problem. I'll have to check out how often it would occur. Maybe the geospatial indexes are a better bet. It looks like MongoDB supports them also. Good excuse to try that out.
- thibaut_barrere 16y agoI've been using either MySQL with Sphinx or MongoDB with the built-in geonear successfully. If you're already using MongoDB, it's really dead-easy to setup (see the docs).
- nl 16y agoIf you are prepared to introduce new technology specifically to solve this problem, then you should take a look at LocalLucene, too: http://www.gissearch.com/locallucene http://www.gissearch.com/locallucene
- bravo_sierra 16y agoThe edge cases happen all the time. Using a B-Tree on a Geohash (like MongoDB does) is a bit more efficient that just indexing min/max values, but not by much. MySQL, PostgreSQL and even SQLite have R-Tree indices that perform 10x better.
- bravo_sierra 16y agoMySQL can use R-Trees too - http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions.html http://dev.mysql.com/doc/refman/5.0/en/spatial-extensions.ht...