add short train types
This commit is contained in:
parent
3c4a0fc9c8
commit
688c782485
|
@ -9,6 +9,7 @@ import asyncdispatch
|
||||||
|
|
||||||
|
|
||||||
var trainTypes = initTable[string, string]()
|
var trainTypes = initTable[string, string]()
|
||||||
|
var trainTypesShort = initTable[string, string]()
|
||||||
|
|
||||||
proc fetchTrainTypes() {.async.} =
|
proc fetchTrainTypes() {.async.} =
|
||||||
var client = newAsyncHttpClient()
|
var client = newAsyncHttpClient()
|
||||||
|
@ -17,6 +18,8 @@ proc fetchTrainTypes() {.async.} =
|
||||||
for key, info in pairs(data):
|
for key, info in pairs(data):
|
||||||
if info{"type"}.getStr != "" and info{"type"}.getStr != "EC" and info{"type"}.getStr != "IC":
|
if info{"type"}.getStr != "" and info{"type"}.getStr != "EC" and info{"type"}.getStr != "IC":
|
||||||
trainTypes[key] = info{"type"}.getStr
|
trainTypes[key] = info{"type"}.getStr
|
||||||
|
if info{"short"}.getStr != "":
|
||||||
|
trainTypesShort[key] = info{"short"}.getStr
|
||||||
|
|
||||||
asyncCheck fetchTrainTypes()
|
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 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:
|
if trainTypes.contains(res.tripNum) and trainTypes[res.tripNum] != res.productName:
|
||||||
res.trainType = some(trainTypes[res.tripNum])
|
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):
|
if line.nameS.isSome and (res.product == bus or res.product == tram or res.product == ferry):
|
||||||
res.name = line.nameS.get
|
res.name = line.nameS.get
|
||||||
|
|
|
@ -89,6 +89,7 @@ type
|
||||||
operator*: Option[Operator]
|
operator*: Option[Operator]
|
||||||
additionalName*: Option[string]
|
additionalName*: Option[string]
|
||||||
trainType*: Option[string]
|
trainType*: Option[string]
|
||||||
|
trainTypeShort*: Option[string]
|
||||||
|
|
||||||
Operator* = object
|
Operator* = object
|
||||||
id*: string
|
id*: string
|
||||||
|
|
Loading…
Reference in a new issue