-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
48 lines (31 loc) · 1.01 KB
/
main.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
from os import walk
from os import path
from area_extractor import parsePBFFile
INPUT_FOLDER = "input"
OUTPUT_FILE = "output.json"
# Main function
def main():
print("***** Area extractor started *****")
print("Reading input directory...")
pbfFiles = getPBFInputFiles(INPUT_FOLDER)
fileNumber = len(pbfFiles)
print(f"{fileNumber} PBF file(s) found")
if fileNumber < 1:
print("Terminating")
exit(1)
for pbfFile in pbfFiles:
print(f"Processing \"{pbfFile}\"...")
geoJson = parsePBFFile(pbfFile)
with open(OUTPUT_FILE, 'w+') as outputFile:
outputFile.write(geoJson)
print(f"Wrote output file {OUTPUT_FILE}")
print("Completed")
def getPBFInputFiles(inputPath):
pbfFiles = []
for (dirPath, dirNames, fileNames) in walk(inputPath):
for fileName in fileNames:
if fileName.endswith(".pbf"):
pbfFiles.append(path.join(dirPath, fileName))
return pbfFiles
if __name__ == '__main__':
main()