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

marble

  • sources
  • kde-4.12
  • 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 <GeoDataParser.h>
16 #include <GeoWriter.h>
17 
18 #include <QFile>
19 #include <iostream>
20 
21 using namespace std;
22 using namespace Marble;
23 
24 int main(int argc, char** argv)
25 {
26  if (argc != 3) {
27  cout << "Usage: " << argv[0] << " input.kml output.kml" << endl;
28  return 0;
29  }
30 
31  QFile file(argv[1]);
32  file.open(QIODevice::ReadOnly);
33  GeoDataParser parser(GeoData_KML);
34  if ( !parser.read( &file ) ) {
35  cerr << "Error parsing '" << file.fileName().toStdString();
36  cerr << "': '" << parser.errorString().toStdString() << "'" << endl;
37  return 1;
38  }
39 
40  GeoDocument* document = parser.releaseDocument();
41  if (!document) {
42  cerr << "Could not parse kml file. No error message available unfortunately" << endl;
43  return 2;
44  }
45 
46  QFile output(argv[2]);
47  if (!output.open(QIODevice::WriteOnly)) {
48  cerr << "Unable to write to " << output.fileName().toStdString() << endl;
49  return 3;
50  }
51 
52  GeoWriter().write(&output, dynamic_cast<GeoDataFeature*>(document));
53 }
Marble::GeoDataParser
Definition: GeoDataParser.h:40
GeoDataParser.h
GeoWriter.h
Marble::GeoData_KML
Definition: GeoDataParser.h:36
Marble::GeoParser::read
bool read(QIODevice *)
Main API for reading the XML document.
Definition: GeoParser.cpp:74
main
int main(int argc, char **argv)
Definition: kml2kml.cpp:24
Marble::GeoWriter
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition: GeoWriter.h:28
Marble::GeoDocument
A shared base class between GeoDataDocument/GeoSourceDocument.
Definition: GeoDocument.h:42
MarbleWidget.h
This file contains the headers for MarbleWidget.
Marble::GeoWriter::write
bool write(QIODevice *device, const GeoNode *feature)
The main API call to use the XML writer.
Definition: GeoWriter.cpp:28
Marble::GeoParser::releaseDocument
GeoDocument * releaseDocument()
retrieve the parsed document and reset the parser If parsing was successful, retrieve the resulting d...
Definition: GeoParser.cpp:205
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:50 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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