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

Handle TRIAS interchange legs

Also retain location ids for locations not provided in the response
context.
parent 7ac774b5
......@@ -13,6 +13,31 @@
"scheduledArrivalTime": "2021-09-11T11:25:00Z",
"scheduledDepartureTime": "2021-09-11T11:22:00Z",
"to": {
"identifier": {
"ifopt": "de:14511:30062",
"test_id": "de:14511:30062"
},
"name": "Chemnitz, Hauptbahnhof"
}
},
{
"disruptionEffect": "NormalService",
"distance": 0,
"from": {
"identifier": {
"ifopt": "de:14511:30062",
"test_id": "de:14511:30062"
},
"name": "Chemnitz, Hauptbahnhof"
},
"mode": "Transfer",
"scheduledArrivalTime": "2021-09-11T11:30:00Z",
"scheduledDepartureTime": "2021-09-11T11:25:00Z",
"to": {
"identifier": {
"ifopt": "de:14511:30062:7:12",
"test_id": "de:14511:30062:7:12"
},
"name": "Chemnitz, Hauptbahnhof"
}
},
......@@ -22,6 +47,10 @@
"expectedArrivalTime": "2021-09-11T11:46:00Z",
"expectedDepartureTime": "2021-09-11T11:30:00Z",
"from": {
"identifier": {
"ifopt": "de:14511:30062:7:12",
"test_id": "de:14511:30062:7:12"
},
"name": "Chemnitz, Hauptbahnhof"
},
"intermediateStops": [
......@@ -33,6 +62,10 @@
"scheduledDepartureTime": "2021-09-11T11:34:00Z",
"scheduledPlatform": "2",
"stopPoint": {
"identifier": {
"ifopt": "de:14511:30085:3:2",
"test_id": "de:14511:30085:3:2"
},
"name": "Chemnitz, Bahnhof Hilbersdorf"
}
},
......@@ -44,6 +77,10 @@
"scheduledDepartureTime": "2021-09-11T11:38:00Z",
"scheduledPlatform": "2",
"stopPoint": {
"identifier": {
"ifopt": "de:14522:30320:3:2",
"test_id": "de:14522:30320:3:2"
},
"name": "Niederwiesa, Bf"
}
},
......@@ -55,6 +92,10 @@
"scheduledDepartureTime": "2021-09-11T11:43:00Z",
"scheduledPlatform": "5",
"stopPoint": {
"identifier": {
"ifopt": "de:14522:55108:3:5",
"test_id": "de:14522:55108:3:5"
},
"name": "Flöha, Bahnhof"
}
}
......@@ -76,6 +117,31 @@
"scheduledDeparturePlatform": "12",
"scheduledDepartureTime": "2021-09-11T11:30:00Z",
"to": {
"identifier": {
"ifopt": "de:14522:51529:2:2",
"test_id": "de:14522:51529:2:2"
},
"name": "Falkenau (Sachs), Süd"
}
},
{
"disruptionEffect": "NormalService",
"distance": 0,
"from": {
"identifier": {
"ifopt": "de:14522:51529:2:2",
"test_id": "de:14522:51529:2:2"
},
"name": "Falkenau (Sachs), Süd"
},
"mode": "Transfer",
"scheduledArrivalTime": "2021-09-11T11:47:00Z",
"scheduledDepartureTime": "2021-09-11T11:46:00Z",
"to": {
"identifier": {
"ifopt": "de:14522:51529",
"test_id": "de:14522:51529"
},
"name": "Falkenau (Sachs), Süd"
}
},
......@@ -83,6 +149,10 @@
"disruptionEffect": "NormalService",
"distance": 0,
"from": {
"identifier": {
"ifopt": "de:14522:51529",
"test_id": "de:14522:51529"
},
"name": "Falkenau (Sachs), Süd"
},
"mode": "Walking",
......
......@@ -16,6 +16,10 @@
"scheduledDepartureTime": "2021-09-10T19:41:00Z",
"scheduledPlatform": "3",
"stopPoint": {
"identifier": {
"ifopt": "de:14612:131:1:1",
"test_id": "de:14612:131:1:1"
},
"name": "Dresden Reichenbachstraße"
}
},
......@@ -32,6 +36,10 @@
"scheduledDepartureTime": "2021-09-10T19:41:00Z",
"scheduledPlatform": "1",
"stopPoint": {
"identifier": {
"ifopt": "de:14612:32:1:1",
"test_id": "de:14612:32:1:1"
},
"name": "Dresden Hauptbahnhof Nord"
}
}
......
......@@ -127,13 +127,7 @@ Location OpenJourneyPlannerParser::parseLocationInformationLocation(ScopedXmlStr
while (subR.readNextSibling()) {
if (subR.isElement("StopPlaceRef") || subR.isElement("StopPointRef")) {
const auto id = subR.readElementText();
loc.setIdentifier(m_identifierType, id);
if (IfoptUtil::isValid(id)) {
loc.setIdentifier(IfoptUtil::identifierType(), id);
}
if (!m_uicIdentifierType.isEmpty() && UicUtil::isStationId(id)) {
loc.setIdentifier(m_uicIdentifierType, id);
}
setLocationIdentifier(loc, id);
} else if (subR.isElement("StopPlaceName") || subR.isElement("StopPointName")) {
loc.setName(parseTextElement(subR.subReader()));
}
......@@ -284,7 +278,12 @@ void OpenJourneyPlannerParser::parseCallAtStop(ScopedXmlStreamReader &&r, Stopov
while (r.readNextSibling()) {
if (r.isElement("StopPointRef")) {
const auto id = r.readElementText();
loc = m_contextLocations.value(id);
auto l = m_contextLocations.value(id);
if (l.isEmpty()) {
setLocationIdentifier(loc, id);
} else {
loc = l;
}
} else if (r.isElement("GeoPosition")) {
const auto p = parseGeoPosition(r.subReader());
loc.setLatitude(p.y());
......@@ -427,7 +426,7 @@ Journey OpenJourneyPlannerParser::parseTrip(ScopedXmlStreamReader &&r) const
while (subR.readNextSibling()) {
if (subR.isElement("TimedLeg")) {
sections.push_back(parseTimedLeg(subR.subReader()));
} else if (subR.isElement("TransferLeg")) {
} else if (subR.isElement("TransferLeg") || subR.isElement("InterchangeLeg")) {
auto section = parseTransferLeg(subR.subReader());
section.setMode(JourneySection::Transfer);
sections.push_back(std::move(section));
......@@ -561,3 +560,14 @@ void OpenJourneyPlannerParser::parseError(ScopedXmlStreamReader &&r)
}
}
}
void OpenJourneyPlannerParser::setLocationIdentifier(Location &loc, const QString &id) const
{
loc.setIdentifier(m_identifierType, id);
if (IfoptUtil::isValid(id)) {
loc.setIdentifier(IfoptUtil::identifierType(), id);
}
if (!m_uicIdentifierType.isEmpty() && UicUtil::isStationId(id)) {
loc.setIdentifier(m_uicIdentifierType, id);
}
}
......@@ -82,6 +82,8 @@ private:
void parseError(ScopedXmlStreamReader &&r);
void setLocationIdentifier(Location &loc, const QString &id) const;
QString m_identifierType;
QString m_uicIdentifierType;
QHash<QString, Location> m_contextLocations;
......
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