summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-07-24 16:45:07 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-07-24 16:55:02 (GMT)
commit8b0a09cb1bc0391949db8e740775a7c254878f3b (patch)
tree6108063e38fc21abbeb4b3b91607d0b67a6b4b92
parent8907b7e525ccb926c3fbaac1cccd3498cdd224d0 (diff)
Use QVector<GeoDataPlacemark*> instead of QList<GeoDataObject*>
This is more efficient and avoids loads of static_casts.
-rw-r--r--tools/osm-simplify/BaseFilter.cpp19
-rw-r--r--tools/osm-simplify/BaseFilter.h8
-rw-r--r--tools/osm-simplify/LineStringProcessor.cpp16
-rw-r--r--tools/osm-simplify/NodeReducer.cpp6
-rw-r--r--tools/osm-simplify/PlacemarkFilter.cpp4
-rw-r--r--tools/osm-simplify/ShpCoastlineProcessor.cpp6
-rw-r--r--tools/osm-simplify/TagsFilter.cpp15
-rw-r--r--tools/osm-simplify/TagsFilter.h6
-rw-r--r--tools/osm-simplify/TinyPlanetProcessor.cpp3
-rw-r--r--tools/osm-simplify/WayConcatenator.cpp25
-rw-r--r--tools/osm-simplify/WayConcatenator.h2
11 files changed, 49 insertions, 61 deletions
diff --git a/tools/osm-simplify/BaseFilter.cpp b/tools/osm-simplify/BaseFilter.cpp
index 7649c19..3b04d20 100644
--- a/tools/osm-simplify/BaseFilter.cpp
+++ b/tools/osm-simplify/BaseFilter.cpp
@@ -15,14 +15,11 @@
#include "GeoDataObject.h"
#include "GeoDataTypes.h"
-BaseFilter::BaseFilter(GeoDataDocument* document, const char *type) :
- m_document(document)
+BaseFilter::BaseFilter(GeoDataDocument* document) :
+ m_document(document),
+ m_placemarks(document->placemarkList())
{
- foreach (GeoDataFeature* feature, m_document->featureList()) {
- if(feature->nodeType() == type) {
- m_objects.append(feature);
- }
- }
+ // nothing to do
}
BaseFilter::~BaseFilter()
@@ -30,12 +27,12 @@ BaseFilter::~BaseFilter()
}
-QList<GeoDataObject*>::const_iterator BaseFilter::objectsBegin() const
+QVector<GeoDataPlacemark*>::const_iterator BaseFilter::objectsBegin() const
{
- return m_objects.begin();
+ return m_placemarks.begin();
}
-QList<GeoDataObject*>::const_iterator BaseFilter::objectsEnd() const
+QVector<GeoDataPlacemark*>::const_iterator BaseFilter::objectsEnd() const
{
- return m_objects.end();
+ return m_placemarks.end();
}
diff --git a/tools/osm-simplify/BaseFilter.h b/tools/osm-simplify/BaseFilter.h
index 3e3ce7d..1c77c8b 100644
--- a/tools/osm-simplify/BaseFilter.h
+++ b/tools/osm-simplify/BaseFilter.h
@@ -23,17 +23,17 @@ using namespace Marble;
class BaseFilter
{
public:
- BaseFilter(GeoDataDocument* document, const char *type);
+ BaseFilter(GeoDataDocument* document);
virtual ~BaseFilter();
virtual void process() = 0;
- QList<GeoDataObject*>::const_iterator objectsBegin() const;
- QList<GeoDataObject*>::const_iterator objectsEnd() const;
+ QVector<GeoDataPlacemark*>::const_iterator objectsBegin() const;
+ QVector<GeoDataPlacemark*>::const_iterator objectsEnd() const;
protected:
GeoDataDocument* m_document;
- QList<GeoDataObject*> m_objects;
+ QVector<GeoDataPlacemark*> m_placemarks;
};
#endif // OBJECTHANDLER_H
diff --git a/tools/osm-simplify/LineStringProcessor.cpp b/tools/osm-simplify/LineStringProcessor.cpp
index 7c88a52..d578794 100644
--- a/tools/osm-simplify/LineStringProcessor.cpp
+++ b/tools/osm-simplify/LineStringProcessor.cpp
@@ -19,26 +19,26 @@ LineStringProcessor::LineStringProcessor(GeoDataDocument* document) :
PlacemarkFilter(document)
{
QList<GeoDataPlacemark*> toRemove;
- foreach (GeoDataObject* placemark, m_objects) {
- if( static_cast<GeoDataPlacemark*>(placemark)->geometry()->nodeType() != GeoDataTypes::GeoDataLineStringType) {
- toRemove.append(static_cast<GeoDataPlacemark*>(placemark));
+ foreach (GeoDataPlacemark* placemark, m_placemarks) {
+ if(placemark->geometry()->nodeType() != GeoDataTypes::GeoDataLineStringType) {
+ toRemove.append(placemark);
}
}
- foreach (GeoDataObject* placemark, toRemove) {
- m_objects.removeOne(placemark);
+ foreach (GeoDataPlacemark* placemark, toRemove) {
+ m_placemarks.removeOne(placemark);
}
}
void LineStringProcessor::process()
{
- qDebug() << "Polylines to process: " << m_objects.size();
+ qDebug() << "Polylines to process: " << m_placemarks.size();
QList<GeoDataObject*> polylinesToDrop;
- foreach (GeoDataObject* polyline, m_objects) {
- switch(static_cast<GeoDataPlacemark*>(polyline)->visualCategory())
+ foreach (GeoDataPlacemark* polyline, m_placemarks) {
+ switch(polyline->visualCategory())
{
case GeoDataFeature::HighwayCycleway :
case GeoDataFeature::HighwayFootway :
diff --git a/tools/osm-simplify/NodeReducer.cpp b/tools/osm-simplify/NodeReducer.cpp
index 875078b..1947a6b 100644
--- a/tools/osm-simplify/NodeReducer.cpp
+++ b/tools/osm-simplify/NodeReducer.cpp
@@ -28,9 +28,7 @@ NodeReducer::NodeReducer(GeoDataDocument* document, int zoomLevel) :
void NodeReducer::process()
{
- foreach (GeoDataObject* object, m_objects) {
-
- GeoDataPlacemark* placemark = static_cast<GeoDataPlacemark*>(object);
+ foreach (GeoDataPlacemark* placemark, m_placemarks) {
if(placemark->geometry()->nodeType() == GeoDataTypes::GeoDataLineStringType){
GeoDataLineString* prevLine = static_cast<GeoDataLineString*>(placemark->geometry());
@@ -160,4 +158,4 @@ qreal NodeReducer::resolutionForLevel(int level) {
return 0.0000005;
break;
}
-} \ No newline at end of file
+}
diff --git a/tools/osm-simplify/PlacemarkFilter.cpp b/tools/osm-simplify/PlacemarkFilter.cpp
index c6de262..41b74f4 100644
--- a/tools/osm-simplify/PlacemarkFilter.cpp
+++ b/tools/osm-simplify/PlacemarkFilter.cpp
@@ -13,8 +13,8 @@
#include "GeoDataPlacemark.h"
PlacemarkFilter::PlacemarkFilter(GeoDataDocument *document) :
- BaseFilter(document, GeoDataTypes::GeoDataPlacemarkType)
+ BaseFilter(document)
{
- qDebug() << "Placemark count:" << m_objects.size();
+ qDebug() << "Placemark count:" << m_placemarks.size();
}
diff --git a/tools/osm-simplify/ShpCoastlineProcessor.cpp b/tools/osm-simplify/ShpCoastlineProcessor.cpp
index b1f8f68..a745d6a 100644
--- a/tools/osm-simplify/ShpCoastlineProcessor.cpp
+++ b/tools/osm-simplify/ShpCoastlineProcessor.cpp
@@ -29,8 +29,7 @@ void ShpCoastlineProcessor::process()
OsmPlacemarkData marbleLand;
marbleLand.addTag("marble_land","landmass");
- foreach (GeoDataObject* object, m_objects) {
- GeoDataPlacemark* placemark = static_cast<GeoDataPlacemark*>(object);
+ foreach (GeoDataPlacemark* placemark, m_placemarks) {
if(placemark->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType) {
placemark->setOsmData(marbleLand);
}
@@ -58,8 +57,7 @@ GeoDataDocument *ShpCoastlineProcessor::cutToTiles(unsigned int zoomLevel, unsig
tileBoundary.setBoundaries(north, south, east, west);
- foreach (GeoDataObject* object, m_objects) {
- GeoDataPlacemark* placemark = static_cast<GeoDataPlacemark*>(object);
+ foreach (GeoDataPlacemark* placemark, m_placemarks) {
if(placemark->geometry()->nodeType() == GeoDataTypes::GeoDataPolygonType) {
GeoDataPolygon* marblePolygon = static_cast<GeoDataPolygon*>(placemark->geometry());
diff --git a/tools/osm-simplify/TagsFilter.cpp b/tools/osm-simplify/TagsFilter.cpp
index 5024924..7860831 100644
--- a/tools/osm-simplify/TagsFilter.cpp
+++ b/tools/osm-simplify/TagsFilter.cpp
@@ -24,11 +24,10 @@ TagsFilter::TagsFilter(GeoDataDocument *document, const QStringList &tagsList, b
{
int total=0, tagCount=0;
// qDebug()<<"Entered tagFilter";
- QList<GeoDataObject*> previousObjects(m_objects);
- m_objects.clear();
- foreach (GeoDataObject *object, previousObjects) {
+ QVector<GeoDataPlacemark*> previousObjects(m_placemarks);
+ m_placemarks.clear();
+ foreach (GeoDataPlacemark *placemark, previousObjects) {
++total;
- GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>(object);
bool flag = andFlag;
QStringList::const_iterator itr = tagsList.begin();
for (; itr != tagsList.end(); ++itr) {
@@ -63,10 +62,10 @@ TagsFilter::TagsFilter(GeoDataDocument *document, const QStringList &tagsList, b
if (flag) {
++tagCount;
// qDebug()<<"Contained tag";
- m_objects.append(object);
+ m_placemarks.append(placemark);
// qDebug()<<"ID "<<placemark->osmData().id();
} else {
- m_rejectedObjects.append(object);
+ m_rejectedObjects.append(placemark);
}
}
@@ -84,12 +83,12 @@ void TagsFilter::process()
}
-QList<GeoDataObject*>::const_iterator TagsFilter::rejectedObjectsBegin() const
+QVector<GeoDataPlacemark*>::const_iterator TagsFilter::rejectedObjectsBegin() const
{
return m_rejectedObjects.begin();
}
-QList<GeoDataObject*>::const_iterator TagsFilter::rejectedObjectsEnd() const
+QVector<GeoDataPlacemark*>::const_iterator TagsFilter::rejectedObjectsEnd() const
{
return m_rejectedObjects.end();
}
diff --git a/tools/osm-simplify/TagsFilter.h b/tools/osm-simplify/TagsFilter.h
index 9e2bf3f..d17cb98 100644
--- a/tools/osm-simplify/TagsFilter.h
+++ b/tools/osm-simplify/TagsFilter.h
@@ -27,10 +27,10 @@ public:
//Filters placemarks which have tags in the hash
TagsFilter(GeoDataDocument* document, const QStringList& tagsList, bool andFlag = false);
virtual void process();
- QList<GeoDataObject*>::const_iterator rejectedObjectsBegin() const;
- QList<GeoDataObject*>::const_iterator rejectedObjectsEnd() const;
+ QVector<GeoDataPlacemark*>::const_iterator rejectedObjectsBegin() const;
+ QVector<GeoDataPlacemark*>::const_iterator rejectedObjectsEnd() const;
private:
- QList<GeoDataObject*> m_rejectedObjects;
+ QVector<GeoDataPlacemark*> m_rejectedObjects;
};
}
diff --git a/tools/osm-simplify/TinyPlanetProcessor.cpp b/tools/osm-simplify/TinyPlanetProcessor.cpp
index 22cd8ed..5dee6f3 100644
--- a/tools/osm-simplify/TinyPlanetProcessor.cpp
+++ b/tools/osm-simplify/TinyPlanetProcessor.cpp
@@ -48,8 +48,7 @@ GeoDataDocument *TinyPlanetProcessor::cutToTiles(unsigned int zoomLevel, unsigne
BaseClipper clipper;
clipper.initClipRect(tileBoundary);
- foreach (GeoDataObject* object, m_objects) {
- GeoDataPlacemark* placemark = static_cast<GeoDataPlacemark*>(object);
+ foreach (GeoDataPlacemark* placemark, m_placemarks) {
if(tileBoundary.intersects(placemark->geometry()->latLonAltBox())) {
diff --git a/tools/osm-simplify/WayConcatenator.cpp b/tools/osm-simplify/WayConcatenator.cpp
index df1671f..642d2db 100644
--- a/tools/osm-simplify/WayConcatenator.cpp
+++ b/tools/osm-simplify/WayConcatenator.cpp
@@ -45,9 +45,7 @@ void WayConcatenator::process()
qint64 placemarkCount = 0;
// qDebug()<<"** Number of TagFiletered placemarks "<< m_objects.size();
- foreach (GeoDataObject *object, m_objects) {
- GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>(object);
-
+ foreach (GeoDataPlacemark* placemark, m_placemarks) {
qDebug()<<" ";
++placemarkCount;
// qDebug()<<"No."<<plcCount;
@@ -108,7 +106,7 @@ void WayConcatenator::process()
// qDebug()<< "Both* Both chunks found, concatenating to it";
if(chunk == otherChunk){
qDebug()<<"#### Both the chunks are same, directly adding to the list of placemarks";
- m_placemarks.append(*placemark);
+ m_wayPlacemarks.append(*placemark);
} else {
concatBoth(placemark, chunk, otherChunk);
++count;
@@ -137,10 +135,10 @@ void WayConcatenator::process()
// if(flag){
// qDebug()<<" Concat not possible";
- // m_placemarks.append(*placemark);
+ // m_wayPlacemarks.append(*placemark);
// }
} else{
- m_placemarks.append(*placemark);
+ m_wayPlacemarks.append(*placemark);
}
}
@@ -158,11 +156,10 @@ void WayConcatenator::process()
void WayConcatenator::addRejectedPlacemarks()
{
- QList<GeoDataObject*>::const_iterator itr = rejectedObjectsBegin();
- QList<GeoDataObject*>::const_iterator endItr = rejectedObjectsEnd();
+ QVector<GeoDataPlacemark*>::const_iterator itr = rejectedObjectsBegin();
+ QVector<GeoDataPlacemark*>::const_iterator endItr = rejectedObjectsEnd();
for (; itr != endItr; ++itr) {
- GeoDataPlacemark *placemark = static_cast<GeoDataPlacemark*>(*itr);
- m_placemarks.append(*placemark);
+ m_wayPlacemarks << **itr;
}
}
@@ -180,7 +177,7 @@ void WayConcatenator::addWayChunks()
chunkSet.insert(*itr);
GeoDataPlacemark* placemark = (*itr)->merge();
if (placemark) {
- m_placemarks.append(*placemark);
+ m_wayPlacemarks.append(*placemark);
totalSize += (*itr)->size();
qDebug()<<"Chunk:";
(*itr)->printIds();
@@ -199,9 +196,9 @@ void WayConcatenator::addWayChunks()
void WayConcatenator::modifyDocument()
{
m_document->clear();
- QList<GeoDataPlacemark>::iterator itr;
- itr = m_placemarks.begin();
- for (; itr != m_placemarks.end(); ++itr) {
+ QVector<GeoDataPlacemark>::iterator itr;
+ itr = m_wayPlacemarks.begin();
+ for (; itr != m_wayPlacemarks.end(); ++itr) {
GeoDataPlacemark *placemark = new GeoDataPlacemark(*itr);
m_document->append(placemark);
}
diff --git a/tools/osm-simplify/WayConcatenator.h b/tools/osm-simplify/WayConcatenator.h
index 394f150..4e75c20 100644
--- a/tools/osm-simplify/WayConcatenator.h
+++ b/tools/osm-simplify/WayConcatenator.h
@@ -27,7 +27,7 @@ public:
private:
QMultiHash<qint64, WayChunk*> m_hash;
QVector<WayChunk*> m_chunks;
- QList<GeoDataPlacemark> m_placemarks;
+ QVector<GeoDataPlacemark> m_wayPlacemarks;
void createWayChunk(GeoDataPlacemark *placemark, qint64 firstId, qint64 lastId);
WayChunk* getWayChunk(GeoDataPlacemark *placemark, qint64 matchId);
void concatFirst(GeoDataPlacemark *placemark, WayChunk *chunk);