MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / geohashDecode

Function geohashDecode

src/Functions/GeoHash.cpp:246–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

244}
245
246void geohashDecode(const char * encoded_string, size_t encoded_len, Float64 * longitude, Float64 * latitude)
247{
248 const uint8_t precision = static_cast<uint8_t>(std::min(encoded_len, MAX_PRECISION));
249 if (precision == 0)
250 {
251 // Empty string is converted to (0, 0)
252 *longitude = 0;
253 *latitude = 0;
254 return;
255 }
256
257 Encoded lat_encoded;
258 Encoded lon_encoded;
259 std::tie(lon_encoded, lat_encoded) = split(base32Decode(encoded_string, precision), precision);
260
261 *longitude = decodeCoordinate(lon_encoded, LON_MIN, LON_MAX, singleCoordBitsPrecision(precision, LONGITUDE));
262 *latitude = decodeCoordinate(lat_encoded, LAT_MIN, LAT_MAX, singleCoordBitsPrecision(precision, LATITUDE));
263}
264
265GeohashesInBoxPreparedArgs geohashesInBoxPrepare(
266 Float64 longitude_min,

Callers 1

tryExecuteMethod · 0.85

Calls 5

base32DecodeFunction · 0.85
decodeCoordinateFunction · 0.85
singleCoordBitsPrecisionFunction · 0.85
minFunction · 0.70
splitFunction · 0.70

Tested by

no test coverage detected