Fix negative minute bug
This commit is contained in:
parent
12c8c77402
commit
dd917558ac
@ -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,
|
||||||
|
@ -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);
|
||||||
|
Loading…
Reference in New Issue
Block a user