Function oldnav_lib::navdata::geohash::encode [] [src]

pub fn encode(position: &Vector2<f64>, precision: u8, range: &Bounds) -> Result<u64String>

encode a Vector2 position into an unsigned integer geohash. wraps the position around the boundaries, to keep it within them.

Example

use nalgebra::Vector2;
let p = Vector2{y: 31.23, x: 121.473};
let bounds = LATLON_BOUNDS.clone();
let gh = encode(&p, 8, &bounds).unwrap();
assert_eq!(hash_to_string(gh).unwrap(), "11100110");