• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • tools
  • kml2kml
kml2kml.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2012 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 // A simple tool to read a .kml file and write it back to a new .kml file
12 // Mainly useful to test the successful reading and writing of KML data
13 
14 #include <MarbleWidget.h>
15 #include <ParsingRunnerManager.h>
16 #include <PluginManager.h>
17 #include <GeoWriter.h>
18 
19 #include <QApplication>
20 #include <QFile>
21 #include <QDebug>
22 
23 using namespace std;
24 using namespace Marble;
25 
26 int main(int argc, char** argv)
27 {
28  QApplication app(argc,argv);
29 
30  QString inputFilename;
31  int inputIndex = app.arguments().indexOf( "-i" );
32  if ( inputIndex > 0 && inputIndex + 1 < argc ) {
33  inputFilename = app.arguments().at( inputIndex + 1 );
34  } else {
35  qDebug( " Syntax: kml2kml -i sourcefile [-o kml-targetfile]" );
36  return 1;
37  }
38 
39  QString outputFilename = "output.kml";
40  int outputIndex = app.arguments().indexOf("-o");
41  if ( outputIndex > 0 && outputIndex + 1 < argc )
42  outputFilename = app.arguments().at( outputIndex + 1 );
43 
44  ParsingRunnerManager* manager = new ParsingRunnerManager( new PluginManager );
45  GeoDataDocument* document = manager->openFile( inputFilename );
46  if (!document) {
47  qDebug() << "Could not parse input file. No error message available unfortunately";
48  return 2;
49  }
50 
51 
52  QFile output(outputFilename);
53  if (!output.open(QIODevice::WriteOnly)) {
54  qDebug() << "Unable to write to " << output.fileName();
55  return 3;
56  }
57 
58  GeoWriter().write(&output, dynamic_cast<GeoDataFeature*>(document));
59 }
Marble::PluginManager
The class that handles Marble's plugins.
Definition: PluginManager.h:45
Marble::GeoDataDocument
A container for Features, Styles and in the future Schemas.
Definition: GeoDataDocument.h:65
Marble::ParsingRunnerManager
Definition: ParsingRunnerManager.h:31
QList::at
const T & at(int i) const
QFile::fileName
QString fileName() const
QApplication
QFile
ParsingRunnerManager.h
GeoWriter.h
main
int main(int argc, char **argv)
Definition: kml2kml.cpp:26
Marble::ParsingRunnerManager::openFile
GeoDataDocument * openFile(const QString &fileName, DocumentRole role=UserDocument, int timeout=30000)
Definition: ParsingRunnerManager.cpp:121
Marble::GeoWriter
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition: GeoWriter.h:29
QString
QFile::open
virtual bool open(QFlags< QIODevice::OpenModeFlag > mode)
PluginManager.h
MarbleWidget.h
This file contains the headers for MarbleWidget.
QStringList::indexOf
int indexOf(const QRegExp &rx, int from) const
Marble::GeoWriter::write
bool write(QIODevice *device, const GeoNode *feature)
The main API call to use the XML writer.
Definition: GeoWriter.cpp:28
QCoreApplication::arguments
QStringList arguments()
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal