QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
qgsosmbase.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsosmbase.h
3  ---------------------
4  begin : February 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 #ifndef OSMBASE_H
16 #define OSMBASE_H
17 
18 #include <QString>
19 
20 #include "qgspoint.h"
21 
22 #include <sqlite3.h>
23 
24 typedef qint64 QgsOSMId;
25 
26 class QgsOSMDatabase;
27 
29 {
30  enum Type { Invalid, Node, Way, Relation };
31 
34 };
35 
36 
43 class ANALYSIS_EXPORT QgsOSMElement
44 {
45  public:
46  QgsOSMElement() { mElemID.type = QgsOSMElementID::Invalid; mElemID.id = 0; }
47  QgsOSMElement( QgsOSMElementID::Type t, QgsOSMId id ) { mElemID.type = t; mElemID.id = id; }
48 
49  bool isValid() const { return mElemID.type != QgsOSMElementID::Invalid; }
50 
51  // fetched automatically from DB
52  QgsOSMElementID elemID() const { return mElemID; }
53  QgsOSMId id() const { return mElemID.id; }
54  //QString username() const;
55  //QDateTime timestamp() const;
56  //int version() const;
57 
58  private:
59  QgsOSMElementID mElemID;
60 };
61 
62 
63 
70 class ANALYSIS_EXPORT QgsOSMNode : public QgsOSMElement
71 {
72  public:
73  QgsOSMNode() : mPoint() {}
74  QgsOSMNode( QgsOSMId id, const QgsPoint& point )
76  , mPoint( point )
77  {}
78 
79  QgsPoint point() const { return mPoint; }
80 
81  private:
82  QgsPoint mPoint;
83 };
84 
85 
93 class ANALYSIS_EXPORT QgsOSMWay : public QgsOSMElement
94 {
95  public:
96  QgsOSMWay() {}
97  QgsOSMWay( QgsOSMId id, const QList<QgsOSMId>& nodes )
99  , mNodes( nodes )
100  {}
101 
102  QList<QgsOSMId> nodes() const { return mNodes; }
103 
104  // fetched on-demand
105  //QList<OSMElementID> relations() const;
106 
107  private:
108  QList<QgsOSMId> mNodes;
109 };
110 
111 
112 #if 0
113 
119 class ANALYSIS_EXPORT QgsOSMRelation : public QgsOSMElement
120 {
121  public:
122  QString relationType() const;
123 
124  QList< QPair<QgsOSMElementID, QString> > members() const;
125 };
126 #endif
127 
131 class ANALYSIS_EXPORT QgsOSMTags
132 {
133  public:
135 
136  int count() const { return mMap.count(); }
137  QList<QString> keys() const { return mMap.keys(); }
138  bool contains( const QString& k ) const { return mMap.contains( k ); }
139  void insert( const QString& k, const QString& v ) { mMap.insert( k, v ); }
140  QString value( const QString& k ) const { return mMap.value( k ); }
141 
142  private:
144 };
145 
146 #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:93
QgsOSMId id() const
Definition: qgsosmbase.h:53
Node is a class used by Line3D.
Definition: Node.h:24
int count() const
Definition: qgsosmbase.h:136
Elements (also data primitives) are the basic components in OpenStreetMap from which everything else ...
Definition: qgsosmbase.h:43
QString value(const QString &k) const
Definition: qgsosmbase.h:140
bool isValid() const
Definition: qgsosmbase.h:49
qint64 QgsOSMId
Definition: qgsosmbase.h:24
void insert(const QString &k, const QString &v)
Definition: qgsosmbase.h:139
QList< QString > keys() const
Definition: qgsosmbase.h:137
This class is a container of tags for a node, way or a relation.
Definition: qgsosmbase.h:131
QgsOSMWay(QgsOSMId id, const QList< QgsOSMId > &nodes)
Definition: qgsosmbase.h:97
QgsOSMId id
Definition: qgsosmbase.h:33
A node is one of the core elements in the OpenStreetMap data model.
Definition: qgsosmbase.h:70
Class that encapsulates access to OpenStreetMap data stored in a database previously imported from XM...
QgsOSMElement(QgsOSMElementID::Type t, QgsOSMId id)
Definition: qgsosmbase.h:47
A class to represent a point.
Definition: qgspoint.h:117
QList< QgsOSMId > nodes() const
Definition: qgsosmbase.h:102
QgsOSMNode(QgsOSMId id, const QgsPoint &point)
Definition: qgsosmbase.h:74
QgsPoint point() const
Definition: qgsosmbase.h:79
QgsOSMElementID elemID() const
Definition: qgsosmbase.h:52
bool contains(const QString &k) const
Definition: qgsosmbase.h:138