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 5324/week @ 2024-08-23 5622/week @ 2024-08-30 5920/week @ 2024-09-06 4989/week @ 2024-09-13 6008/week @ 2024-09-20 4941/week @ 2024-09-27 4739/week @ 2024-10-04 6371/week @ 2024-10-11 5379/week @ 2024-10-18 6728/week @ 2024-10-25 7142/week @ 2024-11-01 8380/week @ 2024-11-08 8107/week @ 2024-11-15 7819/week @ 2024-11-22 7299/week @ 2024-11-29 6343/week @ 2024-12-06

31,004 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