| 180 | } |
| 181 | |
| 182 | void LatLonToString(double lat, double lon, char * s, size_t nBytes) |
| 183 | { |
| 184 | if (nBytes > kMaxPointBytes) |
| 185 | nBytes = kMaxPointBytes; |
| 186 | |
| 187 | int const latI = LatToInt(lat, (1 << kMaxCoordBits) - 1); |
| 188 | int const lonI = LonToInt(lon, (1 << kMaxCoordBits) - 1); |
| 189 | |
| 190 | size_t i; |
| 191 | int shift; |
| 192 | for (i = 0, shift = kMaxCoordBits - 3; i < nBytes; ++i, shift -= 3) |
| 193 | { |
| 194 | int const latBits = latI >> shift & 7; |
| 195 | int const lonBits = lonI >> shift & 7; |
| 196 | |
| 197 | int const nextByte = (latBits >> 2 & 1) << 5 | (lonBits >> 2 & 1) << 4 | (latBits >> 1 & 1) << 3 | |
| 198 | (lonBits >> 1 & 1) << 2 | (latBits & 1) << 1 | (lonBits & 1); |
| 199 | |
| 200 | s[i] = Base64Char(nextByte); |
| 201 | } |
| 202 | } |
| 203 | } // namespace ge0 |