summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Nienhüser <nienhueser@kde.org>2016-08-14 10:00:48 (GMT)
committerDennis Nienhüser <nienhueser@kde.org>2016-08-14 10:00:48 (GMT)
commit21e3f103ca388e7925ea42500e386e6d6f32fbe4 (patch)
treec07514620d839e3d7892d71eaaa76480f4fe646c
parentedff1b3a14c15d4dc6e7590d2718fa20b82367ea (diff)
Simplify
-rw-r--r--tools/osm-simplify/main.cpp34
1 files changed, 4 insertions, 30 deletions
diff --git a/tools/osm-simplify/main.cpp b/tools/osm-simplify/main.cpp
index 239d289..2a3fcdd 100644
--- a/tools/osm-simplify/main.cpp
+++ b/tools/osm-simplify/main.cpp
@@ -83,40 +83,14 @@ GeoDataDocument* mergeDocuments(GeoDataDocument* map1, GeoDataDocument* map2)
bool writeTile(const QCommandLineParser &parser, const QString &outputName, GeoDataDocument* tile, int x, int y, int zoomLevel)
{
QString const extension = parser.value("extension");
- QString outputFile;
- if(parser.isSet("output")) {
- outputFile = QString("%1/%2/%3/%4.%5").arg(outputName).arg(zoomLevel).arg(x).arg(y).arg(extension);
- } else {
- outputFile = QString("%1/%2/%3.%4").arg(zoomLevel).arg(x).arg(y).arg(extension);
- }
-
- QDir dir;
- if(parser.isSet("output")) {
- if(!dir.exists(outputName)) {
- dir.mkdir(outputName);
- }
-
- if(!dir.exists(QString("%1/%2").arg(outputName).arg(zoomLevel))) {
- dir.mkdir(QString("%1/%2").arg(outputName).arg(zoomLevel));
- }
-
- if(!dir.exists(QString("%1/%2/%3").arg(outputName).arg(zoomLevel).arg(x))) {
- dir.mkdir(QString("%1/%2/%3").arg(outputName).arg(zoomLevel).arg(x));
- }
- } else {
- if(!dir.exists(QString::number(zoomLevel))) {
- dir.mkdir(QString::number(zoomLevel));
- }
- if(!dir.exists(QString("%1/%2").arg(zoomLevel).arg(x))) {
- dir.mkdir(QString("%1/%2").arg(zoomLevel).arg(x));
- }
- }
-
+ QString const baseDir = parser.isSet("output") ? QString("%1/").arg(outputName) : QString();
+ QString const outputDir = QString("%1%2/%3").arg(baseDir).arg(zoomLevel).arg(x);
+ QDir().mkpath(outputDir);
+ QString const outputFile = QString("%1/%2.%3").arg(outputDir).arg(y).arg(extension);
if (!GeoDataDocumentWriter::write(outputFile, *tile)) {
qDebug() << "Could not write the file " << outputName;
return false;
}
-
return true;
}