#geohash #gis #geography

substrate-geohash

Geohash implementation for Rust. Forked for use with substrate

1 unstable release

0.13.0 Oct 25, 2023

#10 in #geohash

Download history 480/week @ 2024-07-29 299/week @ 2024-08-05 426/week @ 2024-08-12 612/week @ 2024-08-19 463/week @ 2024-08-26 119/week @ 2024-09-02 197/week @ 2024-09-09 196/week @ 2024-09-16 208/week @ 2024-09-23 321/week @ 2024-09-30 336/week @ 2024-10-07 448/week @ 2024-10-14 519/week @ 2024-10-21 492/week @ 2024-10-28 319/week @ 2024-11-04 140/week @ 2024-11-11

1,476 downloads per month
Used in 23 crates (via encointer-primitives)

MIT/Apache

17KB
267 lines

crates.io

Rust-Geohash for Substrate

This is a fork which derives SCALE codec info for use with parity substrate

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

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 fixed::types::I64F64;

fn main() -> Result<(), Box<geohash::GeohashError>> {
use std::convert::TryFrom;
use geohash::{GeoHash, Direction};
let lon = I64F64::from_num(112.5584);
  let lat = I64F64::from_num(37.8324f64);

  // decode a geohash
  let (lon, lat, _, _) = GeoHash::<9>::try_from("ww8p1r4t8")?.try_as_coordinates()?;

  // find a neighboring hash
  let sw = GeoHash::<9>::try_from("ww8p1r4t8")?.neighbor(Direction::SW)?;

  Ok(())
}

Dependencies

~3.5MB
~69K SLoC