Commit 2aeba314 authored by Volker Krause's avatar Volker Krause
Browse files

Parse IFOPT ids from compact EFA reponses too

parent 8a54f6df
......@@ -18,6 +18,7 @@
"scheduledPlatform": "4",
"stopPoint": {
"identifier": {
"ifopt": "de:09663:177:3:4",
"testid": "80001152"
},
"latitude": 49.80202865600586,
......@@ -39,6 +40,7 @@
"scheduledDepartureTime": "2019-11-11T20:22:00",
"stopPoint": {
"identifier": {
"ifopt": "de:09663:75:10:22",
"testid": "80029081"
},
"latitude": 49.800758361816406,
......@@ -59,6 +61,7 @@
"scheduledDepartureTime": "2019-11-11T20:22:00",
"stopPoint": {
"identifier": {
"ifopt": "de:09663:170:1:02",
"testid": "80029079"
},
"latitude": 49.80030059814453,
......
[
{
"identifier": {
"ifopt": "de:09663:177",
"testid": "80001152"
},
"latitude": 49.80179977416992,
......
......@@ -8,6 +8,7 @@
"expectedDepartureTime": "2019-11-11T21:26:00",
"from": {
"identifier": {
"ifopt": "de:09564:1391:11:2",
"testid": "3001391"
},
"latitude": 49.49388122558594,
......@@ -23,6 +24,7 @@
"scheduledPlatform": "1",
"stopPoint": {
"identifier": {
"ifopt": "de:09564:1320:11:1",
"testid": "3001320"
},
"latitude": 49.485328674316406,
......@@ -37,6 +39,7 @@
"scheduledPlatform": "1",
"stopPoint": {
"identifier": {
"ifopt": "de:09564:1324:11:1",
"testid": "3001324"
},
"latitude": 49.47829055786133,
......@@ -51,6 +54,7 @@
"scheduledPlatform": "1",
"stopPoint": {
"identifier": {
"ifopt": "de:09564:1335:11:1",
"testid": "80003151"
},
"latitude": 49.47246170043945,
......@@ -66,6 +70,7 @@
"scheduledPlatform": "1",
"stopPoint": {
"identifier": {
"ifopt": "de:09564:341:11:1",
"testid": "3000341"
},
"latitude": 49.464900970458984,
......@@ -80,6 +85,7 @@
"scheduledPlatform": "1",
"stopPoint": {
"identifier": {
"ifopt": "de:09564:340:11:1",
"testid": "3000340"
},
"latitude": 49.460960388183594,
......@@ -94,6 +100,7 @@
"scheduledPlatform": "1",
"stopPoint": {
"identifier": {
"ifopt": "de:09564:332:11:1",
"testid": "3000332"
},
"latitude": 49.45685958862305,
......@@ -108,6 +115,7 @@
"scheduledPlatform": "1",
"stopPoint": {
"identifier": {
"ifopt": "de:09564:333:11:1",
"testid": "3000333"
},
"latitude": 49.452579498291016,
......@@ -161,6 +169,7 @@
"scheduledDepartureTime": "2019-11-11T21:26:00",
"to": {
"identifier": {
"ifopt": "de:09564:510:11:U2",
"testid": "80001020"
},
"latitude": 49.447059631347656,
......@@ -174,6 +183,7 @@
"distance": 4156,
"from": {
"identifier": {
"ifopt": "de:09564:510:11:U1_2",
"testid": "80001020"
},
"latitude": 49.446388244628906,
......@@ -223,6 +233,7 @@
"scheduledDepartureTime": "2019-11-11T21:50:00",
"to": {
"identifier": {
"ifopt": "de:09564:1502:11:2",
"testid": "3001502"
},
"latitude": 49.41590118408203,
......
......@@ -7,6 +7,7 @@
#include "efacompactparser.h"
#include "logging.h"
#include "scopedxmlstreamreader.h"
#include "ifopt/ifoptutil.h"
#include <KPublicTransport/Journey>
#include <KPublicTransport/Location>
......@@ -27,6 +28,21 @@ static void parseCompactCoordinate(const QString &text, Location &loc)
}
}
static void parseCompactIfopt(ScopedXmlStreamReader &reader, Location &loc)
{
if (reader.name() == QLatin1String("pgid")) {
const auto id = reader.readElementText();
if (IfoptUtil::isValid(id)) {
loc.setIdentifier(QStringLiteral("ifopt"), id);
}
} else if (reader.name() == QLatin1String("gid")) {
const auto id = reader.readElementText();
if (IfoptUtil::isValid(id) && loc.identifier(QLatin1String("ifopt")).isEmpty()) {
loc.setIdentifier(QStringLiteral("ifopt"), id);
}
}
}
Location EfaCompactParser::parseCompactSf(ScopedXmlStreamReader &&reader) const
{
Location loc;
......@@ -53,6 +69,8 @@ Location EfaCompactParser::parseCompactSf(ScopedXmlStreamReader &&reader) const
}
} else if (sub.name() == QLatin1String("pc")) {
loc.setLocality(sub.readElementText());
} else {
parseCompactIfopt(sub, loc);
}
}
}
......@@ -156,6 +174,8 @@ Stopover EfaCompactParser::parseCompactDp(ScopedXmlStreamReader &&reader) const
parseCompactCoordinate(reader.readElementText(), loc);
} else if (reader.name() == QLatin1String("ns")) {
dep.setNotes(parseNotes(reader.subReader()));
} else {
parseCompactIfopt(reader, loc);
}
}
......@@ -209,8 +229,9 @@ void EfaCompactParser::parseTripSectionHalf(ScopedXmlStreamReader &&reader, Jour
parseCompactCoordinate(subReader.readElementText(), loc);
}
}
} else {
parseCompactIfopt(reader, loc);
}
}
if (isArr) {
......@@ -316,6 +337,12 @@ JourneySection EfaCompactParser::parseTripSection(ScopedXmlStreamReader &&reader
}
loc.setCoordinate(coord[1].toFloat(), coord[0].toFloat());
if (IfoptUtil::isValid(stopParams[13])) {
loc.setIdentifier(QStringLiteral("ifopt"), stopParams[13]);
} else if (IfoptUtil::isValid(stopParams[12])) {
loc.setIdentifier(QStringLiteral("ifopt"), stopParams[12]);
}
const auto dt = QDateTime::fromString(stopParams[2] + stopParams[3], QStringLiteral("yyyyMMddhhmm"));
if (!dt.isValid()) {
continue;
......
Markdown is supported
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