Function geohash::decode

source ·
pub fn decode(hash_str: &str) -> Result<(Coord<f64>, f64, f64), GeohashError>
Expand description

Decode a geohash into a coordinate with some longitude/latitude error. The return value is (<coordinate>, <longitude error>, <latitude error>).

§Examples

Decoding a length five geohash:

let geohash_str = "9q60y";

let decoded = geohash::decode(geohash_str).expect("Invalid hash string");

assert_eq!(
    decoded,
    (
        geohash::Coord {
            x: -120.65185546875,
            y: 35.31005859375,
        },
        0.02197265625,
        0.02197265625,
    ),
);

Decoding a length ten geohash:

let geohash_str = "9q60y60rhs";

let decoded = geohash::decode(geohash_str).expect("Invalid hash string");

assert_eq!(
    decoded,
    (
        geohash::Coord {
            x: -120.66229999065399,
            y: 35.300298035144806,
        },
        0.000005364418029785156,
        0.000002682209014892578,
    ),
);