-
The Geohash algorithm takes a latitude/longitude pair and makes a base 32 string out of them. That is useful in itself, it packs the floats in a convenient structure for saving in a database, no need to worry about rounding or significant digits. For example, the geohash of the location of our offices (57.6997, 11.9661) is “u6280rcky”.
Geohashes also have a very useful property: close locations (can) have a common prefix. The reason for this is that geohashes are actually bounding boxes. Chop things off the end and you get a bigger bounding box.
This means that you can do a quick “locations close by” search by using just a regular database index. It’s not guaranteed that two close locations will fall in the same bounding box, one may be just inside and the other just outside. Because of this you have to calculate the adjacent boxes to do a proper search, but it’s still quite an easy operation compared to calculating the Haversine distance between a point and every other point in your database.
There’s a great interactive demonstration of how it works here: http://openlocation.org/geohash/geohash-js/