Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions opendm/tiles/gdal2tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ class GlobalMercator(object):
def __init__(self, tileSize=256):
"Initialize the TMS Global Mercator pyramid"
self.tileSize = tileSize
self.invTileSize = 1.0 / tileSize
self.initialResolution = 2 * math.pi * 6378137 / self.tileSize
# 156543.03392804062 for tileSize 256 pixels
self.originShift = 2 * math.pi * 6378137 / 2.0
Expand Down Expand Up @@ -248,8 +249,8 @@ def MetersToPixels(self, mx, my, zoom):
def PixelsToTile(self, px, py):
"Returns a tile covering region in given pixel coordinates"

tx = int(math.ceil(px / float(self.tileSize)) - 1)
ty = int(math.ceil(py / float(self.tileSize)) - 1)
tx = int(math.ceil(px * self.invTileSize) - 1)
ty = int(math.ceil(py * self.invTileSize) - 1)
return tx, ty

def PixelsToRaster(self, px, py, zoom):
Expand Down