diff --git a/stop_areas/make_stop_areas.py b/stop_areas/make_stop_areas.py index 70a8333..9f059b9 100755 --- a/stop_areas/make_stop_areas.py +++ b/stop_areas/make_stop_areas.py @@ -13,20 +13,20 @@ import urllib.request QUERY = """ [out:json][timeout:250][bbox:{{bbox}}]; ( - node["railway"="subway_entrance"]; - node["station"="subway"]; - node["station"="light_rail"]; - node["public_transport"="stop_position"]["train"="yes"]; - node["public_transport"="stop_position"]["subway"="yes"]; - way["station"="subway"]; - relation["station"="subway"]; - way["railway"="platform"]; - relation["railway"="platform"]; - relation[route="subway"]; - relation[route="light_rail"]; + relation["route"="subway"];<<; + relation["route"="light_rail"];<<; + relation["public_transport"="stop_area"];<<; + way["station"="subway"]; + way["station"="light_rail"]; + node["railway"="station"]["subway"="yes"]; + node["railway"="station"]["light_rail"="yes"]; + node["station"="subway"]; + node["station"="light_rail"]; + node["railway"="subway_entrance"]; + node["public_transport"]["subway"="yes"]; + node["public_transport"]["light_rail"="yes"]; ); (._;>;); -(._;rel(bn);); out meta center qt; """ @@ -94,6 +94,9 @@ def add_stop_areas(src): if 'tags' in el and el['tags'].get('station', None) in ('subway', 'light_rail'): stations.add(StationWrapper(el)) + if stations.is_leaf: + raise Exception('No stations found') + # Populate a list of nearby subway exits and platforms for each station MAX_DISTANCE = 300 # meters stop_areas = {} @@ -174,7 +177,7 @@ if __name__ == '__main__': print('Usage: {} {{|}} [output.osm]'.format(sys.argv[0])) sys.exit(1) - if re.match(r'', sys.argv[1]): + if re.match(r'^[-0-9.,]+$', sys.argv[1]): src = overpass_request(sys.argv[1]) else: with open(sys.argv[1], 'r') as f: diff --git a/stop_areas/serve.py b/stop_areas/serve.py index 264516c..c6f4c49 100755 --- a/stop_areas/serve.py +++ b/stop_areas/serve.py @@ -13,9 +13,7 @@ def form(): @app.route('/process', methods=['GET']) def convert(): - bbox = request.args.get('bbox').split(',') - bbox_r = ','.join([bbox[i] for i in (1, 0, 3, 2)]) - src = overpass_request(bbox_r) + src = overpass_request(request.args.get('bbox')) if not src: return 'No data from overpass, sorry.' result = add_stop_areas(src) diff --git a/stop_areas/templates/index.html b/stop_areas/templates/index.html index e9b7738..c154e25 100644 --- a/stop_areas/templates/index.html +++ b/stop_areas/templates/index.html @@ -50,7 +50,8 @@ L.DomEvent.on(link, 'click', L.DomEvent.stop) .on(link, 'click', function () { if (!box) return; - bbox = box.getBounds().toBBoxString(); + var b = box.getBounds(), + bbox = [b.getSouth(), b.getWest(), b.getNorth(), b.getEast()].join(',') window.open('{{ url_for('convert') }}?bbox='+bbox, 'stop_area'); });