Function geohash::encode

source ·
pub fn encode(c: Coord<f64>, len: usize) -> Result<String, GeohashError>
Expand description

Encode a coordinate to a geohash with length len.

§Examples

Encoding a coordinate to a length five geohash:

let coord = geohash::Coord { x: -120.6623, y: 35.3003 };

let geohash_string = geohash::encode(coord, 5).expect("Invalid coordinate");

assert_eq!(geohash_string, "9q60y");

Encoding a coordinate to a length ten geohash:

let coord = geohash::Coord { x: -120.6623, y: 35.3003 };

let geohash_string = geohash::encode(coord, 10).expect("Invalid coordinate");

assert_eq!(geohash_string, "9q60y60rhs");