From a87904f2ffb66e38ea8995927d2ca2130dcea68e Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 20 Mar 2026 05:48:59 +0000 Subject: [PATCH] Handle photo data including NaN for location --- platform/communication.go | 1 - platform/types/image.go | 15 ++++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) delete mode 100644 platform/communication.go diff --git a/platform/communication.go b/platform/communication.go deleted file mode 100644 index 0d3b65ce..00000000 --- a/platform/communication.go +++ /dev/null @@ -1 +0,0 @@ -package platform diff --git a/platform/types/image.go b/platform/types/image.go index 1009d4b0..fe77afcf 100644 --- a/platform/types/image.go +++ b/platform/types/image.go @@ -3,6 +3,7 @@ package types import ( "encoding/json" "fmt" + "math" "time" "github.com/Gleipnir-Technology/nidus-sync/config" @@ -41,7 +42,7 @@ type Image struct { ExifMake string `db:"exif_make" json:"-"` ExifModel string `db:"exif_model" json:"-"` ExifDateTime string `db:"exif_datetime" json:"-"` - Location Location `db:"location"` + Location *Location `db:"location"` ReportID int32 `db:"report_id" json:"-"` URLContent string `db:"-" json:"url_content"` UUID uuid.UUID `db:"uuid"` @@ -49,13 +50,21 @@ type Image struct { func (i *Image) MarshalJSON() ([]byte, error) { to_marshal := make(map[string]interface{}, 0) - to_marshal["distance_from_reporter_meters"] = i.DistanceToReporterMeters + if i.DistanceToReporterMeters != nil && math.IsNaN(*i.DistanceToReporterMeters) { + to_marshal["distance_from_reporter_meters"] = nil + } else { + to_marshal["distance_from_reporter_meters"] = i.DistanceToReporterMeters + } to_marshal["exif"] = Exif{ Created: i.ExifDateTime, Make: i.ExifMake, Model: i.ExifModel, } - to_marshal["location"] = i.Location + if math.IsNaN(i.Location.Latitude) || math.IsNaN(i.Location.Longitude) { + to_marshal["location"] = nil + } else { + to_marshal["location"] = i.Location + } //to_marshal["report_id"] = i.ReportID to_marshal["url_content"] = config.MakeURLNidus("/api/image/%s/content", i.UUID.String()) to_marshal["uuid"] = i.UUID