commit 7ac9fb84a5524abadeabd54dbec58556e82d0718
parent cf2eb0e5a3aed1cae872a37e9aa05b11434e315c
Author: Milan Pässler <milan@petabyte.dev>
Date: Fri, 11 Sep 2020 19:41:43 +0200
parent cf2eb0e5a3aed1cae872a37e9aa05b11434e315c
Author: Milan Pässler <milan@petabyte.dev>
Date: Fri, 11 Sep 2020 19:41:43 +0200
filter out "EC" and "IC" train types They are usually not useful, because the train type is already contained in the line name.
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/backend/hafas/parse/line.nim b/src/backend/hafas/parse/line.nim @@ -15,7 +15,8 @@ proc fetchTrainTypes() {.async.} = let resp = await client.getContent("https://lib.finalrewind.org/dbdb/ice_type.json") let data = parseJson(resp) for key, info in pairs(data): - trainTypes[key] = info{"type"}.getStr + if info{"type"}.getStr != "" and info{"type"}.getStr != "EC" and info{"type"}.getStr != "IC": + trainTypes[key] = info{"type"}.getStr asyncCheck fetchTrainTypes() @@ -43,7 +44,7 @@ proc parseLine*(common: CommonData, i: int): Option[Line] = # DB if res.productName == "IC" or res.productName == "ICE" or res.productName == "EE" or res.productName == "ECE": - if trainTypes.contains(res.tripNum): + if trainTypes.contains(res.tripNum) and trainTypes[res.tripNum] != res.productName: res.trainType = some(trainTypes[res.tripNum]) if line.nameS.isSome and (res.product == bus or res.product == tram or res.product == ferry):