libosmscout  1.1.1
VehiclePosition.h
Go to the documentation of this file.
1 #ifndef OSMSCOUT_CLIENT_QT_VEHICLEPOSITION_H
2 #define OSMSCOUT_CLIENT_QT_VEHICLEPOSITION_H
3 
4 /*
5  OSMScout - a Qt backend for libosmscout and libosmscout-map
6  Copyright (C) 2019 Lukas Karas
7 
8  This library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Lesser General Public
10  License as published by the Free Software Foundation; either
11  version 2.1 of the License, or (at your option) any later version.
12 
13  This library is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public
19  License along with this library; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21  */
22 
24 
26 #include <osmscout/util/Bearing.h>
27 
28 #include <QObject>
29 
30 #include <memory>
31 #include <optional>
32 
33 namespace osmscout {
34 
41 {
42  Q_OBJECT
43 
44  Q_PROPERTY(double lat READ getLat CONSTANT)
45  Q_PROPERTY(double lon READ getLon CONSTANT)
46  Q_PROPERTY(double bearing READ getBearingRadians CONSTANT)
47 
48 public:
49  inline explicit VehiclePosition(QObject *parent = nullptr) :
50  QObject(parent)
51  {}
52 
53  inline VehiclePosition(const Vehicle &vehicle,
54  const PositionAgent::PositionState &state,
55  const GeoCoord &coord,
56  const std::optional<Bearing> &bearing,
57  const std::optional<GeoCoord> &nextStepCoord,
58  QObject *parent = nullptr):
59  QObject(parent), vehicle(vehicle), state(state), coord(coord), bearing(bearing), nextStepCoord(nextStepCoord)
60  {}
61 
63  {
64  vehicle=o.vehicle;
65  state=o.state;
66  coord=o.coord;
67  bearing=o.bearing;
68  nextStepCoord=o.nextStepCoord;
69  return *this;
70  }
71 
72  inline double getLat() const
73  {
74  return coord.GetLat();
75  }
76 
77  inline double getLon() const
78  {
79  return coord.GetLon();
80  }
81 
82  inline GeoCoord getCoord() const
83  {
84  return coord;
85  }
86 
87  inline std::optional<Bearing> getBearing() const
88  {
89  return bearing;
90  }
91 
92  inline double getBearingRadians() const
93  {
94  return bearing ? bearing->AsRadians() : 0;
95  }
96 
97  inline std::optional<GeoCoord> getNextStepCoord() const
98  {
99  return nextStepCoord;
100  }
101 
102  inline PositionAgent::PositionState getState() const
103  {
104  return state;
105  }
106 
107 private:
108  Vehicle vehicle;
109  PositionAgent::PositionState state;
110  GeoCoord coord;
111  std::optional<Bearing> bearing;
112  std::optional<GeoCoord> nextStepCoord;
113 };
114 
115 }
116 
117 #endif //OSMSCOUT_CLIENT_QT_VEHICLEPOSITION_H
#define OSMSCOUT_CLIENT_QT_API
Definition: ClientQtImportExport.h:45
double bearing
Definition: VehiclePosition.h:46
PositionAgent::PositionState getState() const
Definition: VehiclePosition.h:102
Vehicle
Definition: OSMScoutTypes.h:55
VehiclePosition(const Vehicle &vehicle, const PositionAgent::PositionState &state, const GeoCoord &coord, const std::optional< Bearing > &bearing, const std::optional< GeoCoord > &nextStepCoord, QObject *parent=nullptr)
Definition: VehiclePosition.h:53
std::optional< Bearing > getBearing() const
Definition: VehiclePosition.h:87
Definition: Area.h:38
double getLat() const
Definition: VehiclePosition.h:72
GeoCoord getCoord() const
Definition: VehiclePosition.h:82
std::optional< GeoCoord > getNextStepCoord() const
Definition: VehiclePosition.h:97
Definition: VehiclePosition.h:40
double getLon() const
Definition: VehiclePosition.h:77
double getBearingRadians() const
Definition: VehiclePosition.h:92
VehiclePosition & operator=(const VehiclePosition &o)
Definition: VehiclePosition.h:62