summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Rauter <matthias.rauter@qt.io>2023-02-16 15:55:05 +0100
committerVolker Hilsheimer <volker.hilsheimer@qt.io>2023-02-20 10:27:02 +0000
commit992f57fcf993b9804dcda9b12bf4d67ed102f284 (patch)
tree759ea3a62c54a72397c737d8dc88b926df1fd29d
parente770809db4b6c92ee4be22b5ea021ccc505cec8f (diff)
downloadqtlocation-992f57fcf993b9804dcda9b12bf4d67ed102f284.tar.gz
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 <volker.hilsheimer@qt.io>
-rw-r--r--src/plugins/geoservices/osm/qplacemanagerengineosm.cpp3
-rw-r--r--src/plugins/geoservices/osm/qplacesearchreplyosm.cpp14
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 <QtLocation/QPlaceAttribute>
#include <QtLocation/QPlaceIcon>
#include <QtLocation/QPlaceResult>
+#include <QtLocation/QPlaceCategory>
#include <QtLocation/QPlaceSearchRequest>
#include <QtLocation/private/qplacesearchrequest_p.h>
@@ -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);