summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-08-13 14:14:59 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-08-13 14:15:21 (GMT)
commitab548999e35929d570f268ef924ef67bad3e06e9 (patch)
treef15d996bb403574f858cb444de6a9e3d090669e4
parentbc4e5df8650eebc8938e077d42cf9110469d451b (diff)
Add copyTags method to avoid redundancy
-rw-r--r--tools/osm-simplify/TinyPlanetProcessor.cpp29
-rw-r--r--tools/osm-simplify/TinyPlanetProcessor.h3
2 files changed, 14 insertions, 18 deletions
diff --git a/tools/osm-simplify/TinyPlanetProcessor.cpp b/tools/osm-simplify/TinyPlanetProcessor.cpp
index 19b0ef3..496b65d 100644
--- a/tools/osm-simplify/TinyPlanetProcessor.cpp
+++ b/tools/osm-simplify/TinyPlanetProcessor.cpp
@@ -107,15 +107,7 @@ GeoDataDocument *TinyPlanetProcessor::cutToTiles(unsigned int zoomLevel, unsigne
GeoDataPlacemark* newPlacemark = new GeoDataPlacemark();
newPlacemark->setGeometry(newMarbleWay);
newPlacemark->setVisualCategory(placemark->visualCategory());
-
- OsmPlacemarkData osmData;
- auto it = placemark->osmData().tagsBegin();
- auto itEnd = placemark->osmData().tagsEnd();
- while(it != itEnd) {
- osmData.addTag(it.key(), it.value());
- ++it;
- }
- newPlacemark->setOsmData(osmData);
+ copyTags(*placemark, *newPlacemark);
tile->append(newPlacemark);
}
@@ -141,15 +133,7 @@ GeoDataDocument *TinyPlanetProcessor::cutToTiles(unsigned int zoomLevel, unsigne
GeoDataPlacemark* newPlacemark = new GeoDataPlacemark();
newPlacemark->setGeometry(newMarbleWay);
newPlacemark->setVisualCategory(placemark->visualCategory());
-
- OsmPlacemarkData osmData;
- auto it = placemark->osmData().tagsBegin();
- auto itEnd = placemark->osmData().tagsEnd();
- while(it != itEnd) {
- osmData.addTag(it.key(), it.value());
- ++it;
- }
- newPlacemark->setOsmData(osmData);
+ copyTags(*placemark, *newPlacemark);
tile->append(newPlacemark);
}
@@ -163,3 +147,12 @@ GeoDataDocument *TinyPlanetProcessor::cutToTiles(unsigned int zoomLevel, unsigne
return tile;
}
+
+void TinyPlanetProcessor::copyTags(const GeoDataPlacemark &source, GeoDataPlacemark &target) const
+{
+ auto const originalPlacemarkData = source.osmData();
+ OsmPlacemarkData & osmData = target.osmData();
+ for (auto iter=originalPlacemarkData.tagsBegin(), end=originalPlacemarkData.tagsEnd(); iter != end; ++iter) {
+ osmData.addTag(iter.key(), iter.value());
+ }
+}
diff --git a/tools/osm-simplify/TinyPlanetProcessor.h b/tools/osm-simplify/TinyPlanetProcessor.h
index 862f55e..0b12eeb 100644
--- a/tools/osm-simplify/TinyPlanetProcessor.h
+++ b/tools/osm-simplify/TinyPlanetProcessor.h
@@ -21,6 +21,9 @@ public:
virtual void process();
GeoDataDocument* cutToTiles(unsigned int zoomLevel, unsigned int tileX, unsigned int tileY);
+
+private:
+ void copyTags(const GeoDataPlacemark &source, GeoDataPlacemark &target) const;
};
#endif // TINYPLANETPROCESSOR_H