Esempio n. 1
0
 def test_parent(self):
     from raw_tiles.tile import Tile
     self.assertEquals(Tile(0, 0, 0), Tile(1, 0, 0).parent())
     self.assertEquals(Tile(1, 0, 0), Tile(2, 1, 1).parent())
Esempio n. 2
0
def convert_coord_object(coord):
    """Convert ModestMaps.Core.Coordinate -> raw_tiles.tile.Tile"""
    assert isinstance(coord, Coordinate)
    coord = coord.container()
    return Tile(int(coord.zoom), int(coord.column), int(coord.row))
Esempio n. 3
0
    import argparse

    parser = argparse.ArgumentParser(description='Generate RAWR tiles')
    parser.add_argument('zoom', metavar='Z', type=int, nargs=1,
                        help='The zoom level.')
    parser.add_argument('x', metavar='X', nargs=1,
                        help='The x coordinate, or coordinate range '
                        '(e.g: 0-8). Use * to indicate the whole range.')
    parser.add_argument('y', metavar='Y', nargs=1,
                        help='The y coordinate, or coordinate range '
                        '(e.g: 0-8). Use * to indicate the whole range.')

    parser.add_argument('--dbparams', help='Database parameters')

    args = parser.parse_args()

    z = int(args.zoom[0])
    x_range = parse_range(z, args.x)
    y_range = parse_range(z, args.y)

    conn_ctx = ConnectionContextManager(args.dbparams)
    src = OsmSource(conn_ctx)
    fmt = Gzip(Msgpack())
    sink = LocalSink('tiles', '.msgpack.gz')
    rawr_gen = RawrGenerator(src, fmt, sink)

    for x in x_range:
        for y in y_range:
            tile = Tile(z, x, y)
            rawr_gen(tile)
Esempio n. 4
0
# for example, run as:
#
# $ python raw_tiles/command.py --dbparams dbname=california 10 163 395
# $ python raw_tiles/index/index.py 10/163/395 w225516713 w123741422 \
#      n298078639 t10/163/395 t15/5241/12668
#
# the first command generates a z10 tile over San Francisco. the second
# indexes that tile and looks up a couple of ways which are part of route
# relations, a node which is a gate and a couple of tiles containing
# various bits of landuse.
#
if __name__ == '__main__':
    import sys

    z, x, y = map(int, sys.argv[1].split("/"))
    tile = Tile(z, x, y)
    extension = '.msgpack'

    def get_table(table):
        return tile_contents(tile, table, extension)

    rt_idx = RouteIndex()
    hw_idx = HighwayIndex()
    landuse_idx = FeatureTileIndex(tile, tile.z + 5, landuse_min_zoom)
    index(
        get_table, {
            'planet_osm_rels': [rt_idx],
            'planet_osm_ways': [hw_idx],
            'planet_osm_polygon': [landuse_idx],
        })
Esempio n. 5
0
 def tile(self):
     from raw_tiles.tile import Tile
     return Tile(self.z, self.x, self.y)