Commit ab422aa3 authored by Volker Krause's avatar Volker Krause
Browse files

Parse alternative Hafas platform format as well

Found e.g. in VSN and ZVV responses.
parent b4b01199
Pipeline #108625 passed with stage
in 2 minutes and 27 seconds
{"ver":"1.27","lang":"deu","err":"OK","graph":{"id":"standard","index":0},"subGraph":{"id":"global","index":0},"view":{"id":"standard","index":0,"type":"WGS84"},"svcResL":[{"meth":"TripSearch","err":"OK","res":{"common":{"locL":[{"lid":"A=1@O=Hannover Messe/Laatzen@X=9792867@Y=52316896@U=80@L=8003487@","type":"S","name":"Hannover Messe/Laatzen","icoX":0,"extId":"8003487","state":"F","crd":{"x":9792867,"y":52316896,"floor":0},"pCls":63,"gidL":["A×de:03241:9830"]},{"lid":"A=1@O=Hannover Hbf@X=9741988@Y=52377375@U=80@L=8000152@","type":"S","name":"Hannover Hbf","icoX":0,"extId":"8000152","state":"F","crd":{"x":9741988,"y":52377375,"floor":0},"pCls":31,"gidL":["A×de:03241:31"]},{"lid":"A=1@O=Hildesheim Hbf@X=9953495@Y=52160627@U=80@L=8000169@","type":"S","name":"Hildesheim Hbf","icoX":0,"extId":"8000169","state":"F","crd":{"x":9953495,"y":52160627,"floor":0},"pCls":31,"gidL":["A×de:03254:9922"]}],"prodL":[{"pid":"L::4::S::B0269298727::800244_S4::*","name":"S4","nameS":"S4","number":"S4","icoX":2,"cls":16,"oprX":0,"prodCtx":{"name":" S4","num":"36","line":"S4","matchId":"34434","catOut":"S ","catOutS":"s","catOutL":"S-Bahn","catIn":"s","catCode":"4","admin":"800244"}},{"pid":"L::4::S::B0269298727::800244_S4::*","name":"S4","nameS":"S4","number":"S4","icoX":2,"cls":16,"oprX":1,"prodCtx":{"name":" S4","num":"36","line":"S4","lineId":"800244_S4","matchId":"34434","catOut":"S ","catOutS":"s","catOutL":"S-Bahn","catIn":"s","catCode":"4","admin":"800244"}}],"opL":[{"name":"DB Regio AG Nord","icoX":3},{"name":"DB Regio AG Nord","icoX":3,"id":"1689"}],"remL":[{"type":"A","code":"PF","prio":200,"icoX":4,"txtN":"Maskenpflicht nach gesetzl. Regelung; denken Sie an eine FFP2-Maske"},{"type":"A","code":"3G","prio":205,"icoX":4,"txtN":"Im Zug gilt bundesweit 3G-Regel: ein gültiger Nachweis ist mitzuführen"},{"type":"A","code":"FK","prio":260,"icoX":5,"txtN":"Fahrradmitnahme begrenzt möglich (Hannover Messe/Laatzen)"},{"type":"A","code":"FK","prio":260,"icoX":5,"txtN":"Fahrradmitnahme begrenzt möglich (Hannover Hbf)"},{"type":"A","code":"AO","prio":350,"icoX":4,"txtN":"Konsum alkoholischer Getränke im Zug verboten"},{"type":"A","code":"EH","prio":560,"icoX":4,"txtN":"Fahrzeuggebundene Einstiegshilfe vorhanden"}],"himL":[{"hid":"25662","act":true,"head":"Corona-Präventionsmaßnahme","text":"3G-Regel im ÖPNV (geimpft, genesen oder getestet). Bitte beachten Sie die Maskenpflicht!","icoX":6,"prio":1,"fLocX":2,"tLocX":2,"prod":65535,"src":99,"lModDate":"20211123","lModTime":"171447","sDate":"20211124","sTime":"000000","eDate":"20221231","eTime":"235900","sDaily":"000000","eDaily":"235900","comp":"VBN","catRefL":[0],"pubChL":[{"name":"TIMETABLE","fDate":"20211123","fTime":"171300","tDate":"20221231","tTime":"235900"}]}],"icoL":[{"res":"prod_ice","fg":{"r":255,"g":255,"b":255},"bg":{"r":150,"g":25,"b":29}},{"res":"rt_ont"},{"res":"prod_comm","fg":{"r":255,"g":255,"b":255},"bg":{"r":19,"g":148,"b":69}},{"res":"RE","txt":"DB Regio AG Nord"},{"res":"INFO"},{"res":"attr_bike"},{"res":"HIM2"},{"res":"cl_all"}],"himMsgCatL":[{"id":2}],"lDrawStyleL":[{"sIcoX":2,"type":"SOLID","bg":{"r":19,"g":148,"b":69}},{"type":"SOLID","bg":{"r":19,"g":148,"b":69}}]},"outConL":[{"cid":"C-0","date":"20211212","dur":"000800","chg":0,"sDays":{"sDaysR":"nicht täglich","sDaysI":"12. Dez 2021 bis 1. Apr 2022","sDaysB":"0003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFE00000000000000000000000"},"dep":{"locX":0,"idx":5,"dProdX":0,"dPltfS":{"type":"PL","txt":"16"},"dPltfR":{"type":"PL","txt":"16"},"dTimeS":"123000","dTimeR":"123000","dProgType":"PROGNOSED","type":"N"},"arr":{"locX":1,"idx":7,"aProdX":0,"aPltfS":{"type":"PL","txt":"2"},"aPltfR":{"type":"PL","txt":"2"},"aTimeS":"123800","aTimeR":"123800","aProgType":"PROGNOSED","type":"N"},"secL":[{"type":"JNY","dep":{"locX":0,"idx":5,"dProdX":0,"dPltfS":{"type":"PL","txt":"16"},"dPltfR":{"type":"PL","txt":"16"},"dTimeS":"123000","dTimeR":"123000","dProgType":"PROGNOSED","type":"N"},"arr":{"locX":1,"idx":7,"aProdX":0,"aPltfS":{"type":"PL","txt":"2"},"aPltfR":{"type":"PL","txt":"2"},"aTimeS":"123800","aTimeR":"123800","aProgType":"PROGNOSED","type":"N"},"jny":{"jid":"1|235190|6|80|12122021","prodX":1,"dirTxt":"Bennemühlen","dirFlg":"2","status":"P","isRchbl":true,"pos":{"x":9792606,"y":52317363},"freq":{"minC":60,"maxC":60,"numC":3},"ctxRecon":"T$A=1@O=Hannover Messe/Laatzen@L=8003487@a=128@$A=1@O=Hannover Hbf@L=8000152@a=128@$202112121230$202112121238$ S4$$1$$$$$$","msgL":[{"type":"REM","remX":0,"sty":"I","fLocX":0,"tLocX":1,"tagL":["RES_JNY_DTL"],"sort":831520768},{"type":"REM","remX":1,"sty":"I","fLocX":0,"tLocX":1,"tagL":["RES_JNY_DTL"],"sort":832176128},{"type":"REM","remX":2,"sty":"I","fLocX":0,"tLocX":0,"tagL":["RES_JNY_DTL"],"sort":839385088},{"type":"REM","remX":3,"sty":"I","fLocX":1,"tLocX":1,"tagL":["RES_JNY_DTL"],"sort":839385088},{"type":"REM","remX":4,"sty":"I","fLocX":0,"tLocX":1,"tagL":["RES_JNY_DTL"],"sort":851181568},{"type":"REM","remX":5,"sty":"I","fLocX":0,"tLocX":1,"tagL":["RES_JNY_DTL"],"sort":878706688},{"type":"HIM","himX":0,"sty":"M","fLocX":0,"tagL":["RES_GLB_HDR_H3","SUM_GLB_HDR_H3"],"sort":269798358}],"subscr":"F","prodL":[{"prodX":1,"fLocX":0,"tLocX":1,"fIdx":5,"tIdx":7}],"sumLDrawStyleX":0,"resLDrawStyleX":1,"trainStartDate":"20211212","durS":"000800"}}],"ctxRecon":"¶HKI¶T$A=1@O=Hannover Messe/Laatzen@L=8003487@a=128@$A=1@O=Hannover Hbf@L=8000152@a=128@$202112121230$202112121238$ S4$$1$$$$$$","freq":{"minC":60},"trfRes":{"statusCode":"NA","statusText":" [1104]","bkgData":{"common":{},"BOG":{},"errCode":1200,"errMsg":"no relation between 32413487 and 32410152 on 20211212 for bits 2"}},"conSubscr":"F","recState":"U","cksum":"12bc658a_3","cksumDti":"310925bc_3","intvlSubscr":"F"}]}}]}
[
{
"sections": [
{
"disruptionEffect": "NormalService",
"distance": 7561,
"expectedArrivalPlatform": "2",
"expectedArrivalTime": "2021-12-12T12:38:00",
"expectedDeparturePlatform": "16",
"expectedDepartureTime": "2021-12-12T12:30:00",
"from": {
"identifier": {
"unit-test": "8003487"
},
"latitude": 52.31689453125,
"longitude": 9.792866706848145,
"name": "Hannover Messe/Laatzen",
"type": "Stop"
},
"mode": "PublicTransport",
"notes": [
"Maskenpflicht nach gesetzl. Regelung; denken Sie an eine FFP2-Maske",
"Im Zug gilt bundesweit 3G-Regel: ein gültiger Nachweis ist mitzuführen",
"Fahrradmitnahme begrenzt möglich (Hannover Messe/Laatzen)",
"Fahrradmitnahme begrenzt möglich (Hannover Hbf)",
"Konsum alkoholischer Getränke im Zug verboten",
"Fahrzeuggebundene Einstiegshilfe vorhanden",
"Corona-Präventionsmaßnahme\n\n3G-Regel im ÖPNV (geimpft, genesen oder getestet). Bitte beachten Sie die Maskenpflicht!"
],
"route": {
"direction": "Bennemühlen",
"line": {
"color": "#139445",
"name": "S4",
"textColor": "#ffffff"
}
},
"scheduledArrivalPlatform": "2",
"scheduledArrivalTime": "2021-12-12T12:38:00",
"scheduledDeparturePlatform": "16",
"scheduledDepartureTime": "2021-12-12T12:30:00",
"to": {
"identifier": {
"unit-test": "8000152"
},
"latitude": 52.377376556396484,
"longitude": 9.741988182067871,
"name": "Hannover Hbf",
"type": "Stop"
}
}
]
}
]
......@@ -139,6 +139,9 @@ private Q_SLOTS:
QTest::newRow("de-bvg-alternative-load-messages")
<< s(SOURCE_DIR "/data/hafas/journey-bvg-load-messages.in.json")
<< s(SOURCE_DIR "/data/hafas/journey-bvg-load-messages.out.json");
QTest::newRow("de-vsn-alternative-platform-data")
<< s(SOURCE_DIR "/data/hafas/journey-vsn-alternative-platform-data.in.json")
<< s(SOURCE_DIR "/data/hafas/journey-vsn-alternative-platform-data.out.json");
}
void testParseJourneys()
......
......@@ -271,6 +271,17 @@ std::vector<Line> HafasMgateParser::parseLines(const QJsonArray &prodL, const st
return lines;
}
static QString parsePlatform(const QJsonObject &obj, char ad, char rs)
{
const auto p = obj.value(QLatin1Char(ad) + QLatin1String("Platf") + QLatin1Char(rs)).toString();
if (!p.isEmpty()) {
return p;
}
const auto pObj = obj.value(QLatin1Char(ad) + QLatin1String("Pltf") + QLatin1Char(rs)).toObject();
return pObj.value(QLatin1String("txt")).toString();
}
std::vector<Stopover> HafasMgateParser::parseStationBoardResponse(const QJsonObject &obj) const
{
const auto commonObj = obj.value(QLatin1String("common")).toObject();
......@@ -302,13 +313,13 @@ std::vector<Stopover> HafasMgateParser::parseStationBoardResponse(const QJsonObj
dep.setScheduledArrivalTime(parseDateTime(dateStr, stbStop.value(QLatin1String("aTimeS")), stbStop.value(QLatin1String("aTZOffset"))));
dep.setExpectedArrivalTime(parseDateTime(dateStr, stbStop.value(QLatin1String("aTimeR")), stbStop.value(QLatin1String("aTZOffset"))));
dep.setScheduledPlatform(stbStop.value(QLatin1String("dPlatfS")).toString());
dep.setExpectedPlatform(stbStop.value(QLatin1String("dPlatfR")).toString());
dep.setScheduledPlatform(parsePlatform(stbStop, 'd', 'S'));
dep.setExpectedPlatform(parsePlatform(stbStop, 'd', 'R'));
if (dep.scheduledPlatform().isEmpty()) {
dep.setScheduledPlatform(stbStop.value(QLatin1String("aPlatfS")).toString());
dep.setScheduledPlatform(parsePlatform(stbStop, 'a', 'S'));
}
if (dep.expectedPlatform().isEmpty()) {
dep.setExpectedPlatform(stbStop.value(QLatin1String("aPlatfR")).toString());
dep.setExpectedPlatform(parsePlatform(stbStop, 'a', 'R'));
}
if (stbStop.value(QLatin1String("dCncl")).toBool()) {
dep.setDisruptionEffect(Disruption::NoService);
......@@ -634,8 +645,8 @@ std::vector<Journey> HafasMgateParser::parseTripSearch(const QJsonObject &obj)
parseMcpData(dep, loc);
section.setFrom(std::move(loc));
}
section.setScheduledDeparturePlatform(dep.value(QLatin1String("dPlatfS")).toString());
section.setExpectedDeparturePlatform(dep.value(QLatin1String("dPlatfR")).toString());
section.setScheduledDeparturePlatform(parsePlatform(dep, 'd', 'S'));
section.setExpectedDeparturePlatform(parsePlatform(dep, 'd', 'R'));
if (dep.value(QLatin1String("dCncl")).toBool()) {
section.setDisruptionEffect(Disruption::NoService);
}
......@@ -649,8 +660,8 @@ std::vector<Journey> HafasMgateParser::parseTripSearch(const QJsonObject &obj)
parseMcpData(arr, loc);
section.setTo(loc);
}
section.setScheduledArrivalPlatform(arr.value(QLatin1String("aPlatfS")).toString());
section.setExpectedArrivalPlatform(arr.value(QLatin1String("aPlatfR")).toString());
section.setScheduledArrivalPlatform(parsePlatform(arr, 'a', 'S'));
section.setExpectedArrivalPlatform(parsePlatform(arr, 'a', 'R'));
if (arr.value(QLatin1String("aCncl")).toBool()) {
section.setDisruptionEffect(Disruption::NoService);
}
......@@ -687,8 +698,8 @@ std::vector<Journey> HafasMgateParser::parseTripSearch(const QJsonObject &obj)
stop.setExpectedDepartureTime(parseDateTime(dateStr, stopObj.value(QLatin1String("dTimeR")), stopObj.value(QLatin1String("dTZOffset"))));
stop.setScheduledArrivalTime(parseDateTime(dateStr, stopObj.value(QLatin1String("aTimeS")), stopObj.value(QLatin1String("aTZOffset"))));
stop.setExpectedArrivalTime(parseDateTime(dateStr, stopObj.value(QLatin1String("aTimeR")), stopObj.value(QLatin1String("aTZOffset"))));
stop.setScheduledPlatform(stopObj.value(QLatin1String("dPlatfS")).toString());
stop.setExpectedPlatform(stopObj.value(QLatin1String("dPlatfR")).toString());
stop.setScheduledPlatform(parsePlatform(stopObj, 'd', 'S'));
stop.setExpectedPlatform(parsePlatform(stopObj, 'd', 'R'));
if (stopObj.value(QLatin1String("aCncl")).toBool() || stopObj.value(QLatin1String("dCncl")).toBool()) {
stop.setDisruptionEffect(Disruption::NoService);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment