diff options
Diffstat (limited to 'src/plugins/geoservices')
27 files changed, 174 insertions, 55 deletions
diff --git a/src/plugins/geoservices/esri/geocodereply_esri.cpp b/src/plugins/geoservices/esri/geocodereply_esri.cpp index fd1071c9..eca3def1 100644 --- a/src/plugins/geoservices/esri/geocodereply_esri.cpp +++ b/src/plugins/geoservices/esri/geocodereply_esri.cpp @@ -73,7 +73,7 @@ GeoCodeReplyEsri::~GeoCodeReplyEsri() void GeoCodeReplyEsri::networkReplyError(QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); setError(QGeoCodeReply::CommunicationError, reply->errorString()); diff --git a/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp b/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp index 17ed3cd2..5a40467e 100644 --- a/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp +++ b/src/plugins/geoservices/esri/geocodingmanagerengine_esri.cpp @@ -106,7 +106,7 @@ QGeoCodeReply *GeoCodingManagerEngineEsri::geocode(const QGeoAddress &address, QGeoCodeReply *GeoCodingManagerEngineEsri::geocode(const QString &address, int limit, int offset, const QGeoShape &bounds) { - Q_UNUSED(offset) + Q_UNUSED(offset); QNetworkRequest request; request.setHeader(QNetworkRequest::UserAgentHeader, m_userAgent); @@ -140,7 +140,7 @@ QGeoCodeReply *GeoCodingManagerEngineEsri::geocode(const QString &address, int l QGeoCodeReply *GeoCodingManagerEngineEsri::reverseGeocode(const QGeoCoordinate &coordinate, const QGeoShape &bounds) { - Q_UNUSED(bounds) + Q_UNUSED(bounds); QNetworkRequest request; request.setHeader(QNetworkRequest::UserAgentHeader, m_userAgent); diff --git a/src/plugins/geoservices/esri/georoutereply_esri.cpp b/src/plugins/geoservices/esri/georoutereply_esri.cpp index 95de6b55..a47db6fb 100644 --- a/src/plugins/geoservices/esri/georoutereply_esri.cpp +++ b/src/plugins/geoservices/esri/georoutereply_esri.cpp @@ -87,7 +87,7 @@ void GeoRouteReplyEsri::networkReplyFinished() void GeoRouteReplyEsri::networkReplyError(QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); setError(QGeoRouteReply::CommunicationError, reply->errorString()); diff --git a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp index dede9dbc..1ebad08d 100644 --- a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp +++ b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.cpp @@ -65,6 +65,7 @@ public: virtual QList<QGeoMapObject *> mapObjects() const override; void removeMapObject(QGeoMapObject *obj); void updateMapObjects(QSGNode *root, QQuickWindow *window); + QList<QObject *>mapObjectsAt(const QGeoCoordinate &coordinate) const; QGeoMapObjectQSGSupport m_qsgSupport; #endif @@ -112,7 +113,7 @@ bool QGeoMapItemsOverlay::createMapObjectImplementation(QGeoMapObject *obj) QSGNode *QGeoMapItemsOverlay::updateSceneGraph(QSGNode *node, QQuickWindow *window) { #ifndef LOCATIONLABS - Q_UNUSED(window) + Q_UNUSED(window); return node; #else Q_D(QGeoMapItemsOverlay); @@ -137,6 +138,16 @@ void QGeoMapItemsOverlay::removeMapObject(QGeoMapObject *obj) #endif } +QList<QObject *> QGeoMapItemsOverlay::mapObjectsAt(const QGeoCoordinate &coordinate) const +{ +#ifdef LOCATIONLABS + Q_D(const QGeoMapItemsOverlay); + return d->mapObjectsAt(coordinate); +#else + return QGeoMap::mapObjectsAt(coordinate); +#endif +} + void QGeoMapItemsOverlayPrivate::setVisibleArea(const QRectF &visibleArea) { Q_Q(QGeoMapItemsOverlay); @@ -185,6 +196,34 @@ void QGeoMapItemsOverlayPrivate::updateMapObjects(QSGNode *root, QQuickWindow *w { m_qsgSupport.updateMapObjects(root, window); } + +QList<QObject *> QGeoMapItemsOverlayPrivate::mapObjectsAt(const QGeoCoordinate &coordinate) const +{ + // ToDo: use a space partitioning strategy + QList<QObject *> res; + for (const auto o: mapObjects()) { + // explicitly handle lines + bool contains = false; + if (o->type() == QGeoMapObject::PolylineType ) { + QMapPolylineObject *mpo = static_cast<QMapPolylineObject *>(o); + qreal mpp = QLocationUtils::metersPerPixel(m_cameraData.zoomLevel(), coordinate); + QGeoPath path = o->geoShape(); + path.setWidth(mpp * mpo->border()->width()); + contains = path.contains(coordinate); + } else if (o->type() == QGeoMapObject::RouteType) { + qreal mpp = QLocationUtils::metersPerPixel(m_cameraData.zoomLevel(), coordinate); + QGeoPath path = o->geoShape(); + path.setWidth(mpp * 4); // MapRouteObjectQSG has a hardcoded 4 pixels width; + contains = path.contains(coordinate); + } else { + contains = o->geoShape().contains(coordinate); + } + + if (contains) + res.append(o); + } + return res; +} #endif void QGeoMapItemsOverlayPrivate::updateObjectsGeometry() diff --git a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h index 1594ffb3..c287345c 100644 --- a/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h +++ b/src/plugins/geoservices/itemsoverlay/qgeomapitemsoverlay.h @@ -56,6 +56,7 @@ public: QGeoMap::Capabilities capabilities() const override; bool createMapObjectImplementation(QGeoMapObject *obj) override; void removeMapObject(QGeoMapObject *obj) override; + QList<QObject *> mapObjectsAt(const QGeoCoordinate &coordinate) const override; protected: QSGNode *updateSceneGraph(QSGNode *node, QQuickWindow *window) override; diff --git a/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp b/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp index c19815e8..abaffdb7 100644 --- a/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp +++ b/src/plugins/geoservices/itemsoverlay/qgeomappingmanagerengineitemsoverlay.cpp @@ -47,9 +47,9 @@ QT_BEGIN_NAMESPACE QGeoMappingManagerEngineItemsOverlay::QGeoMappingManagerEngineItemsOverlay(const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) : QGeoMappingManagerEngine() { - Q_UNUSED(parameters) - Q_UNUSED(error) - Q_UNUSED(errorString) + Q_UNUSED(parameters); + Q_UNUSED(error); + Q_UNUSED(errorString); QGeoCameraCapabilities cameraCaps; cameraCaps.setMinimumZoomLevel(0.0); cameraCaps.setMaximumZoomLevel(30.0); diff --git a/src/plugins/geoservices/itemsoverlay/qgeoserviceproviderpluginitemsoverlay.cpp b/src/plugins/geoservices/itemsoverlay/qgeoserviceproviderpluginitemsoverlay.cpp index b83a5eb1..417e1ee4 100644 --- a/src/plugins/geoservices/itemsoverlay/qgeoserviceproviderpluginitemsoverlay.cpp +++ b/src/plugins/geoservices/itemsoverlay/qgeoserviceproviderpluginitemsoverlay.cpp @@ -42,9 +42,9 @@ QT_BEGIN_NAMESPACE QGeoCodingManagerEngine *QGeoServiceProviderFactoryItemsOverlay::createGeocodingManagerEngine( const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const { - Q_UNUSED(parameters) - Q_UNUSED(error) - Q_UNUSED(errorString) + Q_UNUSED(parameters); + Q_UNUSED(error); + Q_UNUSED(errorString); return 0; } @@ -58,9 +58,9 @@ QGeoMappingManagerEngine *QGeoServiceProviderFactoryItemsOverlay::createMappingM QGeoRoutingManagerEngine *QGeoServiceProviderFactoryItemsOverlay::createRoutingManagerEngine( const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const { - Q_UNUSED(parameters) - Q_UNUSED(error) - Q_UNUSED(errorString) + Q_UNUSED(parameters); + Q_UNUSED(error); + Q_UNUSED(errorString); return 0; } @@ -68,9 +68,9 @@ QGeoRoutingManagerEngine *QGeoServiceProviderFactoryItemsOverlay::createRoutingM QPlaceManagerEngine *QGeoServiceProviderFactoryItemsOverlay::createPlaceManagerEngine( const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const { - Q_UNUSED(parameters) - Q_UNUSED(error) - Q_UNUSED(errorString) + Q_UNUSED(parameters); + Q_UNUSED(error); + Q_UNUSED(errorString); return 0; } diff --git a/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp b/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp index db7a35c4..bb84b531 100644 --- a/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeocodereplymapbox.cpp @@ -97,7 +97,7 @@ void QGeoCodeReplyMapbox::onNetworkReplyFinished() void QGeoCodeReplyMapbox::onNetworkReplyError(QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); setError(QGeoCodeReply::CommunicationError, reply->errorString()); diff --git a/src/plugins/geoservices/mapbox/qgeocodingmanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qgeocodingmanagerenginemapbox.cpp index e0c4f6a5..3780d6ca 100644 --- a/src/plugins/geoservices/mapbox/qgeocodingmanagerenginemapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeocodingmanagerenginemapbox.cpp @@ -137,7 +137,7 @@ QGeoCodeReply *QGeoCodingManagerEngineMapbox::geocode(const QGeoAddress &address QGeoCodeReply *QGeoCodingManagerEngineMapbox::geocode(const QString &address, int limit, int offset, const QGeoShape &bounds) { - Q_UNUSED(offset) + Q_UNUSED(offset); QUrlQuery queryItems; queryItems.addQueryItem(QStringLiteral("type"), allAddressTypes); diff --git a/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp b/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp index 8b0772ad..86da24ab 100644 --- a/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp +++ b/src/plugins/geoservices/mapbox/qgeoroutereplymapbox.cpp @@ -155,7 +155,7 @@ void QGeoRouteReplyMapbox::networkReplyFinished() void QGeoRouteReplyMapbox::networkReplyError(QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); setError(QGeoRouteReply::CommunicationError, reply->errorString()); diff --git a/src/plugins/geoservices/mapbox/qplacemanagerenginemapbox.cpp b/src/plugins/geoservices/mapbox/qplacemanagerenginemapbox.cpp index 56678a45..4fb8cd1d 100644 --- a/src/plugins/geoservices/mapbox/qplacemanagerenginemapbox.cpp +++ b/src/plugins/geoservices/mapbox/qplacemanagerenginemapbox.cpp @@ -264,7 +264,7 @@ QPlaceReply *QPlaceManagerEngineMapbox::initializeCategories() QString QPlaceManagerEngineMapbox::parentCategoryId(const QString &categoryId) const { - Q_UNUSED(categoryId) + Q_UNUSED(categoryId); // Only a single category level. return QString(); diff --git a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp index b2f2f043..8d34d2ec 100644 --- a/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp +++ b/src/plugins/geoservices/mapbox/qplacesearchreplymapbox.cpp @@ -222,7 +222,7 @@ void QPlaceSearchReplyMapbox::onReplyFinished() void QPlaceSearchReplyMapbox::onNetworkError(QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); setError(CommunicationError, reply->errorString()); diff --git a/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp b/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp index 23d76175..8c0bfdc1 100644 --- a/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp +++ b/src/plugins/geoservices/mapbox/qplacesearchsuggestionreplymapbox.cpp @@ -111,7 +111,7 @@ void QPlaceSearchSuggestionReplyMapbox::onReplyFinished() void QPlaceSearchSuggestionReplyMapbox::onNetworkError(QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); setError(CommunicationError, reply->errorString()); diff --git a/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp b/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp index afa723a5..dfc0be0b 100644 --- a/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp +++ b/src/plugins/geoservices/mapboxgl/qgeoserviceproviderpluginmapboxgl.cpp @@ -49,9 +49,9 @@ QGeoServiceProviderFactoryMapboxGL::QGeoServiceProviderFactoryMapboxGL() QGeoCodingManagerEngine *QGeoServiceProviderFactoryMapboxGL::createGeocodingManagerEngine( const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const { - Q_UNUSED(parameters) - Q_UNUSED(error) - Q_UNUSED(errorString) + Q_UNUSED(parameters); + Q_UNUSED(error); + Q_UNUSED(errorString); return 0; } @@ -65,9 +65,9 @@ QGeoMappingManagerEngine *QGeoServiceProviderFactoryMapboxGL::createMappingManag QGeoRoutingManagerEngine *QGeoServiceProviderFactoryMapboxGL::createRoutingManagerEngine( const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const { - Q_UNUSED(parameters) - Q_UNUSED(error) - Q_UNUSED(errorString) + Q_UNUSED(parameters); + Q_UNUSED(error); + Q_UNUSED(errorString); return 0; } @@ -75,9 +75,9 @@ QGeoRoutingManagerEngine *QGeoServiceProviderFactoryMapboxGL::createRoutingManag QPlaceManagerEngine *QGeoServiceProviderFactoryMapboxGL::createPlaceManagerEngine( const QVariantMap ¶meters, QGeoServiceProvider::Error *error, QString *errorString) const { - Q_UNUSED(parameters) - Q_UNUSED(error) - Q_UNUSED(errorString) + Q_UNUSED(parameters); + Q_UNUSED(error); + Q_UNUSED(errorString); return 0; } diff --git a/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp b/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp index 0fb6eb2a..2a8549ff 100644 --- a/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeocodereply_nokia.cpp @@ -99,7 +99,7 @@ void QGeoCodeReplyNokia::networkFinished() void QGeoCodeReplyNokia::networkError(QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender()); reply->deleteLater(); @@ -118,7 +118,7 @@ void QGeoCodeReplyNokia::appendResults(const QList<QGeoLocation> &locations) void QGeoCodeReplyNokia::parseError(const QString &errorString) { - Q_UNUSED(errorString) + Q_UNUSED(errorString); setError(QGeoCodeReply::ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, RESPONSE_NOT_RECOGNIZABLE)); diff --git a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp index b5fdfee1..941a0200 100644 --- a/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeoroutereply_nokia.cpp @@ -119,7 +119,7 @@ void QGeoRouteReplyNokia::appendResults(const QList<QGeoRoute> &routes) void QGeoRouteReplyNokia::parserError(const QString &errorString) { - Q_UNUSED(errorString) + Q_UNUSED(errorString); emit aborted(); setError(QGeoRouteReply::ParseError, QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, RESPONSE_NOT_RECOGNIZABLE)); diff --git a/src/plugins/geoservices/nokia/qgeouriprovider.cpp b/src/plugins/geoservices/nokia/qgeouriprovider.cpp index cef3d484..7be90bb2 100644 --- a/src/plugins/geoservices/nokia/qgeouriprovider.cpp +++ b/src/plugins/geoservices/nokia/qgeouriprovider.cpp @@ -84,8 +84,8 @@ void QGeoUriProvider::setCurrentHost(const QString &host) void QGeoUriProvider::mobileCountryCodeChanged(int interfaceId, const QString& mcc) { - Q_UNUSED(interfaceId) - Q_UNUSED(mcc) + Q_UNUSED(interfaceId); + Q_UNUSED(mcc); setCurrentHost(isInternationalNetwork() || m_localizedHost.isEmpty() ? m_internationalHost : m_localizedHost); } diff --git a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp index 5094b72e..3b507ff2 100644 --- a/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp +++ b/src/plugins/geoservices/nokia/qplacemanagerengine_nokiav2.cpp @@ -556,7 +556,7 @@ QPlaceIdReply *QPlaceManagerEngineNokiaV2::removePlace(const QString &placeId) QPlaceIdReply *QPlaceManagerEngineNokiaV2::saveCategory(const QPlaceCategory &category, const QString &parentId) { - Q_UNUSED(parentId) + Q_UNUSED(parentId); QPlaceIdReplyImpl *reply = new QPlaceIdReplyImpl(QPlaceIdReply::SaveCategory, this); reply->setId(category.categoryId()); @@ -735,7 +735,7 @@ QPlaceIcon QPlaceManagerEngineNokiaV2::icon(const QString &remotePath, QUrl QPlaceManagerEngineNokiaV2::constructIconUrl(const QPlaceIcon &icon, const QSize &size) const { - Q_UNUSED(size) + Q_UNUSED(size); QVariantMap params = icon.parameters(); QString nokiaIcon = params.value(NokiaIcon).toString(); diff --git a/src/plugins/geoservices/osm/qgeocodereplyosm.cpp b/src/plugins/geoservices/osm/qgeocodereplyosm.cpp index a30601d0..b4733d69 100644 --- a/src/plugins/geoservices/osm/qgeocodereplyosm.cpp +++ b/src/plugins/geoservices/osm/qgeocodereplyosm.cpp @@ -46,11 +46,12 @@ #include <QtPositioning/QGeoAddress> #include <QtPositioning/QGeoLocation> #include <QtPositioning/QGeoRectangle> +#include <QtLocation/private/qgeojson_p.h> QT_BEGIN_NAMESPACE -QGeoCodeReplyOsm::QGeoCodeReplyOsm(QNetworkReply *reply, QObject *parent) -: QGeoCodeReply(parent) +QGeoCodeReplyOsm::QGeoCodeReplyOsm(QNetworkReply *reply, bool includeExtraData, QObject *parent) +: QGeoCodeReply(*new QGeoCodeReplyOsmPrivate, parent), m_includeExtraData(includeExtraData) { if (!reply) { setError(UnknownError, QStringLiteral("Null reply")); @@ -98,6 +99,31 @@ static QGeoAddress parseAddressObject(const QJsonObject &object) return address; } +static void injectExtra(QGeoLocation &location, const QJsonObject &object) +{ + QVariantMap extra; + static const QList<QString> extraKeys = { QStringLiteral("geojson"), + QStringLiteral("icon"), + QStringLiteral("importance"), + QStringLiteral("type"), + QStringLiteral("osm_id"), + QStringLiteral("osm_type"), + QStringLiteral("licence"), + QStringLiteral("place_id"), + QStringLiteral("class") }; + + for (const auto k: extraKeys) { + if (object.contains(k)) { + extra[k] = object.value(k).toVariant(); + if (k == QStringLiteral("geojson")) + extra[QStringLiteral("geojson_model")] = + QGeoJson::importGeoJson(QJsonDocument::fromVariant(extra[k])); + } + } + + location.setExtendedAttributes(extra); +} + void QGeoCodeReplyOsm::networkReplyFinished() { QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); @@ -121,6 +147,8 @@ void QGeoCodeReplyOsm::networkReplyFinished() location.setCoordinate(coordinate); location.setAddress(parseAddressObject(object)); + if (m_includeExtraData) + injectExtra(location, object); locations.append(location); setLocations(locations); @@ -154,6 +182,8 @@ void QGeoCodeReplyOsm::networkReplyFinished() location.setCoordinate(coordinate); location.setBoundingBox(rectangle); location.setAddress(parseAddressObject(object)); + if (m_includeExtraData) + injectExtra(location, object); locations.append(location); } @@ -165,10 +195,27 @@ void QGeoCodeReplyOsm::networkReplyFinished() void QGeoCodeReplyOsm::networkReplyError(QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); setError(QGeoCodeReply::CommunicationError, reply->errorString()); } +QGeoCodeReplyOsmPrivate::QGeoCodeReplyOsmPrivate() +{ + +} + +QGeoCodeReplyOsmPrivate::~QGeoCodeReplyOsmPrivate() +{ + +} + +QVariantMap QGeoCodeReplyOsmPrivate::extraData() const +{ + return m_extraData; +} + QT_END_NAMESPACE + + diff --git a/src/plugins/geoservices/osm/qgeocodereplyosm.h b/src/plugins/geoservices/osm/qgeocodereplyosm.h index 0847f58c..f00a8bb2 100644 --- a/src/plugins/geoservices/osm/qgeocodereplyosm.h +++ b/src/plugins/geoservices/osm/qgeocodereplyosm.h @@ -42,6 +42,7 @@ #include <QtNetwork/QNetworkReply> #include <QtLocation/QGeoCodeReply> +#include <QtLocation/private/qgeocodereply_p.h> QT_BEGIN_NAMESPACE @@ -50,12 +51,25 @@ class QGeoCodeReplyOsm : public QGeoCodeReply Q_OBJECT public: - explicit QGeoCodeReplyOsm(QNetworkReply *reply, QObject *parent = 0); + explicit QGeoCodeReplyOsm(QNetworkReply *reply, bool includeExtraData = false, QObject *parent = 0); ~QGeoCodeReplyOsm(); private Q_SLOTS: void networkReplyFinished(); void networkReplyError(QNetworkReply::NetworkError error); + +private: + bool m_includeExtraData = false; +}; + +class QGeoCodeReplyOsmPrivate : public QGeoCodeReplyPrivate +{ +public: + QGeoCodeReplyOsmPrivate(); + ~QGeoCodeReplyOsmPrivate(); + QVariantMap extraData() const override; + + QVariantMap m_extraData; }; QT_END_NAMESPACE diff --git a/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp index d7751287..85554c76 100644 --- a/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp +++ b/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.cpp @@ -38,7 +38,6 @@ ****************************************************************************/ #include "qgeocodingmanagerengineosm.h" -#include "qgeocodereplyosm.h" #include <QtCore/QVariantMap> #include <QtCore/QUrl> @@ -50,6 +49,8 @@ #include <QtPositioning/QGeoAddress> #include <QtPositioning/QGeoShape> #include <QtPositioning/QGeoRectangle> +#include "qgeocodereplyosm.h" + QT_BEGIN_NAMESPACE @@ -85,6 +86,11 @@ QGeoCodingManagerEngineOsm::QGeoCodingManagerEngineOsm(const QVariantMap ¶me else m_urlPrefix = QStringLiteral("https://nominatim.openstreetmap.org"); + if (parameters.contains(QStringLiteral("osm.geocoding.debug_query"))) + m_debugQuery = parameters.value(QStringLiteral("osm.geocoding.debug_query")).toBool(); + if (parameters.contains(QStringLiteral("osm.geocoding.include_extended_data"))) + m_includeExtraData = parameters.value(QStringLiteral("osm.geocoding.include_extended_data")).toBool(); + *error = QGeoServiceProvider::NoError; errorString->clear(); } @@ -100,7 +106,7 @@ QGeoCodeReply *QGeoCodingManagerEngineOsm::geocode(const QGeoAddress &address, c QGeoCodeReply *QGeoCodingManagerEngineOsm::geocode(const QString &address, int limit, int offset, const QGeoShape &bounds) { - Q_UNUSED(offset) + Q_UNUSED(offset); QNetworkRequest request; request.setRawHeader("User-Agent", m_userAgent); @@ -125,7 +131,12 @@ QGeoCodeReply *QGeoCodingManagerEngineOsm::geocode(const QString &address, int l QNetworkReply *reply = m_networkManager->get(request); - QGeoCodeReplyOsm *geocodeReply = new QGeoCodeReplyOsm(reply, this); + QGeoCodeReplyOsm *geocodeReply = new QGeoCodeReplyOsm(reply, m_includeExtraData, this); + if (m_debugQuery) { + QGeoCodeReplyOsmPrivate *replyPrivate + = static_cast<QGeoCodeReplyOsmPrivate *>(QGeoCodeReplyPrivate::get(*geocodeReply)); + replyPrivate->m_extraData["request_url"] = url; + } connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished())); connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)), @@ -137,7 +148,7 @@ QGeoCodeReply *QGeoCodingManagerEngineOsm::geocode(const QString &address, int l QGeoCodeReply *QGeoCodingManagerEngineOsm::reverseGeocode(const QGeoCoordinate &coordinate, const QGeoShape &bounds) { - Q_UNUSED(bounds) + Q_UNUSED(bounds); QNetworkRequest request; request.setRawHeader("User-Agent", m_userAgent); @@ -156,7 +167,12 @@ QGeoCodeReply *QGeoCodingManagerEngineOsm::reverseGeocode(const QGeoCoordinate & QNetworkReply *reply = m_networkManager->get(request); - QGeoCodeReplyOsm *geocodeReply = new QGeoCodeReplyOsm(reply, this); + QGeoCodeReplyOsm *geocodeReply = new QGeoCodeReplyOsm(reply, m_includeExtraData, this); + if (m_debugQuery) { + QGeoCodeReplyOsmPrivate *replyPrivate + = static_cast<QGeoCodeReplyOsmPrivate *>(QGeoCodeReplyPrivate::get(*geocodeReply)); + replyPrivate->m_extraData["request_url"] = url; + } connect(geocodeReply, SIGNAL(finished()), this, SLOT(replyFinished())); connect(geocodeReply, SIGNAL(error(QGeoCodeReply::Error,QString)), diff --git a/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.h b/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.h index 0fec49de..7a54fa43 100644 --- a/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.h +++ b/src/plugins/geoservices/osm/qgeocodingmanagerengineosm.h @@ -71,6 +71,8 @@ private: QNetworkAccessManager *m_networkManager; QByteArray m_userAgent; QString m_urlPrefix; + bool m_debugQuery = false; + bool m_includeExtraData = false; }; QT_END_NAMESPACE diff --git a/src/plugins/geoservices/osm/qgeofiletilecacheosm.cpp b/src/plugins/geoservices/osm/qgeofiletilecacheosm.cpp index d79702cf..3bb1ea7b 100644 --- a/src/plugins/geoservices/osm/qgeofiletilecacheosm.cpp +++ b/src/plugins/geoservices/osm/qgeofiletilecacheosm.cpp @@ -82,7 +82,7 @@ QSharedPointer<QGeoTileTexture> QGeoFileTileCacheOsm::get(const QGeoTileSpec &sp void QGeoFileTileCacheOsm::onProviderResolutionFinished(const QGeoTileProviderOsm *provider) { clearObsoleteTiles(provider); - Q_UNUSED(provider) + Q_UNUSED(provider); for (int i = 0; i < m_providers.size(); i++) { if (m_providers[i]->isHighDpi() != m_highDpi[i]) { // e.g., HiDpi was requested but only LoDpi is available int mapId = m_providers[i]->mapType().mapId(); @@ -103,7 +103,7 @@ void QGeoFileTileCacheOsm::onProviderResolutionFinished(const QGeoTileProviderOs // Hardcoded fallbacks also have a timestamp, that can get updated with Qt releases. void QGeoFileTileCacheOsm::onProviderResolutionError(const QGeoTileProviderOsm *provider, QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); clearObsoleteTiles(provider); // this still removes tiles who happen to be older than qgeotileproviderosm.cpp defaultTs } diff --git a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp index af2a03b1..e60dc068 100644 --- a/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp +++ b/src/plugins/geoservices/osm/qgeoroutereplyosm.cpp @@ -94,7 +94,7 @@ void QGeoRouteReplyOsm::networkReplyFinished() void QGeoRouteReplyOsm::networkReplyError(QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); setError(QGeoRouteReply::CommunicationError, reply->errorString()); diff --git a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp index e0008068..f52968b0 100644 --- a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp +++ b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp @@ -196,7 +196,7 @@ void QGeoTileProviderOsm::disableRedirection() void QGeoTileProviderOsm::onResolutionFinished(TileProvider *provider) { - Q_UNUSED(provider) + Q_UNUSED(provider); // provider and m_provider are the same, at this point. m_status is Resolving. m_status = Resolved; emit resolutionFinished(this); @@ -204,7 +204,7 @@ void QGeoTileProviderOsm::onResolutionFinished(TileProvider *provider) void QGeoTileProviderOsm::onResolutionError(TileProvider *provider) { - Q_UNUSED(provider) + Q_UNUSED(provider); // provider and m_provider are the same at this point. m_status is Resolving. if (!m_provider || m_provider->isInvalid()) { m_provider = nullptr; diff --git a/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp b/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp index be66414f..80964d35 100644 --- a/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp +++ b/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp @@ -220,7 +220,7 @@ QPlaceReply *QPlaceManagerEngineOsm::initializeCategories() QString QPlaceManagerEngineOsm::parentCategoryId(const QString &categoryId) const { - Q_UNUSED(categoryId) + Q_UNUSED(categoryId); // Only a two category levels return QString(); diff --git a/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp b/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp index 80c50d1b..d65b0735 100644 --- a/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp +++ b/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp @@ -165,7 +165,7 @@ void QPlaceSearchReplyOsm::replyFinished() void QPlaceSearchReplyOsm::networkError(QNetworkReply::NetworkError error) { - Q_UNUSED(error) + Q_UNUSED(error); QNetworkReply *reply = static_cast<QNetworkReply *>(sender()); reply->deleteLater(); setError(QPlaceReply::CommunicationError, reply->errorString()); |