21 {
"turn-slight-left", QGeoManeuver::DirectionLightLeft},
22 {
"turn-sharp-left", QGeoManeuver::DirectionHardLeft},
23 {
"uturn-left", QGeoManeuver::DirectionUTurnLeft},
24 {
"turn-left", QGeoManeuver::DirectionLeft},
25 {
"turn-slight-right", QGeoManeuver::DirectionLightRight},
26 {
"turn-sharp-right", QGeoManeuver::DirectionHardRight},
27 {
"uturn-right", QGeoManeuver::DirectionUTurnRight},
28 {
"turn-right", QGeoManeuver::DirectionRight},
29 {
"straight", QGeoManeuver::DirectionForward},
30 {
"ramp-left", QGeoManeuver::DirectionBearLeft},
31 {
"ramp-right", QGeoManeuver::DirectionBearRight},
32 {
"fork-left", QGeoManeuver::DirectionBearLeft},
33 {
"fork-right", QGeoManeuver::DirectionBearRight},
34 {
"roundabout-left", QGeoManeuver::DirectionLeft},
35 {
"roundabout-right", QGeoManeuver::DirectionRight},
51 QGeoManeuver maneuver;
53 maneuver.setInstructionText(stepObj.value(
"instruction").toString());
55 OhosMapKit::CoordinateJson::tryConvertToQGeoCoordinate(stepObj.value(
"startLocation").toObject()));
56 maneuver.setDistanceToNextInstruction(stepObj.value(
"distance").toDouble());
57 maneuver.setTimeToNextInstruction(stepObj.value(
"duration").toDouble());
59 auto action = stepObj.value(
"action").toString();
60 maneuver.setDirection(actionsToDirectionsMap.value(action, QGeoManeuver::NoDirection));
67 QGeoRouteSegment segment;
69 segment.setDistance(stepObj.value(
"distance").toDouble());
70 segment.setTravelTime(stepObj.value(
"duration").toDouble());
71 segment.setPath(parsePolyline(stepObj.value(
"polyline").toArray()));
72 segment.setManeuver(parseManeuver(stepObj));
82 OhosMapKit::CoordinateBoundsJson::tryConvertToQGeoRectangle(routeObj.value(
"bounds").toObject()));
84 double totalDistance = 0.0;
85 double totalTimeSeconds = 0.0;
86 QList<QGeoCoordinate> fullRoutePath;
87 QList<QGeoRouteSegment> routeSegments;
89 auto pathsArray = routeObj.value(
"paths").toArray();
90 for (
const auto &pathVal : pathsArray) {
91 auto pathObj = pathVal.toObject();
92 totalDistance += pathObj.value(
"distance").toDouble();
93 totalTimeSeconds += pathObj.value(
"duration").toDouble();
95 auto stepsArray = pathObj.value(
"steps").toArray();
96 for (
const auto &stepVal : stepsArray) {
97 routeSegments.push_back(parseStep(stepVal.toObject()));
99 auto segmentPath = routeSegments.last().path();
100 if (!segmentPath.isEmpty()) {
101 if (!fullRoutePath.isEmpty() && fullRoutePath.last() == segmentPath.first())
102 segmentPath.pop_front();
104 fullRoutePath += segmentPath;
109 route.setDistance(totalDistance);
110 route.setTravelTime(totalTimeSeconds);
111 route.setPath(fullRoutePath);
112 if (!routeSegments.isEmpty()) {
113 auto currentRouteSegment = routeSegments.last();
114 for (
int i = routeSegments.size() - 2; i >= 0; --i) {
115 auto tmpRouteSegment = routeSegments[i];
116 tmpRouteSegment.setNextRouteSegment(currentRouteSegment);
117 currentRouteSegment = tmpRouteSegment;
119 route.setFirstRouteSegment(currentRouteSegment);
148 QNetworkReply *reply,
const QGeoRouteRequest &request, QObject *parent)
151 if (reply ==
nullptr) {
152 setError(QGeoRouteReply::UnknownError, QStringLiteral(
"Null reply"));
157 connect(reply, &QNetworkReply::errorOccurred,
this, &QGeoRouteReplyOhosMapKit::networkReplyError);
158 connect(
this, &QGeoRouteReply::aborted, reply, &QNetworkReply::abort);
159 connect(
this, &QObject::destroyed, reply, &QObject::deleteLater);