Crate geohash

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 geohash algorithm on Wikipedia

Usage

extern crate geohash;

use std::error::Error;

use geohash::{encode, decode, neighbor, Direction, Coord};

fn main() -> Result<(), Box<Error>> {
  // encode a coordinate
  let c = Coord { 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(())
}

Structs

A lightweight struct used to store coordinates on the 2-dimensional Cartesian plane.
An axis-aligned bounded 2D rectangle whose area is defined by minimum and maximum Coords.

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.