Exemple #1
0
 def nearby(self):
     tile, level = TileSystem.quadkey_to_tile(self.key)
     perms = [(-1, -1), (-1, 0), (-1, 1), (0, -1),
              (0, 1), (1, -1), (1, 0), (1, 1)]
     tiles = set(
         map(lambda perm: (abs(tile[0] + perm[0]), abs(tile[1] + perm[1])), perms))
     return [TileSystem.tile_to_quadkey(tile, level) for tile in tiles]
Exemple #2
0
 def nearby(self):
     tile, level = TileSystem.quadkey_to_tile(self.key)
     perms = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0),
              (1, 1)]
     tiles = set(
         map(lambda perm: (abs(tile[0] + perm[0]), abs(tile[1] + perm[1])),
             perms))
     return [TileSystem.tile_to_quadkey(tile, level) for tile in tiles]
Exemple #3
0
def lonlat_to_quadkey(lonlat, level):
    pix = tsm.geo_to_pixel(lonlat, level)
    pix = np.column_stack((pix[0], pix[1]))
    tile = tsm.pixel_to_tile(pix)
    tile = np.column_stack((tile[0], tile[1]))
    qk = tsm.tile_to_quadkey(tile, level)
    qk = qk.reshape(-1, 1)
    qk = pd.Series(qk[:, 0]).astype(str)

    return qk.values
Exemple #4
0
def lonlat_to_quadkey_with_shift(quadkey, loshift):
    quadkeys = np.array([quadkey] * len(loshift))
    tilex, tiley, level = tsm.quadkey_to_tile(quadkeys)
    tile = np.column_stack((tilex, tiley))
    shift = np.array(loshift)
    tile = tile + shift
    loquadkey = tsm.tile_to_quadkey(tile, level)
    loquadkey = loquadkey.reshape(-1, 1)
    loquadkey = pd.Series(loquadkey[:, 0]).astype(str)
    loquadkey = loquadkey.str[1:]

    return loquadkey.values.astype(str)
Exemple #5
0
def from_geo(geo, level):
    """
    Constucts a quadkey representation from geo and level
    geo => (lat, lon)
    If lat or lon are outside of bounds, they will be clipped
    If level is outside of bounds, an AssertionError is raised

    """
    pixel = TileSystem.geo_to_pixel(geo, level)
    tile = TileSystem.pixel_to_tile(pixel)
    key = TileSystem.tile_to_quadkey(tile, level)
    return QuadKey(key)
Exemple #6
0
def from_geo(geo, level):
    """
    Constucts a quadkey representation from geo and level
    geo => (lat, lon)
    If lat or lon are outside of bounds, they will be clipped
    If level is outside of bounds, an AssertionError is raised

    """
    pixel = TileSystem.geo_to_pixel(geo, level)
    tile = TileSystem.pixel_to_tile(pixel)
    key = TileSystem.tile_to_quadkey(tile, level)
    return QuadKey(key)
Exemple #7
0
def from_tile(tile, level):
    return QuadKey(TileSystem.tile_to_quadkey(tile, level))
Exemple #8
0
def from_tile(tile, level):
    return QuadKey(TileSystem.tile_to_quadkey(tile, level))