-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathLatitude.cpp
More file actions
45 lines (39 loc) · 1.18 KB
/
Latitude.cpp
File metadata and controls
45 lines (39 loc) · 1.18 KB
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
#include "../Configuration.hpp"
#include "Utility.hpp"
#include "Latitude.hpp"
//////////////////////////////////////////////////////////////////////////////////////
//
// 90 is north pole, -90 is south pole
Latitude::Latitude(const Latitude &other) : DayTime(other)
{
}
Latitude::Latitude(int h, int m, int s) : DayTime(h, m, s)
{
}
Latitude::Latitude(float inDegrees) : DayTime(inDegrees)
{
}
void Latitude::checkHours()
{
if (totalSeconds > 90L * 3600L)
{
LOG(DEBUG_GENERAL, "[LATITUDE]: CheckHours: Degrees is more than 90, clamping");
totalSeconds = 90L * 3600L;
}
if (totalSeconds < (-90L * 3600L))
{
LOG(DEBUG_GENERAL, "[LATITUDE]: CheckHours: Degrees is less than -90, clamping");
totalSeconds = -90L * 3600L;
}
}
Latitude Latitude::ParseFromMeade(String const &s)
{
Latitude result(0.0);
LOG(DEBUG_MEADE, "[LATITUDE]: Latitude.Parse(%s)", s.c_str());
// Use the DayTime code to parse it.
DayTime dt = DayTime::ParseFromMeade(s);
result.totalSeconds = dt.getTotalSeconds();
result.checkHours();
LOG(DEBUG_MEADE, "[LATITUDE]: Latitude.Parse(%s) -> %s", s.c_str(), result.ToString());
return result;
}