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

Support Entur path navigation guidance information

parent 2794e981
Pipeline #86655 passed with stage
in 1 minute and 20 seconds
{"plan":{"itineraries":[{"legs":[{"startTime":"2021-10-07T17:32:33+0200","endTime":"2021-10-07T17:37:16+0200","realTime":false,"expectedStartTime":"2021-10-07T17:32:33+0200","expectedEndTime":"2021-10-07T17:37:16+0200","distance":286.635,"mode":"foot","transitLeg":false,"rentedBike":false,"from":{"name":"Origin","lat":59.911190032958984,"lon":10.753250122070312,"stop":null,"bikeRentalStation":null},"to":{"name":"Jernbanetorget","lat":59.912197,"lon":10.75131,"stop":{"platformCode":"1","id":"NSR:Quay:7183","timezone":"Europe/Oslo"},"bikeRentalStation":null},"line":null,"legGeometry":{"length":39,"points":"}ktlJyfs`A@IAADY@GIGCCAASOACCAACC@EDEFCJIRC@?BCCQOGAC@E?AAEEGMIICAC?A?EBGHc@l@TlAAT?ZAPUlG"},"steps":[{"lat":59.911194046285516,"lon":10.75325405384248,"legStepText":"Start on steps heading southeast."},{"lat":59.911181600000006,"lon":10.7533046,"legStepText":"Left on to path."},{"lat":59.9111923,"lon":10.7533163,"legStepText":"Right to continue on path."},{"lat":59.9120823,"lon":10.7526512,"legStepText":"Continue on to ."}]},{"startTime":"2021-10-07T17:36:00+0200","endTime":"2021-10-07T17:48:00+0200","realTime":true,"expectedStartTime":"2021-10-07T17:37:16+0200","expectedEndTime":"2021-10-07T17:49:16+0200","distance":5630.406793177133,"mode":"metro","transitLeg":true,"rentedBike":false,"from":{"name":"Jernbanetorget","lat":59.912197,"lon":10.75131,"stop":{"platformCode":"1","id":"NSR:Quay:7183","timezone":"Europe/Oslo"},"bikeRentalStation":null},"to":{"name":"Nydalen","lat":59.949532,"lon":10.765338,"stop":{"platformCode":"1","id":"NSR:Quay:11151","timezone":"Europe/Oslo"},"bikeRentalStation":null},"line":{"presentation":{"color":"EC700C","textColor":"FFFFFF"},"transportMode":"metro","type":"metro","shortName":"5","name":"Sognsvann - Vestli","alerts":[]},"legGeometry":{"length":184,"points":"grtlJuzr`A@m@@[JyE@uA@oAAiAGaAGy@Iy@M{@{@sEOeAIo@IiAEkAAeA?qAH}H@i@?CDyDDqC@y@@e@B{@Be@H_ArAeMR}BFuA@yAEwAIsAO{ASqAWgAa@mAe@_Ag@m@mByB]k@[q@Yy@YkASkAQsAYkCKy@Ko@Ms@Ka@Me@Ma@O_@O_@Sa@Yi@uAeCCG]m@w@yAQc@Oa@K[K_@Ma@Mg@g@uBOk@Oi@Mc@Oa@O[Q[_@i@Y[YWYQYKYI[EUCY@W@Y@}@DsCNoDPyBJ{CNuBJgDTyCLkABq@Cg@Gc@Gi@K_Ba@A?UGiBe@USm@e@e@m@c@s@g@qAWeA_@mBs@iD[qAm@iBs@aBk@iAy@mAo@w@yAoAiAk@u@Wm@Mw@Iu@Aa@Bi@Fi@Jw@Xq@\\y@j@_@Zk@l@sAxAaAdAo@p@STkArAeAfAk@d@YTc@Vs@^s@Xw@XkAb@q@RyAh@EB_@LeBn@m@Rm@Rq@Tm@RkA\\}Af@mA`@eBl@}Bx@QFs@Vi@PmAb@]L_@Lu@TqC|@u@Ts@VuBv@GDg@PYJwAn@kD`BqAn@eAnA{@|B]fA_AxEERsA`L}B~TyAvOk@~F"},"steps":[]},{"startTime":"2021-10-07T17:49:16+0200","endTime":"2021-10-07T17:51:13+0200","realTime":false,"expectedStartTime":"2021-10-07T17:49:16+0200","expectedEndTime":"2021-10-07T17:51:13+0200","distance":109.566,"mode":"foot","transitLeg":false,"rentedBike":false,"from":{"name":"Nydalen","lat":59.949532,"lon":10.765338,"stop":{"platformCode":"1","id":"NSR:Quay:11151","timezone":"Europe/Oslo"},"bikeRentalStation":null},"to":{"name":"Destination","lat":59.94956970214844,"lon":10.764439582824707,"stop":null,"bikeRentalStation":null},"line":null,"legGeometry":{"length":18,"points":"o{{lJkru`ABDL???@?\\GJN?N?F@T?H?LC?i@VWj@@@AN?J"},"steps":[{"lat":59.949528149153245,"lon":10.765347689224011,"legStepText":"Start on path heading south."},{"lat":59.9492077,"lon":10.7649281,"legStepText":"Right to continue on bike path."},{"lat":59.9495567,"lon":10.764580800000001,"legStepText":"Hard left to continue on sidewalk."},{"lat":59.9495482,"lon":10.764579000000001,"legStepText":"Right to continue on path."}]}],"endTime":"2021-10-07T17:51:13+0200","distance":6026.607793177133,"duration":1120,"startTime":"2021-10-07T17:32:33+0200"}]}}
This diff is collapsed.
......@@ -194,6 +194,10 @@ private Q_SLOTS:
<< s(SOURCE_DIR "/data/otp/de-stadtnavi-bike-parking-journey.in.json")
<< s(SOURCE_DIR "/data/otp/de-stadtnavi-bike-parking-journey.out.json")
<< s(SOURCE_DIR "/../src/lib/networks/de_bw_stadtnavi.json");
QTest::newRow("no-entur-navigation-guides")
<< s(SOURCE_DIR "/data/otp/no-entur-navigation-guides.in.json")
<< s(SOURCE_DIR "/data/otp/no-entur-navigation-guides.out.json")
<< QString();
}
void testParseJourney()
......
......@@ -478,12 +478,55 @@ JourneySection OpenTripPlannerParser::parseJourneySection(const QJsonObject &obj
section.setIntermediateStops(std::move(stops));
const auto geometryObj = obj.value(QLatin1String("legGeometry")).toObject();
QPolygonF poly;
if (!geometryObj.empty()) {
QPolygonF poly;
poly.reserve(geometryObj.value(QLatin1String("length")).toInt());
const auto points = geometryObj.value(QLatin1String("points")).toString().toUtf8();
PolylineDecoder<2> decoder(points.constData());
decoder.readPolygon(poly);
}
const auto stepsArray = obj.value(QLatin1String("steps")).toArray();
if (!stepsArray.empty()) {
std::vector<PathSection> pathSections;
pathSections.reserve(stepsArray.size());
PathSection prevPathSec;
int prevPolyIdx = 0;
bool isFirstSection = true;
for (const auto &stepsV : stepsArray) {
const auto stepsObj = stepsV.toObject();
PathSection pathSec;
pathSec.setDescription(stepsObj.value(QLatin1String("legStepText")).toString());
if (!isFirstSection) {
const QPointF coord(stepsObj.value(QLatin1String("lon")).toDouble(), stepsObj.value(QLatin1String("lat")).toDouble());
const auto it = std::min_element(poly.begin() + prevPolyIdx, poly.end(), [coord](QPointF lhs, QPointF rhs) {
return Location::distance(lhs.y(), lhs.x(), coord.y(), coord.x()) < Location::distance(rhs.y(), rhs.x(), coord.y(), coord.x());
});
int polyIdx = std::distance(poly.begin(), it);
QPolygonF subPoly;
subPoly.reserve(polyIdx - prevPolyIdx + 1);
std::copy(poly.begin() + prevPolyIdx, poly.begin() + polyIdx + 1, std::back_inserter(subPoly));
prevPathSec.setPath(std::move(subPoly));
prevPolyIdx = polyIdx;
pathSections.push_back(std::move(prevPathSec));
} else {
isFirstSection = false;
}
prevPathSec = pathSec;
}
QPolygonF subPoly;
subPoly.reserve(prevPolyIdx - poly.size() + 1);
std::copy(poly.begin() + prevPolyIdx, poly.end(), std::back_inserter(subPoly));
prevPathSec.setPath(std::move(subPoly));
pathSections.push_back(std::move(prevPathSec));
Path path;
path.setSections(std::move(pathSections));
section.setPath(std::move(path));
} else if (!poly.isEmpty()) {
PathSection pathSec;
pathSec.setPath(std::move(poly));
Path path;
......
......@@ -72,6 +72,11 @@ query journeys(
length
points
}
steps @include(if: $withPaths) {
lat: latitude
lon: longitude
legStepText(locale: $lang)
}
}
}
}
......
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