• 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
  • osm-addresses
tools/osm-addresses/main.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 2011 Dennis Nienhüser <earthwings@gentoo.org>
9 //
10 
11 #include "SqlWriter.h"
12 #include "pbf/PbfParser.h"
13 #include "xml/XmlParser.h"
14 
15 #include <QCoreApplication>
16 #include <QDebug>
17 #include <QFileInfo>
18 #include <QTime>
19 
20 using namespace Marble;
21 
22 enum DebugLevel {
23  Debug,
24  Info,
25  Mute
26 };
27 
28 DebugLevel debugLevel = Info;
29 
30 void debugOutput( QtMsgType type, const char *msg )
31 {
32  switch ( type ) {
33  case QtDebugMsg:
34  if ( debugLevel == Debug ) {
35  fprintf( stderr, "Debug: %s\n", msg );
36  }
37  break;
38  case QtWarningMsg:
39  if ( debugLevel < Mute ) {
40  fprintf( stderr, "Info: %s\n", msg );
41  }
42  break;
43  case QtCriticalMsg:
44  if ( debugLevel < Mute ) {
45  fprintf( stderr, "Warning: %s\n", msg );
46  }
47  break;
48  case QtFatalMsg:
49  if ( debugLevel < Mute ) {
50  fprintf( stderr, "Fatal: %s\n", msg );
51  abort();
52  }
53  }
54 }
55 
56 void usage()
57 {
58  qDebug() << "Usage: [options] osm-addresses [options] input.osm.pbf|input.osm output.sqlite output.kml";
59  qDebug() << "\tOptions affect verbosity and store additional metadata in output.kml:";
60  qDebug() << "\t-q quiet";
61  qDebug() << "\t-v debug output";
62  qDebug() << "\t--version aVersion";
63  qDebug() << "\t--name aName";
64  qDebug() << "\t--date aDate";
65  qDebug() << "\t--payload aFilename";
66 }
67 
68 int main( int argc, char *argv[] )
69 {
70  if ( argc < 4 ) {
71  usage();
72  return 1;
73  }
74 
75  QCoreApplication app( argc, argv );
76 
77  QString inputFile = argv[argc-3];
78  QString outputSqlite = argv[argc-2];
79  QString outputKml = argv[argc-1];
80  QString name;
81  QString version;
82  QString date;
83  QString transport;
84  QString payload;
85  for ( int i=1; i<argc-3; ++i ) {
86  QString arg( argv[i] );
87  if ( arg == "-v" ) {
88  debugLevel = Debug;
89  } else if ( arg == "-q" ) {
90  debugLevel = Mute;
91  } else if ( arg == "--name" ) {
92  name = argv[++i];
93  } else if ( arg == "--version" ) {
94  version = argv[++i];
95  } else if ( arg == "--date" ) {
96  date = argv[++i];
97  } else if ( arg == "--transport" ) {
98  transport = argv[++i];
99  } else if ( arg == "--payload" ) {
100  payload = argv[++i];
101  } else {
102  usage();
103  return 1;
104  }
105  }
106 
107  qInstallMsgHandler( debugOutput );
108  QFileInfo file( inputFile );
109  if ( !file.exists() ) {
110  qDebug() << "File " << file.absoluteFilePath() << " does not exist. Exiting.";
111  return 2;
112  }
113 
114  OsmParser* parser = 0;
115  if ( file.fileName().endsWith( QLatin1String( ".osm" ) ) ) {
116  parser = new XmlParser;
117  } else if ( file.fileName().endsWith( QLatin1String( ".pbf" ) ) ) {
118  parser = new PbfParser;
119  } else {
120  qDebug() << "Unsupported file format: " << file.fileName();
121  return 3;
122  }
123 
124  Q_ASSERT( parser );
125  SqlWriter sql( outputSqlite );
126  parser->addWriter( &sql );
127  parser->read( file, name );
128  parser->writeKml( name, version, date, transport, payload, outputKml );
129 }
PbfParser.h
main
int main(int argc, char *argv[])
Definition: tools/osm-addresses/main.cpp:68
PbfParser
Definition: PbfParser.h:28
Info
Definition: tools/osm-addresses/main.cpp:24
Marble::OsmParser::writeKml
void writeKml(const QString &area, const QString &version, const QString &date, const QString &transport, const QString &payload, const QString &outputKml) const
Definition: tools/osm-addresses/OsmParser.cpp:702
Marble::OsmParser::read
void read(const QFileInfo &file, const QString &areaName)
Definition: tools/osm-addresses/OsmParser.cpp:218
debugOutput
void debugOutput(QtMsgType type, const char *msg)
Definition: tools/osm-addresses/main.cpp:30
Marble::XmlParser
Definition: XmlParser.h:34
Marble::SqlWriter
Definition: SqlWriter.h:23
DebugLevel
DebugLevel
Definition: tools/osm-addresses/main.cpp:22
SqlWriter.h
usage
void usage()
Definition: tools/osm-addresses/main.cpp:56
Debug
Definition: tools/osm-addresses/main.cpp:23
QCoreApplication
Mute
Definition: tools/osm-addresses/main.cpp:25
XmlParser.h
Marble::OsmParser
Definition: src/plugins/runner/osm/OsmParser.h:17
debugLevel
DebugLevel debugLevel
Definition: tools/osm-addresses/main.cpp:28
Marble::OsmParser::addWriter
void addWriter(Writer *writer)
Definition: tools/osm-addresses/OsmParser.cpp:117
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:51 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