diff --git a/src/backend/hafas/parse/line.nim b/src/backend/hafas/parse/line.nim index 1e946ec..32393bc 100644 --- a/src/backend/hafas/parse/line.nim +++ b/src/backend/hafas/parse/line.nim @@ -9,6 +9,7 @@ import asyncdispatch var trainTypes = initTable[string, string]() +var trainTypesShort = initTable[string, string]() proc fetchTrainTypes() {.async.} = var client = newAsyncHttpClient() @@ -17,6 +18,8 @@ proc fetchTrainTypes() {.async.} = for key, info in pairs(data): if info{"type"}.getStr != "" and info{"type"}.getStr != "EC" and info{"type"}.getStr != "IC": trainTypes[key] = info{"type"}.getStr + if info{"short"}.getStr != "": + trainTypesShort[key] = info{"short"}.getStr asyncCheck fetchTrainTypes() @@ -46,6 +49,8 @@ proc parseLine*(common: CommonData, i: int): Option[Line] = if res.productName == "IC" or res.productName == "ICE" or res.productName == "EC" or res.productName == "ECE": if trainTypes.contains(res.tripNum) and trainTypes[res.tripNum] != res.productName: res.trainType = some(trainTypes[res.tripNum]) + if trainTypesShort.contains(res.tripNum): + res.trainTypeShort = some(trainTypesShort[res.tripNum]) if line.nameS.isSome and (res.product == bus or res.product == tram or res.product == ferry): res.name = line.nameS.get diff --git a/src/types.nim b/src/types.nim index d80d047..cca0c80 100644 --- a/src/types.nim +++ b/src/types.nim @@ -89,6 +89,7 @@ type operator*: Option[Operator] additionalName*: Option[string] trainType*: Option[string] + trainTypeShort*: Option[string] Operator* = object id*: string