From 792c045884b6b01f2e5e055594c77689728b1f63 Mon Sep 17 00:00:00 2001 From: merspieler Date: Sun, 24 Mar 2019 06:59:16 +0000 Subject: [PATCH] Added worldbuild script Signed-off-by: merspieler --- scripts/worldbuild.py | 68 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 scripts/worldbuild.py diff --git a/scripts/worldbuild.py b/scripts/worldbuild.py new file mode 100755 index 0000000..9e5693b --- /dev/null +++ b/scripts/worldbuild.py @@ -0,0 +1,68 @@ +#! /usr/bin/python +import os +import sys + +pbf_path = sys.argv[1] + +# Expecting project +os.system("mkdir -p projects/worldbuild/output/error") + +def build_tile(name, west, south, east, north): + if west < 0: + west = "*" + str(west) + else: + west = str(west) + south = str(south) + east = str(east) + north = str(north) + + os.system("./read-pbf worldbuild " + pbf_path + name + ".osm.pbf") + os.system('echo "bounds=' + west + "_" + south + "_" + east + "_" + north + '" > projects/settings') + os.system("./build worldbuild -z") + +def after_build(name): + if os.path.isfile("projects/worldbuild/osm2city-exceptions.log"): + os.system("mv projects/worldbuild/osm2city-exceptions.log projects/worldbuild/output/error/" + name + ".exceptions.log") + else: + os.system("mv projects/worldbuild/worldbuild.zip projects/worldbuild/output/" + name + ".zip") + os.system("rm -r projects/worldbuild/scenery/*" + +def prepare(): + os.system("./delete-db worldbuild") + os.system("./create-db worldbuild") + +def run_all(name, w, s, e, n): + prepare() + build_tile(name, w, s, e, n) + after_build(name) + +def norm(num, length): + num = str(num) + while len(num) < length: + num = "0" + num + return num + +# Build poles first +run_all("n-pole", -180, 80, 180, 90) +run_all("s-pole", -180, -90, 180, -80) + +for i in range(-8, 8): + i *= 10 + for j in range(-18, 18): + j *= 10 + if i >= 0: + ns = "n" + else: + ns = "s" + if j >= 0: + ew = "e" + else: + ew = "w" + + name = ew + norm(j, 3) + ns + norm(i, 2) + + run_all(name, j, i, j + 10, i + 10) + + + +