some protection if you dont have osmtogeojson installed

parent a680c6bb
......@@ -86,7 +86,10 @@ Would overpass be able to do this?
### Running Dutch municipality merge of 2018
Get the latest dataset from the server, get it to your dev environment
Get the latest dataset from the server, get it to your dev environment.
This requires the node package [osmtogeojson]( which does an awesome job at
polygon detection and is being well maintained. There is no python alternative.
# DEVELOPMENT ONLY: failmap create_dataset -o -> dataset_12mar2018.json
import json
import logging
import subprocess
from subprocess import CalledProcessError
from datetime import datetime
from typing import Dict
......@@ -28,8 +29,25 @@ resampling_resolutions = {
'NL': {'municipality': 0.001}
def osmtogeojson_available():
subprocess.check_output(["osmtogeojson", "tesfile.osm"], stderr=subprocess.STDOUT, )
except CalledProcessError as e:
if "no such file or directory, open 'tesfile.osm'" in str(e.output):
return True
return False
except FileNotFoundError:
return False
def update_coordinates(country: str = "NL", organization_type: str="municipality", when=None):
if not osmtogeojson_available():
raise FileNotFoundError("osmtogeojson was not found. Please install it and make sure python can access it. "
"Cannot continue.")"Attempting to update coordinates for: %s %s " % (country, organization_type))
update_coordinates_task.s(country, organization_type, when).apply_async()
......@@ -37,8 +55,6 @@ def update_coordinates(country: str = "NL", organization_type: str="municipality
def update_coordinates_task(country: str = "NL", organization_type: str="municipality", when=None):"Attempting to update coordinates for: %s %s " % (country, organization_type))
# you are about to load 50 megabyte of data. Or MORE! :)
data = get_osm_data(country, organization_type)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment