Crate geohash_16

Source
Expand description

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

Structs§

  • A lightweight struct used to store coordinates on the 2-dimensional Cartesian plane.
  • A bounded 2D quadrilateral whose area is defined by minimum and maximum Coordinates.

Enums§

Functions§

  • Decode a geohash into a coordinate with some longitude/latitude error. The return value is (<coordinate>, <longitude error>, <latitude error>).
  • Decode geohash string into latitude, longitude
  • Encode a coordinate to a geohash with length len.
  • Find neighboring geohashes for the given geohash and direction.
  • Find all neighboring geohashes for the given geohash.