Have noticed a great number of libraries that calculate the bounds for a tile like so:
def TileBounds(self, tx, ty, zoom):
"Returns bounds of the given tile in EPSG:900913 coordinates"
minx, miny = self.PixelsToMeters( tx*self.tileSize, ty*self.tileSize, zoom )
maxx, maxy = self.PixelsToMeters( (tx+1)*self.tileSize, (ty+1)*self.tileSize, zoom )
return ( minx, miny, maxx, maxy )
source: https://docs.maptiler.com/google-maps-coordinates-tile-bounds-projection/#3/50.00/15.00
Why is the tx+1/ty+1 is used in the calculation?
I'm perplexed as it means that the bottom and right border overlap with the neighboring tile. In short the bounds that is returned is slightly too big.
tx = int( math.ceil( px / float(self.tileSize) ) - 1 ). I think that +1 is there for compensating -1.mercator = GlobalMercator() bounds = mercator.TileLatLonBounds( 5, 5, 13) print print "\tEPSG:900913 Extent: ", bounds bounds = mercator.TileLatLonBounds( 5, 6, 13) print print "\tEPSG:900913 Extent: ", boundsYou'll notice the max of the first tile is the min for the second, they do in fact overlap.