summaryrefslogtreecommitdiff
path: root/bin/efa-gw
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-03-27 14:56:16 +0100
committerDaniel Friesel <derf@finalrewind.org>2021-03-27 14:56:16 +0100
commit08ba0611c2c6a0e022a9fd0aff6399c7b957a9e7 (patch)
tree8a02813242ad56eb3f2898a01c747e42ae7aec34 /bin/efa-gw
parent2bd30e325041ad7ec5afe7044e559070616621e9 (diff)
switch to geolocation-based station matching
Diffstat (limited to 'bin/efa-gw')
-rwxr-xr-xbin/efa-gw17
1 files changed, 4 insertions, 13 deletions
diff --git a/bin/efa-gw b/bin/efa-gw
index fc6e949..4d92e2c 100755
--- a/bin/efa-gw
+++ b/bin/efa-gw
@@ -6,7 +6,6 @@ import argparse
import aiohttp
from aiohttp import web
-import csv
import json
headers = {
@@ -19,17 +18,6 @@ occupancy_map = {"MANY_SEATS": 1, "FEW_SEATS": 2, "STANDING_ONLY": 3}
eva_to_name = dict()
-def load_eva_to_name(filename):
- ret = dict()
- with open(filename, "r") as f:
- f.readline()
- cr = csv.reader(f, delimiter=";")
- for city, place, _, _, _, _, _, name, _, eva, transports in cr:
- if "TRAIN" in transports:
- ret[int(eva)] = name
- return ret
-
-
def get_occupancy(occupancy):
try:
return occupancy_map[occupancy]
@@ -75,7 +63,10 @@ if __name__ == "__main__":
parser.add_argument("--prefix", type=str, metavar="PATH", default="/")
args = parser.parse_args()
- eva_to_name = load_eva_to_name(args.eva_csv)
+ with open("share/vrr.json", "r") as f:
+ for eva, (city, stop, name) in json.load(f).items():
+ eva_to_name[int(eva)] = name
+
app = web.Application()
app.add_routes([web.get(f"{args.prefix}{{eva}}.json", handle_eva)])
web.run_app(app, host="localhost", port=args.port)