Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qgeoroutingmanagerengine.cpp
Go to the documentation of this file.
1
// Copyright (C) 2015 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4
#
include
"qgeoroutingmanagerengine.h"
5
#
include
"qgeoroutingmanagerengine_p.h"
6
7
QT_BEGIN_NAMESPACE
8
9
/*!
10
\class QGeoRoutingManagerEngine
11
\inmodule QtLocation
12
\ingroup QtLocation-impl
13
\since 5.6
14
15
\brief The QGeoRoutingManagerEngine class provides an interface and
16
convenience methods to implementers of QGeoServiceProvider plugins who want
17
to provide access to geographic routing information.
18
19
\note There are no source or binary compatibility guarantees for the
20
backend classes. The API is only guaranteed to work with the Qt version it
21
was developed against. API changes will however only be made in minor
22
releases. (6.6, 6.7, and so on.)
23
24
Subclasses of QGeoRoutingManagerEngine need to provide an implementation of
25
calculateRoute().
26
27
In the default implementation, supportsRouteUpdates() returns false and
28
updateRoute() returns a QGeoRouteReply object containing a
29
QGeoRouteReply::UnsupportedOptionError.
30
31
If the routing service supports updating routes as they are being
32
traveled, the subclass should provide an implementation of updateRoute()
33
and call setSupportsRouteUpdates(true) at some point in time before
34
updateRoute() is called.
35
36
The function setSupportsRouteUpdates() is one of several functions which
37
configure the reported capabilities of the engine. If the capabilities
38
of an engine differ from the default values these functions should be
39
used so that the reported capabilities are accurate.
40
41
It is important that this is done before calculateRoute(), updateRoute()
42
or any of the capability reporting functions are used to prevent
43
incorrect or inconsistent behavior.
44
45
A subclass of QGeoRouteManagerEngine will often make use of a subclass
46
fo QGeoRouteReply internally, in order to add any engine-specific
47
data (such as a QNetworkReply object for network-based services) to the
48
QGeoRouteReply instances used by the engine.
49
50
\sa QGeoRoutingManager
51
*/
52
53
/*!
54
Constructs a new engine with the specified \a parent, using \a parameters
55
to pass any implementation specific data to the engine.
56
*/
57
QGeoRoutingManagerEngine::QGeoRoutingManagerEngine(
const
QVariantMap ¶meters, QObject *parent)
58
: QObject(parent),
59
d_ptr(
new
QGeoRoutingManagerEnginePrivate())
60
{
61
Q_UNUSED(parameters);
62
}
63
64
/*!
65
Destroys this engine.
66
*/
67
QGeoRoutingManagerEngine::~QGeoRoutingManagerEngine()
68
{
69
delete
d_ptr;
70
}
71
72
/*!
73
Sets the name which this engine implementation uses to distinguish itself
74
from the implementations provided by other plugins to \a managerName.
75
76
The combination of managerName() and managerVersion() should be unique
77
amongst plugin implementations.
78
*/
79
void
QGeoRoutingManagerEngine::setManagerName(
const
QString &managerName)
80
{
81
d_ptr->managerName = managerName;
82
}
83
84
/*!
85
Returns the name which this engine implementation uses to distinguish
86
itself from the implementations provided by other plugins.
87
88
The combination of managerName() and managerVersion() should be unique
89
amongst plugin implementations.
90
*/
91
QString QGeoRoutingManagerEngine::managerName()
const
92
{
93
return
d_ptr->managerName;
94
}
95
96
/*!
97
Sets the version of this engine implementation to \a managerVersion.
98
99
The combination of managerName() and managerVersion() should be unique
100
amongst plugin implementations.
101
*/
102
void
QGeoRoutingManagerEngine::setManagerVersion(
int
managerVersion)
103
{
104
d_ptr->managerVersion = managerVersion;
105
}
106
107
/*!
108
Returns the version of this engine implementation.
109
110
The combination of managerName() and managerVersion() should be unique
111
amongst plugin implementations.
112
*/
113
int
QGeoRoutingManagerEngine::managerVersion()
const
114
{
115
return
d_ptr->managerVersion;
116
}
117
118
/*!
119
\fn QGeoRouteReply *QGeoRoutingManagerEngine::calculateRoute(const QGeoRouteRequest &request)
120
121
Begins the calculation of the route specified by \a request.
122
123
A QGeoRouteReply object will be returned, which can be used to manage the
124
routing operation and to return the results of the operation.
125
126
This engine and the returned QGeoRouteReply object will emit signals
127
indicating if the operation completes or if errors occur.
128
129
Once the operation has completed, QGeoRouteReply::routes can be used to
130
retrieve the calculated route or routes.
131
132
If \a request includes features which are not supported by this engine, as
133
reported by the methods in this engine, then a
134
QGeoRouteReply::UnsupportedOptionError will occur.
135
136
The user is responsible for deleting the returned reply object, although
137
this can be done in the slot connected to QGeoRoutingManagerEngine::finished(),
138
QGeoRoutingManagerEngine::errorOccurred(), QGeoRouteReply::finished() or
139
QGeoRouteReply::errorOccurred() with deleteLater().
140
*/
141
142
/*!
143
Begins the process of updating \a route based on the current position \a
144
position.
145
146
A QGeoRouteReply object will be returned, which can be used to manage the
147
routing operation and to return the results of the operation.
148
149
This engine and the returned QGeoRouteReply object will emit signals
150
indicating if the operation completes or if errors occur.
151
152
If supportsRouteUpdates() returns false an
153
QGeoRouteReply::UnsupportedOptionError will occur.
154
155
Once the operation has completed, QGeoRouteReply::routes can be used to
156
retrieve the updated route.
157
158
The returned route could be entirely different to the original route,
159
especially if \a position is far enough away from the initial route.
160
Otherwise the route will be similar, although the remaining time and
161
distance will be updated and any segments of the original route which
162
have been traversed will be removed.
163
164
The user is responsible for deleting the returned reply object, although
165
this can be done in the slot connected to QGeoRoutingManagerEngine::finished(),
166
QGeoRoutingManagerEngine::errorOccurred(), QGeoRouteReply::finished() or
167
QGeoRouteReply::errorOccurred() with deleteLater().
168
*/
169
QGeoRouteReply *QGeoRoutingManagerEngine::updateRoute(
const
QGeoRoute &route,
const
QGeoCoordinate &position)
170
{
171
Q_UNUSED(route);
172
Q_UNUSED(position);
173
return
new
QGeoRouteReply(QGeoRouteReply::UnsupportedOptionError,
174
QLatin1String(
"The updating of routes is not supported by this service provider."
),
this
);
175
}
176
177
/*!
178
Sets the travel modes supported by this engine to \a travelModes.
179
180
It is important that subclasses use this method to ensure that the engine
181
reports its capabilities correctly. If this function is not used the
182
engine will report that it supports no travel modes at all.
183
*/
184
void
QGeoRoutingManagerEngine::setSupportedTravelModes(QGeoRouteRequest::TravelModes travelModes)
185
{
186
d_ptr->supportedTravelModes = travelModes;
187
}
188
189
/*!
190
Returns the travel modes supported by this engine.
191
*/
192
QGeoRouteRequest::TravelModes QGeoRoutingManagerEngine::supportedTravelModes()
const
193
{
194
return
d_ptr->supportedTravelModes;
195
}
196
197
/*!
198
Sets the types of features that this engine can take into account
199
during route planning to \a featureTypes.
200
201
It is important that subclasses use this method to ensure that the engine
202
reports its capabilities correctly. If this function is not used the
203
engine will report that it supports no feature types at all.
204
*/
205
void
QGeoRoutingManagerEngine::setSupportedFeatureTypes(QGeoRouteRequest::FeatureTypes featureTypes)
206
{
207
d_ptr->supportedFeatureTypes = featureTypes;
208
}
209
210
/*!
211
Returns the types of features that this engine can take into account
212
during route planning.
213
*/
214
QGeoRouteRequest::FeatureTypes QGeoRoutingManagerEngine::supportedFeatureTypes()
const
215
{
216
return
d_ptr->supportedFeatureTypes;
217
}
218
219
/*!
220
Sets the weightings which this engine can apply to different features
221
during route planning to \a featureWeights.
222
223
It is important that subclasses use this method to ensure that the engine
224
reports its capabilities correctly. If this function is not used the
225
engine will report that it supports no feature weights at all.
226
*/
227
void
QGeoRoutingManagerEngine::setSupportedFeatureWeights(QGeoRouteRequest::FeatureWeights featureWeights)
228
{
229
d_ptr->supportedFeatureWeights = featureWeights;
230
d_ptr->supportedFeatureWeights |= QGeoRouteRequest::NeutralFeatureWeight;
231
}
232
233
/*!
234
Returns the weightings which this engine can apply to different features
235
during route planning.
236
*/
237
QGeoRouteRequest::FeatureWeights QGeoRoutingManagerEngine::supportedFeatureWeights()
const
238
{
239
return
d_ptr->supportedFeatureWeights;
240
}
241
242
/*!
243
Sets the route optimizations supported by this engine to \a optimizations.
244
245
It is important that subclasses use this method to ensure that the engine
246
reports its capabilities correctly. If this function is not used the
247
engine will report that it supports no route optimizations at all.
248
*/
249
void
QGeoRoutingManagerEngine::setSupportedRouteOptimizations(QGeoRouteRequest::RouteOptimizations optimizations)
250
{
251
d_ptr->supportedRouteOptimizations = optimizations;
252
}
253
254
/*!
255
Returns the route optimizations supported by this engine.
256
*/
257
QGeoRouteRequest::RouteOptimizations QGeoRoutingManagerEngine::supportedRouteOptimizations()
const
258
{
259
return
d_ptr->supportedRouteOptimizations;
260
}
261
262
/*!
263
Sets the levels of detail for routing segments which can be
264
requested by this engine to \a segmentDetails.
265
266
It is important that subclasses use this method to ensure that the engine
267
reports its capabilities correctly. If this function is not used the
268
engine will report that it supports no segment detail at all.
269
*/
270
void
QGeoRoutingManagerEngine::setSupportedSegmentDetails(QGeoRouteRequest::SegmentDetails segmentDetails)
271
{
272
d_ptr->supportedSegmentDetails = segmentDetails;
273
}
274
275
/*!
276
Returns the levels of detail for routing segments which can be
277
requested by this engine.
278
*/
279
QGeoRouteRequest::SegmentDetails QGeoRoutingManagerEngine::supportedSegmentDetails()
const
280
{
281
return
d_ptr->supportedSegmentDetails;
282
}
283
284
/*!
285
Sets the levels of detail for navigation maneuvers which can be
286
requested by this engine to \a maneuverDetails.
287
288
It is important that subclasses use this method to ensure that the engine
289
reports its capabilities correctly. If this function is not used the
290
engine will report that it supports no maneuver details at all.
291
*/
292
void
QGeoRoutingManagerEngine::setSupportedManeuverDetails(QGeoRouteRequest::ManeuverDetails maneuverDetails)
293
{
294
d_ptr->supportedManeuverDetails = maneuverDetails;
295
}
296
297
/*!
298
Returns the levels of detail for navigation maneuvers which can be
299
requested by this engine.
300
*/
301
QGeoRouteRequest::ManeuverDetails QGeoRoutingManagerEngine::supportedManeuverDetails()
const
302
{
303
return
d_ptr->supportedManeuverDetails;
304
}
305
306
/*!
307
Sets the locale to be used by this manager to \a locale.
308
309
If this routing manager supports returning addresses and instructions
310
in different languages, they will be returned in the language of \a locale.
311
312
The locale used defaults to the system locale if this is not set.
313
*/
314
void
QGeoRoutingManagerEngine::setLocale(
const
QLocale &locale)
315
{
316
d_ptr->locale = locale;
317
d_ptr->measurementSystem = locale.measurementSystem();
318
}
319
320
/*!
321
Returns the locale used to hint to this routing manager about what
322
language to use for addresses and instructions.
323
*/
324
QLocale QGeoRoutingManagerEngine::locale()
const
325
{
326
return
d_ptr->locale;
327
}
328
329
/*!
330
Sets the measurement system used by this manager to \a system.
331
332
The measurement system can be set independently of the locale. Both setLocale() and this
333
function set the measurement system. The value set by the last function called will be used.
334
335
\sa measurementSystem(), locale(), setLocale()
336
*/
337
void
QGeoRoutingManagerEngine::setMeasurementSystem(QLocale::MeasurementSystem system)
338
{
339
d_ptr->measurementSystem = system;
340
}
341
342
/*!
343
Returns the measurement system used by this manager.
344
345
If setMeasurementSystem() has been called then the value returned by this function may be
346
different to that returned by locale().\l {QLocale::measurementSystem()}{measurementSystem()}.
347
In which case the value returned by this function is what will be used by the manager.
348
349
\sa setMeasurementSystem(), setLocale()
350
*/
351
QLocale::MeasurementSystem QGeoRoutingManagerEngine::measurementSystem()
const
352
{
353
return
d_ptr->measurementSystem;
354
}
355
356
/*!
357
\fn void QGeoRoutingManagerEngine::finished(QGeoRouteReply *reply)
358
359
This signal is emitted when \a reply has finished processing.
360
361
If reply::error() equals QGeoRouteReply::NoError then the processing
362
finished successfully.
363
364
This signal and QGeoRouteReply::finished() will be emitted at the same time.
365
366
\note Do not delete the \a reply object in the slot connected to this signal.
367
Use deleteLater() instead.
368
*/
369
370
/*!
371
\fn void QGeoRoutingManagerEngine::errorOccurred(QGeoRouteReply *reply, QGeoRouteReply::Error error, const QString &errorString)
372
373
This signal is emitted when an error has been detected in the processing of
374
\a reply. The QGeoRoutingManagerEngine::finished() signal will probably follow.
375
376
The error will be described by the error code \a error. If \a errorString is
377
not empty it will contain a textual description of the error.
378
379
This signal and QGeoRouteReply::errorOccurred() will be emitted at the same time.
380
381
\note Do not delete the \a reply object in the slot connected to this signal.
382
Use deleteLater() instead.
383
*/
384
385
QT_END_NAMESPACE
QPlatformGraphicsBufferHelper
\inmodule QtGui
qtlocation
src
location
maps
qgeoroutingmanagerengine.cpp
Generated on
for Qt by
1.14.0