-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now all classes and members are either exposed to bindings or marked as "not available in Python bindings" in the docs. Drop test thresholds to 0. Now it should be much easier to determine what missing members have been added which are causing test failures.
- Loading branch information
1 parent
2341c2b
commit 881074b
Showing
165 changed files
with
1,542 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
typedef qint64 QgsOSMId; | ||
|
||
struct QgsOSMElementID | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsosmbase.h> | ||
%End | ||
enum Type { Invalid, Node, Way, Relation }; | ||
|
||
Type type; | ||
qint64 id; | ||
}; | ||
|
||
|
||
/** | ||
Elements (also data primitives) are the basic components in OpenStreetMap from which everything else | ||
is defined. These consist of Nodes (which define a point in space), Ways (which define a linear features | ||
and areas), and Relations - with an optional role - which are sometimes used to define the relation | ||
between other elements. All of the above can have one of more associated tags. | ||
*/ | ||
class QgsOSMElement | ||
{ | ||
|
||
%TypeHeaderCode | ||
#include <qgsosmbase.h> | ||
%End | ||
|
||
public: | ||
QgsOSMElement(); | ||
QgsOSMElement( QgsOSMElementID::Type t, qint64 id ); | ||
|
||
bool isValid() const; | ||
|
||
// fetched automatically from DB | ||
QgsOSMElementID elemID() const; | ||
qint64 id() const; | ||
//QString username() const; | ||
//QDateTime timestamp() const; | ||
//int version() const; | ||
|
||
}; | ||
|
||
|
||
|
||
/** | ||
A node is one of the core elements in the OpenStreetMap data model. It consists of a single geospatial | ||
point using a latitude and longitude. A third optional dimension, altitude, can be recorded; key:ele | ||
and a node can also be defined at a particular layer=* or level=*. Nodes can be used to define standalone | ||
point features or be used to define the path of a way. | ||
*/ | ||
class QgsOSMNode : QgsOSMElement | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsosmbase.h> | ||
%End | ||
public: | ||
QgsOSMNode(); | ||
QgsOSMNode( qint64 id, const QgsPoint& point ); | ||
|
||
QgsPoint point() const; | ||
|
||
}; | ||
|
||
|
||
/** | ||
A way is an ordered list of nodes which normally also has at least one tag or is included within | ||
a Relation. A way can have between 2 and 2,000 nodes, although it's possible that faulty ways with zero | ||
or a single node exist. A way can be open or closed. A closed way is one whose last node on the way | ||
is also the first on that way. A closed way may be interpreted either as a closed polyline, or an area, | ||
or both. | ||
*/ | ||
class QgsOSMWay : QgsOSMElement | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsosmbase.h> | ||
%End | ||
public: | ||
QgsOSMWay(); | ||
QgsOSMWay( qint64 id, const QList<qint64>& nodes ); | ||
|
||
QList<qint64> nodes() const; | ||
|
||
// fetched on-demand | ||
//QList<OSMElementID> relations() const; | ||
|
||
}; | ||
|
||
/** | ||
* This class is a container of tags for a node, way or a relation. | ||
*/ | ||
class QgsOSMTags | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsosmbase.h> | ||
%End | ||
public: | ||
QgsOSMTags(); | ||
|
||
int count() const; | ||
QList<QString> keys() const; | ||
bool contains( const QString& k ) const; | ||
void insert( const QString& k, const QString& v ); | ||
QString value( const QString& k ) const; | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
typedef QPair<QString, int> QgsOSMTagCountPair; | ||
|
||
/** | ||
* Class that encapsulates access to OpenStreetMap data stored in a database | ||
* previously imported from XML file. | ||
* | ||
* Internal database structure consists of the following tables: | ||
* - nodes | ||
* - nodes_tags | ||
* - ways | ||
* - ways_tags | ||
* - ways_nodes | ||
* | ||
* The topology representation can be translated to simple features representation | ||
* using exportSpatiaLite() method into SpatiaLite layers (tables). These can be | ||
* easily used in QGIS like any other layers. | ||
*/ | ||
class QgsOSMDatabase | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsosmdatabase.h> | ||
%End | ||
public: | ||
explicit QgsOSMDatabase( const QString& dbFileName = QString() ); | ||
~QgsOSMDatabase(); | ||
|
||
void setFileName( const QString& dbFileName ); | ||
QString filename() const; | ||
bool isOpen() const; | ||
|
||
bool open(); | ||
bool close(); | ||
|
||
QString errorString() const; | ||
|
||
// data access | ||
|
||
int countNodes() const; | ||
int countWays() const; | ||
|
||
//! @note not available in Python bindings | ||
//QgsOSMNodeIterator listNodes() const; | ||
//! @note not available in Python bindings | ||
//QgsOSMWayIterator listWays() const; | ||
|
||
QgsOSMNode node( qint64 id ) const; | ||
QgsOSMWay way( qint64 id ) const; | ||
//OSMRelation relation( OSMId id ) const; | ||
|
||
QgsOSMTags tags( bool way, qint64 id ) const; | ||
|
||
//! @note available in Python bindings | ||
//QList<QPair<QString, int>> usedTags( bool ways ) const; | ||
|
||
QgsPolyline wayPoints( qint64 id ) const; | ||
|
||
// export to spatialite | ||
|
||
enum ExportType { Point, Polyline, Polygon }; | ||
bool exportSpatiaLite( ExportType type, const QString& tableName, | ||
const QStringList& tagKeys = QStringList(), | ||
const QStringList& noNullTagKeys = QStringList() ); | ||
|
||
protected: | ||
bool prepareStatements(); | ||
int runCountStatement( const char* sql ) const; | ||
|
||
/** @note not available in Python bindings | ||
*/ | ||
//void deleteStatement( sqlite3_stmt*& stmt ); | ||
|
||
void exportSpatiaLiteNodes( const QString& tableName, const QStringList& tagKeys, const QStringList& notNullTagKeys = QStringList() ); | ||
void exportSpatiaLiteWays( bool closed, const QString& tableName, const QStringList& tagKeys, const QStringList& notNullTagKeys = QStringList() ); | ||
bool createSpatialTable( const QString& tableName, const QString& geometryType, const QStringList& tagKeys ); | ||
bool createSpatialIndex( const QString& tableName ); | ||
|
||
QString quotedIdentifier( QString id ); | ||
QString quotedValue( QString value ); | ||
|
||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @brief OSMDownload is a utility class for downloading OpenStreetMap via Overpass API. | ||
* | ||
* To use this class, it is necessary to set query, output file name and start the request. | ||
* The interface is asynchronous, the caller has to wait for finished() signal that is | ||
* emitted whe the request has finished (successfully or with an error). | ||
* | ||
* To check whether the the request has been successful, check hasError() and use errorString() | ||
* to retreive error message. An error may happen either directly in start() method | ||
* or during the network communication. | ||
* | ||
* By default OSMDownload uses remote service at location returned by defaultServiceUrl() method. | ||
*/ | ||
class QgsOSMDownload : QObject | ||
{ | ||
%TypeHeaderCode | ||
#include <qgsosmdownload.h> | ||
%End | ||
public: | ||
|
||
//! Return URL of the service that is used by default | ||
static QString defaultServiceUrl(); | ||
|
||
//! Create query (in Overpass Query Language) that fetches everything in given rectangle | ||
static QString queryFromRect( const QgsRectangle& rect ); | ||
|
||
QgsOSMDownload(); | ||
~QgsOSMDownload(); | ||
|
||
void setServiceUrl( const QString& serviceUrl ); | ||
QString serviceUrl() const; | ||
|
||
void setQuery( const QString& query ); | ||
QString query() const; | ||
|
||
void setOutputFileName( const QString& outputFileName ); | ||
QString outputFileName() const; | ||
|
||
bool hasError() const; | ||
QString errorString() const; | ||
|
||
/** | ||
* @brief Starts network request for data. The prerequisite is that the query string and output | ||
* file name have been set. | ||
* | ||
* Only one request may be pending at one point - if you need more requests at once, use several instances. | ||
* | ||
* @return true if the network request has been issued, false otherwise (and sets error string) | ||
*/ | ||
bool start(); | ||
|
||
/** | ||
* @brief Aborts current pending request | ||
* @return true if there is a pending request and has been aborted, false otherwise | ||
*/ | ||
bool abort(); | ||
|
||
//! Returns true if the request has already finished | ||
bool isFinished() const; | ||
|
||
signals: | ||
void finished(); //!< emitted when the network reply has finished (with success or with an error) | ||
void downloadProgress( qint64, qint64 ); //!< normally the total length is not known (until we reach end) | ||
|
||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
|
||
/** | ||
* @brief The QgsOSMXmlImport class imports OpenStreetMap XML format to our topological representation | ||
* in a SQLite database (see QgsOSMDatabase for details). | ||
* | ||
* How to use the classs: | ||
* 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: | ||
explicit QgsOSMXmlImport( const QString& xmlFileName = QString(), const QString& dbFileName = QString() ); | ||
|
||
void setInputXmlFileName( const QString& xmlFileName ); | ||
QString inputXmlFileName() const; | ||
|
||
void setOutputDbFileName( const QString& dbFileName ); | ||
QString outputDbFileName() const; | ||
|
||
/** | ||
* 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 | ||
//void deleteStatement( sqlite3_stmt*& stmt ); | ||
|
||
bool createIndexes(); | ||
|
||
void readRoot( QXmlStreamReader& xml ); | ||
void readNode( QXmlStreamReader& xml ); | ||
void readWay( QXmlStreamReader& xml ); | ||
void readTag( bool way, qint64 id, QXmlStreamReader& xml ); | ||
|
||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,4 +86,6 @@ class QgsRasterMatrix | |
bool tangens(); | ||
bool atangens(); | ||
bool changeSign(); | ||
bool log(); | ||
bool log10(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
881074b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow nice work.