QGIS API Documentation  2.14.0-Essen
qgsosmbase.h
Go to the documentation of this file.
1 #ifndef OSMBASE_H
2 #define OSMBASE_H
3 
4 #include <QString>
5 
6 #include "qgspoint.h"
7 
8 #include <sqlite3.h>
9 
10 typedef qint64 QgsOSMId;
11 
12 class QgsOSMDatabase;
13 
15 {
16  enum Type { Invalid, Node, Way, Relation };
17 
20 };
21 
22 
29 class ANALYSIS_EXPORT QgsOSMElement
30 {
31  public:
32  QgsOSMElement() { mElemID.type = QgsOSMElementID::Invalid; mElemID.id = 0; }
33  QgsOSMElement( QgsOSMElementID::Type t, QgsOSMId id ) { mElemID.type = t; mElemID.id = id; }
34 
35  bool isValid() const { return mElemID.type != QgsOSMElementID::Invalid; }
36 
37  // fetched automatically from DB
38  QgsOSMElementID elemID() const { return mElemID; }
39  QgsOSMId id() const { return mElemID.id; }
40  //QString username() const;
41  //QDateTime timestamp() const;
42  //int version() const;
43 
44  private:
45  QgsOSMElementID mElemID;
46 };
47 
48 
49 
56 class ANALYSIS_EXPORT QgsOSMNode : public QgsOSMElement
57 {
58  public:
59  QgsOSMNode() : mPoint() {}
60  QgsOSMNode( QgsOSMId id, const QgsPoint& point ) : QgsOSMElement( QgsOSMElementID::Node, id ), mPoint( point ) {}
61 
62  QgsPoint point() const { return mPoint; }
63 
64  private:
65  QgsPoint mPoint;
66 };
67 
68 
76 class ANALYSIS_EXPORT QgsOSMWay : public QgsOSMElement
77 {
78  public:
79  QgsOSMWay() {}
80  QgsOSMWay( QgsOSMId id, const QList<QgsOSMId>& nodes ) : QgsOSMElement( QgsOSMElementID::Way, id ), mNodes( nodes ) {}
81 
82  QList<QgsOSMId> nodes() const { return mNodes; }
83 
84  // fetched on-demand
85  //QList<OSMElementID> relations() const;
86 
87  private:
88  QList<QgsOSMId> mNodes;
89 };
90 
91 
92 #if 0
93 
99 class ANALYSIS_EXPORT QgsOSMRelation : public QgsOSMElement
100 {
101  public:
102  QString relationType() const;
103 
104  QList< QPair<QgsOSMElementID, QString> > members() const;
105 };
106 #endif
107 
111 class ANALYSIS_EXPORT QgsOSMTags
112 {
113  public:
115 
116  int count() const { return mMap.count(); }
117  QList<QString> keys() const { return mMap.keys(); }
118  bool contains( const QString& k ) const { return mMap.contains( k ); }
119  void insert( const QString& k, const QString& v ) { mMap.insert( k, v ); }
120  QString value( const QString& k ) const { return mMap.value( k ); }
121 
122  private:
124 };
125 
126 #endif // OSMBASE_H
A way is an ordered list of nodes which normally also has at least one tag or is included within a Re...
Definition: qgsosmbase.h:76
QgsOSMId id() const
Definition: qgsosmbase.h:39
Node is a class used by Line3D.
Definition: Node.h:23
int count() const
Definition: qgsosmbase.h:116
Elements (also data primitives) are the basic components in OpenStreetMap from which everything else ...
Definition: qgsosmbase.h:29
QString value(const QString &k) const
Definition: qgsosmbase.h:120
bool isValid() const
Definition: qgsosmbase.h:35
qint64 QgsOSMId
Definition: qgsosmbase.h:10
void insert(const QString &k, const QString &v)
Definition: qgsosmbase.h:119
QList< QString > keys() const
Definition: qgsosmbase.h:117
This class is a container of tags for a node, way or a relation.
Definition: qgsosmbase.h:111
QgsOSMWay(QgsOSMId id, const QList< QgsOSMId > &nodes)
Definition: qgsosmbase.h:80
QgsOSMId id
Definition: qgsosmbase.h:19
A node is one of the core elements in the OpenStreetMap data model.
Definition: qgsosmbase.h:56
Class that encapsulates access to OpenStreetMap data stored in a database previously imported from XM...
QgsOSMElement(QgsOSMElementID::Type t, QgsOSMId id)
Definition: qgsosmbase.h:33
A class to represent a point.
Definition: qgspoint.h:65
QList< QgsOSMId > nodes() const
Definition: qgsosmbase.h:82
QgsOSMNode(QgsOSMId id, const QgsPoint &point)
Definition: qgsosmbase.h:60
QgsPoint point() const
Definition: qgsosmbase.h:62
QgsOSMElementID elemID() const
Definition: qgsosmbase.h:38
bool contains(const QString &k) const
Definition: qgsosmbase.h:118