Handle EXIF location data set to "NaN"

Probably Android's new privacy thing. Jerks.
This commit is contained in:
Eli Ribble 2026-04-30 15:34:08 +00:00
parent 1cfe51f894
commit 00d26a684a
No known key found for this signature in database

View file

@ -10,6 +10,7 @@ import (
_ "image/jpeg" // register JPEG format
_ "image/png" // register PNG format
"io"
"math"
"time"
"github.com/Gleipnir-Technology/bob"
@ -107,7 +108,7 @@ func saveImageUploads(ctx context.Context, tx bob.Tx, uploads []ImageUpload) (mo
// TODO: figure out how to do this via the setter...?
if u.Exif != nil {
if u.Exif.GPS != nil {
if u.Exif.GPS != nil && !(math.IsNaN(u.Exif.GPS.Longitude) || math.IsNaN(u.Exif.GPS.Latitude)) {
_, err = psql.Update(
um.Table("publicreport.image"),
um.SetCol("location").To(fmt.Sprintf("ST_Point(%f, %f, 4326)", u.Exif.GPS.Longitude, u.Exif.GPS.Latitude)),