-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspace_syntax_utils.py
49 lines (43 loc) · 2.29 KB
/
space_syntax_utils.py
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
41
42
43
44
45
46
47
48
49
import subprocess
from sys import platform
if platform == "linux" or platform == "linux2":
binary = "depthmapXcli_linux64"
elif platform == "darwin":
binary = "depthmapXcli_macos"
elif platform == "win32":
binary = "depthmapXcli_win32.exe"
elif platform == "win64":
binary = "depthmapXcli_win64.exe"
else:
raise("Couldn't detect operating system.")
def space_syntax_help():
process = subprocess.Popen(['./'+binary, '-h'],
stdout=subprocess.PIPE,
universal_newlines=True)
while True:
output = process.stdout.readline()
print(output.strip())
# Do something else
return_code = process.poll()
if return_code is not None:
print('RETURN CODE', return_code)
# Process has finished, read rest of the output
for output in process.stdout.readlines():
print(output.strip())
break
def gpkg_to_dxf(path_to_gpkg, path_to_dxf, _debug=False):
print("converting %s to %s..." % (path_to_gpkg, path_to_dxf))
subprocess.run('ogr2ogr -t_srs "EPSG:2056" -f "DXF" %s %s -dim XY -sql "SELECT geom FROM edges"' % (path_to_dxf, path_to_gpkg), shell=True)
def depthmapX(mode,path_to_input,path_to_output,options=''):
subprocess.run('./%s -m %s -f %s -o %s %s' % (binary,mode,path_to_input,path_to_output,options), shell=True)
def run_segment_analysis(path_to_dxf, path_to_graph):
print("importing %s..." % (path_to_dxf))
# ./depthmapXcli_macos -m IMPORT -f data/lucerne.dxf -o data/lucerne.graph
depthmapX("IMPORT", path_to_dxf, path_to_graph)
print("converting %s to segment map..." % (path_to_dxf))
# ./depthmapXcli_macos -m MAPCONVERT -f data/lucerne.graph -co segment -con segment -o data/lucerne.graph
depthmapX("MAPCONVERT", path_to_graph, path_to_graph, '-co segment -con segment')
print("calculating 500m, 1km, 2.5km and 5km angular segment analysis...")
# ./depthmapXcli_macos -m SEGMENT -st angular -sr 500,1000,2500,5000 -f data/lucerne.graph -o data/lucerne.graph
#./depthmapXcli_macos -m SEGMENT -st tulip -sr 500,1000,2500,5000 -srt metric -sic -stb 1024 -f data/lucerne.graph -o data/lucerne.graph
depthmapX("SEGMENT", path_to_graph, path_to_graph, '-st tulip -sr 500,1000,2500,5000 -srt metric -sic -stb 1024')