RouteQuery QML Type

The RouteQuery type is used to provide query parameters to a RouteModel. More...

Import Statement: import QtLocation 5.15
Since: QtLocation 5.5

Properties

Methods

Detailed Description

A RouteQuery is used to pack all the parameters necessary to make a request to a routing service, which can then populate the contents of a RouteModel.

These parameters describe key details of the route, such as waypoints to pass through, excludedAreas to avoid, the travelModes in use, as well as detailed preferences on how to optimize the route and what features to prefer or avoid along the path (such as toll roads, highways, etc).

RouteQuery objects are used exclusively to fill out the value of a RouteModel's query property, which can then begin the retrieval process to populate the model.

Some plugins might allow or require specific parameters to operate. In order to specify these plugin-specific parameters, MapParameter elements can be nested inside a RouteQuery.

Example Usage

The following snipped shows an incomplete example of creating a RouteQuery object and setting it as the value of a RouteModel's query property.

 RouteQuery {
     id: aQuery
 }

 RouteModel {
     query: aQuery
     autoUpdate: false
 }

For a more complete example, see the documentation for the RouteModel type, and the Mapviewer example.

See also RouteModel.

Property Documentation

departureTime : date

The departure time to be used when querying for the route. The default value is an invalid date, meaning no departure time will be used in the query.

This property was introduced in Qt 5.13.


excludedAreas : list<georectangle>

Areas that the route must not cross.

Excluded areas can be set as part of the RouteQuery type declaration or dynamically with the functions provided.

See also addExcludedArea, removeExcludedArea, and clearExcludedAreas.


[read-only] extraParameters : VariantMap

The route query extra parameters. This property is read only. If the query is defined by the user, these can be set by using MapParameters. If the route query comes from the engine via signals, the query is intended to be read-only.

This property was introduced in Qt 5.11.


featureTypes : QList<FeatureType>

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

  • RouteQuery.NoFeature - No features will be taken into account when planning the route
  • RouteQuery.TollFeature - Consider tollways when planning the route
  • RouteQuery.HighwayFeature - Consider highways when planning the route
  • RouteQuery.PublicTransitFeature - Consider public transit when planning the route
  • RouteQuery.FerryFeature - Consider ferries when planning the route
  • RouteQuery.TunnelFeature - Consider tunnels when planning the route
  • RouteQuery.DirtRoadFeature - Consider dirt roads when planning the route
  • RouteQuery.ParksFeature - Consider parks when planning the route
  • RouteQuery.MotorPoolLaneFeature - Consider motor pool lanes when planning the route
  • RouteQuery.TrafficFeature - Consider traffic when planning the route

See also setFeatureWeight and featureWeight.


maneuverDetail : enumeration

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

ConstantDescription
RouteQuery.NoManeuversNo maneuvers should be included with the route
RouteQuery.BasicManeuversBasic maneuvers will be included with the route

The default value is RouteQuery.BasicManeuvers.


numberAlternativeRoutes : int

The number of alternative routes requested when requesting routes. The default value is 0.


routeOptimizations : enumeration

The route optimizations which should be considered during the planning of the route. Values can be combined with OR ('|') -operator.

ConstantDescription
RouteQuery.ShortestRouteMinimize the length of the journey
RouteQuery.FastestRouteMinimize the traveling time for the journey
RouteQuery.MostEconomicRouteMinimize the cost of the journey
RouteQuery.MostScenicRouteMaximize the scenic potential of the journey

The default value is RouteQuery.FastestRoute.


segmentDetail : enumeration

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

ConstantDescription
RouteQuery.NoSegmentDataNo segment data should be included with the route
RouteQuery.BasicSegmentDataBasic segment data will be included with the route

The default value is RouteQuery.BasicSegmentData.


travelModes : enumeration

The travel modes which should be considered during the planning of the route. Values can be combined with OR ('|') -operator.

ConstantDescription
RouteQuery.CarTravelThe route will be optimized for someone who is driving a car
RouteQuery.PedestrianTravelThe route will be optimized for someone who is walking
RouteQuery.BicycleTravelThe route will be optimized for someone who is riding a bicycle
RouteQuery.PublicTransitTravel The route will be optimized for someone who is making use of public transit
RouteQuery.TruckTravelThe route will be optimized for someone who is driving a truck

The default value is RouteQuery.CarTravel.


waypoints : list<coordinate>

The coordinates of the waypoints for the desired route. The waypoints should be given in order from origin to destination. Two or more coordinates are needed.

Waypoints can be set as part of the RouteQuery type declaration or dynamically with the functions provided.

When setting this property to a list of waypoints, each waypoint can be either a coordinate or a Waypoint, interchangeably. If a coordinate is passed, it will be internally converted to a Waypoint.

This property, however, always contains a list of coordinates.

See also waypointObjects, addWaypoint, removeWaypoint, and clearWaypoints.


Method Documentation

void addExcludedArea(georectangle area)

Adds the specified georectangle area to the excluded areas (areas that the route must not cross). The same area can only be added once.

See also removeExcludedArea and clearExcludedAreas.


void addWaypoint(coordinate)

Appends a coordinate to the list of waypoints. Same coordinate can be set multiple times. The coordinate argument can be a coordinate or a Waypoint. If a coordinate is used, it will be internally converted to a Waypoint.

See also removeWaypoint and clearWaypoints.


void clearExcludedAreas()

Clears all excluded areas (areas that the route must not cross).

See also addExcludedArea and removeExcludedArea.


void clearWaypoints()

Clears all waypoints.

See also removeWaypoint and addWaypoint.


FeatureWeight featureWeight(FeatureType featureType)

Gets the weight for the featureType.

See also featureTypes, setFeatureWeight, and resetFeatureWeights.


void removeExcludedArea(georectangle area)

Removes the given area from excluded areas (areas that the route must not cross).

See also addExcludedArea and clearExcludedAreas.


void removeWaypoint(coordinate)

Removes the given coordinate from the list of waypoints. If the same coordinate appears multiple times, the most recently added coordinate instance is removed.

See also addWaypoint and clearWaypoints.


void resetFeatureWeights()

Resets all feature weights to their default state (NeutralFeatureWeight).

See also featureTypes, setFeatureWeight, and featureWeight.


void setFeatureWeight(FeatureType feature, FeatureWeight weight)

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

Following lists the possible feature weights:

ConstantDescription
RouteQuery.NeutralFeatureWeightThe presence or absence of the feature does not affect the planning of the route
RouteQuery.PreferFeatureWeightRoutes which contain the feature are preferred over those that do not
RouteQuery.RequireFeatureWeightOnly routes which contain the feature are considered, otherwise no route will be returned
RouteQuery.AvoidFeatureWeightRoutes which do not contain the feature are preferred over those that do
RouteQuery.DisallowFeatureWeightOnly routes which do not contain the feature are considered, otherwise no route will be returned

See also featureTypes, resetFeatureWeights, and featureWeight.


list<Waypoint> waypointObjects()

This method can be used to retrieve the list of Waypoint objects relative to RouteQuery::waypoints.

See also waypointObjects, addWaypoint, removeWaypoint, and clearWaypoints.