25 unstable releases

0.13.1 Mar 13, 2024
0.13.0 Jan 15, 2023
0.12.0 Oct 8, 2021
0.11.0 Jan 17, 2021
0.1.1 Nov 21, 2014

#8 in Geospatial

Download history 5624/week @ 2024-08-12 5127/week @ 2024-08-19 5333/week @ 2024-08-26 6071/week @ 2024-09-02 5704/week @ 2024-09-09 4930/week @ 2024-09-16 5908/week @ 2024-09-23 4541/week @ 2024-09-30 5204/week @ 2024-10-07 6088/week @ 2024-10-14 6397/week @ 2024-10-21 6209/week @ 2024-10-28 7169/week @ 2024-11-04 8898/week @ 2024-11-11 7745/week @ 2024-11-18 7644/week @ 2024-11-25

31,771 downloads per month
Used in 10 crates (5 directly)

MIT/Apache

115KB
242 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, Coord};

fn main() -> Result<(), Box<Error>> {
  // encode a coordinate
  let c = Coord { 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

~740KB
~14K SLoC