openstreetmap-website/lib/quad_tile/quad_tile.h
Han Chao ade561d3e6 Fix clang build error
By default, Clang builds C code in GNU C11 mode, so it uses
standard C99 semantics for the inline keyword:

http://clang.llvm.org/compatibility.html#inline

Closes #1399
2016-12-30 07:38:28 +00:00

25 lines
477 B
C

#include <math.h>
static inline unsigned int xy2tile(unsigned int x, unsigned int y)
{
unsigned int tile = 0;
int i;
for (i = 15; i >= 0; i--)
{
tile = (tile << 1) | ((x >> i) & 1);
tile = (tile << 1) | ((y >> i) & 1);
}
return tile;
}
static inline unsigned int lon2x(double lon)
{
return round((lon + 180.0) * 65535.0 / 360.0);
}
static inline unsigned int lat2y(double lat)
{
return round((lat + 90.0) * 65535.0 / 180.0);
}