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

Function encodeCoordinate

src/Functions/GeoHash.cpp:68–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68inline Encoded encodeCoordinate(Float64 coord, Float64 min, Float64 max, uint8_t bits)
69{
70 Encoded result;
71 result.fill(0);
72
73 for (size_t i = 0; i < bits; ++i)
74 {
75 const Float64 mid = (max + min) / 2;
76 if (coord >= mid)
77 {
78 result[i] = 1;
79 min = mid;
80 }
81 else
82 {
83 result[i] = 0;
84 max = mid;
85 }
86 }
87
88 return result;
89}
90
91inline Float64 decodeCoordinate(const Encoded & coord, Float64 min, Float64 max, uint8_t bits)
92{

Callers 1

geohashEncodeImplFunction · 0.85

Calls 1

fillMethod · 0.45

Tested by

no test coverage detected