2016-01-04 22:51:18 +11:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The QgsOSMXmlImport class imports OpenStreetMap XML format to our topological representation
|
|
|
|
* in a SQLite database (see QgsOSMDatabase for details).
|
|
|
|
*
|
2017-01-12 22:01:50 +01:00
|
|
|
* How to use the class:
|
2016-01-04 22:51:18 +11:00
|
|
|
* 1. set input XML file name and output DB file name (in constructor or with respective functions)
|
|
|
|
* 2. run import()
|
|
|
|
* 3. check errorString() if the import failed
|
|
|
|
*/
|
|
|
|
class QgsOSMXmlImport : public QObject
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsosmimport.h>
|
|
|
|
%End
|
|
|
|
public:
|
2017-05-01 18:13:15 +02:00
|
|
|
explicit QgsOSMXmlImport( const QString &xmlFileName = QString(), const QString &dbFileName = QString() );
|
2016-01-04 22:51:18 +11:00
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
void setInputXmlFileName( const QString &xmlFileName );
|
2016-01-04 22:51:18 +11:00
|
|
|
QString inputXmlFileName() const;
|
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
void setOutputDatabaseFileName( const QString &fileName );
|
2017-02-06 09:21:38 +10:00
|
|
|
QString outputDatabaseFileName() const;
|
2016-01-04 22:51:18 +11:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Run import. This will parse the XML file and store the data in a SQLite database.
|
|
|
|
* @return true on success, false when import failed (see errorString() for the error)
|
|
|
|
*/
|
|
|
|
bool import();
|
|
|
|
|
|
|
|
bool hasError() const;
|
|
|
|
QString errorString() const;
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void progress( int percent );
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
|
|
|
bool createDatabase();
|
|
|
|
bool closeDatabase();
|
|
|
|
|
|
|
|
//! @note not available in Python bindings
|
2017-05-01 18:13:15 +02:00
|
|
|
//void deleteStatement( sqlite3_stmt* &stmt );
|
2016-01-04 22:51:18 +11:00
|
|
|
|
|
|
|
bool createIndexes();
|
|
|
|
|
2017-05-01 18:13:15 +02:00
|
|
|
void readRoot( QXmlStreamReader &xml );
|
|
|
|
void readNode( QXmlStreamReader &xml );
|
|
|
|
void readWay( QXmlStreamReader &xml );
|
|
|
|
void readTag( bool way, qint64 id, QXmlStreamReader &xml );
|
2016-01-04 22:51:18 +11:00
|
|
|
|
|
|
|
};
|
|
|
|
|