From 3ebd9c3e907e5f9374b78dac4684318dc0fde5dd Mon Sep 17 00:00:00 2001 From: Anders Brander Date: Fri, 5 Apr 2024 00:43:52 +0200 Subject: [PATCH] Increase precision of GpsDegrees.Raw(). --- v3/gps.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/v3/gps.go b/v3/gps.go index 7a61cd9..672b365 100644 --- a/v3/gps.go +++ b/v3/gps.go @@ -77,14 +77,15 @@ func (d GpsDegrees) Decimal() float64 { return decimal } -// Raw returns a Rational struct that can be used to *write* coordinates. In -// practice, the denominator are typically (1) in the original EXIF data, and, -// that being the case, this will best preserve precision. +// Raw returns a slice of Rationals that can be used to *write* coordinates. The +// conversion uses a denominator of 1 for degrees and minutes and 1000 for +// seconds. These denominators are not necessarily the same as the original +// data, but they will provide a precision of about an inch at the equator. func (d GpsDegrees) Raw() []exifcommon.Rational { return []exifcommon.Rational{ {Numerator: uint32(d.Degrees), Denominator: 1}, {Numerator: uint32(d.Minutes), Denominator: 1}, - {Numerator: uint32(d.Seconds), Denominator: 1}, + {Numerator: uint32(d.Seconds * 1000.0), Denominator: 1000}, } }