Fix negative minute bug

This commit is contained in:
Austen Adler 2023-04-22 14:02:30 -04:00
parent 12c8c77402
commit dd917558ac
2 changed files with 2 additions and 3 deletions

View File

@ -108,7 +108,7 @@ impl DMM {
pub fn from_decimal_degrees(d: f64, is_latitude: bool) -> Self { pub fn from_decimal_degrees(d: f64, is_latitude: bool) -> Self {
let degrees = d as i16; let degrees = d as i16;
let minutes = d.fract() * 60_f64; let minutes = d.abs().fract() * 60_f64;
let (degrees, direction) = normalize_degrees_direction( let (degrees, direction) = normalize_degrees_direction(
degrees, degrees,

View File

@ -108,7 +108,7 @@ impl DMS {
pub fn from_decimal_degrees(d: f64, is_latitude: bool) -> Self { pub fn from_decimal_degrees(d: f64, is_latitude: bool) -> Self {
let degrees = d as i16; let degrees = d as i16;
let minutes = d.fract() * 60_f64; let minutes = d.abs().fract() * 60_f64;
let seconds = minutes.fract() * 60_f64; let seconds = minutes.fract() * 60_f64;
let minutes = minutes as i16; let minutes = minutes as i16;
@ -187,7 +187,6 @@ mod tests {
eprintln!("Testing: {} => {:?}", $tt, cvt); eprintln!("Testing: {} => {:?}", $tt, cvt);
assert!(cvt.is_ok()); assert!(cvt.is_ok());
eprintln!("Now converting to latlon"); eprintln!("Now converting to latlon");
// assert!(dbg!(TryInto::<LatLon>::try_into(cvt.unwrap())).is_ok());
}}; }};
($tt:tt, DMS) => {{ ($tt:tt, DMS) => {{
let cvt = DMS::parse($tt); let cvt = DMS::parse($tt);