forked from BlitzGLEP1326/vehicle-can-daq
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtrack.cpp
131 lines (110 loc) · 2.98 KB
/
track.cpp
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#include "track.h"
Track::Track(){
track_name_ = "";
state_ = "";
city_ = "";
postal_code_ = "";
latitude_ = 0.0;
longitude_ = 0.0;
length_ = 0.0;
turns_ = 0;
track_found_ = false;
}
Track::Track(const std::string &trackName, const std::string &state, const std::string &city, const std::string &postalCode,
const double &latitude, const double &longitude, const float &length, const unsigned short &turns) {
track_name_ = trackName;
state_ = state;
city_ = city;
postal_code_ = postalCode;
latitude_ = latitude;
longitude_ = longitude;
length_ = length;
turns_ = turns;
track_found_ = true;
}
Track::Track(const QJsonObject &jsonObj)
{
if(!jsonObj.isEmpty()) {
track_name_ = jsonObj["Track Name"].toString().toStdString();
state_ = jsonObj["State"].toString().toStdString();
city_ = jsonObj["City"].toString().toStdString();
postal_code_ = jsonObj["Postal Code"].toString().toStdString();
latitude_ = jsonObj["Latitude"].toDouble();
longitude_ = jsonObj["Longitude"].toDouble();
length_ = jsonObj["Length"].toDouble();
turns_ = jsonObj["Turns"].toInt();
track_found_ = true;
}
else {
track_name_ = "";
state_ = "";
city_ = "";
postal_code_ = "";
latitude_ = 0.0;
longitude_ = 0.0;
length_ = 0.0;
turns_ = 0;
track_found_ = false;
}
}
std::string Track::getTrackName() const {
return track_name_;
}
void Track::setTrackName(const std::string &trackName) {
track_name_ = trackName;
}
std::string Track::getState() const {
return state_;
}
void Track::setState(const std::string &state) {
state_ = state;
}
std::string Track::getCity() const {
return city_;
}
void Track::setCity(const std::string &city) {
city_ = city;
}
std::string Track::getPostalCode() const {
return postal_code_;
}
void Track::setPostalCode(const std::string &postalCode) {
postal_code_ = postalCode;
}
double Track::getLatitude() const {
return latitude_;
}
void Track::setLatitude(const double &latitude) {
latitude_ = latitude;
}
double Track::getLongitude() const {
return longitude_;
}
void Track::setLongitude(const double &longitude) {
longitude_ = longitude;
}
float Track::getLength() const {
return length_;
}
void Track::setLength(const float &length) {
length_ = length;
}
unsigned short Track::getTurns() const {
return turns_;
}
void Track::setTurns(const unsigned short &turns) {
turns_ = turns;
}
bool Track::trackFound() const {
return track_found_;
}
std::string Track::toString() const {
return track_name_ + "\n" +
state_ + "\n" +
city_ + "\n" +
postal_code_ + "\n" +
std::to_string(latitude_) + "\n" +
std::to_string(longitude_) + "\n" +
std::to_string(length_) + "\n" +
std::to_string(turns_);
}