summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-09-11 05:45:59 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-09-11 05:53:40 (GMT)
commite258fe0bf2ec44e31e51663bf8e08cb1691cce77 (patch)
treee3767d8ae437977aaeb60abfd20e6224757f82b9
parent792a609668e8e34a6cd2bdeb021e9f36316b3948 (diff)
Fix placemark ownership problems
-rw-r--r--tools/vectorosm-tilecreator/TagsFilter.cpp23
-rw-r--r--tools/vectorosm-tilecreator/TagsFilter.h5
-rw-r--r--tools/vectorosm-tilecreator/main.cpp6
3 files changed, 27 insertions, 7 deletions
diff --git a/tools/vectorosm-tilecreator/TagsFilter.cpp b/tools/vectorosm-tilecreator/TagsFilter.cpp
index 055b23b..09c7fcc 100644
--- a/tools/vectorosm-tilecreator/TagsFilter.cpp
+++ b/tools/vectorosm-tilecreator/TagsFilter.cpp
@@ -20,12 +20,13 @@
namespace Marble {
-TagsFilter::TagsFilter(GeoDataDocument *document, const QStringList &tagsList, bool andFlag ) : PlacemarkFilter(document)
+TagsFilter::TagsFilter(GeoDataDocument *geoDocument, const QStringList &tagsList, bool andFlag )
+ : PlacemarkFilter(geoDocument),
+ m_accepted(new GeoDataDocument)
{
int total=0, tagCount=0;
// qDebug()<<"Entered tagFilter";
QVector<GeoDataPlacemark*> previousObjects(placemarks());
- placemarks().clear();
foreach (GeoDataPlacemark *placemark, previousObjects) {
++total;
bool flag = andFlag;
@@ -62,19 +63,26 @@ TagsFilter::TagsFilter(GeoDataDocument *document, const QStringList &tagsList, b
if (flag) {
++tagCount;
// qDebug()<<"Contained tag";
- placemarks().append(placemark);
+ m_accepted->append(new GeoDataPlacemark(*placemark));
// qDebug()<<"ID "<<placemark->osmData().id();
} else {
- m_rejectedObjects.append(placemark);
+ m_rejectedObjects.append(new GeoDataPlacemark(*placemark));
}
}
+
// qDebug()<<"Done TagFiltering";
// qDebug()<<"Total"<<total;
- // qDebug()<<"TagCount"<<tagcon;
+ // qDebug()<<"TagCount"<<tagCount;
// qDebug()<<"Is and : "<<andFlag;
}
+TagsFilter::~TagsFilter()
+{
+ delete m_accepted;
+ qDeleteAll(m_rejectedObjects);
+}
+
void TagsFilter::process()
{
//does nothing
@@ -90,4 +98,9 @@ QVector<GeoDataPlacemark*>::const_iterator TagsFilter::rejectedObjectsEnd() cons
return m_rejectedObjects.end();
}
+GeoDataDocument *TagsFilter::accepted()
+{
+ return m_accepted;
+}
+
}
diff --git a/tools/vectorosm-tilecreator/TagsFilter.h b/tools/vectorosm-tilecreator/TagsFilter.h
index ed0724a..a5ce3cc 100644
--- a/tools/vectorosm-tilecreator/TagsFilter.h
+++ b/tools/vectorosm-tilecreator/TagsFilter.h
@@ -26,11 +26,16 @@ class TagsFilter : public PlacemarkFilter
public:
//Filters placemarks which have tags in the hash
TagsFilter(GeoDataDocument* document, const QStringList& tagsList, bool andFlag = false);
+ ~TagsFilter();
+
void process() override;
QVector<GeoDataPlacemark*>::const_iterator rejectedObjectsBegin() const;
QVector<GeoDataPlacemark*>::const_iterator rejectedObjectsEnd() const;
+ GeoDataDocument* accepted();
+
private:
+ GeoDataDocument* m_accepted;
QVector<GeoDataPlacemark*> m_rejectedObjects;
};
diff --git a/tools/vectorosm-tilecreator/main.cpp b/tools/vectorosm-tilecreator/main.cpp
index b7ca9bf..3feedac 100644
--- a/tools/vectorosm-tilecreator/main.cpp
+++ b/tools/vectorosm-tilecreator/main.cpp
@@ -11,6 +11,7 @@
#include "GeoDataDocumentWriter.h"
#include "MarbleModel.h"
#include "ParsingRunnerManager.h"
+#include "GeoDataPlacemark.h"
#include <QApplication>
#include <QCommandLineParser>
@@ -73,8 +74,9 @@ GeoDataDocument* mergeDocuments(GeoDataDocument* map1, GeoDataDocument* map2)
{
GeoDataDocument* mergedMap = new GeoDataDocument(*map1);
- foreach (GeoDataFeature* feature, map2->featureList()) {
- mergedMap->append(feature);
+ foreach (auto placemark, map2->placemarkList()) {
+ GeoDataPlacemark* land = new GeoDataPlacemark(*placemark);
+ mergedMap->append(land);
}
return mergedMap;