Skip to content

Comment on Show HN: An API to encode and decode coordinates using Geohash

Comments

I honestly don't understand why anyone would use Geohash? Because it's one number instead of 2?

The short definition is "A geohash is a convenient way of expressing a location (anywhere in the world) using a short alphanumeric string, with greater precision obtained with longer strings."

Here's another way to "use a short alphanumeric string" and "get greater precision with longer strings": "37,122", "37.7,122.4", "37.77,122.41", "37.774,122.419"

That seems so simple and universal and has been a standard since before our great grandparents were born, time to disrupt it to save a couple of bytes?

There are some algorithms that are trivial to implement with Geohashes that are non-trivial with lat-long coordinates. For example, given a set of n points find the k nearest neighbors. To do this with geohash you maintain an ordered list of geohashes, and find k points adjacent in the list. Doing this efficiently with lat-long requires some relatively exotic data structures like an R-tree or k-d-tree.

That is a lossy, incorrect algorithm. Sorry, there is not a continuous mapping from one dimension that covers two dimensions.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.