encode

Function encode 

Source
pub fn encode(lat: f64, lng: f64, precision: usize) -> String
Expand description

Encodes a latitude and longitude into a geohash string.

This function takes a latitude and longitude as floating-point numbers and returns a geohash string representation. The geohash is a hierarchical spatial data structure which subdivides space into buckets of grid shape.

§Arguments

  • lat - The latitude in decimal degrees (range: -90 to 90)
  • lng - The longitude in decimal degrees (range: -180 to 180)
  • precision - The number of characters in the resulting geohash string

§Returns

A String containing the geohash representation of the given coordinates.

§Example

use geohasher::encode;

let geohash = encode(57.64911, 10.40744, 8);
assert_eq!(geohash, "u4pruydq");