23 unstable releases

0.12.0 Oct 8, 2021
0.11.0 Jan 17, 2021
0.10.0 Aug 29, 2020
0.9.0 Apr 28, 2019
0.1.1 Nov 21, 2014

#28 in Science

Download history 2931/week @ 2021-07-07 2611/week @ 2021-07-14 2431/week @ 2021-07-21 3016/week @ 2021-07-28 2812/week @ 2021-08-04 2542/week @ 2021-08-11 2464/week @ 2021-08-18 2051/week @ 2021-08-25 2050/week @ 2021-09-01 3363/week @ 2021-09-08 3447/week @ 2021-09-15 3476/week @ 2021-09-22 3032/week @ 2021-09-29 2698/week @ 2021-10-06 3601/week @ 2021-10-13 2894/week @ 2021-10-20

11,913 downloads per month
Used in 7 crates (2 directly)

MIT/Apache

115KB
219 lines

Rust-Geohash

Rust-Geohash is a Rust library for Geohash algorithm. Ported from node-geohash module.

Docs

Check the API doc at docs.rs

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Geohash

Geohash algorithm implementation in Rust. It encodes/decodes a longitude-latitude tuple into/from a hashed string. You can find more about geohash algorithm on Wikipedia

Usage

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("ww8p1r4t8")?;
  println!("decoding ww8p1r4t8 to: {}, {}", c.y, c.x);

  // find a neighboring hash
  let sw = neighbor("ww8p1r4t8", Direction::SW)?;

  Ok(())
}

Dependencies

~690KB
~14K SLoC