I am trying to generate map tiles based on data we have stored in a DB and serve them up to Cesium using an UrlTemplateImageryProvider. For each map tile, I need to know the lat/long bounds in order to find matching data. I'm using the same tile scheme as Google Maps with a request like http://host/tiles/zoom/x/y. Initially I've been using the equations to convert these map tile coordinates into lat/long bounds found here: http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#Tile_bounding_box but now I'm wondering if this is not the correct projection to be using.

For starters, all the Web Mercator documentation I see says that Tile 0,0 @ zoom lvl 0 should cover the entire world. That's not what I see with Cesium (there are 2 tiles at zoom level 0). That said, my calculations seem to work for zoom levels 0,1,2, and 3, but as I go to Zoom level 4, the Latitude calculation starts to move south. If I plot my generated lat, long point on a 2D Google Map, they look correct, but I can clearly see that the tiles requested by cesium have different bounds. So I am now assuming I'm just using the wrong projection to calculate the tile bounds.

I've also tried the calculations here: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/

converting from pixes, to meters, to lat/long but they seem to be the same results as the web mercator calculations.

So can anyone help me figure out how to calculate a Lat/Long bounding box for the tiles requested by Cesium?

Thanks

Andrew