geohasher/lib.rs
1#![doc(html_root_url = "https://docs.rs/geohasher/")]
2
3//! # Geohasher
4//! ## Simple geohash encode/decode functions without any dependencies.
5//!
6//!
7//! ### Installation
8//! `cargo install geohasher`
9//!
10//! ### Encoding
11//!
12//! To encode a latitude and longitude into a geohash:
13//!
14//! ```rust
15//! use geohasher::encode;
16//!
17//! let geohash = encode(57.64911, 10.40744, 8);
18//! assert_eq!(geohash, "u4pruydq");
19//! ```
20//!
21//! ### Decoding
22//!
23//! To decode a geohash back into latitude and longitude:
24//!
25//! ```rust
26//! use geohasher::decode;
27//!
28//! let (lat, lng) = decode("u4pruydq");
29//! assert!((lat - 57.64911).abs() < 0.001);
30//! assert!((lng - 10.40744).abs() < 0.001);
31//! ```
32//!
33//! ### References:
34//! According to [Wikipedia](https://en.wikipedia.org/wiki/Geohash):
35//! > "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]."
36//!
37//! 1. https://web.archive.org/web/20080305223755/http://blog.labix.org/#post-85
38//! 2. https://web.archive.org/web/20190125020453/https://domino.research.ibm.com/library/cyberdig.nsf/papers/0DABF9473B9C86D48525779800566A39/$File/Morton1966.pdf
39//!
40
41mod encode;
42mod decode;
43mod constants;
44
45pub use encode::encode;
46pub use decode::decode;