1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#![doc(html_root_url = "https://docs.rs/geohash/")]

//! # Geohash
//!
//! Geohash algorithm implementation in Rust. It encodes/decodes a
//! longitude-latitude tuple into/from a hashed string.
//! You can find more about the original geohash algorithm on [Wikipedia](https://en.wikipedia.org/wiki/Geohash)
//! This crate provides an alternative base16 encoded version
//!
//! ## Usage
//! ```rust
//! extern crate geohash;
//!
//! use std::error::Error;
//!
//! use geohash::{encode, decode, neighbor, Direction, Coordinate};
//!
//! fn main() -> Result<(), Box<Error>> {
//!   // encode a coordinate
//!   let c = Coordinate { x: 112.5584f64, y: 37.8324f64 };
//!   println!("encoding 37.8324, 112.5584: {}", encode(c, 9usize)?);
//!
//!   // decode a geohash
//!   let (c, _, _) = decode("e71150dc9")?;
//!   println!("decoding ww8p1r4t8 to: {}, {}", c.y, c.x);
//!
//!   // find a neighboring hash
//!   let sw = neighbor("e71150dc9", Direction::SW)?;
//!
//!   Ok(())
//! }
//! ```
//!

extern crate geo_types;
#[cfg(test)]
extern crate num_traits;
#[macro_use]
extern crate failure;

mod core;
mod error;
mod neighbors;

pub use crate::core::{decode, decode_bbox, encode, neighbor, neighbors};
pub use crate::error::GeohashError;
pub use crate::neighbors::{Direction, Neighbors};
pub use geo_types::{Coordinate, Rect};