def parent(ctx, input, depth):
"""Takes a [x, y, z] tile as input and writes its parent to stdout
in the same form.
$ echo "[486, 332, 10]" | mercantile parent
Output:
[243, 166, 9]
"""
src = normalize_input(input)
for line in iter_lines(src):
tile = json.loads(line)[:3]
if tile[2] - depth < 0:
raise click.UsageError("Invalid parent level: {0}".format(tile[2] - depth))
for i in range(depth):
tile = mercantile.parent(tile)
output = json.dumps(tile)
click.echo(output)
评论列表
文章目录