-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathunderpass_detection_main.py
More file actions
40 lines (28 loc) · 1.33 KB
/
underpass_detection_main.py
File metadata and controls
40 lines (28 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import argparse
import sys
import json
import underpass_detection
def main():
parser = argparse.ArgumentParser(description="Detect buildings with underpasses")
parser.add_argument("inputfile", help="Input cityjson file (required)")
parser.add_argument("output_file_nm", help="Output file name without extension (required)")
args = parser.parse_args()
try:
with open(args.inputfile) as f:
data = json.load(f)
except Exception as e:
print(e)
sys.exit()
# 1) Create lists of outer ceiling surfaces per city object
obj_ocs, ocs_bounds, measuredHeights, elevations = underpass_detection.ocs_boundaries(data)
# 2) Translate vertex coordinates from indices
v_coords = underpass_detection.vertex_idx_to_coords(data)
# 3) Get boundary coordinates
ocs_bounds_coords = underpass_detection.boundary_idx_to_coords(ocs_bounds, v_coords)
# 4) Calculate average heights for all outer ceiling surfaces
surface_heights = underpass_detection.all_outer_ceiling_surface_heights(ocs_bounds_coords)
# 5) Generate a shp file of underpass surfaces, area, and height attribute
output_file_nm = args.output_file_nm
underpass_detection.output_shp(obj_ocs, ocs_bounds_coords, surface_heights, measuredHeights, elevations, output_file_nm)
if __name__ == "__main__":
main()