Skip to content

Instantly share code, notes, and snippets.

@kuwapa
Created April 24, 2022 14:27
Show Gist options
  • Save kuwapa/54795471e9070ec6fcf3c3450ae66254 to your computer and use it in GitHub Desktop.
Save kuwapa/54795471e9070ec6fcf3c3450ae66254 to your computer and use it in GitHub Desktop.
def getTotalTileCount(leftBottom, rightTop, fromZoom, toZoom):
totalTileCount = 0
for zoom in range(fromZoom, toZoom + 1):
leftBottomTiles = deg2num(leftBottom, zoom)
rightTopTiles = deg2num(rightTop, zoom)
currentTileCount = (rightTopTiles[0] - leftBottomTiles[0] + 1) * (leftBottomTiles[1] - rightTopTiles[1] + 1)
print("zoom = " + str(zoom) + ", leftBottomTiles = " + str(leftBottomTiles) +
", rightTopTiles = " + str(rightTopTiles) + ", tileCount = " + str(currentTileCount))
totalTileCount += currentTileCount
return totalTileCount
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment