-
Notifications
You must be signed in to change notification settings - Fork 1
/
navsatfixmsg.hpp
91 lines (67 loc) · 2.56 KB
/
navsatfixmsg.hpp
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef POSITIONMSG_HPP
#define POSITIONMSG_HPP
#include "base64.hpp"
#include <string>
#include <vector>
class navsatfixmsg
{
public:
int8_t status;
uint8_t service;
double latitude;
double longitude;
double altitude;
double covariance[9];
uint8_t position_covariance_type;
navsatfixmsg() { }
navsatfixmsg(const std::string& message)
{
size_t start, size;
start = message.find("{\"status\": ") + 11;
size = message.substr(start).find(",");
status = std::stoi(message.substr(start, size).c_str());
start = message.find("\"service\": ") + 11;
size = message.substr(start).find(",");
service = std::stoi(message.substr(start, size).c_str());
start = message.find("\"latitude\": ") + 12;
size = message.substr(start).find(",");
latitude = std::atof(message.substr(start, size).c_str());
start = message.find("\"longitude\": ") + 13;
size = message.substr(start).find(",");
longitude = std::atof(message.substr(start, size).c_str());
start = message.find("\"altitude\": ") + 12;
size = message.substr(start).find(",");
altitude = std::atof(message.substr(start, size).c_str());
start = message.find("\"position_covariance\": [") + 24;
size = message.substr(start).find(",");
covariance[0] = std::atof(message.substr(start, size).c_str());
start += size + 1;
size = message.substr(start).find(",");
covariance[1] = std::atof(message.substr(start, size).c_str());
start += size + 1;
size = message.substr(start).find(",");
covariance[2] = std::atof(message.substr(start, size).c_str());
start += size + 1;
size = message.substr(start).find(",");
covariance[3] = std::atof(message.substr(start, size).c_str());
start += size + 1;
size = message.substr(start).find(",");
covariance[4] = std::atof(message.substr(start, size).c_str());
start += size + 1;
size = message.substr(start).find(",");
covariance[5] = std::atof(message.substr(start, size).c_str());
start += size + 1;
size = message.substr(start).find(",");
covariance[6] = std::atof(message.substr(start, size).c_str());
start += size + 1;
size = message.substr(start).find(",");
covariance[7] = std::atof(message.substr(start, size).c_str());
start += size + 1;
size = message.substr(start).find("]");
covariance[8] = std::atof(message.substr(start, size).c_str());
start = message.find("\"position_covariance_type\": ") + 28;
size = 2;
position_covariance_type = std::stoi(message.substr(start, size).c_str());
}
};
#endif // POSITIONMSG_HPP