Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qgeorouterequest.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 "qgeorouterequest.h"
6
7#include <QtPositioning/QGeoCoordinate>
8#include <QtPositioning/QGeoRectangle>
9
11
13
14
37/*
38 DESIGN NOTE
39
40 There are plans to make this extensible by allowing the user to set a
41 list of QGeoTransportOptions (or QGeoTransitOptions). We don't have any
42 subclasses for that just yet, otherwise they'd be present.
43
44 A QGeoPublicTransportOption subclass would allow users to specify things
45 like cost limits, the maximum number of changes of vehicle, the maximum
46 walking time / distance between changes of vehicle.
47
48 There's Nokia / Navteq support for specifying things like Truck attributes
49 so you can route around various road restrictions and conditions which
50 effect trucks.
51
52 A QGeoTrafficAwareTransportOption is probably also a good place to put the
53 inputs for the various traffic / time aware bits of information. A
54 departure / arrrival time could be set, and the presence of this transport
55 options subclass (and the fact that user auth said that the user had
56 support) would mean we could provide better values for the estimated
57 travel times and so on.
58
59 This all relies on at least one service making this data available to us,
60 which would probably be tied to token based authorization. It could be
61 some time before this becomes available.
62*/
63
64
140// TODO improve description of MostScenicRoute
193 : d_ptr(new QGeoRouteRequestPrivate())
194{
195 d_ptr->waypoints = waypoints;
196}
197
203 : d_ptr(new QGeoRouteRequestPrivate())
204{
205 d_ptr->waypoints.append(origin);
207}
208
213
218
224{
225 if (this == &other)
226 return *this;
227
228 d_ptr = other.d_ptr;
229 return *this;
230}
231
244bool QGeoRouteRequest::isEqual(const QGeoRouteRequest &other) const noexcept
245{
246 return ((d_ptr.constData() == other.d_ptr.constData())
247 || (*d_ptr) == (*other.d_ptr));
248}
249
258void QGeoRouteRequest::setWaypoints(const QList<QGeoCoordinate> &waypoints)
259{
260 d_ptr->waypoints = waypoints;
261}
262
266QList<QGeoCoordinate> QGeoRouteRequest::waypoints() const
267{
268 return d_ptr->waypoints;
269}
270
274void QGeoRouteRequest::setExcludeAreas(const QList<QGeoRectangle> &areas)
275{
276 d_ptr->excludeAreas = areas;
277}
278
282QList<QGeoRectangle> QGeoRouteRequest::excludeAreas() const
283{
284 return d_ptr->excludeAreas;
285}
286
294{
295 d_ptr->numberAlternativeRoutes = qMax(0, alternatives);
296}
297
305
312void QGeoRouteRequest::setTravelModes(QGeoRouteRequest::TravelModes travelModes)
313{
314 d_ptr->travelModes = travelModes;
315}
316
321QGeoRouteRequest::TravelModes QGeoRouteRequest::travelModes() const
322{
323 return d_ptr->travelModes;
324}
325
335{
337 if (featureType != QGeoRouteRequest::NoFeature)
338 d_ptr->featureWeights[featureType] = featureWeight;
339 } else {
340 d_ptr->featureWeights.remove(featureType);
341 }
342}
343
354
359QList<QGeoRouteRequest::FeatureType> QGeoRouteRequest::featureTypes() const
360{
361 return d_ptr->featureWeights.keys();
362}
363
370void QGeoRouteRequest::setRouteOptimization(QGeoRouteRequest::RouteOptimizations optimization)
371{
372 d_ptr->routeOptimization = optimization;
373}
374
379QGeoRouteRequest::RouteOptimizations QGeoRouteRequest::routeOptimization() const
380{
381 return d_ptr->routeOptimization;
382}
383
392
401
412
421
432{
434}
435
442{
443 return d_ptr->departureTime;
444}
445
446/*******************************************************************************
447*******************************************************************************/
448
450{
451 return ((waypoints == other.waypoints)
452 && (excludeAreas == other.excludeAreas)
453 && (numberAlternativeRoutes == other.numberAlternativeRoutes)
454 && (travelModes == other.travelModes)
455 && (featureWeights == other.featureWeights)
456 && (routeOptimization == other.routeOptimization)
457 && (segmentDetail == other.segmentDetail)
458 && (maneuverDetail == other.maneuverDetail));
459}
460
\inmodule QtCore\reentrant
Definition qdatetime.h:283
\inmodule QtPositioning
QGeoRouteRequest::TravelModes travelModes
QGeoRouteRequest::SegmentDetail segmentDetail
QList< QGeoRectangle > excludeAreas
QGeoRouteRequest::ManeuverDetail maneuverDetail
QMap< QGeoRouteRequest::FeatureType, QGeoRouteRequest::FeatureWeight > featureWeights
QGeoRouteRequest::RouteOptimizations routeOptimization
bool operator==(const QGeoRouteRequestPrivate &other) const
QList< QGeoCoordinate > waypoints
\inmodule QtLocation
QDateTime departureTime() const
Returns the departure time in the request.
SegmentDetail segmentDetail() const
Returns the level of detail which will be used in the representation of routing segments.
void setManeuverDetail(ManeuverDetail maneuverDetail)
Sets the level of detail to use when representing routing maneuvers to maneuverDetail.
void setDepartureTime(const QDateTime &departureTime)
Sets the departure time departureTime for the route calculation.
void setRouteOptimization(RouteOptimizations optimization)
Sets the optimization criteria to use while planning the route to optimization.
void setSegmentDetail(SegmentDetail segmentDetail)
Sets the level of detail to use when representing routing segments to segmentDetail.
FeatureWeight
Defines the weight to associate with a feature during the planning of a route.
QGeoRouteRequest & operator=(const QGeoRouteRequest &other) noexcept
Assigns other to this route request object and then returns a reference to this route request object.
FeatureWeight featureWeight(FeatureType featureType) const
Returns the weight assigned to featureType in the planning of the route.
QList< FeatureType > featureTypes() const
Returns the list of features that will be considered when planning the route.
QGeoRouteRequest(const QList< QGeoCoordinate > &waypoints=QList< QGeoCoordinate >())
Constructs a request to calculate a route through the coordinates waypoints.
void setWaypoints(const QList< QGeoCoordinate > &waypoints)
Sets waypoints as the waypoints that the route should pass through.
TravelModes travelModes() const
Returns the travel modes which this request specifies should be considered during the planning of the...
RouteOptimizations routeOptimization() const
Returns the optimization criteria which this request specifies should be used while planning the rout...
QList< QGeoCoordinate > waypoints() const
Returns the waypoints that the route will pass through.
SegmentDetail
Defines the amount of route segment information that should be included with the route.
~QGeoRouteRequest()
Destroys the request.
void setFeatureWeight(FeatureType featureType, FeatureWeight featureWeight)
Assigns the weight featureWeight to the feature featureType during the planning of the route.
void setNumberAlternativeRoutes(int alternatives)
Sets the number of alternative routes to request to alternatives.
void setTravelModes(TravelModes travelModes)
Sets the travel modes which should be considered during the planning of the route to travelModes.
ManeuverDetail
Defines the amount of maneuver information that should be included with the route.
int numberAlternativeRoutes() const
Returns the number of alternative routes which will be requested.
void setExcludeAreas(const QList< QGeoRectangle > &areas)
Sets areas as excluded areas that the route must not cross.
QList< QGeoRectangle > excludeAreas() const
Returns areas the route must not cross.
FeatureType
Defines a feature which is important to the planning of a route.
ManeuverDetail maneuverDetail() const
Returns the level of detail which will be used in the representation of routing maneuvers.
Definition qlist.h:75
void append(parameter_type t)
Definition qlist.h:458
T value(const Key &key, const T &defaultValue=T()) const
Definition qmap.h:357
size_type remove(const Key &key)
Definition qmap.h:300
QList< Key > keys() const
Definition qmap.h:383
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char * destination
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
#define QT_DEFINE_QESDP_SPECIALIZATION_DTOR(Class)
QSharedPointer< T > other(t)
[5]