def tileAddress(self, zoom, point):
"Returns a tile address based on a zoom level and \
a point in the tile"
[x, y] = point
assert x <= self.extent[2] and x >= self.extent[0]
assert y <= self.extent[3] and y >= self.extent[1]
assert zoom in range(0, len(self.RESOLUTIONS))
tileS = self.tileSize(zoom)
offsetX = abs(x - self.MINX)
if self.originCorner == 'bottom-left':
offsetY = abs(y - self.MINY)
elif self.originCorner == 'top-left':
offsetY = abs(self.MAXY - y)
col = offsetX / tileS
row = offsetY / tileS
# We are exactly on the edge of a tile and the extent
if x in (self.MINX, self.MAXX) and col.is_integer():
col = max(0, col - 1)
if y in (self.MINY, self.MAXY) and row.is_integer():
row = max(0, row - 1)
return [
int(math.floor(col)),
int(math.floor(row))
]
评论列表
文章目录