-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.c
More file actions
26 lines (22 loc) · 677 Bytes
/
utils.c
File metadata and controls
26 lines (22 loc) · 677 Bytes
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
#include "meta_ext.h"
double rational_to_double(Rational number) {
return number.denominator == 0 ? 0.0 : (double)number.numerator / number.denominator;
}
double convert_to_decimal(Rational *coords, char ref) {
if(!coords)
return 0;
double deg = rational_to_double(coords[0]);
double min = rational_to_double(coords[1]);
double sec = rational_to_double(coords[2]);
double result = deg + min / 60.0 + sec / 3600.0;
if (ref == 'S' || ref == 'W')
result *= -1.0;
return result;
}
GPS_Coord convert_coord(Rational *coords) {
GPS_Coord result;
result.degrees = coords[0];
result.minutes = coords[1];
result.seconds = coords[2];
return result;
}