diff options
-rw-r--r-- | src/location/doc/src/plugins/osm.qdoc | 7 | ||||
-rw-r--r-- | src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp | 7 | ||||
-rw-r--r-- | src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.h | 1 |
3 files changed, 14 insertions, 1 deletions
diff --git a/src/location/doc/src/plugins/osm.qdoc b/src/location/doc/src/plugins/osm.qdoc index 2d3a7a68..f10059d2 100644 --- a/src/location/doc/src/plugins/osm.qdoc +++ b/src/location/doc/src/plugins/osm.qdoc @@ -65,12 +65,18 @@ The following table lists optional parameters that can be passed to the Open Str \li mapping.copyright \li Custom copryright string is used when setting the \l{Map::activeMapType} to \l{MapType}.CustomMap via urlprefix parameter. This copyright will only be used when using the CustomMap from above. If empty no copyright will be displayed for the custom map. +\row + \li routing.host + \li Url string set when making network requests to the routing server. This parameter should be set to a + valid server url with the correct osrm api. If not specified the default \l {http://router.project-osrm.org/viaroute}{url} will be used. + \note The api documentation and sources are available at \l {http://project-osrm.org/}{Project OSRM}. \endtable \section1 Parameter Usage Example The following example shows how to create an OSM plugin instance with parameters supplied for an useragent, and if necessary, a custom server url plus the corresponding copyright information for the tile provider. +Additionally, it is possible to choose another routing server than the public osrm one. \section2 QML @@ -80,6 +86,7 @@ Plugin { PluginParameter { name: "useragent"; value: "My great Qt OSM application" } PluginParameter { name: "mapping.host"; value: "http://osm.tile.server.address/" } PluginParameter { name: "mapping.copyright"; value: "All mine" } + PluginParameter { name: "routing.host"; value: "http://osrm.server.address/viaroute" } } \endcode */ diff --git a/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp index 36913146..ab582434 100644 --- a/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp +++ b/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.cpp @@ -48,6 +48,11 @@ QGeoRoutingManagerEngineOsm::QGeoRoutingManagerEngineOsm(const QVariantMap ¶ else m_userAgent = "Qt Location based application"; + if (parameters.contains(QStringLiteral("routing.host"))) + m_urlPrefix = parameters.value(QStringLiteral("routing.host")).toString().toLatin1(); + else + m_urlPrefix = QStringLiteral("http://router.project-osrm.org/viaroute"); + *error = QGeoServiceProvider::NoError; errorString->clear(); } @@ -61,7 +66,7 @@ QGeoRouteReply* QGeoRoutingManagerEngineOsm::calculateRoute(const QGeoRouteReque QNetworkRequest networkRequest; networkRequest.setRawHeader("User-Agent", m_userAgent); - QUrl url(QStringLiteral("http://router.project-osrm.org/viaroute")); + QUrl url(m_urlPrefix); QUrlQuery query; query.addQueryItem(QStringLiteral("instructions"), QStringLiteral("true")); diff --git a/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.h b/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.h index 793c8ace..618ef900 100644 --- a/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.h +++ b/src/plugins/geoservices/osm/qgeoroutingmanagerengineosm.h @@ -60,6 +60,7 @@ private Q_SLOTS: private: QNetworkAccessManager *m_networkManager; QByteArray m_userAgent; + QString m_urlPrefix; }; QT_END_NAMESPACE |