-
Notifications
You must be signed in to change notification settings - Fork 0
/
headers.py
44 lines (35 loc) · 1.38 KB
/
headers.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
# mapv/places.py
"""Given a place name and state, print out the headers of all the DLG-3 files
that make up both halves of the quadrangle. """
import os
import sys
import dlg
from storage import dlg_base_dir
#-------------------------------------------------------------------------------
# show_headers -
#-------------------------------------------------------------------------------
def show_headers(name, state):
path = os.path.join(dlg_base_dir, name[0].upper())
for half in 'ew':
mapname = f'{name}-{half}_{state}'
map_path = os.path.join(path, mapname)
if not os.path.isdir(map_path):
print(f"Can't find '{mapname}'")
else:
layer_path = os.path.join(map_path, 'transportation')
for f in os.listdir(layer_path):
if f.endswith('.opt.gz'):
filepath = os.path.join(layer_path, f)
d = dlg.load_data(filepath)
print(d.show_headers())
#===============================================================================
# main
#===============================================================================
if __name__ == '__main__':
# Check cmd line args
if len(sys.argv) != 3:
print(f'usage: {sys.argv[0]} <place> <state>')
exit(-1)
name = sys.argv[1]
state = sys.argv[2]
show_headers(name, state)