#substrate #gis #geohash #geography #direction #hash

substrate-geohash

Geohash implementation for Rust. Forked for use with substrate

2 unstable releases

new 0.14.0 May 1, 2025
0.13.0 Oct 25, 2023

#8 in #geohash

Download history 779/week @ 2025-01-09 1040/week @ 2025-01-16 1434/week @ 2025-01-23 736/week @ 2025-01-30 808/week @ 2025-02-06 535/week @ 2025-02-13 1000/week @ 2025-02-20 641/week @ 2025-02-27 429/week @ 2025-03-06 1169/week @ 2025-03-13 1298/week @ 2025-03-20 509/week @ 2025-03-27 1303/week @ 2025-04-03 1602/week @ 2025-04-10 814/week @ 2025-04-17 1269/week @ 2025-04-24

5,055 downloads per month
Used in 23 crates (via encointer-primitives)

MIT/Apache

18KB
268 lines

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(())
}

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.

Dependencies

~4.5MB
~101K SLoC