summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWolfgang Bremer <wolfgang@w-bremer.de>2015-05-09 21:42:30 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2015-05-28 06:35:36 +0000
commit92d684aadda7f670643222b9cda4d368f2a82cb2 (patch)
treefa7d367463b956ef12ae04905a3be72b4c125249
parenta5d615f5b49b29f91f979b4b338f7febbe445ebf (diff)
Allow custom URLs for OSM geocoding
This enables the usage of another geocoding server than the default osm project. The api still needs to be the same, but it is possible to use another server. Change-Id: I72f3835f28b9c52c042b23e9c4fdf2e85c752c56 Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r--src/location/doc/src/plugins/osm.qdoc6
-rw-r--r--src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp9
-rw-r--r--src/plugins/geoservices/osm/qgeocodingmanagerengineosm.h1
3 files changed, 14 insertions, 2 deletions
diff --git a/src/location/doc/src/plugins/osm.qdoc b/src/location/doc/src/plugins/osm.qdoc
index 574322cc..d5b23437 100644
--- a/src/location/doc/src/plugins/osm.qdoc
+++ b/src/location/doc/src/plugins/osm.qdoc
@@ -74,6 +74,11 @@ a prefix.
\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}.
+\row
+ \li osm.geocoding.host
+ \li Url string set when making network requests to the geocoding server. This parameter should be set to a
+ valid server url with the correct osm api. If not specified the default \l {http://nominatim.openstreetmap.org/}{url} will be used.
+ \note The api documentation is available at \l {https://wiki.openstreetmap.org/wiki/Nominatim}{Project OSM Nominatim}.
\endtable
\section1 Parameter Usage Example
@@ -91,6 +96,7 @@ Plugin {
PluginParameter { name: "osm.mapping.host"; value: "http://osm.tile.server.address/" }
PluginParameter { name: "osm.mapping.copyright"; value: "All mine" }
PluginParameter { name: "osm.routing.host"; value: "http://osrm.server.address/viaroute" }
+ PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" }
}
\endcode
*/
diff --git a/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp
index c9b0effd..3278939d 100644
--- a/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp
+++ b/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp
@@ -74,6 +74,11 @@ QGeoCodingManagerEngineOsm::QGeoCodingManagerEngineOsm(const QVariantMap &parame
else
m_userAgent = "Qt Location based application";
+ if (parameters.contains(QStringLiteral("osm.geocoding.host")))
+ m_urlPrefix = parameters.value(QStringLiteral("geocoding.host")).toString().toLatin1();
+ else
+ m_urlPrefix = QStringLiteral("http://nominatim.openstreetmap.org");
+
*error = QGeoServiceProvider::NoError;
errorString->clear();
}
@@ -94,7 +99,7 @@ QGeoCodeReply *QGeoCodingManagerEngineOsm::geocode(const QString &address, int l
QNetworkRequest request;
request.setRawHeader("User-Agent", m_userAgent);
- QUrl url(QStringLiteral("http://nominatim.openstreetmap.org/search"));
+ QUrl url(QString("%1/search").arg(m_urlPrefix));
QUrlQuery query;
query.addQueryItem(QStringLiteral("q"), address);
query.addQueryItem(QStringLiteral("format"), QStringLiteral("json"));
@@ -131,7 +136,7 @@ QGeoCodeReply *QGeoCodingManagerEngineOsm::reverseGeocode(const QGeoCoordinate &
QNetworkRequest request;
request.setRawHeader("User-Agent", m_userAgent);
- QUrl url(QStringLiteral("http://nominatim.openstreetmap.org/reverse"));
+ QUrl url(QString("%1/reverse").arg(m_urlPrefix));
QUrlQuery query;
query.addQueryItem(QStringLiteral("format"), QStringLiteral("json"));
query.addQueryItem(QStringLiteral("accept-language"), locale().name().left(2));
diff --git a/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.h b/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.h
index c2282cc7..533f0d2f 100644
--- a/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.h
+++ b/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.h
@@ -64,6 +64,7 @@ private Q_SLOTS:
private:
QNetworkAccessManager *m_networkManager;
QByteArray m_userAgent;
+ QString m_urlPrefix;
};
QT_END_NAMESPACE