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

Parse journey section paths in EFA responses

There is a second format for transfer navigation maneuvers which we yet
have to implement though, this only covers public transport sections.
parent 6ed158bf
Pipeline #50204 passed with stage
in 23 seconds
......@@ -21,6 +21,33 @@
"notes": [
"Construction works somewhere - further infos on some random website"
],
"path": {
"sections": [
{
"path": {
"coordinates": [
[
11.00223,
49.59591
],
[
11.00222,
49.59593
],
[
11.00181,
49.59502
],
[
11.0018,
49.59502
]
],
"type": "LineString"
}
}
]
},
"route": {
"direction": "Nürnberg Röthenbach",
"line": {
......@@ -90,6 +117,33 @@
}
],
"mode": "PublicTransport",
"path": {
"sections": [
{
"path": {
"coordinates": [
[
11.00184,
49.59502
],
[
11.00187,
49.59495
],
[
11.08067,
49.44532
],
[
11.08166,
49.44554
]
],
"type": "LineString"
}
}
]
},
"route": {
"direction": "Nürnberg Langwasser Süd",
"line": {
......
......@@ -111,7 +111,7 @@
<itdPathCoordinates>
<coordEllipsoid>WGS84</coordEllipsoid>
<coordType>GEO_DECIMAL</coordType>
<itdCoordinateString decimal="." cs="," ts="&amp;#x20;" format="x,y">...</itdCoordinateString>
<itdCoordinateString decimal="." cs="," ts="&amp;#x20;" format="x,y">11.00223,49.59591 11.00222,49.59593 11.00181,49.59502 11.00180,49.59502</itdCoordinateString>
<itdCoordinateReductionList/>
</itdPathCoordinates>
<itdITPathDescription altitudeDiffUp="" altitudeDiffDown="">...</itdITPathDescription>
......@@ -193,7 +193,7 @@
<itdPathCoordinates>
<coordEllipsoid>WGS84</coordEllipsoid>
<coordType>GEO_DECIMAL</coordType>
<itdCoordinateString decimal="." cs="," ts="&amp;#x20;" format="x,y">...</itdCoordinateString>
<itdCoordinateString decimal="." cs="," ts="&amp;#x20;" format="x,y">11.00184,49.59502 11.00187,49.59495 11.08067,49.44532 11.08166,49.44554</itdCoordinateString>
<itdCoordinateReductionList/>
</itdPathCoordinates>
</itdPartialRoute>
......
......@@ -247,6 +247,29 @@ std::vector<Stopover> EfaXmlParser::parsePartialTripStopSequence(ScopedXmlStream
return stops;
}
static Path parsePathCoordinates(ScopedXmlStreamReader &&reader)
{
QPolygonF poly;
while (reader.readNextSibling()) {
if (reader.name() == QLatin1String("itdCoordinateString")) {
// TODO do we need to support the format attributes, or is this always the same anyway?
const auto coords = reader.readElementText().split(QLatin1Char(' '), Qt::SkipEmptyParts);
poly.reserve(coords.size());
for (const auto &coord : coords) {
const auto p = coord.split(QLatin1Char(','));
if (p.size() == 2) {
poly.push_back({p[0].toDouble(), p[1].toDouble()});
}
}
}
}
PathSection section;
section.setPath(poly);
Path path;
path.setSections({section});
return path;
}
struct {
int type;
JourneySection::Mode mode;
......@@ -300,6 +323,8 @@ JourneySection EfaXmlParser::parseTripPartialRoute(ScopedXmlStreamReader &&reade
section.addNotes(parseInfoLink(reader.subReader()));
} else if (reader.name() == QLatin1String("itdStopSeq")) {
section.setIntermediateStops(parsePartialTripStopSequence(reader.subReader()));
} else if (reader.name() == QLatin1String("itdPathCoordinates")) {
section.setPath(parsePathCoordinates(reader.subReader()));
}
}
......
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