MCPcopy Create free account
hub / github.com/comaps/comaps / LatLonToString

Function LatLonToString

libs/ge0/url_generator.cpp:182–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180}
181
182void 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

Callers 5

GenerateShortShowMapUrlFunction · 0.70
TestLatLonToStrFunction · 0.50
UNIT_TESTFunction · 0.50
ConvergenceTestFunction · 0.50

Calls 3

LatToIntFunction · 0.85
LonToIntFunction · 0.85
Base64CharFunction · 0.85

Tested by 3

TestLatLonToStrFunction · 0.40
UNIT_TESTFunction · 0.40
ConvergenceTestFunction · 0.40