Ejemplo n.º 1
0
 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))
Ejemplo n.º 2
0
 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)
     )
Ejemplo n.º 3
0
def line_to_row_col(line, hg):
    splits = line.split(',')
    try:
        lon = float(splits[10])
        lat = float(splits[11])
        x, y = Mercator.to_web_mercator(lon, lat)
        rc = hg.xy2rc(x, y)
        return rc, 1
    except:
        return (0, 0), -1
Ejemplo n.º 4
0
def line_to_row_col(line):
    splits = line.split(',')
    try:
        lon = float(splits[10])
        lat = float(splits[11])
        x, y = Mercator.to_web_mercator(lon, lat)
        c = int(math.floor(x / 100))
        r = int(math.floor(y / 100))
        return (r, c), 1
    except:
        return (0, 0), -1