Crates.io | geohasher |
lib.rs | geohasher |
version | 0.1.4 |
source | src |
created_at | 2024-10-15 00:36:08.288721 |
updated_at | 2024-10-18 18:26:41.616963 |
description | Simple geohash encode/decode functions without any dependencies. |
homepage | |
repository | https://github.com/conbrad/geohasher |
max_upload_size | |
id | 1408810 |
size | 24,074 |
Simple geohash encode/decode functions without any dependencies.
cargo install geohasher
To encode a latitude and longitude into a geohash:
use geohasher::encode;
let geohash = encode(57.64911, 10.40744, 8);
assert_eq!(geohash, "u4pruydq");
To decode a geohash back into latitude and longitude:
use geohasher::decode;
let (lat, lng) = decode("u4pruydq");
assert!((lat - 57.64911).abs() < 0.001);
assert!((lng - 10.40744).abs() < 0.001);
According to Wikipedia:
"Geohash is a public domain geocode system invented in 2008 by Gustavo Niemeyer[1] which encodes a geographic location into a short string of letters and digits. Similar ideas were introduced by G.M. Morton in 1966[2]."