pub fn encode(latitude: f32, longitude: f32, length_geohash: u32) -> StringExpand description
We take the latitude and longitude, and we split the geohash into two parts, one for the latitude and one for the longitude. We then iterate over the length of the geohash, and for each iteration we get the next bit of the geohash, and then we encode that bit into base32
Arguments:
latitude: the latitude of the point you want to encodelongitude: the longitude of the point you want to encodelength_geohash: The length of the geohash string. The longer the string, the more precise the geohash.
Returns:
A string of length length_geohash, which is the geohash of the input coordinates.
Panics:
Panics when latitude input does not bound into -90.0 ~ 90.0 or longitude input does not bound into -180 ~ 180
ยงExamples
use geohash_rs;
let geohash = geohash_rs::encode(37.5666805, 126.9784147, 8);
assert_eq!(geohash, String::from("wydm9qyc"))