pub struct TimeAndPos {
pub system_time: u32,
pub unix_time: u32,
- pub latitude: i32, // Positive means north, negative means south.
- pub longitude: i32, // Positive means east, negative means west.
+ pub latitude_deg: i32, // Positive means north, negative means south.
+ pub longitude_deg: i32, // Positive means east, negative means west.
pub latitude_rad: Fixed, // Positive means north, negative means south.
pub longitude_rad: Fixed, // Positive means east, negative means west.
}
TimeAndPos {
system_time: 0,
unix_time: 0,
- latitude: 0,
- longitude: 0,
+ latitude_deg: 0,
+ longitude_deg: 0,
latitude_rad: Fixed::from_i64(0),
longitude_rad: Fixed::from_i64(0),
}
tap.system_time = systick::now();
tap.unix_time = unix_time;
- tap.latitude = parse_coordinate(latitude);
- tap.longitude = parse_coordinate(longitude);
+ tap.latitude_deg = parse_coordinate(latitude);
+ tap.longitude_deg = parse_coordinate(longitude);
tap.latitude_rad = parse_coordinate_q(latitude).to_radians();
tap.longitude_rad = parse_coordinate_q(longitude).to_radians();
if north_south == b"S" {
- tap.latitude = -tap.latitude;
+ tap.latitude_deg = -tap.latitude_deg;
tap.latitude_rad = -tap.latitude_rad;
}
if east_west == b"W" {
- tap.longitude = -tap.longitude;
+ tap.longitude_deg = -tap.longitude_deg;
tap.longitude_rad = -tap.longitude_rad;
}
self.prepare_write_buffer(true);
- self.write_packet(0, tap.latitude, tap.longitude);
+ self.write_packet(0, tap.latitude_deg, tap.longitude_deg);
self.recording_id
}
// the intervals to full seconds.
let d_time_s = (d_time_ms + 500) / 1000;
- let d_lat = tap.latitude - prev_tap.latitude;
- let d_lon = tap.longitude - prev_tap.longitude;
+ let d_lat = tap.latitude_deg - prev_tap.latitude_deg;
+ let d_lon = tap.longitude_deg - prev_tap.longitude_deg;
if self.write_packet(d_time_s, d_lat, d_lon) {
self.flush_in_flight(false);
assert_eq!(true, has_fix);
assert_eq!(1477998218, tap.unix_time);
- assert_eq!(7545678, tap.latitude);
- assert_eq!(74256789, tap.longitude);
+ assert_eq!(7545678, tap.latitude_deg);
+ assert_eq!(74256789, tap.longitude_deg);
assert_eq!(0.21949487565883447, tap.latitude_rad.to_f32());
assert_eq!(2.160042433347846, tap.longitude_rad.to_f32());
}
let tap0 = gps::TimeAndPos {
system_time: 0,
unix_time: 0,
- latitude: 0,
- longitude: 0,
+ latitude_deg: 0,
+ longitude_deg: 0,
latitude_rad: Fixed::from_f32(49.02541333).to_radians(),
longitude_rad: Fixed::from_f32(8.79440167).to_radians(),
};
let tap1 = gps::TimeAndPos {
system_time: 1,
unix_time: 1,
- latitude: 0,
- longitude: 0,
+ latitude_deg: 0,
+ longitude_deg: 0,
latitude_rad: Fixed::from_f32(49.02541000).to_radians(),
longitude_rad: Fixed::from_f32(8.79443667).to_radians(),
};
let tap = gps::TimeAndPos {
system_time: 0,
unix_time: 1478026311,
- latitude: 0x73234e,
- longitude: 0x73234f,
+ latitude_deg: 0x73234e,
+ longitude_deg: 0x73234f,
latitude_rad: Fixed::from_f32(12.57613).to_radians(),
longitude_rad: Fixed::from_f32(12.576131666666667).to_radians(),
};
let tap = gps::TimeAndPos {
system_time: 0,
unix_time: 1478026312,
- latitude: 0x73234e,
- longitude: 0x73234f,
+ latitude_deg: 0x73234e,
+ longitude_deg: 0x73234f,
latitude_rad: Fixed::from_f32(12.57613).to_radians(),
longitude_rad: Fixed::from_f32(12.576131666666667).to_radians(),
};
let tap = gps::TimeAndPos {
system_time: 0,
unix_time: 1578425250,
- latitude: 0x73234e,
- longitude: 0x73234f,
+ latitude_deg: 0x73234e,
+ longitude_deg: 0x73234f,
latitude_rad: Fixed::from_f32(12.57613).to_radians(),
longitude_rad: Fixed::from_f32(12.576131666666667).to_radians(),
};
let tap = gps::TimeAndPos {
system_time: 0,
unix_time: prev_tap.unix_time + 1,
- latitude: prev_tap.latitude + 1,
- longitude: prev_tap.longitude + 1,
+ latitude_deg: prev_tap.latitude_deg + 1,
+ longitude_deg: prev_tap.longitude_deg + 1,
latitude_rad: Fixed::from_f32(
- (prev_tap.latitude + 1) as f32 / 600000.0).to_radians(),
+ (prev_tap.latitude_deg + 1) as f32 / 600000.0).to_radians(),
longitude_rad: Fixed::from_f32(
- (prev_tap.longitude + 1) as f32 / 600000.0).to_radians(),
+ (prev_tap.longitude_deg + 1) as f32 / 600000.0).to_radians(),
};
logger.log(&prev_tap, &tap);
let tap0 = gps::TimeAndPos {
system_time: 0,
unix_time: 1478026311,
- latitude: 0x73234e,
- longitude: 0x73234f,
+ latitude_deg: 0x73234e,
+ longitude_deg: 0x73234f,
latitude_rad: Fixed::from_f32(12.57613).to_radians(),
longitude_rad: Fixed::from_f32(12.576131666666667).to_radians(),
};
let tap1 = gps::TimeAndPos {
system_time: 0,
unix_time: 1478026311 + 1,
- latitude: 0x73234e + 5,
- longitude: 0x73234f + 5,
+ latitude_deg: 0x73234e + 5,
+ longitude_deg: 0x73234f + 5,
latitude_rad: Fixed::from_f32(12.576138333333333).to_radians(),
longitude_rad: Fixed::from_f32(12.57614).to_radians(),
};
let tap2 = gps::TimeAndPos {
system_time: 0,
unix_time: 1478026311 + 2,
- latitude: 0x73234e + 10,
- longitude: 0x73234f + 10,
+ latitude_deg: 0x73234e + 10,
+ longitude_deg: 0x73234f + 10,
latitude_rad: Fixed::from_f32(12.576146666666666).to_radians(),
longitude_rad: Fixed::from_f32(12.576148333333334).to_radians(),
};