QGeoRouteRequest Class

The QGeoRouteRequest class represents the parameters and restrictions which define a request for routing information. More...

Header: #include <QGeoRouteRequest>
qmake: QT += location
Since: Qt 5.6

This class was introduced in Qt 5.6.

Public Types

enum FeatureType { NoFeature, TollFeature, HighwayFeature, PublicTransitFeature, FerryFeature, …, TrafficFeature }
flags FeatureTypes
enum FeatureWeight { NeutralFeatureWeight, PreferFeatureWeight, RequireFeatureWeight, AvoidFeatureWeight, DisallowFeatureWeight }
flags FeatureWeights
enum ManeuverDetail { NoManeuvers, BasicManeuvers }
flags ManeuverDetails
enum RouteOptimization { ShortestRoute, FastestRoute, MostEconomicRoute, MostScenicRoute }
flags RouteOptimizations
enum SegmentDetail { NoSegmentData, BasicSegmentData }
flags SegmentDetails
enum TravelMode { CarTravel, PedestrianTravel, BicycleTravel, PublicTransitTravel, TruckTravel }
flags TravelModes

Public Functions

QGeoRouteRequest(const QGeoRouteRequest &other)
QGeoRouteRequest(const QGeoCoordinate &origin, const QGeoCoordinate &destination)
QGeoRouteRequest(const QList<QGeoCoordinate> &waypoints = QList<QGeoCoordinate>())
QGeoRouteRequest &operator=(const QGeoRouteRequest &other)
~QGeoRouteRequest()
QDateTime departureTime() const
QList<QGeoRectangle> excludeAreas() const
QVariantMap extraParameters() const
QList<QGeoRouteRequest::FeatureType> featureTypes() const
QGeoRouteRequest::FeatureWeight featureWeight(QGeoRouteRequest::FeatureType featureType) const
QGeoRouteRequest::ManeuverDetail maneuverDetail() const
int numberAlternativeRoutes() const
QGeoRouteRequest::RouteOptimizations routeOptimization() const
QGeoRouteRequest::SegmentDetail segmentDetail() const
void setDepartureTime(const QDateTime &departureTime)
void setExcludeAreas(const QList<QGeoRectangle> &areas)
void setExtraParameters(const QVariantMap &extraParameters)
void setFeatureWeight(QGeoRouteRequest::FeatureType featureType, QGeoRouteRequest::FeatureWeight featureWeight)
void setManeuverDetail(QGeoRouteRequest::ManeuverDetail maneuverDetail)
void setNumberAlternativeRoutes(int alternatives)
void setRouteOptimization(QGeoRouteRequest::RouteOptimizations optimization)
void setSegmentDetail(QGeoRouteRequest::SegmentDetail segmentDetail)
void setTravelModes(QGeoRouteRequest::TravelModes travelModes)
void setWaypoints(const QList<QGeoCoordinate> &waypoints)
void setWaypointsMetadata(const QList<QVariantMap> &waypointMetadata)
QGeoRouteRequest::TravelModes travelModes() const
QList<QGeoCoordinate> waypoints() const
QList<QVariantMap> waypointsMetadata() const
bool operator!=(const QGeoRouteRequest &other) const
bool operator==(const QGeoRouteRequest &other) const

Detailed Description

The default state of a QGeoRouteRequest instance will result in a request for basic route segment and navigation maneuvers describing the fastest route by car which covers the given waypoints.

There may be significant variation in the features supported by different providers of routing information, or even in the features supported by the same provider if different levels of authorization are used.

There are several functions in QGeoRoutingManager which can be used to check which features are supported with the current provider and authorization level.

See also QGeoRoutingManager.

Member Type Documentation

enum QGeoRouteRequest::FeatureType
flags QGeoRouteRequest::FeatureTypes

Defines a feature which is important to the planning of a route.

These values will be used in combination with QGeoRouteRequest::FeatureWeight to determine if they should or should not be part of the route.

ConstantValueDescription
QGeoRouteRequest::NoFeature0x00000000Used by QGeoRoutingManager::supportedFeatureTypes() to indicate that no features will be taken into account when planning the route.
QGeoRouteRequest::TollFeature0x00000001Consdier tollways when planning the route.
QGeoRouteRequest::HighwayFeature0x00000002Consider highways when planning the route.
QGeoRouteRequest::PublicTransitFeature0x00000004Consider public transit when planning the route.
QGeoRouteRequest::FerryFeature0x00000008Consider ferries when planning the route.
QGeoRouteRequest::TunnelFeature0x00000010Consider tunnels when planning the route.
QGeoRouteRequest::DirtRoadFeature0x00000020Consider dirt roads when planning the route.
QGeoRouteRequest::ParksFeature0x00000040Consider parks when planning the route.
QGeoRouteRequest::MotorPoolLaneFeature0x00000080Consider motor pool lanes when planning the route.
QGeoRouteRequest::TrafficFeature0x00000100Consider the current traffic situation when planning the route. Since QtLocation 5.10

The FeatureTypes type is a typedef for QFlags<FeatureType>. It stores an OR combination of FeatureType values.

enum QGeoRouteRequest::FeatureWeight
flags QGeoRouteRequest::FeatureWeights

Defines the weight to associate with a feature during the planning of a route.

These values will be used in combination with QGeoRouteRequest::Feature to determine if they should or should not be part of the route.

ConstantValueDescription
QGeoRouteRequest::NeutralFeatureWeight0x00000000The presence or absence of the feature will not affect the planning of the route.
QGeoRouteRequest::PreferFeatureWeight0x00000001Routes which contain the feature will be preferred over those that do not.
QGeoRouteRequest::RequireFeatureWeight0x00000002Only routes which contain the feature will be considered, otherwise no route will be returned.
QGeoRouteRequest::AvoidFeatureWeight0x00000004Routes which do not contain the feature will be preferred over those that do.
QGeoRouteRequest::DisallowFeatureWeight0x00000008Only routes which do not contain the feature will be considered, otherwise no route will be returned.

The FeatureWeights type is a typedef for QFlags<FeatureWeight>. It stores an OR combination of FeatureWeight values.

enum QGeoRouteRequest::ManeuverDetail
flags QGeoRouteRequest::ManeuverDetails

Defines the amount of maneuver information that should be included with the route.

ConstantValueDescription
QGeoRouteRequest::NoManeuvers0x0000No maneuvers should be included with the route.
QGeoRouteRequest::BasicManeuvers0x0001Basic manevuers will be included with the route. This will include QGeoManeuver::instructionText().

The ManeuverDetails type is a typedef for QFlags<ManeuverDetail>. It stores an OR combination of ManeuverDetail values.

enum QGeoRouteRequest::RouteOptimization
flags QGeoRouteRequest::RouteOptimizations

Defines the type of optimization which is applied to the planning of the route.

ConstantValueDescription
QGeoRouteRequest::ShortestRoute0x0001Minimize the length of the journey.
QGeoRouteRequest::FastestRoute0x0002Minimize the traveling time for the journey.
QGeoRouteRequest::MostEconomicRoute0x0004Minimize the cost of the journey.
QGeoRouteRequest::MostScenicRoute0x0008Maximize the scenic potential of the journey.

The RouteOptimizations type is a typedef for QFlags<RouteOptimization>. It stores an OR combination of RouteOptimization values.

enum QGeoRouteRequest::SegmentDetail
flags QGeoRouteRequest::SegmentDetails

Defines the amount of route segment information that should be included with the route.

ConstantValueDescription
QGeoRouteRequest::NoSegmentData0x0000No segment data should be included with the route. A route requested with this level of segment detail will initialize QGeoRouteSegment::path() as a straight line between the positions of the previous and next QGeoManeuver instances.
QGeoRouteRequest::BasicSegmentData0x0001Basic segment data will be included with the route. This will include QGeoRouteSegment::path().

The SegmentDetails type is a typedef for QFlags<SegmentDetail>. It stores an OR combination of SegmentDetail values.

enum QGeoRouteRequest::TravelMode
flags QGeoRouteRequest::TravelModes

Defines modes of travel to be used for a route.

ConstantValueDescription
QGeoRouteRequest::CarTravel0x0001The route will be optimized for someone who is driving a car.
QGeoRouteRequest::PedestrianTravel0x0002The route will be optimized for someone who is walking.
QGeoRouteRequest::BicycleTravel0x0004The route will be optimized for someone who is riding a bicycle.
QGeoRouteRequest::PublicTransitTravel0x0008The route will be optimized for someone who is making use of public transit.
QGeoRouteRequest::TruckTravel0x0010The route will be optimized for someone who is driving a truck.

The TravelModes type is a typedef for QFlags<TravelMode>. It stores an OR combination of TravelMode values.

Member Function Documentation

QGeoRouteRequest::QGeoRouteRequest(const QGeoRouteRequest &other)

Constructs a route request object from the contents of other.

QGeoRouteRequest::QGeoRouteRequest(const QGeoCoordinate &origin, const QGeoCoordinate &destination)

Constructs a request to calculate a route between origin and destination.

QGeoRouteRequest::QGeoRouteRequest(const QList<QGeoCoordinate> &waypoints = QList<QGeoCoordinate>())

Constructs a request to calculate a route through the coordinates waypoints.

The route will traverse the objects of waypoints in order.

QGeoRouteRequest &QGeoRouteRequest::operator=(const QGeoRouteRequest &other)

Assigns other to this route request object and then returns a reference to this route request object.

QGeoRouteRequest::~QGeoRouteRequest()

Destroys the request.

QDateTime QGeoRouteRequest::departureTime() const

Returns the departure time in the request.

This function was introduced in Qt 5.13.

See also setDepartureTime().

QList<QGeoRectangle> QGeoRouteRequest::excludeAreas() const

Returns areas the route must not cross.

See also setExcludeAreas().

QVariantMap QGeoRouteRequest::extraParameters() const

Returns the extra parameters set for this route request.

This function was introduced in Qt 5.11.

See also setExtraParameters().

QList<QGeoRouteRequest::FeatureType> QGeoRouteRequest::featureTypes() const

Returns the list of features that will be considered when planning the route. Features with a weight of NeutralFeatureWeight will not be returned.

QGeoRouteRequest::FeatureWeight QGeoRouteRequest::featureWeight(QGeoRouteRequest::FeatureType featureType) const

Returns the weight assigned to featureType in the planning of the route.

If no feature weight has been specified for featureType then NeutralFeatureWeight will be returned.

See also setFeatureWeight().

QGeoRouteRequest::ManeuverDetail QGeoRouteRequest::maneuverDetail() const

Returns the level of detail which will be used in the representation of routing maneuvers.

See also setManeuverDetail().

int QGeoRouteRequest::numberAlternativeRoutes() const

Returns the number of alternative routes which will be requested.

See also setNumberAlternativeRoutes().

QGeoRouteRequest::RouteOptimizations QGeoRouteRequest::routeOptimization() const

Returns the optimization criteria which this request specifies should be used while planning the route.

See also setRouteOptimization().

QGeoRouteRequest::SegmentDetail QGeoRouteRequest::segmentDetail() const

Returns the level of detail which will be used in the representation of routing segments.

See also setSegmentDetail().

void QGeoRouteRequest::setDepartureTime(const QDateTime &departureTime)

Sets the departure time departureTime for the route calculation. This information can be used by the backend to calculate a faster route, for example, by avoiding traffic congestion during rush hour.

The default value is an invalid QDateTime.

This function was introduced in Qt 5.13.

See also departureTime().

void QGeoRouteRequest::setExcludeAreas(const QList<QGeoRectangle> &areas)

Sets areas as excluded areas that the route must not cross.

See also excludeAreas().

void QGeoRouteRequest::setExtraParameters(const QVariantMap &extraParameters)

Sets the extra parameters extraParameters for the route request. The format of the extra parameters is plugin specific, and documented per plugin.

This function was introduced in Qt 5.11.

See also extraParameters().

void QGeoRouteRequest::setFeatureWeight(QGeoRouteRequest::FeatureType featureType, QGeoRouteRequest::FeatureWeight featureWeight)

Assigns the weight featureWeight to the feature featureType during the planning of the route.

By default all features are assigned a weight of NeutralFeatureWeight.

It is impossible to assign a weight to QGeoRouteRequest::NoFeature.

See also featureWeight().

void QGeoRouteRequest::setManeuverDetail(QGeoRouteRequest::ManeuverDetail maneuverDetail)

Sets the level of detail to use when representing routing maneuvers to maneuverDetail.

The default value is QGeoRouteRequest::BasicManeuvers.

See also maneuverDetail().

void QGeoRouteRequest::setNumberAlternativeRoutes(int alternatives)

Sets the number of alternative routes to request to alternatives. If alternatives is negative the number of alternative routes is set to 0.

The default value is 0.

See also numberAlternativeRoutes().

void QGeoRouteRequest::setRouteOptimization(QGeoRouteRequest::RouteOptimizations optimization)

Sets the optimization criteria to use while planning the route to optimization.

The default value is QGeoRouteRequest::FastestRoute.

See also routeOptimization().

void QGeoRouteRequest::setSegmentDetail(QGeoRouteRequest::SegmentDetail segmentDetail)

Sets the level of detail to use when representing routing segments to segmentDetail.

See also segmentDetail().

void QGeoRouteRequest::setTravelModes(QGeoRouteRequest::TravelModes travelModes)

Sets the travel modes which should be considered during the planning of the route to travelModes.

The default value is QGeoRouteRequest::CarTravel.

See also travelModes().

void QGeoRouteRequest::setWaypoints(const QList<QGeoCoordinate> &waypoints)

Sets waypoints as the waypoints that the route should pass through.

The waypoints should be given in order from origin to destination.

This request will be invalid until the waypoints have been set to a list containing two or more coordinates.

See also waypoints().

void QGeoRouteRequest::setWaypointsMetadata(const QList<QVariantMap> &waypointMetadata)

Sets waypointMetadata as the metadata for the waypoints set in this request. The metadata are intended as one QVariantMap per waypoint, given in the same order as the waypoints.

The content of the QVariantMap is somehow backend-specific, but properties that can be specified using Waypoint elements in QML can be assumed to be named and to work the same way across plugins, where supported.

See also waypointsMetadata().

QGeoRouteRequest::TravelModes QGeoRouteRequest::travelModes() const

Returns the travel modes which this request specifies should be considered during the planning of the route.

See also setTravelModes().

QList<QGeoCoordinate> QGeoRouteRequest::waypoints() const

Returns the waypoints that the route will pass through.

See also setWaypoints().

QList<QVariantMap> QGeoRouteRequest::waypointsMetadata() const

Returns the metadata for the waypoints in this request.

See also setWaypointsMetadata().

bool QGeoRouteRequest::operator!=(const QGeoRouteRequest &other) const

Returns whether this route request and other are equal.

bool QGeoRouteRequest::operator==(const QGeoRouteRequest &other) const

Returns whether this route request and other are equal.

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.