forked from chozabu/FriendMap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PositionManager.h
62 lines (48 loc) · 1.47 KB
/
PositionManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef POSITIONMANAGER_H
#define POSITIONMANAGER_H
#include <marble/GeoDataCoordinates.h>
#include <math.h>
#include <retroshare/rsdisc.h>
#include <retroshare/rsplugin.h>
#include <QMap>
#define TAU 6.28318530718
using namespace Marble;
class GeoPeerLoc;
class Offset {
public:
Offset();
Offset(double angle, double distance);
Offset getIncreased();
GeoDataCoordinates offsetCoord(const GeoDataCoordinates& coord) const;
private:
static constexpr double angular_step = TAU / 10.0;
double distance;
double angle;
};
class PositionManager {
public:
const GeoDataCoordinates getPosition(const GeoPeerLoc& geoloc);
/*!
* \brief getPosition Looks for the position corresponding to a ssl_id. Only call this if after ssl_id was inserted into the PositionManager.
* \param ssl_id
* \return Pointer to an GeoDataCoordinates object.
*/
GeoDataCoordinates getPosition(const RsPeerId ssl_id) {
return map.value(ssl_id);
}
static PositionManager& instance() {
static PositionManager instance;
return instance;
}
private:
PositionManager();
PositionManager(const PositionManager&);
PositionManager& operator=(const PositionManager&);
QMap<RsPeerId, GeoDataCoordinates> map;
QMap<std::pair<double, double>, Offset> coord_map;
double roundCoord(double x) {
int precision = 1000;
return roundf(x * precision) / precision;
}
};
#endif // POSITIONMANAGER_H