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

Function geohashesInBox

src/Functions/GeoHash.cpp:322–355  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322UInt64 geohashesInBox(const GeohashesInBoxPreparedArgs & args, char * out)
323{
324 if (args.precision == 0
325 || args.precision > MAX_PRECISION
326 || args.longitude_step <= 0
327 || args.latitude_step <= 0)
328 {
329 return 0;
330 }
331
332 UInt64 items = 0;
333 for (size_t i = 0; i < args.longitude_items; ++i)
334 {
335 for (size_t j = 0; j < args.latitude_items; ++j)
336 {
337 size_t length = geohashEncodeImpl(
338 args.longitude_min + args.longitude_step * static_cast<Float64>(i),
339 args.latitude_min + args.latitude_step * static_cast<Float64>(j),
340 args.precision,
341 out);
342
343 out += length;
344 ++items;
345 }
346 }
347
348 if (items == 0)
349 {
350 geohashEncodeImpl(args.longitude_min, args.latitude_min, args.precision, out);
351 ++items;
352 }
353
354 return items;
355}
356
357}

Callers 1

executeMethod · 0.85

Calls 1

geohashEncodeImplFunction · 0.85

Tested by

no test coverage detected