Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qgeomaneuver.cpp
Go to the documentation of this file.
1
// Copyright (C) 2022 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
// Qt-Security score:significant reason:default
4
5
#
include
"qgeomaneuver.h"
6
#
include
"qgeomaneuver_p.h"
7
8
#
include
<
QtCore
/
QVariant
>
9
#
include
"qgeocoordinate.h"
10
11
QT_BEGIN_NAMESPACE
12
13
QT_DEFINE_QSDP_SPECIALIZATION_DTOR(QGeoManeuverPrivate)
14
15
/*!
16
\class QGeoManeuver
17
\inmodule QtLocation
18
\ingroup QtLocation-routing
19
\since 5.6
20
21
\brief The QGeoManeuver class represents the information relevant to the
22
point at which two QGeoRouteSegments meet.
23
24
QGeoRouteSegment instances can be thought of as edges on a routing
25
graph, with QGeoManeuver instances as optional labels attached to the
26
vertices of the graph.
27
28
The most interesting information help in a QGeoManeuver instance is
29
normally the textual navigation to provide and the position at which to
30
provide it, accessible by instructionText() and position() respectively.
31
32
It is also possible to determine if a routing waypoint has been passed by
33
checking if waypoint() returns a valid QGeoCoordinate.
34
*/
35
36
/*!
37
\qmltype routeManeuver
38
\inqmlmodule QtLocation
39
\ingroup qml-QtLocation5-routing
40
\since QtLocation 5.5
41
42
\brief The routeManeuver type represents the information relevant to the
43
point at which two routeSegments meet.
44
45
Instances of routeSegment can be thought of as edges on a routing
46
graph, with routeManeuver instances as optional labels attached to the
47
vertices of the graph.
48
49
The most interesting information held in a routeManeuver instance is
50
normally the textual navigation to provide and the position at which to
51
provide it, accessible by \l instructionText and \l position respectively.
52
53
\section1 Example
54
55
The following QML snippet demonstrates how to print information about a
56
route maneuver:
57
58
\snippet declarative/routing.qml QtQuick import
59
\snippet declarative/maps.qml QtLocation import
60
\codeline
61
\snippet declarative/routing.qml routeManeuver
62
*/
63
64
/*!
65
\enum QGeoManeuver::InstructionDirection
66
67
Describes the change in direction associated with the instruction text
68
that is associated with a QGeoManaeuver.
69
70
\value NoDirection
71
There is no direction associated with the instruction text.
72
73
\value DirectionForward
74
The instruction indicates that the direction of travel does not need to change.
75
76
\value DirectionBearRight
77
The instruction indicates that the direction of travel should bear to the right.
78
79
\value DirectionLightRight
80
The instruction indicates that a light turn to the right is required.
81
82
\value DirectionRight
83
The instruction indicates that a turn to the right is required.
84
85
\value DirectionHardRight
86
The instruction indicates that a hard turn to the right is required.
87
88
\value DirectionUTurnRight
89
The instruction indicates that a u-turn to the right is required.
90
91
\value DirectionUTurnLeft
92
The instruction indicates that a u-turn to the left is required.
93
94
\value DirectionHardLeft
95
The instruction indicates that a hard turn to the left is required.
96
97
\value DirectionLeft
98
The instruction indicates that a turn to the left is required.
99
100
\value DirectionLightLeft
101
The instruction indicates that a light turn to the left is required.
102
103
\value DirectionBearLeft
104
The instruction indicates that the direction of travel should bear to the left.
105
106
*/
107
108
/*!
109
Constructs a invalid maneuver object.
110
111
The maneuver will remain invalid until one of
112
setPosition(), setInstructionText(), setDirection(),
113
setTimeToNextInstruction(), setDistanceToNextInstruction() or
114
setWaypoint() is called.
115
*/
116
QGeoManeuver::QGeoManeuver()
117
: d_ptr(
new
QGeoManeuverPrivate()) {}
118
119
/*!
120
Constructs a maneuver object from the contents of \a other.
121
*/
122
QGeoManeuver::QGeoManeuver(
const
QGeoManeuver &other)
noexcept
=
default
;
123
124
/*!
125
Destroys this maneuver object.
126
*/
127
QGeoManeuver::~QGeoManeuver() =
default
;
128
129
/*!
130
Assigns \a other to this maneuver object and then returns
131
a reference to this maneuver object.
132
*/
133
QGeoManeuver &QGeoManeuver::operator= (
const
QGeoManeuver & other)
134
{
135
if
(
this
== &other)
136
return
*
this
;
137
138
d_ptr = other.d_ptr;
139
return
*
this
;
140
}
141
142
/*!
143
\fn bool QGeoManeuver::operator==(const QGeoManeuver &lhs, const QGeoManeuver &rhs) noexcept
144
145
Returns whether the \a lhs maneuver is equal to \a rhs.
146
*/
147
148
/*!
149
\fn bool QGeoManeuver::operator!= (const QGeoManeuver &lhs, const QGeoManeuver &rhs) noexcept
150
151
Returns whether the \a lhs maneuver is not equal to \a rhs.
152
*/
153
154
bool
QGeoManeuver::isEqual(
const
QGeoManeuver &other)
const
155
{
156
return
( (d_ptr.constData() == other.d_ptr.constData())
157
|| (d_ptr->equals(*other.d_ptr)) );
158
}
159
160
/*!
161
\qmlproperty bool routeManeuver::valid
162
163
This read-only property holds whether this maneuver is valid or not.
164
165
Invalid maneuvers are used when there is no information
166
that needs to be attached to the endpoint of a QGeoRouteSegment instance.
167
*/
168
169
/*!
170
\property QGeoManeuver::valid
171
\brief whether this maneuver is valid or not.
172
173
Invalid maneuvers are used when there is no information
174
that needs to be attached to the endpoint of a QGeoRouteSegment instance.
175
*/
176
bool
QGeoManeuver::isValid()
const
177
{
178
return
d_ptr->valid();
179
}
180
181
/*!
182
\qmlproperty coordinate routeManeuver::position
183
184
This read-only property holds where the \l instructionText should be displayed.
185
186
*/
187
188
/*!
189
\property QGeoManeuver::position
190
\brief the position where \l instructionText should be displayed.
191
*/
192
void
QGeoManeuver::setPosition(
const
QGeoCoordinate &position)
193
{
194
d_ptr->setValid(
true
);
195
d_ptr->setPosition(position);
196
}
197
198
QGeoCoordinate QGeoManeuver::position()
const
199
{
200
return
d_ptr->position();
201
}
202
203
/*!
204
\qmlproperty string routeManeuver::instructionText
205
206
This read-only property holds textual navigation instruction.
207
*/
208
209
/*!
210
\property QGeoManeuver::instructionText
211
\brief the textual navigation instructions.
212
*/
213
void
QGeoManeuver::setInstructionText(
const
QString &instructionText)
214
{
215
d_ptr->setValid(
true
);
216
d_ptr->setText(instructionText);
217
}
218
219
QString QGeoManeuver::instructionText()
const
220
{
221
return
d_ptr->text();
222
}
223
224
/*!
225
\qmlproperty enumeration routeManeuver::direction
226
227
Describes the change in direction associated with the instruction text
228
that is associated with a routeManeuver.
229
230
\list
231
\li RouteManeuver.NoDirection - There is no direction associated with the instruction text
232
\li RouteManeuver.DirectionForward - The instruction indicates that the direction of travel does not need to change
233
\li RouteManeuver.DirectionBearRight - The instruction indicates that the direction of travel should bear to the right
234
\li RouteManeuver.DirectionLightRight - The instruction indicates that a light turn to the right is required
235
\li RouteManeuver.DirectionRight - The instruction indicates that a turn to the right is required
236
\li RouteManeuver.DirectionHardRight - The instruction indicates that a hard turn to the right is required
237
\li RouteManeuver.DirectionUTurnRight - The instruction indicates that a u-turn to the right is required
238
\li RouteManeuver.DirectionUTurnLeft - The instruction indicates that a u-turn to the left is required
239
\li RouteManeuver.DirectionHardLeft - The instruction indicates that a hard turn to the left is required
240
\li RouteManeuver.DirectionLeft - The instruction indicates that a turn to the left is required
241
\li RouteManeuver.DirectionLightLeft - The instruction indicates that a light turn to the left is required
242
\li RouteManeuver.DirectionBearLeft - The instruction indicates that the direction of travel should bear to the left
243
\endlist
244
*/
245
246
/*!
247
\property QGeoManeuver::direction
248
\brief the direction associated with the associated instruction.
249
*/
250
void
QGeoManeuver::setDirection(QGeoManeuver::InstructionDirection direction)
251
{
252
d_ptr->setValid(
true
);
253
d_ptr->setDirection(direction);
254
}
255
256
QGeoManeuver::InstructionDirection QGeoManeuver::direction()
const
257
{
258
return
d_ptr->direction();
259
}
260
261
/*!
262
\qmlproperty int routeManeuver::timeToNextInstruction
263
264
This read-only property holds the estimated time, in seconds, that it will take
265
to travel from the point at which the associated instruction was issued
266
to the point at which the next instruction should be issued, in seconds.
267
*/
268
269
/*!
270
\property QGeoManeuver::timeToNextInstruction
271
\brief the estimated time, in seconds, that it will take to travel from the
272
point at which the associated instruction was issued to the point at which the
273
next instruction should be issued.
274
*/
275
void
QGeoManeuver::setTimeToNextInstruction(
int
secs)
276
{
277
d_ptr->setValid(
true
);
278
d_ptr->setTimeToNextInstruction(secs);
279
}
280
281
int
QGeoManeuver::timeToNextInstruction()
const
282
{
283
return
d_ptr->timeToNextInstruction();
284
}
285
286
/*!
287
\qmlproperty real routeManeuver::distanceToNextInstruction
288
289
This read-only property holds the distance, in meters, between the point at which
290
the associated instruction was issued and the point that the next instruction should
291
be issued.
292
*/
293
294
/*!
295
\property QGeoManeuver::distanceToNextInstruction
296
\brief the distance, in meters, between the point at which this instruction was
297
issued, and the point at which the next instruction should be issued.
298
*/
299
void
QGeoManeuver::setDistanceToNextInstruction(qreal distance)
300
{
301
d_ptr->setValid(
true
);
302
d_ptr->setDistanceToNextInstruction(distance);
303
}
304
305
qreal QGeoManeuver::distanceToNextInstruction()
const
306
{
307
return
d_ptr->distanceToNextInstruction();
308
}
309
310
/*!
311
\qmlproperty coordinate routeManeuver::waypoint
312
313
This property holds the waypoint associated with this maneuver.
314
Not all maneuvers have a waypoint associated with them.
315
*/
316
317
/*!
318
\property QGeoManeuver::waypoint
319
\brief the waypoint associated with this maneuver.
320
321
If there is not waypoint associated with this maneuver, then this
322
property holds an invalid QGeoCoordinate.
323
*/
324
void
QGeoManeuver::setWaypoint(
const
QGeoCoordinate &coordinate)
325
{
326
d_ptr->setValid(
true
);
327
d_ptr->setWaypoint(coordinate);
328
}
329
330
QGeoCoordinate QGeoManeuver::waypoint()
const
331
{
332
return
d_ptr->waypoint();
333
}
334
335
/*!
336
\qmlproperty Object routeManeuver::extendedAttributes
337
338
This property holds the extended attributes of the maneuver and is a map.
339
These attributes are plugin specific, and can be empty.
340
341
Consult the \l {Qt Location#Plugin References and Parameters}{plugin documentation}
342
for what attributes are supported and how they should be used.
343
344
Note, due to limitations of the QQmlPropertyMap, it is not possible
345
to declaratively specify the attributes in QML, assignment of attributes keys
346
and values can only be accomplished by JavaScript.
347
348
\since QtLocation 5.11
349
*/
350
351
/*!
352
\property QGeoManeuver::extendedAttributes
353
\brief the extended attributes associated with this maneuver.
354
\since QtLocation 5.11
355
*/
356
void
QGeoManeuver::setExtendedAttributes(
const
QVariantMap &extendedAttributes)
357
{
358
d_ptr->setValid(
true
);
359
d_ptr->setExtendedAttributes(extendedAttributes);
360
}
361
362
QVariantMap QGeoManeuver::extendedAttributes()
const
363
{
364
return
d_ptr->extendedAttributes();
365
}
366
367
/*******************************************************************************
368
*******************************************************************************/
369
370
bool
QGeoManeuverPrivate::equals(
const
QGeoManeuverPrivate &other)
const
371
{
372
return
((valid() == other.valid())
373
&& (position() == other.position())
374
&& (text() == other.text())
375
&& (direction() == other.direction())
376
&& (timeToNextInstruction() == other.timeToNextInstruction())
377
&& (distanceToNextInstruction() == other.distanceToNextInstruction())
378
&& (waypoint() == other.waypoint()));
379
}
380
381
/*******************************************************************************
382
*******************************************************************************/
383
384
bool
QGeoManeuverPrivate::valid()
const
385
{
386
return
m_valid;
387
}
388
389
void
QGeoManeuverPrivate::setValid(
bool
valid)
390
{
391
m_valid = valid;
392
}
393
394
QString QGeoManeuverPrivate::id()
const
395
{
396
return
m_id;
397
}
398
399
void
QGeoManeuverPrivate::setId(
const
QString &id)
400
{
401
m_id = id;
402
}
403
404
QGeoCoordinate QGeoManeuverPrivate::position()
const
405
{
406
return
m_position;
407
}
408
409
void
QGeoManeuverPrivate::setPosition(
const
QGeoCoordinate &position)
410
{
411
m_position = position;
412
}
413
414
QString QGeoManeuverPrivate::text()
const
415
{
416
return
m_text;
417
}
418
419
void
QGeoManeuverPrivate::setText(
const
QString &text)
420
{
421
m_text = text;
422
}
423
424
QGeoManeuver::InstructionDirection QGeoManeuverPrivate::direction()
const
425
{
426
return
m_direction;
427
}
428
429
void
QGeoManeuverPrivate::setDirection(QGeoManeuver::InstructionDirection direction)
430
{
431
m_direction = direction;
432
}
433
434
int
QGeoManeuverPrivate::timeToNextInstruction()
const
435
{
436
return
m_timeToNextInstruction;
437
}
438
439
void
QGeoManeuverPrivate::setTimeToNextInstruction(
int
timeToNextInstruction)
440
{
441
m_timeToNextInstruction = timeToNextInstruction;
442
}
443
444
qreal QGeoManeuverPrivate::distanceToNextInstruction()
const
445
{
446
return
m_distanceToNextInstruction;
447
}
448
449
void
QGeoManeuverPrivate::setDistanceToNextInstruction(qreal distanceToNextInstruction)
450
{
451
m_distanceToNextInstruction = distanceToNextInstruction;
452
}
453
454
QGeoCoordinate QGeoManeuverPrivate::waypoint()
const
455
{
456
return
m_waypoint;
457
}
458
459
void
QGeoManeuverPrivate::setWaypoint(
const
QGeoCoordinate &waypoint)
460
{
461
m_waypoint = waypoint;
462
}
463
464
QVariantMap QGeoManeuverPrivate::extendedAttributes()
const
465
{
466
return
m_extendedAttributes;
467
}
468
469
void
QGeoManeuverPrivate::setExtendedAttributes(
const
QVariantMap &extendedAttributes)
470
{
471
m_extendedAttributes = extendedAttributes;
472
}
473
474
QT_END_NAMESPACE
475
476
#
include
"moc_qgeomaneuver.cpp"
qtlocation
src
location
maps
qgeomaneuver.cpp
Generated on
for Qt by
1.18.0