Skip to content

Instantly share code, notes, and snippets.

@kuwapa
Last active April 24, 2022 14:26
Show Gist options
  • Select an option

  • Save kuwapa/72c61355bf9d707abee5acc889959a5b to your computer and use it in GitHub Desktop.

Select an option

Save kuwapa/72c61355bf9d707abee5acc889959a5b to your computer and use it in GitHub Desktop.

Revisions

  1. kuwapa revised this gist Apr 24, 2022. 1 changed file with 0 additions and 13 deletions.
    13 changes: 0 additions & 13 deletions total_tile_count.py
    Original file line number Diff line number Diff line change
    @@ -1,13 +0,0 @@
    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
  2. kuwapa revised this gist Apr 24, 2022. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions total_tile_count.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    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
  3. kuwapa created this gist Apr 24, 2022.
    7 changes: 7 additions & 0 deletions lat_lng_zoom.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    import math
    def deg2num(lat_deg, lon_deg, zoom):
    lat_rad = math.radians(lat_deg)
    n = 2.0 ** zoom
    xtile = int((lon_deg + 180.0) / 360.0 * n)
    ytile = int((1.0 - math.asinh(math.tan(lat_rad)) / math.pi) / 2.0 * n)
    return (xtile, ytile)