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 5940/week @ 2024-08-04 5586/week @ 2024-08-11 5200/week @ 2024-08-18 5263/week @ 2024-08-25 6115/week @ 2024-09-01 5761/week @ 2024-09-08 4797/week @ 2024-09-15 5846/week @ 2024-09-22 4704/week @ 2024-09-29 5165/week @ 2024-10-06 6054/week @ 2024-10-13 6422/week @ 2024-10-20 6087/week @ 2024-10-27 7227/week @ 2024-11-03 8847/week @ 2024-11-10 7585/week @ 2024-11-17

30,244 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