Crate geohash[−][src]
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, 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("ww8p1r4t8")?; println!("decoding ww8p1r4t8 to: {}, {}", c.y, c.x); // find a neighboring hash let sw = neighbor("ww8p1r4t8", Direction::SW)?; Ok(()) }
Structs
Coordinate |
A lightweight struct used to store coordinates on the 2-dimensional Cartesian plane. |
Neighbors | |
Rect |
Enums
Direction | |
GeohashError |
Functions
decode |
Decode a geohash into a coordinate with some longitude/latitude error. The
return value is |
decode_bbox |
Decode geohash string into latitude, longitude |
encode |
Encode a coordinate to a geohash with length |
neighbor |
Find neighboring geohashes for the given geohash and direction. |
neighbors |
Find all neighboring geohashes for the given geohash. |