From 8fe440c759e09a2d227815d561c91cdb3b17f640 Mon Sep 17 00:00:00 2001 From: NetterSilver <133535268+Silvertree2010@users.noreply.github.com> Date: Tue, 20 Oct 2026 19:59:03 +0000 Subject: [PATCH] Carry rounded GPS minutes into degrees in XMP writer Found while testing crates/meta/src/xmp.rs:458 (fmt_gps_coord) Co-Authored-By: Claude Haiku 5.5 Co-Authored-By: Claude Sonnet 5.5 --- crates/meta/src/xmp.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/meta/src/xmp.rs b/crates/meta/src/xmp.rs index dbfdd5458..1fb789164 100644 --- a/crates/meta/src/xmp.rs +++ b/crates/meta/src/xmp.rs @@ -457,8 +457,12 @@ fn parse_one_region(item: &XmpValue, px_dims: Option<(f64, f64)>) -> Option String { let a = v.abs(); - let d = a.trunc(); - let m = (a - d) * 60.0; + let mut d = a.trunc(); + let mut m = ((a - d) * 60.0 * 1e6).round() / 1e6; + if m >= 60.0 { + d += 1.0; + m = 0.0; + } format!("{},{:.6}{}", d as i64, m, if v < 0.0 { neg } else { pos }) } @@ -866,6 +870,8 @@ mod tests { assert_eq!(parse_gps_coord(""), None); assert_eq!(parse_gps_coord("é"), None); assert_eq!(fmt_gps_coord(-45.51, 'N', 'S'), "45,30.600000S"); + assert_eq!(fmt_gps_coord(10.9999999999, 'N', 'S'), "11,0.000000N"); + assert_eq!(fmt_gps_coord(-0.9999999999, 'E', 'W'), "1,0.000000W"); } /// Like the EXIF and GPX readers, XMP drops a position outside latitude ±90° / longitude ±180°.