Commit 0092cf04 authored by Volker Krause's avatar Volker Krause
Browse files

Provide location types for EFA results

parent b9fde3a1
......@@ -23,7 +23,8 @@
},
"latitude": 49.80202865600586,
"longitude": 9.93593978881836,
"name": "Würzburg Hbf"
"name": "Würzburg Hbf",
"type": "Stop"
}
},
{
......@@ -45,7 +46,8 @@
},
"latitude": 49.800758361816406,
"longitude": 9.934450149536133,
"name": "Würzburg, Busbahnhof"
"name": "Würzburg, Busbahnhof",
"type": "Stop"
}
},
{
......@@ -66,7 +68,8 @@
},
"latitude": 49.80030059814453,
"longitude": 9.9364595413208,
"name": "Würzburg, Hauptbahnhof Ost"
"name": "Würzburg, Hauptbahnhof Ost",
"type": "Stop"
}
}
]
......@@ -18,7 +18,8 @@
"latitude": 49.49388122558594,
"locality": "Nürnberg",
"longitude": 11.079079627990723,
"name": "Nürnberg Flughafen"
"name": "Nürnberg Flughafen",
"type": "Stop"
}
},
{
......@@ -44,7 +45,8 @@
"latitude": 49.493858337402344,
"locality": "Nürnberg",
"longitude": 11.078929901123047,
"name": "Nürnberg Flughafen"
"name": "Nürnberg Flughafen",
"type": "Stop"
}
}
]
......@@ -5,6 +5,7 @@
},
"latitude": 51.90190887451172,
"longitude": -8.458080291748047,
"name": "Cork Kent"
"name": "Cork Kent",
"type": "Stop"
}
]
......@@ -5,7 +5,8 @@
},
"latitude": 48.784881591796875,
"longitude": 9.18278980255127,
"name": "Hauptbahnhof"
"name": "Hauptbahnhof",
"type": "Stop"
},
{
"identifier": {
......@@ -15,7 +16,8 @@
"latitude": 48.784881591796875,
"locality": "Stuttgart",
"longitude": 9.18278980255127,
"name": "Stuttgart Hauptbahnhof (oben)"
"name": "Stuttgart Hauptbahnhof (oben)",
"type": "Stop"
},
{
"identifier": {
......@@ -25,7 +27,8 @@
"latitude": 48.783390045166016,
"locality": "Stuttgart",
"longitude": 9.180230140686035,
"name": "Stuttgart Hauptbahnhof (tief)"
"name": "Stuttgart Hauptbahnhof (tief)",
"type": "Stop"
},
{
"identifier": {
......@@ -35,6 +38,7 @@
"latitude": 48.78316116333008,
"locality": "Stuttgart",
"longitude": 9.181119918823242,
"name": "Stuttgart Hauptbf (Arnulf-Klett-Platz)"
"name": "Stuttgart Hauptbf (Arnulf-Klett-Platz)",
"type": "Stop"
}
]
......@@ -15,6 +15,7 @@
"latitude": 41.98918914794922,
"locality": "Chicago",
"longitude": -87.88291931152344,
"name": "O'hare Airport Kiss-N-Fly, Chicago"
"name": "O'hare Airport Kiss-N-Fly, Chicago",
"type": "Stop"
}
]
......@@ -7,7 +7,8 @@
"latitude": 49.49382019042969,
"locality": "Nürnberg",
"longitude": 11.079000473022461,
"name": "Nürnberg Flughafen"
"name": "Nürnberg Flughafen",
"type": "Stop"
},
{
"identifier": {
......@@ -17,7 +18,8 @@
"latitude": 49.492881774902344,
"locality": "Nürnberg",
"longitude": 11.083109855651855,
"name": "Nürnberg Cargo-Zentrum"
"name": "Nürnberg Cargo-Zentrum",
"type": "Stop"
},
{
"identifier": {
......@@ -27,6 +29,7 @@
"latitude": 49.493621826171875,
"locality": "Nürnberg",
"longitude": 11.071249961853027,
"name": "Nürnberg Luftamt Nordbayern"
"name": "Nürnberg Luftamt Nordbayern",
"type": "Stop"
}
]
......@@ -14,7 +14,8 @@
"latitude": 49.49388122558594,
"locality": "Nürnberg",
"longitude": 11.079079627990723,
"name": "Nürnberg Flughafen"
"name": "Nürnberg Flughafen",
"type": "Stop"
},
"intermediateStops": [
{
......@@ -175,7 +176,8 @@
"latitude": 49.447059631347656,
"locality": "Nürnberg",
"longitude": 11.082220077514648,
"name": "Nürnberg Hbf"
"name": "Nürnberg Hbf",
"type": "Stop"
}
},
{
......@@ -189,7 +191,8 @@
"latitude": 49.446388244628906,
"locality": "Nürnberg",
"longitude": 11.081649780273438,
"name": "Nürnberg Hbf"
"name": "Nürnberg Hbf",
"type": "Stop"
},
"mode": "PublicTransport",
"path": {
......@@ -239,7 +242,8 @@
"latitude": 49.41590118408203,
"locality": "Nürnberg",
"longitude": 11.114660263061523,
"name": "Nürnberg Messe"
"name": "Nürnberg Messe",
"type": "Stop"
}
}
]
......
......@@ -16,7 +16,8 @@
"latitude": 49.44636917114258,
"locality": "Nürnberg",
"longitude": 11.081809997558594,
"name": "Nürnberg Hauptbahnhof"
"name": "Nürnberg Hauptbahnhof",
"type": "Stop"
},
"mode": "Walking",
"path": {
......@@ -277,9 +278,6 @@
"scheduledDeparturePlatform": "",
"scheduledDepartureTime": "2020-04-27T22:07:00",
"to": {
"identifier": {
"testid": "99999998"
},
"latitude": 49.445499420166016,
"locality": "Nürnberg",
"longitude": 11.082300186157227,
......
......@@ -16,7 +16,8 @@
"latitude": 49.493961334228516,
"locality": "Nürnberg",
"longitude": 11.078630447387695,
"name": "Nürnberg Flughafen"
"name": "Nürnberg Flughafen",
"type": "Stop"
},
"mode": "PublicTransport",
"notes": [
......@@ -69,7 +70,8 @@
"latitude": 49.44636917114258,
"locality": "Nürnberg",
"longitude": 11.081809997558594,
"name": "Nürnberg Hbf"
"name": "Nürnberg Hbf",
"type": "Stop"
}
},
{
......@@ -87,7 +89,8 @@
"latitude": 49.44636917114258,
"locality": "Nürnberg",
"longitude": 11.081809997558594,
"name": "Nürnberg Hbf"
"name": "Nürnberg Hbf",
"type": "Stop"
},
"intermediateStops": [
{
......@@ -102,7 +105,8 @@
"latitude": 49.429298400878906,
"locality": "Nürnberg",
"longitude": 11.086319923400879,
"name": "Nürnberg Frankenstr."
"name": "Nürnberg Frankenstr.",
"type": "Stop"
}
},
{
......@@ -117,7 +121,8 @@
"latitude": 49.424530029296875,
"locality": "Nürnberg",
"longitude": 11.0897798538208,
"name": "Nürnberg Hasenbuck"
"name": "Nürnberg Hasenbuck",
"type": "Stop"
}
}
],
......@@ -169,7 +174,8 @@
"latitude": 49.41585922241211,
"locality": "Nürnberg",
"longitude": 11.114060401916504,
"name": "Nürnberg Messe"
"name": "Nürnberg Messe",
"type": "Stop"
}
}
]
......
......@@ -64,7 +64,7 @@ Location EfaCompactParser::parseCompactSf(ScopedXmlStreamReader &&reader) const
parseCompactCoordinate(sub.readElementText(), loc);
} else if (sub.name() == QLatin1String("id")) {
const auto id = sub.readElementText();
if (!id.isEmpty()) {
if (!id.isEmpty() && !isDummyStopId(id)) {
loc.setIdentifier(m_locationIdentifierType, id);
}
} else if (sub.name() == QLatin1String("pc")) {
......@@ -165,7 +165,11 @@ Stopover EfaCompactParser::parseCompactDp(ScopedXmlStreamReader &&reader) const
auto subReader = reader.subReader();
while (subReader.readNextSibling()) {
if (subReader.name() == QLatin1String("id")) {
loc.setIdentifier(m_locationIdentifierType, subReader.readElementText());
const auto id = subReader.readElementText();
if (!id.isEmpty() && !isDummyStopId(id)) {
loc.setIdentifier(m_locationIdentifierType, id);
loc.setType(Location::Stop);
}
} else if (subReader.name() == QLatin1String("pl")) {
dep.setScheduledPlatform(subReader.readElementText());
}
......@@ -220,7 +224,11 @@ void EfaCompactParser::parseTripSectionHalf(ScopedXmlStreamReader &&reader, Jour
ScopedXmlStreamReader subReader(reader.subReader());
while (subReader.readNextSibling()) {
if (subReader.name() == QLatin1String("id")) {
loc.setIdentifier(m_locationIdentifierType, subReader.readElementText());
const auto id = subReader.readElementText();
if (!id.isEmpty() && !isDummyStopId(id)) {
loc.setIdentifier(m_locationIdentifierType, id);
loc.setType(Location::Stop);
}
} else if (subReader.name() == QLatin1String("pc")) {
loc.setLocality(subReader.readElementText());
} else if (subReader.name() == QLatin1String("pl") || subReader.name() == QLatin1String("divaPl")) {
......
......@@ -79,3 +79,8 @@ Path EfaParser::parsePathCoordinatesElement(ScopedXmlStreamReader &reader)
path.setSections({section});
return path;
}
bool EfaParser::isDummyStopId(QStringView id)
{
return id == QLatin1String("99999997") || id == QLatin1String("99999998");
}
......@@ -55,6 +55,9 @@ protected:
/** Parse path encoded as a space separated string of coordinate pairs. */
static Path parsePathCoordinatesElement(ScopedXmlStreamReader &reader);
/** Returns @c true if the given stop id is a dummy value used for non-stops. */
static bool isDummyStopId(QStringView id);
QString m_locationIdentifierType;
mutable QString m_errorMsg;
mutable Reply::Error m_error = Reply::NoError;
......
......@@ -34,7 +34,9 @@ void EfaXmlParser::parseLocationCommon(Location &loc, const ScopedXmlStreamReade
const auto id = reader.attributes().value(QLatin1String("stopID")).toString();
if (!id.isEmpty()) {
loc.setIdentifier(m_locationIdentifierType, id);
if (!isDummyStopId(id)) {
loc.setIdentifier(m_locationIdentifierType, id);
}
} else {
loc.setIdentifier(m_locationIdentifierType, reader.attributes().value(QLatin1String("stateless")).toString());
}
......@@ -53,6 +55,8 @@ void EfaXmlParser::parseLocationCommon(Location &loc, const ScopedXmlStreamReade
loc.setType(Location::Stop);
} else if (!type.isEmpty()) {
qCDebug(Log) << "Unhandled EFA location type:" << type;
} else if (!id.isEmpty() && !isDummyStopId(id)) {
loc.setType(Location::Stop);
}
}
......@@ -61,6 +65,7 @@ Location EfaXmlParser::parseItdOdvAssignedStop(const ScopedXmlStreamReader &read
Location loc;
parseLocationCommon(loc, reader);
loc.setName(reader.attributes().value(QLatin1String("nameWithPlace")).toString());
loc.setType(Location::Stop);
return loc;
}
......@@ -137,6 +142,7 @@ Stopover EfaXmlParser::parseDmDeparture(ScopedXmlStreamReader &&reader) const
parseLocationCommon(stop, reader);
stop.setName(reader.attributes().value(QLatin1String("stopName")).toString());
stop.setType(Location::Stop);
dep.setStopPoint(stop);
const auto occupancy = reader.attributes().value(QLatin1String("occupancy"));
......
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