summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude <noreply@anthropic.com>2026-05-28 06:57:57 +0000
committerClaude <noreply@anthropic.com>2026-05-28 06:57:57 +0000
commit8136908f9b733ac0b5ad3e3b79bd27cb8c5628e9 (patch)
treec912f451fede9e448a993d2bf69d9926061e147b
parent91f5816120a6260fb8f057f6b7c0d6f0f2337c0e (diff)
Wire forecast wind direction into recorded TrackPoints
Uses marineConditions.windDirDeg (refreshed every 20 min / 10 nm) falling back to forecast.windDirDeg (initial Open-Meteo fetch) to compute a boat-relative true wind angle: twa = (windDirDeg - cogDeg + 360) % 360. Stores windSpeedKnots, windAngleDeg, and isTrueWind=true on every GPS fix that has forecast data, enabling proper Tack/Jibe classification in buildLogEvents() instead of the "Maneuver" fallback. https://claude.ai/code/session_01KXYBuAHZkvv63DeUG6XaZD
-rw-r--r--android-app/app/src/main/kotlin/org/terst/nav/ui/MainViewModel.kt5
1 files changed, 5 insertions, 0 deletions
diff --git a/android-app/app/src/main/kotlin/org/terst/nav/ui/MainViewModel.kt b/android-app/app/src/main/kotlin/org/terst/nav/ui/MainViewModel.kt
index a750d39..361c8dd 100644
--- a/android-app/app/src/main/kotlin/org/terst/nav/ui/MainViewModel.kt
+++ b/android-app/app/src/main/kotlin/org/terst/nav/ui/MainViewModel.kt
@@ -238,9 +238,14 @@ class MainViewModel(
_currentPosition.value = lat to lon
val conditions = _marineConditions.value
val forecast = _forecast.value.firstOrNull()
+ val windDirDeg = conditions?.windDirDeg ?: forecast?.windDirDeg
+ val twa = windDirDeg?.let { ((it - cogDeg + 360.0) % 360.0) }
val point = TrackPoint(
lat = lat, lon = lon,
sogKnots = sogKnots, cogDeg = cogDeg,
+ windSpeedKnots = conditions?.windSpeedKt ?: forecast?.windKt,
+ windAngleDeg = twa,
+ isTrueWind = twa != null,
airTempC = forecast?.tempC,
waveHeightM = conditions?.waveHeightM,
currentSpeedKts = conditions?.currentSpeedKt,