#gis #geography #geohash

geohash

Geohash implementation for Rust

20 releases

0.9.0 Apr 28, 2019
0.8.0 Oct 8, 2018
0.7.1 Aug 11, 2018
0.7.0 May 27, 2018
0.1.1 Nov 21, 2014

#37 in Science

Download history 170/week @ 2019-02-17 203/week @ 2019-02-24 147/week @ 2019-03-03 182/week @ 2019-03-10 276/week @ 2019-03-17 605/week @ 2019-03-24 227/week @ 2019-03-31 289/week @ 2019-04-07 237/week @ 2019-04-14 190/week @ 2019-04-21 207/week @ 2019-04-28 219/week @ 2019-05-05 310/week @ 2019-05-12 491/week @ 2019-05-19 419/week @ 2019-05-26

1,302 downloads per month
Used in 5 crates (2 directly)

MIT/Apache

12KB
195 lines

Rust-Geohash

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

Build Status

Documentation

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

~251KB