8#include <QtLocation/private/qgeorouteparser_p_p.h>
9#include <QtCore/private/qobject_p.h>
10#include <QtCore/QJsonDocument>
11#include <QtCore/QJsonObject>
12#include <QtCore/QJsonArray>
13#include <QtCore/QUrlQuery>
21 bool parsingLatitude =
true;
28 for (
int i = 0;
i <
data.length(); ++
i) {
29 unsigned char c =
data.at(
i) - 63;
40 if (parsingLatitude) {
41 coord.setLatitude(
coord.latitude() + (double)diff/1e6);
43 coord.setLongitude(
coord.longitude() + (double)diff/1e6);
47 parsingLatitude = !parsingLatitude;
69 switch (trafficSide) {
106 return QGeoRouteParserOsrmV4::tr(
"Go straight.");
108 return QGeoRouteParserOsrmV4::tr(
"Go straight onto %1.").arg(wayname);
111 return QGeoRouteParserOsrmV4::tr(
"Turn slightly right.");
113 return QGeoRouteParserOsrmV4::tr(
"Turn slightly right onto %1.").arg(wayname);
116 return QGeoRouteParserOsrmV4::tr(
"Turn right.");
118 return QGeoRouteParserOsrmV4::tr(
"Turn right onto %1.").arg(wayname);
121 return QGeoRouteParserOsrmV4::tr(
"Make a sharp right.");
123 return QGeoRouteParserOsrmV4::tr(
"Make a sharp right onto %1.").arg(wayname);
126 return QGeoRouteParserOsrmV4::tr(
"When it is safe to do so, perform a U-turn.");
129 return QGeoRouteParserOsrmV4::tr(
"Make a sharp left.");
131 return QGeoRouteParserOsrmV4::tr(
"Make a sharp left onto %1.").arg(wayname);
134 return QGeoRouteParserOsrmV4::tr(
"Turn left.");
136 return QGeoRouteParserOsrmV4::tr(
"Turn left onto %1.").arg(wayname);
139 return QGeoRouteParserOsrmV4::tr(
"Turn slightly left.");
141 return QGeoRouteParserOsrmV4::tr(
"Turn slightly left onto %1.").arg(wayname);
143 return QGeoRouteParserOsrmV4::tr(
"Reached waypoint.");
146 return QGeoRouteParserOsrmV4::tr(
"Head on.");
148 return QGeoRouteParserOsrmV4::tr(
"Head onto %1.").arg(wayname);
150 return QGeoRouteParserOsrmV4::tr(
"Enter the roundabout.");
153 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the first exit.");
155 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the first exit onto %1.").arg(wayname);
158 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the second exit.");
160 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the second exit onto %1.").arg(wayname);
163 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the third exit.");
165 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the third exit onto %1.").arg(wayname);
168 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the fourth exit.");
170 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the fourth exit onto %1.").arg(wayname);
173 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the fifth exit.");
175 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the fifth exit onto %1.").arg(wayname);
178 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the sixth exit.");
180 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the sixth exit onto %1.").arg(wayname);
183 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the seventh exit.");
185 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the seventh exit onto %1.").arg(wayname);
188 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the eighth exit.");
190 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the eighth exit onto %1.").arg(wayname);
193 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the ninth exit.");
195 return QGeoRouteParserOsrmV4::tr(
"At the roundabout take the ninth exit onto %1.").arg(wayname);
198 return QGeoRouteParserOsrmV4::tr(
"Leave the roundabout.");
200 return QGeoRouteParserOsrmV4::tr(
"Leave the roundabout onto %1.").arg(wayname);
202 return QGeoRouteParserOsrmV4::tr(
"Stay on the roundabout.");
205 return QGeoRouteParserOsrmV4::tr(
"Start at the end of the street.");
207 return QGeoRouteParserOsrmV4::tr(
"Start at the end of %1.").arg(wayname);
209 return QGeoRouteParserOsrmV4::tr(
"You have reached your destination.");
211 return QGeoRouteParserOsrmV4::tr(
"Don't know what to say for '%1'").arg(instructionCode);
223 int firstPosition = -1;
228 if (instruction.
count() < 8) {
229 qWarning(
"Instruction does not contain enough fields.");
235 double segmentLength = instruction.
at(2).
toDouble();
243 segment.setDistance(segmentLength);
254 if (firstPosition == -1)
261 segment.setNextRouteSegment(firstSegment);
299 if (document.isObject()) {
309 if (0 != status && 200 != status) {
310 errorString = statusMessage;
317 object.value(
QStringLiteral(
"route_geometry")).toString().toLatin1();
330 object.value(
QStringLiteral(
"alternative_instructions")).toArray();
332 if (alternativeSummaries.
count() == alternativeGeometries.
count() &&
333 alternativeSummaries.
count() == alternativeInstructions.
count()) {
void setInstructionText(const QString &instructionText)
void setTimeToNextInstruction(int secs)
void setDirection(InstructionDirection direction)
void setDistanceToNextInstruction(qreal distance)
void setPosition(const QGeoCoordinate &position)
virtual ~QGeoRouteParserOsrmV4Private()
QGeoRouteParserOsrmV4Private()
QUrl requestUrl(const QGeoRouteRequest &request, const QString &prefix) const override
QGeoRouteReply::Error parseReply(QList< QGeoRoute > &routes, QString &errorString, const QByteArray &reply) const override
QGeoRouteParserOsrmV4(QObject *parent=nullptr)
virtual ~QGeoRouteParserOsrmV4()
QGeoRouteParser::TrafficSide trafficSide
Error
Describes an error which prevented the completion of the operation.
void setFirstRouteSegment(const QGeoRouteSegment &routeSegment)
Sets the first route segment in the route to routeSegment.
void setDistance(qreal distance)
void setTravelTime(int secs)
void setPath(const QList< QGeoCoordinate > &path)
\inmodule QtCore\reentrant
qsizetype count() const
Same as size().
QJsonValue at(qsizetype i) const
Returns a QJsonValue representing the value for index i.
\inmodule QtCore\reentrant
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
\inmodule QtCore\reentrant
QJsonValue value(const QString &key) const
Returns a QJsonValue representing the value for the key key.
QJsonObject toObject() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
QJsonArray toArray() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
double toDouble(double defaultValue=0) const
Converts the value to a double and returns it.
QString toString() const
Converts the value to a QString and returns it.
void append(parameter_type t)
\macro QT_RESTRICTED_CAST_FROM_ASCII
QByteArray toLatin1() const &
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setQuery(const QString &query, ParsingMode mode=TolerantMode)
Sets the query string of the URL to query.
Combined button and popup list for selecting options.
static QT_WARNING_DISABLE_FLOAT_COMPARE ShiftResult shift(const QBezier *orig, QBezier *shifted, qreal offset, qreal threshold)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static QGeoManeuver::InstructionDirection osrmInstructionDirection(const QString &instructionCode, QGeoRouteParser::TrafficSide trafficSide)
static QGeoRoute constructRoute(const QByteArray &geometry, const QJsonArray &instructions, const QJsonObject &summary, QGeoRouteParser::TrafficSide trafficSide)
static QString osrmInstructionText(const QString &instructionCode, const QString &wayname)
static QT_BEGIN_NAMESPACE QList< QGeoCoordinate > parsePolyline(const QByteArray &data)
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLsizei const GLchar *const * path
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
static double toDouble(Value v)
QUrl url("example.com")
[constructor-url-reference]
QNetworkRequest request(url)
\inmodule QtCore \reentrant
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent