summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Angelelli <paolo.angelelli@qt.io>2019-03-18 12:03:49 +0100
committerPaolo Angelelli <paolo.angelelli@qt.io>2019-03-18 13:07:54 +0000
commit13cfc92dc60dd2c215e41bd90e89cdc51273280c (patch)
treee79d1151cb5df92f9a1cf1bc64cef63fb03ee711
parent9f86b7353f1cdb01fe98efa8130fb6ccb5b4337d (diff)
downloadqtlocation-13cfc92dc60dd2c215e41bd90e89cdc51273280c.tar.gz
Import OSM GeoJSON when extended data is requested
Make use of QGeoJSON and import the Nominatim-returned geojson in geocode requests. Useful to get the shape of the geocode results. [ChangeLog] GeoJSON returned in Nominatim queries is now converted into the corresponding geoshapes using QGeoJson. Change-Id: Ie260e82d99363d55ed094e8dbf214d68c2ccadef Fixes: QTBUG-74248 Reviewed-by: Andy Shaw <andy.shaw@qt.io>
-rw-r--r--src/plugins/geoservices/osm/qgeocodereplyosm.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/plugins/geoservices/osm/qgeocodereplyosm.cpp b/src/plugins/geoservices/osm/qgeocodereplyosm.cpp
index 885ba397..b4733d69 100644
--- a/src/plugins/geoservices/osm/qgeocodereplyosm.cpp
+++ b/src/plugins/geoservices/osm/qgeocodereplyosm.cpp
@@ -46,6 +46,7 @@
#include <QtPositioning/QGeoAddress>
#include <QtPositioning/QGeoLocation>
#include <QtPositioning/QGeoRectangle>
+#include <QtLocation/private/qgeojson_p.h>
QT_BEGIN_NAMESPACE
@@ -112,8 +113,12 @@ static void injectExtra(QGeoLocation &location, const QJsonObject &object)
QStringLiteral("class") };
for (const auto k: extraKeys) {
- if (object.contains(k))
+ 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);