diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-05-30 16:52:14 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-06-07 11:13:23 +0000 |
commit | 7bd7815f613c6f1ae0215d0b6a0ab5b7a6e72a59 (patch) | |
tree | fddd667313da52e5df0c48b4ff3d73279f4e62d0 /src | |
parent | 9e566cc5035493a7be8f7496bed57fe6e4060b2d (diff) | |
download | qtlocation-7bd7815f613c6f1ae0215d0b6a0ab5b7a6e72a59.tar.gz |
Support requesting traffic-aware routing from Mapbox
Change-Id: I1c09d5a4d34fdb642ed38b32d9e01cf55802195f
Reviewed-by: Thiago Marcos P. Santos <tmpsantos@gmail.com>
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp index f5776852..78ccab8c 100644 --- a/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp @@ -77,14 +77,21 @@ QGeoRouteReply* QGeoRoutingManagerEngineMapbox::calculateRoute(const QGeoRouteRe QString url("https://api.mapbox.com/directions/v5/mapbox/"); QGeoRouteRequest::TravelModes travelModes = request.travelModes(); - if (travelModes.testFlag(QGeoRouteRequest::PedestrianTravel)) + if (travelModes.testFlag(QGeoRouteRequest::PedestrianTravel)) { url += "walking/"; - else - if (travelModes.testFlag(QGeoRouteRequest::BicycleTravel)) + } else if (travelModes.testFlag(QGeoRouteRequest::BicycleTravel)) { url += "cycling/"; - else - if (travelModes.testFlag(QGeoRouteRequest::CarTravel)) - url += "driving/"; + } else if (travelModes.testFlag(QGeoRouteRequest::CarTravel)) { + const QList<QGeoRouteRequest::FeatureType> &featureTypes = request.featureTypes(); + int trafficFeatureIdx = featureTypes.indexOf(QGeoRouteRequest::TrafficFeature); + QGeoRouteRequest::FeatureWeight trafficWeight = request.featureWeight(QGeoRouteRequest::TrafficFeature); + if (trafficFeatureIdx >= 0 && + (trafficWeight == QGeoRouteRequest::AvoidFeatureWeight || trafficWeight == QGeoRouteRequest::DisallowFeatureWeight)) { + url += "driving-traffic/"; + } else { + url += "driving/"; + } + } foreach (const QGeoCoordinate &c, request.waypoints()) { url += QString("%1,%2;").arg(c.longitude()).arg(c.latitude()); |