Change Ifd.GpsInfo() to calculate Degrees, Mintutes, and Seconds as float64 instead of int

pull/23/head
Keith Woelke 2019-06-20 13:25:13 -07:00 committed by Dustin Oprea
parent 17eaca4233
commit 12b8993a44
2 changed files with 8 additions and 8 deletions

4
gps.go
View File

@ -14,11 +14,11 @@ var (
type GpsDegrees struct {
Orientation byte
Degrees, Minutes, Seconds int
Degrees, Minutes, Seconds float64
}
func (d GpsDegrees) String() string {
return fmt.Sprintf("Degrees<O=[%s] D=(%d) M=(%d) S=(%d)>", string([]byte{d.Orientation}), d.Degrees, d.Minutes, d.Seconds)
return fmt.Sprintf("Degrees<O=[%s] D=(%g) M=(%g) S=(%g)>", string([]byte{d.Orientation}), d.Degrees, d.Minutes, d.Seconds)
}
func (d GpsDegrees) Decimal() float64 {

View File

@ -901,18 +901,18 @@ func (ifd *Ifd) GpsInfo() (gi *GpsInfo, err error) {
gi.Latitude = GpsDegrees{
Orientation: latitudeRefValue.(string)[0],
Degrees: int(float64(latitudeRaw[0].Numerator) / float64(latitudeRaw[0].Denominator)),
Minutes: int(float64(latitudeRaw[1].Numerator) / float64(latitudeRaw[1].Denominator)),
Seconds: int(float64(latitudeRaw[2].Numerator) / float64(latitudeRaw[2].Denominator)),
Degrees: float64(latitudeRaw[0].Numerator) / float64(latitudeRaw[0].Denominator),
Minutes: float64(latitudeRaw[1].Numerator) / float64(latitudeRaw[1].Denominator),
Seconds: float64(latitudeRaw[2].Numerator) / float64(latitudeRaw[2].Denominator),
}
longitudeRaw := longitudeValue.([]Rational)
gi.Longitude = GpsDegrees{
Orientation: longitudeRefValue.(string)[0],
Degrees: int(float64(longitudeRaw[0].Numerator) / float64(longitudeRaw[0].Denominator)),
Minutes: int(float64(longitudeRaw[1].Numerator) / float64(longitudeRaw[1].Denominator)),
Seconds: int(float64(longitudeRaw[2].Numerator) / float64(longitudeRaw[2].Denominator)),
Degrees: float64(longitudeRaw[0].Numerator) / float64(longitudeRaw[0].Denominator),
Minutes: float64(longitudeRaw[1].Numerator) / float64(longitudeRaw[1].Denominator),
Seconds: float64(longitudeRaw[2].Numerator) / float64(longitudeRaw[2].Denominator),
}
// Parse altitude.