cli.py 954 Bytes
Newer Older
1
import argparse
2
import sys
3

4
from wmfmaps.tileset import TileSet
5
6


7
def main():
8
9
10
11
12
13
    parser = argparse.ArgumentParser(
        description="Given a tile list as input, generate a distinct "
        "list of map tiles consisted of all the parent and children tiles "
        "recursively up to a zoom level."
    )
    parser.add_argument(
14
15
16
17
        "minzoom",
        default=0,
        help="The minimum zoom level of the generated tilelist.",
        type=int,
18
19
    )
    parser.add_argument(
20
21
22
        "maxzoom", help="The maximum zoom level of the generated tilelist.", type=int
    )
    parser.add_argument(
23
24
25
26
27
        "tilelist_file",
        help="Path to the tilelist input file.",
        type=argparse.FileType("r"),
        default=sys.stdin,
        nargs="?",
28
29
30
    )
    args = parser.parse_args()

31
    ts = TileSet(args.tilelist_file, args.minzoom, args.maxzoom)
32
33
34
35
    ts.read()

    for tile in ts.tileset:
        print(f"{tile.z}/{tile.x}/{tile.y}")