#base-16 #geohash #geography #gis

geohash-16

Geohash-16 implementation for Rust

1 unstable release

0.1.0 Jun 13, 2019

#5 in #base16

MIT license

11KB
187 lines

GeoHash-16

geohash-16 is a Rust crate for Geohash algorithm using a more simple and sane encoding method (classic Base16). Forked from geohash crate.


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 the original geohash algorithm on Wikipedia This crate provides an alternative base16 encoded version

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("e71150dc9")?;
  println!("decoding ww8p1r4t8 to: {}, {}", c.y, c.x);

  // find a neighboring hash
  let sw = neighbor("e71150dc9", Direction::SW)?;

  Ok(())
}

Dependencies

~405KB