summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-07-23 05:36:21 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-07-23 10:07:01 (GMT)
commit53eb1046b3647a9346c27f309c22e5bf9f5d4402 (patch)
treedc124ce6a24e7f3b614232207ed42e5e9dcec1a9
parent843eb5d37f5ecb913b1bd74a9b4a048e031a2e97 (diff)
Set OSM tags from nominatim reverse geocoding results
-rw-r--r--src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.cpp29
-rw-r--r--src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.h2
2 files changed, 26 insertions, 5 deletions
diff --git a/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.cpp b/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.cpp
index 3dbd3f8..15145f5 100644
--- a/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.cpp
+++ b/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.cpp
@@ -16,6 +16,7 @@
#include "GeoDataPlacemark.h"
#include "GeoDataExtendedData.h"
#include "HttpDownloadManager.h"
+#include "osm/OsmPlacemarkData.h"
#include <QString>
#include <QUrl>
@@ -102,12 +103,12 @@ void OsmNominatimRunner::handleResult( QNetworkReply* reply )
if ( places.size() == 1 ) {
QString address = places.item( 0 ).toElement().text();
GeoDataPlacemark placemark;
+ placemark.setVisualCategory(GeoDataFeature::Coordinate);
placemark.setAddress( address );
placemark.setCoordinate( m_coordinates );
QDomNode details = root.firstChildElement( "addressparts" );
- GeoDataExtendedData extendedData = extractChildren( details );
- placemark.setExtendedData( extendedData );
+ extractChildren( details, placemark );
emit reverseGeocodingFinished( m_coordinates, placemark );
} else {
@@ -115,15 +116,35 @@ void OsmNominatimRunner::handleResult( QNetworkReply* reply )
}
}
-GeoDataExtendedData OsmNominatimRunner::extractChildren(const QDomNode &node)
+void OsmNominatimRunner::extractChildren(const QDomNode &node, GeoDataPlacemark &placemark)
{
+ QMap<QString, QString> tagTranslator;
+ tagTranslator["house_number"] = "addr:housenumber";
+ tagTranslator["road"] = "addr:street";
+ tagTranslator["suburb"] = "addr:suburb";
+ tagTranslator["city"] = "addr:city";
+ tagTranslator["state_district"] = "addr:district";
+ tagTranslator["state"] = "addr:state";
+ tagTranslator["postcode"] = "addr:postcode";
+ tagTranslator["country_code"] = "addr:country"; // correct mapping
+ // @todo Find a proper mapping for those
+ //tagTranslator["village"] = "";
+ //tagTranslator["town"] = "";
+
GeoDataExtendedData data;
+ OsmPlacemarkData osmData;
QDomNodeList nodes = node.childNodes();
for (int i=0, n=nodes.length(); i<n; ++i) {
QDomNode child = nodes.item(i);
data.addValue( GeoDataData( child.nodeName(), child.toElement().text() ) );
+
+ if (tagTranslator.contains(child.nodeName())) {
+ QString const key = tagTranslator[child.nodeName()];
+ osmData.addTag(key, child.toElement().text());
+ }
}
- return data;
+ placemark.setExtendedData(data);
+ placemark.setOsmData(osmData);
}
} // namespace Marble
diff --git a/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.h b/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.h
index dc7baef..8eb1cd8 100644
--- a/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.h
+++ b/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.h
@@ -47,7 +47,7 @@ private Q_SLOTS:
void startReverseGeocoding();
private:
- static GeoDataExtendedData extractChildren(const QDomNode &node);
+ static void extractChildren(const QDomNode &node, GeoDataPlacemark &placemark);
QNetworkAccessManager m_manager;