How to use geohash in a url using ExpressJS
There are many examples of geohash on Github so think of this as a mini example of how to send latitude and longitude coordinates to a URL and receive a geohash.
Geohashes simplifies converting latitude and longitude into a hashed string so that you can store it to your database. Yes, there are many good tools out there like Couchbase, MongoDb and CartoDB but this method works too.
Geohash is an algorithm that was created by Gustavo Niemeyer in 2008. By interleaving latitude and longitude in a bitwise fashion, a composite string is generated that uniquely identifies a geographic point. This string can then be easily stored or used to transmit location point data.
Since the latitude and longitude are interleaved, geohashes have an unique property. As the number of characters decreases from the right side of the string, the accuracy decreases. Points that share similar prefixes will be close together. However, though points can be on the edge of a Geohash bounding box, not all nearby points will share similar prefixes. Since geohashes are easily stored and indexed as strings, in environ- ments and datastores that don’t have strong spatial indexing support, geohashes can be used.
The special handling of proximity queries for points on the edge of a Geohash bounding box can be compensated for by doing lookups and queries of the surrounding Geohash bounding boxes.
- Download the package and unzip it.
- $ cd /path/of/geohash
- $ sudo npm install
- $ npm start