GeoHash
!NPM Versionnpm-imagenpm-url !Build statusbuild-imagebuild-url !Coverage statuscoverage-imagecoverage-url !Dependency Statusdavid-imagedavid-url !devDependency Statusdavid-dev-imagedavid-dev-url !GitHub licenselicense-imagelicense-urlGeohash is a public domain geocoding system invented by Gustavo Niemeyer, which encodes a geographic location into a short string of letters and digits. It is a hierarchical spatial data structure which subdivides space into buckets of grid shape, which is one of the many applications of what is known as a Z-order curve, and generally space-filling curves.
Geohashes offer properties like arbitrary precision and the possibility of gradually removing characters from the end of the code to reduce its size (and gradually lose precision). As a consequence of the gradual precision degradation, nearby places will often (but not always) present similar prefixes. The longer a shared prefix is, the closer the two places are.
Read more on Wikipedia.
Usage
Standalone version
Includegeohash.min.js
which you can find in the build folder.<script src="dist/geohash-js/geohash.min.js"></script>
Now you can use library
var hashedValue = geohash.encode(52.372518, 4.896977);
Usage as module
Installation
With npm$ npm install @alexpavlov/geohash-js
or with yarn
$ yarn add @alexpavlov/geohash-js
Add to your module
CommonJSvar encode = require('@alexpavlov/geohash-js').encode;
var hashedValue = encode(52.372518, 4.896977);
ES2015import { encode } from '@alexpavlov/geohash-js';
let hashedValue = encode(52.372518, 4.896977);