libosmscout  1.1.1
RouteStep.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_CLIENT_QT_ROUTESTEP_H
2 #define OSMSCOUT_CLIENT_QT_ROUTESTEP_H
3 
4 /*
5  OSMScout - a Qt backend for libosmscout and libosmscout-map
6  Copyright (C) 2010 Tim Teulings
7  Copyright (C) 2017 Lukas Karas
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22  */
23 
25 
26 #include <osmscout/util/Time.h>
27 #include <osmscout/util/Distance.h>
28 #include <osmscout/GeoCoord.h>
29 
30 #include <QObject>
31 
32 namespace osmscout {
33 
42 class OSMSCOUT_CLIENT_QT_API RouteStep : public QObject
43 {
44  Q_OBJECT
45  Q_PROPERTY(QString type READ getType NOTIFY update)
46  Q_PROPERTY(double lat READ getLat() NOTIFY update)
47  Q_PROPERTY(double lon READ getLon() NOTIFY update)
48  Q_PROPERTY(double distance READ getDistance NOTIFY update)
49  Q_PROPERTY(double distanceDelta READ getDistanceDelta NOTIFY update)
50  Q_PROPERTY(double distanceTo READ getDistanceTo NOTIFY update)
51  Q_PROPERTY(double time READ getTime NOTIFY update)
52  Q_PROPERTY(double timeDelta READ getTimeDelta NOTIFY update)
53  Q_PROPERTY(QString description READ getDescription NOTIFY update)
54  Q_PROPERTY(QString shortDescription READ getShortDescription NOTIFY update)
55  Q_PROPERTY(QStringList streetNames READ getStreetNames NOTIFY update)
56  Q_PROPERTY(int roundaboutExit READ getRoundaboutExit NOTIFY update)
57  Q_PROPERTY(bool roundaboutClockwise READ getRoundaboutClockwise NOTIFY update)
58 
59 signals:
60  void update();
61 
62 public:
63  enum Roles {
64  ShortDescriptionRole = Qt::UserRole + 1,
65  DescriptionRole = Qt::UserRole + 2,
66  TypeRole = Qt::UserRole + 3,
67  RoundaboutExitRole = Qt::UserRole + 4,
68  RoundaboutClockwiseRole = Qt::UserRole + 5,
69  latRole = Qt::UserRole + 6,
70  lonRole = Qt::UserRole + 7,
71  distanceRole = Qt::UserRole + 8,
72  distanceDeltaRole = Qt::UserRole + 9,
73  distanceToRole = Qt::UserRole + 10,
74  timeRole = Qt::UserRole + 11,
75  timeDeltaRole = Qt::UserRole + 12
76  };
77  Q_ENUM(Roles)
78 
79 public:
80  QString type;
81  GeoCoord coord;
82  Distance distance;
83  Distance distanceDelta;
84  Distance distanceTo;
87  QString description;
88  QString shortDescription;
89  QStringList streetNames;
90  int roundaboutExit{-1};
91 
98  bool roundaboutClockwise{false};
99 
100 public:
101  inline RouteStep() : RouteStep("", GeoCoord(), Distance::Zero(), Distance::Zero(),
102  Duration::zero(), Duration::zero(),
103  QStringList())
104  {};
105 
106  RouteStep(const QString &type,
107  const GeoCoord &coord,
108  const Distance &distance,
109  const Distance &distanceDelta,
110  const Duration &time,
111  const Duration &timeDelta,
112  const QStringList &streetNames);
113 
114  RouteStep(const RouteStep& other);
115 
116  RouteStep& operator=(const RouteStep& other);
117 
118  QString getType() const
119  {
120  return type;
121  };
122 
123  GeoCoord GetCoord() const
124  {
125  return coord;
126  }
127 
128  double getLat() const
129  {
130  return coord.GetLat();
131  }
132 
133  double getLon() const
134  {
135  return coord.GetLon();
136  }
137 
138  Distance GetDistance() const
139  {
140  return distance;
141  }
142 
143  double getDistance() const
144  {
145  return distance.AsMeter();
146  }
147 
148  double getDistanceDelta() const
149  {
150  return distanceDelta.AsMeter();
151  }
152 
153  double getDistanceTo() const
154  {
155  return distanceTo.AsMeter();
156  }
157 
158  double getTime() const
159  {
160  return DurationAsSeconds(time);
161  }
162 
163  double getTimeDelta() const
164  {
165  return DurationAsSeconds(timeDelta);
166  }
167 
168  QString getDescription() const
169  {
170  return description;
171  }
172 
173  QString getShortDescription() const
174  {
175  return shortDescription;
176  }
177 
178  QStringList getStreetNames() const
179  {
180  return streetNames;
181  }
182 
183  int getRoundaboutExit() const
184  {
185  return roundaboutExit;
186  }
187 
189  {
190  return roundaboutClockwise;
191  }
192 
193  QVariant data(int role) const;
194 
195  static QHash<int, QByteArray> roleNames(QHash<int, QByteArray> roles);
196 
197 private:
198  void copyDynamicProperties(const RouteStep &other);
199 };
200 
201 }
202 
203 #endif //OSMSCOUT_CLIENT_QT_ROUTESTEP_H
Duration time
Estimate time from route start.
Definition: RouteStep.h:85
GeoCoord coord
Position.
Definition: RouteStep.h:81
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
Distance GetDistance() const
Definition: RouteStep.h:138
double getDistanceDelta() const
Definition: RouteStep.h:148
double DurationAsSeconds(Duration duration)
Definition: Time.h:33
int getRoundaboutExit() const
Definition: RouteStep.h:183
double getTimeDelta() const
Definition: RouteStep.h:163
double getDistance() const
Definition: RouteStep.h:143
Definition: Area.h:38
double getTime() const
Definition: RouteStep.h:158
double getLon() const
Definition: RouteStep.h:133
Definition: RouteStep.h:42
QString getType() const
Definition: RouteStep.h:118
RouteStep()
Definition: RouteStep.h:101
bool getRoundaboutClockwise() const
Definition: RouteStep.h:188
Roles
Definition: RouteStep.h:63
Duration timeDelta
Estimate time from previous route step.
Definition: RouteStep.h:86
QStringList getStreetNames() const
Definition: RouteStep.h:178
GeoCoord GetCoord() const
Definition: RouteStep.h:123
Timestamp::duration Duration
Definition: Time.h:29
double getDistanceTo() const
Definition: RouteStep.h:153
QString getDescription() const
Definition: RouteStep.h:168
double getLat() const
Definition: RouteStep.h:128
Distance distance
Estimate distance from route start.
Definition: RouteStep.h:82
Distance distanceDelta
Estimate distance from previous route step.
Definition: RouteStep.h:83
QString getShortDescription() const
Definition: RouteStep.h:173
Distance distanceTo
Estimate distance to this step (used with navigation)
Definition: RouteStep.h:84