summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-09-20 19:25:48 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-09-20 19:36:20 (GMT)
commit232ef7aa54cba696660dfa6b5e7a217ea619da3b (patch)
tree29384436bc0b01fba960ce073e2e3e642872ea64
parent8390a968688d6ba803afd24b216a0970f2cd30dd (diff)
Improved progress output
-rw-r--r--tools/vectorosm-tilecreator/NodeReducer.cpp13
-rw-r--r--tools/vectorosm-tilecreator/NodeReducer.h3
-rw-r--r--tools/vectorosm-tilecreator/TileIterator.cpp5
-rw-r--r--tools/vectorosm-tilecreator/TileIterator.h1
-rw-r--r--tools/vectorosm-tilecreator/main.cpp23
5 files changed, 37 insertions, 8 deletions
diff --git a/tools/vectorosm-tilecreator/NodeReducer.cpp b/tools/vectorosm-tilecreator/NodeReducer.cpp
index 2fb1851..706f57b 100644
--- a/tools/vectorosm-tilecreator/NodeReducer.cpp
+++ b/tools/vectorosm-tilecreator/NodeReducer.cpp
@@ -58,9 +58,16 @@ NodeReducer::NodeReducer(GeoDataDocument* document, int zoomLevel) :
placemark->setGeometry(reducedPolygon);
}
}
- double const reduction = m_removedNodes / qMax(1.0, double(m_remainingNodes + m_removedNodes));
- qDebug() << QString("Total nodes reduced: %1%").arg(QString("%1").arg(reduction * 100.0, 0, 'f', 1))
- << "(" << m_removedNodes << "removed," << m_remainingNodes << "remaining)";
+}
+
+qint64 NodeReducer::remainingNodes() const
+{
+ return m_remainingNodes;
+}
+
+qint64 NodeReducer::removedNodes() const
+{
+ return m_removedNodes;
}
qreal NodeReducer::resolutionForLevel(int level) {
diff --git a/tools/vectorosm-tilecreator/NodeReducer.h b/tools/vectorosm-tilecreator/NodeReducer.h
index 41f287b..32f85b2 100644
--- a/tools/vectorosm-tilecreator/NodeReducer.h
+++ b/tools/vectorosm-tilecreator/NodeReducer.h
@@ -21,6 +21,9 @@ class NodeReducer : public BaseFilter {
public:
NodeReducer(GeoDataDocument* document, int zoomLevel);
+ qint64 removedNodes() const;
+ qint64 remainingNodes() const;
+
private:
template<class T>
T* reduce(T* lineString)
diff --git a/tools/vectorosm-tilecreator/TileIterator.cpp b/tools/vectorosm-tilecreator/TileIterator.cpp
index de50dfc..47f365b 100644
--- a/tools/vectorosm-tilecreator/TileIterator.cpp
+++ b/tools/vectorosm-tilecreator/TileIterator.cpp
@@ -76,6 +76,11 @@ int TileIterator::y() const
return m_state.y();
}
+int TileIterator::total() const
+{
+ return (1+m_bounds.width()) * (1+m_bounds.height());
+}
+
TileIterator::TileIterator() :
m_state(-1, -1)
{
diff --git a/tools/vectorosm-tilecreator/TileIterator.h b/tools/vectorosm-tilecreator/TileIterator.h
index 91eb54c..3f157ac 100644
--- a/tools/vectorosm-tilecreator/TileIterator.h
+++ b/tools/vectorosm-tilecreator/TileIterator.h
@@ -30,6 +30,7 @@ public:
TileIterator(const GeoDataLatLonBox &latLonBox, int zoomLevel);
int x() const;
int y() const;
+ int total() const;
private:
TileIterator();
diff --git a/tools/vectorosm-tilecreator/main.cpp b/tools/vectorosm-tilecreator/main.cpp
index 49c05ec..8abbdd5 100644
--- a/tools/vectorosm-tilecreator/main.cpp
+++ b/tools/vectorosm-tilecreator/main.cpp
@@ -29,6 +29,8 @@
#include "WayConcatenator.h"
#include "TileIterator.h"
+#include <iostream>
+
using namespace Marble;
enum DebugLevel {
@@ -242,7 +244,6 @@ int main(int argc, char *argv[])
bool debug = parser.isSet("debug");
bool silent = parser.isSet("silent");
unsigned int zoomLevel = parser.value("zoom-level").toInt();
- qDebug()<<"Zoom level is "<<zoomLevel<<endl;
QString outputName;
if(parser.isSet("output")) {
@@ -250,7 +251,6 @@ int main(int argc, char *argv[])
} else {
outputName = "s_" + inputFileName;
}
- qDebug() << "Output file name is " << outputName << endl;
if(debug) {
debugLevel = Debug;
@@ -264,7 +264,7 @@ int main(int argc, char *argv[])
QFileInfo file( inputFileName );
if ( !file.exists() ) {
- qDebug() << "File " << file.absoluteFilePath() << " does not exist. Exiting.";
+ qWarning() << "File " << file.absoluteFilePath() << " does not exist. Exiting.";
return 2;
}
@@ -300,14 +300,20 @@ int main(int argc, char *argv[])
VectorClipper processor(map.data());
GeoDataLatLonBox world(85.0, -85.0, 180.0, -180.0, GeoDataCoordinates::Degree);
TileIterator iter(world, zoomLevel);
+ qint64 count = 0;
+ qint64 const total = iter.total();
foreach(auto const &tileId, iter) {
+ ++count;
GeoDataDocument* tile = processor.clipTo(zoomLevel, tileId.x(), tileId.y());
NodeReducer reducer(tile, zoomLevel+1);
if (!writeTile(parser, outputName, tile, tileId.x(), tileId.y(), zoomLevel)) {
return 4;
}
- qInfo() << tile->name() << " done";
+ double const reduction = reducer.removedNodes() / qMax(1.0, double(reducer.remainingNodes() + reducer.removedNodes()));
+ std::cout << "Tile " << count << "/" << total << " (" << tile->name().toStdString() << ") done.";
+ std::cout << " Node reduction: " << qRound(reduction * 100.0) << "% " << '\r';
+ std::cout.flush();
delete tile;
}
} else {
@@ -332,7 +338,10 @@ int main(int argc, char *argv[])
//WayConcatenator concatenator(tagsFilter.accepted(), QStringList() << "highway=*", false);
TileIterator iter(input->latLonAltBox(), zoomLevel);
+ qint64 count = 0;
+ qint64 const total = iter.total();
foreach(auto const &tileId, iter) {
+ ++count;
GeoDataDocument* tile1 = processor.clipTo(zoomLevel, tileId.x(), tileId.y());
GeoDataDocument* tile2 = landMassClipper.clipTo(zoomLevel, tileId.x(), tileId.y());
GeoDataDocument* combined = mergeDocuments(tile1, tile2);
@@ -340,7 +349,11 @@ int main(int argc, char *argv[])
if (!writeTile(parser, outputName, combined, tileId.x(), tileId.y(), zoomLevel)) {
return 4;
}
- qInfo() << tile1->name() << " done";
+
+ double const reduction = reducer.removedNodes() / qMax(1.0, double(reducer.remainingNodes() + reducer.removedNodes()));
+ std::cout << "Tile " << count << "/" << total << " (" << combined->name().toStdString() << ") done.";
+ std::cout << " Node reduction: " << qRound(reduction * 100.0) << "% " << '\r';
+ std::cout.flush();
delete combined;
delete tile1;
delete tile2;