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

#97 in Geospatial

Download history 7366/week @ 2024-01-03 7650/week @ 2024-01-10 7953/week @ 2024-01-17 7761/week @ 2024-01-24 7234/week @ 2024-01-31 6259/week @ 2024-02-07 6562/week @ 2024-02-14 7903/week @ 2024-02-21 9857/week @ 2024-02-28 7886/week @ 2024-03-06 9034/week @ 2024-03-13 9545/week @ 2024-03-20 7611/week @ 2024-03-27 6685/week @ 2024-04-03 7167/week @ 2024-04-10 5428/week @ 2024-04-17

28,488 downloads per month
Used in 5 crates (2 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

~755KB
~15K SLoC