From 8035488eb071ede7129687c271cf30a6ba81e427 Mon Sep 17 00:00:00 2001 From: Jan Schill Date: Wed, 24 Jul 2024 21:18:11 +0200 Subject: [PATCH] Go back to int for Altitude --- garmin-api.md | 2 +- internal/db/models.go | 2 +- internal/db/sqlite.go | 6 +++--- internal/server/handlers.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/garmin-api.md b/garmin-api.md index 6b49151..13aa2cf 100644 --- a/garmin-api.md +++ b/garmin-api.md @@ -28,7 +28,7 @@ type Address struct { type Point struct { Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` - Altitude float64 `json:"altitude"` + Altitude int `json:"altitude"` GPSFix int `json:"gpsFix"` Course float64 `json:"course"` Speed float64 `json:"speed"` diff --git a/internal/db/models.go b/internal/db/models.go index 262b845..cbf32d7 100644 --- a/internal/db/models.go +++ b/internal/db/models.go @@ -25,7 +25,7 @@ type Event struct { Status Status Latitude float64 Longitude float64 - Altitude float64 + Altitude int GpsFix int Course int Speed int diff --git a/internal/db/sqlite.go b/internal/db/sqlite.go index 4dc3d13..b7032f2 100644 --- a/internal/db/sqlite.go +++ b/internal/db/sqlite.go @@ -81,7 +81,7 @@ func CreateTables(filePath string) { "timeStamp" INTEGER NOT NULL, "latitude" REAL, "longitude" REAL, - "altitude" REAL, + "altitude" INTEGER, "gpsFix" INTEGER, "course" REAL, "speed" REAL, @@ -127,7 +127,7 @@ func Seed(filePath string) { } defer Db.Close() - file, err := os.Open("./data/visited_points.txt") + file, err := os.Open("./data/route_points.txt") if err != nil { log.Fatal("Failed to open file:", err) } @@ -154,7 +154,7 @@ func Seed(filePath string) { } _, err = Db.Exec("INSERT INTO events(tripId, imei, messageCode, timeStamp, latitude, longitude, altitude, gpsFix, course, speed, autonomous, lowBattery, intervalChange, resetDetected) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?)", - 1, "fake-imei", 0, time.Now().Unix(), latitude, longitude, elevation, 0, 0, 0, 0, 0, 0, 0) + 1, "fake-imei", 0, time.Now().Unix(), latitude, longitude, int(elevation), 0, 0, 0, 0, 0, 0, 0) if err != nil { log.Fatal("Failed to insert into events table:", err) } diff --git a/internal/server/handlers.go b/internal/server/handlers.go index 816ac55..88e1bfd 100644 --- a/internal/server/handlers.go +++ b/internal/server/handlers.go @@ -24,7 +24,7 @@ type GarminOutboundPayload struct { Point struct { Latitude float64 `json:"latitude"` Longitude float64 `json:"longitude"` - Altitude float64 `json:"altitude"` + Altitude int `json:"altitude"` GpsFix int `json:"gpsFix"` Course int `json:"course"` Speed int `json:"speed"`