File indexing completed on 2023-05-30 09:06:26
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2012 Dennis Nienhüser <nienhueser@kde.org> 0004 // 0005 0006 // A simple tool to read a .kml file and write it back to a new .kml file 0007 // Mainly useful to test the successful reading and writing of KML data 0008 0009 #include <MarbleWidget.h> 0010 #include <ParsingRunnerManager.h> 0011 #include <PluginManager.h> 0012 #include <GeoDataDocumentWriter.h> 0013 0014 #include <QApplication> 0015 #include <QFile> 0016 #include <QDebug> 0017 0018 using namespace std; 0019 using namespace Marble; 0020 0021 int main(int argc, char** argv) 0022 { 0023 QApplication app(argc,argv); 0024 0025 QString inputFilename; 0026 int inputIndex = app.arguments().indexOf( "-i" ); 0027 if ( inputIndex > 0 && inputIndex + 1 < argc ) { 0028 inputFilename = app.arguments().at( inputIndex + 1 ); 0029 } else { 0030 qDebug( " Syntax: kml2kml -i sourcefile [-o kml-targetfile]" ); 0031 return 1; 0032 } 0033 0034 QString outputFilename = "output.kml"; 0035 int outputIndex = app.arguments().indexOf("-o"); 0036 if ( outputIndex > 0 && outputIndex + 1 < argc ) 0037 outputFilename = app.arguments().at( outputIndex + 1 ); 0038 0039 ParsingRunnerManager* manager = new ParsingRunnerManager( new PluginManager ); 0040 GeoDataDocument* document = manager->openFile( inputFilename ); 0041 if (!document) { 0042 qDebug() << "Could not parse input file. No error message available unfortunately"; 0043 return 2; 0044 } 0045 0046 GeoDataDocumentWriter::write(outputFilename, *document); 0047 }