def bounds(self, top_level_bounds): """ return lat,lon bounds given toplevel BB bounds ``top_level_bounds`` is a tuple with (ne, sw) being ne and sw a (lat, lon) tuple return bounds in the same format """ righttop = Mercator.project(*top_level_bounds[0]) #ne leftbottom = Mercator.project(*top_level_bounds[1]) #sw topx = leftbottom[0] topy = righttop[1] w = righttop[0] - leftbottom[0] h = -righttop[1] + leftbottom[1] sp = SPLITS**self.z sx = w / sp sy = h / sp return (Mercator.unproject((self.x + 1) * sx + topx, (self.y) * sy + topy), Mercator.unproject(self.x * sx + topx, topy + (self.y + 1) * sy))
def bounds(self, top_level_bounds): """ return lat,lon bounds given toplevel BB bounds ``top_level_bounds`` is a tuple with (ne, sw) being ne and sw a (lat, lon) tuple return bounds in the same format """ righttop = Mercator.project(*top_level_bounds[0]) #ne leftbottom = Mercator.project(*top_level_bounds[1]) #sw topx = leftbottom[0] topy = righttop[1] w = righttop[0] - leftbottom[0]; h = -righttop[1] + leftbottom[1]; sp = SPLITS**self.z sx = w/sp; sy = h/sp; return ( Mercator.unproject((self.x + 1)*sx + topx, (self.y)*sy + topy), Mercator.unproject(self.x*sx + topx, topy + (self.y+1)*sy) )