diff --git a/process_subways.py b/process_subways.py index d4e6aa1..2dce57b 100755 --- a/process_subways.py +++ b/process_subways.py @@ -9,6 +9,7 @@ import time import urllib.parse import urllib.request from processors import processor +from collections import OrderedDict from subway_structure import ( download_cities, @@ -168,15 +169,15 @@ def dump_data(city, f): stops = set() routes = [] for route in city: - stations = ['{} ({})'.format(sa.name, sa.transfer or sa.id) for sa in route.stop_areas()] + stations = OrderedDict([(sa.transfer or sa.id, sa.name) for sa in route.stop_areas()]) rte = { 'type': route.mode, 'ref': route.ref, 'name': route.name, 'colour': route.colour, 'infill': route.infill, - 'station_count': len(set(stations)), - 'stations': stations, + 'station_count': len(stations), + 'stations': list(stations.values()), 'itineraries': {} } for variant in route: diff --git a/scripts/build_city.sh b/scripts/build_city.sh index a63e8dc..6b8d8af 100755 --- a/scripts/build_city.sh +++ b/scripts/build_city.sh @@ -11,6 +11,6 @@ fi if [ -n "${3-}" ]; then export BBOX="$3" elif [ -n "${CITY-}" ]; then - export BBOX="$(python3 -c 'import subway_structure; c = [x for x in subway_structure.download_cities() if x.name == "'$CITY'"]; print("{1},{0},{3},{2}".format(*c[0].bbox))')" || true + export BBOX="$(python3 -c 'import subway_structure; c = [x for x in subway_structure.download_cities() if x.name == "'"$CITY"'"]; print("{1},{0},{3},{2}".format(*c[0].bbox))')" || true fi "$(dirname "$0")/process_subways.sh" "$1"