| 132 | } |
| 133 | |
| 134 | inline std::tuple<Encoded, Encoded> split(const Encoded & combined, uint8_t precision) |
| 135 | { |
| 136 | Encoded lat; |
| 137 | Encoded lon; |
| 138 | lat.fill(0); |
| 139 | lon.fill(0); |
| 140 | |
| 141 | size_t i = 0; |
| 142 | for (; i < precision * BITS_PER_SYMBOL - 1; i += 2) |
| 143 | { |
| 144 | // longitude is even bits |
| 145 | lon[i / 2] = combined[i]; |
| 146 | lat[i / 2] = combined[i + 1]; |
| 147 | } |
| 148 | // precision is even, read the last bit as lat. |
| 149 | if (precision & 0x1) |
| 150 | { |
| 151 | lon[i / 2] = combined[precision * BITS_PER_SYMBOL - 1]; |
| 152 | } |
| 153 | |
| 154 | return std::tie(lon, lat); |
| 155 | } |
| 156 | |
| 157 | inline void base32Encode(const Encoded & binary, uint8_t precision, char * out) |
| 158 | { |