summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernhard Beschow <bbeschow@cs.tu-berlin.de>2016-08-24 19:28:06 (GMT)
committerBernhard Beschow <bbeschow@cs.tu-berlin.de>2016-08-24 20:47:28 (GMT)
commit5c53d7fc46c6dbd0de2aa2839d60f03ffb27d582 (patch)
tree23dc0637eb678f7b53e21c03a75386fe35a805de
parent5b6f30c7d24825c30cbab7b015ccbc06ebb3728f (diff)
make use of OsmPlacemarkData
-rw-r--r--src/plugins/runner/json/JsonParser.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/plugins/runner/json/JsonParser.cpp b/src/plugins/runner/json/JsonParser.cpp
index ed2dc1d..6d48028 100644
--- a/src/plugins/runner/json/JsonParser.cpp
+++ b/src/plugins/runner/json/JsonParser.cpp
@@ -15,6 +15,7 @@
#include "osm/OsmPresetLibrary.h"
#include "MarbleDebug.h"
+#include "osm/OsmPlacemarkData.h"
#include <QIODevice>
@@ -244,7 +245,6 @@ bool JsonParser::read( QIODevice* device )
QScriptValue properties = m_engine.evaluate( "fileData.features[" + count + "].properties" );
QScriptValueIterator propertyIterator ( properties );
- GeoDataFeature::GeoDataVisualCategory category = GeoDataFeature::None;
// First create a placemark for each geometry, there could be multi geometries
// that are translated into more than one geometry/placemark
@@ -253,27 +253,25 @@ bool JsonParser::read( QIODevice* device )
placemarkList.append( placemark );
}
+ OsmPlacemarkData osmData;
while ( propertyIterator.hasNext() ) {
propertyIterator.next();
+ osmData.addTag(propertyIterator.name(), propertyIterator.value().toString());
+ }
- // If the property read, is the features name
- if (propertyIterator.name() == QLatin1String("name")) {
- for ( int pl = 0 ; pl < placemarkList.length() ; pl++) {
- placemarkList.at( pl )->setName( propertyIterator.value().toString() );
- }
+ // If the property read, is the features name
+ if (osmData.containsTagKey(QLatin1String("name"))) {
+ for (int pl = 0 ; pl < placemarkList.length(); ++pl) {
+ placemarkList.at(pl)->setName(osmData.tagValue(QLatin1String("name")));
}
- // Else if the geometry still doesn't have a category, try if this
- // key-value properties match any OSM visual category
- else if ( category == GeoDataFeature::None ) {
- const auto tag = OsmPresetLibrary::OsmTag(propertyIterator.name().toLower(), propertyIterator.value().toString().toLower());
- category = OsmPresetLibrary::osmVisualCategory(tag);
-
- if ( category != GeoDataFeature::None ) {
- // Add the visual category to all the placemarks
- for ( int pl = 0 ; pl < placemarkList.length() ; pl++) {
- placemarkList.at( pl )->setVisualCategory( category );
- }
- }
+ }
+
+ const GeoDataFeature::GeoDataVisualCategory category = OsmPresetLibrary::determineVisualCategory(osmData);
+ if (category != GeoDataFeature::None) {
+ // Add the visual category to all the placemarks
+ for (int pl = 0 ; pl < placemarkList.length(); ++pl) {
+ placemarkList.at(pl)->setVisualCategory(category);
+ placemarkList.at(pl)->setOsmData(osmData);
}
}
}