File indexing completed on 2024-10-13 06:32:31

0001 /*
0002     SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "TileDirectory.h"
0008 
0009 #include "GeoDataLatLonAltBox.h"
0010 #include "GeoDataDocumentWriter.h"
0011 #include "MarbleModel.h"
0012 #include "ParsingRunnerManager.h"
0013 #ifdef STATIC_BUILD
0014 #include "src/plugins/runner/osm/translators/O5mWriter.h"
0015 #endif
0016 
0017 #include <QCoreApplication>
0018 #include <QCommandLineParser>
0019 #include <QDebug>
0020 #include <QDir>
0021 #include <QFileInfo>
0022 
0023 #ifdef STATIC_BUILD
0024 #include <QtPlugin>
0025 Q_IMPORT_PLUGIN(OsmPlugin)
0026 Q_IMPORT_PLUGIN(ShpPlugin)
0027 #endif
0028 
0029 using namespace Marble;
0030 
0031 int main(int argc, char **argv)
0032 {
0033     QCoreApplication app(argc, argv);
0034     QCoreApplication::setApplicationName("marble-vectorosm-process-land-polygons");
0035     QCoreApplication::setApplicationVersion("0.1");
0036 
0037     QCommandLineParser parser;
0038     parser.setApplicationDescription("Preprocess land polygons for use by the on-demand tile generator.");
0039     parser.addHelpOption();
0040     parser.addVersionOption();
0041     parser.addOptions({
0042         {{"c", "cache-directory"}, "Directory for temporary data.", "cache", "cache"},
0043     });
0044     parser.process(app);
0045 
0046     // work around MARBLE_ADD_WRITER not working for static builds
0047 #ifdef STATIC_BUILD
0048     GeoDataDocumentWriter::registerWriter(new O5mWriter, QStringLiteral("o5m"));
0049 #endif
0050 
0051     MarbleModel model;
0052     ParsingRunnerManager manager(model.pluginManager());
0053     QString const cacheDirectory = parser.value("cache-directory");
0054     QDir().mkpath(cacheDirectory);
0055     if (!QFileInfo(cacheDirectory).isWritable()) {
0056         qWarning() << "Cannot write to cache directory" << cacheDirectory;
0057         parser.showHelp(1);
0058     }
0059 
0060     GeoDataLatLonBox world(85.0, -85.0, 180.0, -180.0, GeoDataCoordinates::Degree);
0061     TileDirectory loader(TileDirectory::Landmass, cacheDirectory, manager, 17);
0062     loader.setBoundingBox(world);
0063     loader.createTiles();
0064     return 0;
0065 }