From 8131a71527b5279bca9b80aac37596f6264ea2a1 Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Sun, 19 Jan 2020 21:11:29 +0100 Subject: [PATCH] common: Rename TimeAndPos::latitude to latitude_deg. Same for longitude. --- src/common/gps.rs | 16 ++++++++-------- src/common/logger.rs | 6 +++--- test/gps_test.rs | 12 ++++++------ test/logger_test.rs | 32 ++++++++++++++++---------------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/common/gps.rs b/src/common/gps.rs index 85e1dd4..bda3670 100644 --- a/src/common/gps.rs +++ b/src/common/gps.rs @@ -46,8 +46,8 @@ pub struct Gps { 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. } @@ -57,8 +57,8 @@ impl TimeAndPos { 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), } @@ -430,18 +430,18 @@ impl Gps { 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; } diff --git a/src/common/logger.rs b/src/common/logger.rs index 1c982af..8a1c05c 100644 --- a/src/common/logger.rs +++ b/src/common/logger.rs @@ -360,7 +360,7 @@ impl<'a> Logger<'a> { 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 } @@ -376,8 +376,8 @@ impl<'a> Logger<'a> { // 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); diff --git a/test/gps_test.rs b/test/gps_test.rs index 7a71a76..57c8899 100644 --- a/test/gps_test.rs +++ b/test/gps_test.rs @@ -85,8 +85,8 @@ $GPGGA,110338.000,1234.5678,N,12345.6789,E,\ 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()); } @@ -96,8 +96,8 @@ fn distance_cm0() { 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(), }; @@ -105,8 +105,8 @@ fn distance_cm0() { 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(), }; diff --git a/test/logger_test.rs b/test/logger_test.rs index 7b0cdbd..a030821 100644 --- a/test/logger_test.rs +++ b/test/logger_test.rs @@ -116,8 +116,8 @@ fn first_recording() { 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(), }; @@ -172,8 +172,8 @@ fn second_recording() { 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(), }; @@ -219,8 +219,8 @@ fn multi_sector_recording() { 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(), }; @@ -234,12 +234,12 @@ fn multi_sector_recording() { 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); @@ -335,8 +335,8 @@ fn get_recording_valid() { 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(), }; @@ -346,8 +346,8 @@ fn get_recording_valid() { 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(), }; @@ -357,8 +357,8 @@ fn get_recording_valid() { 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(), }; -- 2.30.2