filter out "EC" and "IC" train types

They are usually not useful, because the train type is already contained
in the line name.
This commit is contained in:
Milan Pässler 2020-09-11 19:41:43 +02:00
parent cf2eb0e5a3
commit 7ac9fb84a5

View file

@ -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):