spatialdev/osmquality

Location of results folder depends on trailing slash

Opened this issue · 1 comments

With the edits from #13, we can run the project. It mostly works, but is a little unstable. If you run it like so:

python3 -m src.mqm inputFolder=/Absolute/path/to/parent/shallow/folder it runs fine.

However, if you run it like python3 -m src.mqm inputFolder=/Absolute/path/to/parent/shallow/folder/ it creates the results folder inside of shallow/folder/ and tries to read from it, failing to do so and throwing an error:

Traceback (most recent call last):
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/micahnacht/github/public-repos/osmquality/src/mqm/__main__.py", line 4, in <module>
    main()
  File "/Users/micahnacht/github/public-repos/osmquality/src/mqm/mqm_tool.py", line 385, in main
    os.path.split(sub_folder)[1])
  File "/Users/micahnacht/github/public-repos/osmquality/src/mqm/mqm_tool.py", line 278, in process_single_folder
    road_file = geo_processor.get_road_file()
  File "/Users/micahnacht/github/public-repos/osmquality/src/mqm/geo_process.py", line 307, in get_road_file
    road_file_name = [f for f in os.listdir(os.path.join(self.folder_path, sub_folder[0])) if f.endswith('.geojson')][0]
IndexError: list index out of range

We should always create the results folder outside of the folder from which we're reading.

Beware: if you have a trailing forward slash in your --folderPath arg, it will create a results folder in your path, which will then break your next run unless you delete it!