From 992f57fcf993b9804dcda9b12bf4d67ed102f284 Mon Sep 17 00:00:00 2001 From: Matthias Rauter Date: Thu, 16 Feb 2023 15:55:05 +0100 Subject: Improve compatibility between OSM plugin and places example The categories are searched as well as possible. However, searches for e.g. all shops are not possible with OSM since a recent API change. The category is written into the PlacesReply object so that they can be displayed in the ui. Pick-to: 6.5 Change-Id: Ic08e5bef393313672775b6f39d365484ee8b0c58 Reviewed-by: Volker Hilsheimer --- src/plugins/geoservices/osm/qplacemanagerengineosm.cpp | 3 --- src/plugins/geoservices/osm/qplacesearchreplyosm.cpp | 14 +++++++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp b/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp index 6eb035b9..60bc55ff 100644 --- a/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp +++ b/src/plugins/geoservices/osm/qplacemanagerengineosm.cpp @@ -129,9 +129,6 @@ QPlaceSearchReply *QPlaceManagerEngineOsm::search(const QPlaceSearchRequest &req for (const QPlaceCategory &category : request.categories()) { QString id = category.categoryId(); - int index = id.indexOf(QLatin1Char('=')); - if (index != -1) - id = id.mid(index+1); queryParts.append(QLatin1Char('[') + id + QLatin1Char(']')); } diff --git a/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp b/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp index 2f8e6fde..359d93f7 100644 --- a/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp +++ b/src/plugins/geoservices/osm/qplacesearchreplyosm.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -150,8 +151,8 @@ QPlaceResult QPlaceSearchReplyOsm::parsePlaceResult(const QJsonObject &item) con item.value(QStringLiteral("lon")).toString().toDouble()); //const QString placeRank = item.value(QStringLiteral("place_rank")).toString(); - const QString category = item.value(QStringLiteral("category")).toString(); - // const QString type = item.value(QStringLiteral("type")).toString(); + const QString categoryName = item.value(QStringLiteral("category")).toString(); + const QString type = item.value(QStringLiteral("type")).toString(); //double importance = item.value(QStringLiteral("importance")).toDouble(); place.setAttribution(item.value(QStringLiteral("licence")).toString()); @@ -165,8 +166,7 @@ QPlaceResult QPlaceSearchReplyOsm::parsePlaceResult(const QJsonObject &item) con place.setIcon(icon); QJsonObject addressDetails = item.value(QStringLiteral("address")).toObject(); - - const QString title = addressDetails.value(category).toString(); + const QString title = addressDetails.value(categoryName).toString(); place.setName(title); @@ -192,9 +192,13 @@ QPlaceResult QPlaceSearchReplyOsm::parsePlaceResult(const QJsonObject &item) con location.setCoordinate(coordinate); location.setAddress(address); location.setBoundingShape(parseBoundingBox(item.value(QStringLiteral("boundingbox")).toArray())); - place.setLocation(location); + QPlaceCategory category; + category.setName(categoryName + "=" + type); + category.setCategoryId(categoryName + "=" + type); + place.setCategory(category); + QPlaceResult result; result.setIcon(icon); result.setPlace(place); -- cgit v1.2.3