summaryrefslogtreecommitdiffstats
path: root/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
diff options
context:
space:
mode:
authorBruno de Oliveira Abinader <bruno@mapbox.com>2017-10-31 18:04:59 +0200
committerPaolo Angelelli <paolo.angelelli@qt.io>2017-11-29 12:52:35 +0000
commit13189f0741c755bfbde889e91c67c168faa3709f (patch)
tree1c1c928d49bce1bfea46656df6dfc07ea75a1900 /src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
parentf59d205a670836cc989ab7f50567bcbb47d56c6f (diff)
Implement QPlaceManagerEngineMapbox
Implements QtLocation's Places functionality, providing points of interests (POIs) support based on Mapbox web services APIs [1]. New 'mapbox' plugin features: - OnlinePlacesFeature - PlaceRecommendationsFeature - SearchSuggestionsFeature - LocalizedPlacesFeature Place icons are kindly provided via Mapbox Maki under CC0 license [2]. [1] https://www.mapbox.com/api-documentation [2] https://www.mapbox.com/maki Change-Id: Ice51abe184908250f584a9c08f70d28e95c30683 Reviewed-by: Paolo Angelelli <paolo.angelelli@qt.io>
Diffstat (limited to 'src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp')
-rw-r--r--src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
index 78ccab8c..1b7cc1b3 100644
--- a/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
+++ b/src/plugins/geoservices/mapbox/qgeoroutingmanagerenginemapbox.cpp
@@ -40,6 +40,7 @@
#include "qgeoroutingmanagerenginemapbox.h"
#include "qgeoroutereplymapbox.h"
+#include "qmapboxcommon.h"
#include <QtCore/QUrlQuery>
#include <QtCore/QDebug>
@@ -51,7 +52,7 @@ QGeoRoutingManagerEngineMapbox::QGeoRoutingManagerEngineMapbox(const QVariantMap
QString *errorString)
: QGeoRoutingManagerEngine(parameters),
m_networkManager(new QNetworkAccessManager(this)),
- m_userAgent("Qt Location based application")
+ m_userAgent(mapboxDefaultUserAgent)
{
if (parameters.contains(QStringLiteral("mapbox.useragent"))) {
m_userAgent = parameters.value(QStringLiteral("mapbox.useragent")).toString().toLatin1();
@@ -74,29 +75,29 @@ QGeoRouteReply* QGeoRoutingManagerEngineMapbox::calculateRoute(const QGeoRouteRe
QNetworkRequest networkRequest;
networkRequest.setRawHeader("User-Agent", m_userAgent);
- QString url("https://api.mapbox.com/directions/v5/mapbox/");
+ QString url = mapboxDirectionsApiPath;
QGeoRouteRequest::TravelModes travelModes = request.travelModes();
if (travelModes.testFlag(QGeoRouteRequest::PedestrianTravel)) {
- url += "walking/";
+ url += QStringLiteral("walking/");
} else if (travelModes.testFlag(QGeoRouteRequest::BicycleTravel)) {
- url += "cycling/";
+ url += QStringLiteral("cycling/");
} 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/";
+ url += QStringLiteral("driving-traffic/");
} else {
- url += "driving/";
+ url += QStringLiteral("driving/");
}
}
foreach (const QGeoCoordinate &c, request.waypoints()) {
url += QString("%1,%2;").arg(c.longitude()).arg(c.latitude());
}
- if (url.right(1) == ";")
+ if (url.right(1) == QLatin1Char(';'))
url.chop(1);
QUrlQuery query;