QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
qgsosmimport.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsosmimport.h
3  --------------------------------------
4  Date : January 2013
5  Copyright : (C) 2013 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef OSMIMPORT_H
17 #define OSMIMPORT_H
18 
19 #include <QFile>
20 #include <QObject>
21 
22 #include "qgsosmbase.h"
23 
24 class QXmlStreamReader;
25 
35 class ANALYSIS_EXPORT QgsOSMXmlImport : public QObject
36 {
37  Q_OBJECT
38  public:
39  explicit QgsOSMXmlImport( const QString& xmlFileName = QString(), const QString& dbFileName = QString() );
40 
41  void setInputXmlFileName( const QString& xmlFileName ) { mXmlFileName = xmlFileName; }
42  QString inputXmlFileName() const { return mXmlFileName; }
43 
44  void setOutputDbFileName( const QString& dbFileName ) { mDbFileName = dbFileName; }
45  QString outputDbFileName() const { return mDbFileName; }
46 
51  bool import();
52 
53  bool hasError() const { return !mError.isEmpty(); }
54  QString errorString() const { return mError; }
55 
56  signals:
57  void progress( int percent );
58 
59  protected:
60 
61  bool createDatabase();
62  bool closeDatabase();
63 
65  void deleteStatement( sqlite3_stmt*& stmt );
66 
67  bool createIndexes();
68 
69  void readRoot( QXmlStreamReader& xml );
70  void readNode( QXmlStreamReader& xml );
71  void readWay( QXmlStreamReader& xml );
72  void readTag( bool way, QgsOSMId id, QXmlStreamReader& xml );
73 
74  private:
75  QString mXmlFileName;
76  QString mDbFileName;
77 
78  QString mError;
79 
80  QFile mInputFile;
81 
82  sqlite3* mDatabase;
83  sqlite3_stmt* mStmtInsertNode;
84  sqlite3_stmt* mStmtInsertNodeTag;
85  sqlite3_stmt* mStmtInsertWay;
86  sqlite3_stmt* mStmtInsertWayNode;
87  sqlite3_stmt* mStmtInsertWayTag;
88 };
89 
90 
91 
92 #endif // OSMIMPORT_H
bool hasError() const
Definition: qgsosmimport.h:53
void setOutputDbFileName(const QString &dbFileName)
Definition: qgsosmimport.h:44
qint64 QgsOSMId
Definition: qgsosmbase.h:24
struct sqlite3 sqlite3
QString errorString() const
Definition: qgsosmimport.h:54
void setInputXmlFileName(const QString &xmlFileName)
Definition: qgsosmimport.h:41
The QgsOSMXmlImport class imports OpenStreetMap XML format to our topological representation in a SQL...
Definition: qgsosmimport.h:35
QString inputXmlFileName() const
Definition: qgsosmimport.h:42
QString outputDbFileName() const
Definition: qgsosmimport.h:45