convertToGeohash function
String
convertToGeohash(
- dynamic y,
- dynamic x,
- dynamic latitude,
- dynamic longitude,
- int precision,
Convert location point to geohash taking into account Earth curvature
Implementation
String convertToGeohash(y, x, latitude, longitude, int precision) {
double pi = 3.14159265359;
double rEarth = 6371000;
double? latDiff = (y / rEarth) * (180 / pi);
double? lonDiff = (x / rEarth) * (180 / pi) / cos(latitude * pi / 180);
double finalLat = latitude + latDiff;
double finalLon = longitude + lonDiff;
return geoHasher.encode(finalLon, finalLat, precision: precision);
}