ctucx.git: oeffisearch

[nimlang] fast and simple tripplanner

commit 688c782485ad70ae4a4150ae7e3d91dcc1fd5e5f
parent 3c4a0fc9c8e833aa956c287f0ba3aba887edcf4f
Author: Milan Pässler <milan@petabyte.dev>
Date: Fri, 11 Sep 2020 19:44:31 +0200

add short train types
2 files changed, 6 insertions(+), 0 deletions(-)
diff --git 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
@@ -89,6 +89,7 @@ type
     operator*:          Option[Operator]
     additionalName*:    Option[string]
     trainType*:         Option[string]
+    trainTypeShort*:    Option[string]
 
   Operator* = object
     id*:   string