|
|
|
@@ -5,31 +5,45 @@ from tqdm import tqdm |
|
|
|
|
|
|
|
config = json.load(open(sys.argv[1])) |
|
|
|
|
|
|
|
if config["mode"] == "bounding-boxes": |
|
|
|
if config["mode"] == "points" or config["mode"] == "bounding-boxes": |
|
|
|
results = [] |
|
|
|
|
|
|
|
for item in config["items"]: |
|
|
|
lon0 = item["corner0"][0] |
|
|
|
lat0 = item["corner0"][1] |
|
|
|
lon1 = item["corner1"][0] |
|
|
|
lat1 = item["corner1"][1] |
|
|
|
|
|
|
|
center_lat = (lat0 + lat1) / 2 |
|
|
|
center_lon = (lon0 + lon1) / 2 |
|
|
|
if config["mode"] == "bounding-boxes": |
|
|
|
lon0 = item["corner0"][0] |
|
|
|
lat0 = item["corner0"][1] |
|
|
|
lon1 = item["corner1"][0] |
|
|
|
lat1 = item["corner1"][1] |
|
|
|
|
|
|
|
center_lat = (lat0 + lat1) / 2 |
|
|
|
center_lon = (lon0 + lon1) / 2 |
|
|
|
elif config["mode"] == "points": |
|
|
|
lon0 = -180 |
|
|
|
lat0 = -90 |
|
|
|
lon1 = 180 |
|
|
|
lat1 = 90 |
|
|
|
|
|
|
|
center_lat = item["lat"] |
|
|
|
center_lon = item["lon"] |
|
|
|
|
|
|
|
path = "../../" + config["directory"] + "/" + item["name"] + ".svg" |
|
|
|
|
|
|
|
CMD = """\ |
|
|
|
mapshaper -i {7} \ |
|
|
|
mapshaper -i "{7}" \ |
|
|
|
-rectangle bbox={0},{1},{2},{3} name=rect \ |
|
|
|
-clip rect target={8} \ |
|
|
|
-proj crs="+proj=ortho +lon_0={4} +lat_0={5}" target={8},rect \ |
|
|
|
-info target={8} \ |
|
|
|
-o "{6}" target={8} |
|
|
|
-clip rect target="{8}" \ |
|
|
|
-proj crs="+proj=ortho +lon_0={4} +lat_0={5}" target="{8}",rect \ |
|
|
|
-info target="{8}" \ |
|
|
|
-o "{6}" target="{8}" |
|
|
|
""" |
|
|
|
|
|
|
|
file = config["shapefile"] |
|
|
|
|
|
|
|
if "file" in item: |
|
|
|
file = item["file"] |
|
|
|
try: |
|
|
|
prepared = CMD.format(lon0, lat0, lon1, lat1, center_lon, center_lat, path, config["shapefile"], config["layer"]) |
|
|
|
prepared = CMD.format(lon0, lat0, lon1, lat1, center_lon, center_lat, path, file, item["name"]) |
|
|
|
result = subprocess.check_output( |
|
|
|
prepared, |
|
|
|
shell=True, |
|
|
|
@@ -44,7 +58,7 @@ if config["mode"] == "bounding-boxes": |
|
|
|
|
|
|
|
results.append([item["name"], height]) |
|
|
|
except Exception as e: |
|
|
|
print(e) |
|
|
|
print(e.output) |
|
|
|
print(result.decode("utf-8")) |
|
|
|
|
|
|
|
print(json.dumps(results)) |
|
|
|
|