From b5ab0c5236d7503dc002b7bf04e0e33b9c7ff9fa Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Wed, 25 Mar 2026 08:36:29 +0000 Subject: fix: resolve all Kotlin compilation errors blocking CI build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Migrate kapt → KSP (Kotlin 2.0 + kapt is broken; KSP is the supported path) - Fix duplicate onResume() override in MainActivity - Fix wrong package imports: com.example.androidapp.data.model → org.terst.nav.data.model across GribFileManager, GribStalenessChecker, SatelliteGribDownloader, LogbookFormatter, LogbookPdfExporter, IsochroneRouter, AnchorWatchHandler - Create missing SensorData, ApparentWind, TrueWindData, TrueWindCalculator classes - Inline missing ScopeCalculator formula (Pythagorean) in AnchorWatchState Co-Authored-By: Claude Sonnet 4.6 --- .../com/example/androidapp/data/model/SensorData.kt | 10 ++++++++++ .../androidapp/data/storage/GribFileManager.kt | 4 ++-- .../androidapp/data/weather/GribStalenessChecker.kt | 4 ++-- .../data/weather/SatelliteGribDownloader.kt | 8 ++++---- .../example/androidapp/logbook/LogbookFormatter.kt | 2 +- .../example/androidapp/logbook/LogbookPdfExporter.kt | 2 +- .../example/androidapp/routing/IsochroneRouter.kt | 4 ++-- .../example/androidapp/safety/AnchorWatchState.kt | 11 ++++++----- .../androidapp/ui/anchorwatch/AnchorWatchHandler.kt | 4 ++-- .../com/example/androidapp/wind/ApparentWind.kt | 3 +++ .../example/androidapp/wind/TrueWindCalculator.kt | 20 ++++++++++++++++++++ .../com/example/androidapp/wind/TrueWindData.kt | 3 +++ .../src/main/kotlin/org/terst/nav/MainActivity.kt | 2 +- 13 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 android-app/app/src/main/kotlin/com/example/androidapp/data/model/SensorData.kt create mode 100644 android-app/app/src/main/kotlin/com/example/androidapp/wind/ApparentWind.kt create mode 100644 android-app/app/src/main/kotlin/com/example/androidapp/wind/TrueWindCalculator.kt create mode 100644 android-app/app/src/main/kotlin/com/example/androidapp/wind/TrueWindData.kt (limited to 'android-app/app/src') diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/data/model/SensorData.kt b/android-app/app/src/main/kotlin/com/example/androidapp/data/model/SensorData.kt new file mode 100644 index 0000000..d427a5d --- /dev/null +++ b/android-app/app/src/main/kotlin/com/example/androidapp/data/model/SensorData.kt @@ -0,0 +1,10 @@ +package com.example.androidapp.data.model + +data class SensorData( + val latitude: Double? = null, + val longitude: Double? = null, + val headingTrueDeg: Double? = null, + val apparentWindSpeedKt: Double? = null, + val apparentWindAngleDeg: Double? = null, + val speedOverGroundKt: Double? = null +) diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/data/storage/GribFileManager.kt b/android-app/app/src/main/kotlin/com/example/androidapp/data/storage/GribFileManager.kt index b336818..d6f685a 100644 --- a/android-app/app/src/main/kotlin/com/example/androidapp/data/storage/GribFileManager.kt +++ b/android-app/app/src/main/kotlin/com/example/androidapp/data/storage/GribFileManager.kt @@ -1,7 +1,7 @@ package com.example.androidapp.data.storage -import com.example.androidapp.data.model.GribFile -import com.example.androidapp.data.model.GribRegion +import org.terst.nav.data.model.GribFile +import org.terst.nav.data.model.GribRegion import java.time.Instant interface GribFileManager { diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/data/weather/GribStalenessChecker.kt b/android-app/app/src/main/kotlin/com/example/androidapp/data/weather/GribStalenessChecker.kt index 63466b2..70f36d9 100644 --- a/android-app/app/src/main/kotlin/com/example/androidapp/data/weather/GribStalenessChecker.kt +++ b/android-app/app/src/main/kotlin/com/example/androidapp/data/weather/GribStalenessChecker.kt @@ -1,8 +1,8 @@ package com.example.androidapp.data.weather -import com.example.androidapp.data.model.GribFile +import org.terst.nav.data.model.GribFile import com.example.androidapp.data.storage.GribFileManager -import com.example.androidapp.data.model.GribRegion +import org.terst.nav.data.model.GribRegion import java.time.Instant /** Outcome of a freshness check. */ diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/data/weather/SatelliteGribDownloader.kt b/android-app/app/src/main/kotlin/com/example/androidapp/data/weather/SatelliteGribDownloader.kt index e2c884a..6e565b7 100644 --- a/android-app/app/src/main/kotlin/com/example/androidapp/data/weather/SatelliteGribDownloader.kt +++ b/android-app/app/src/main/kotlin/com/example/androidapp/data/weather/SatelliteGribDownloader.kt @@ -1,9 +1,9 @@ package com.example.androidapp.data.weather -import com.example.androidapp.data.model.GribFile -import com.example.androidapp.data.model.GribParameter -import com.example.androidapp.data.model.GribRegion -import com.example.androidapp.data.model.SatelliteDownloadRequest +import org.terst.nav.data.model.GribFile +import org.terst.nav.data.model.GribParameter +import org.terst.nav.data.model.GribRegion +import org.terst.nav.data.model.SatelliteDownloadRequest import com.example.androidapp.data.storage.GribFileManager import java.time.Instant import kotlin.math.ceil diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/logbook/LogbookFormatter.kt b/android-app/app/src/main/kotlin/com/example/androidapp/logbook/LogbookFormatter.kt index b0a910a..d4cf50d 100644 --- a/android-app/app/src/main/kotlin/com/example/androidapp/logbook/LogbookFormatter.kt +++ b/android-app/app/src/main/kotlin/com/example/androidapp/logbook/LogbookFormatter.kt @@ -1,6 +1,6 @@ package com.example.androidapp.logbook -import com.example.androidapp.data.model.LogbookEntry +import org.terst.nav.data.model.LogbookEntry import java.util.Calendar import java.util.TimeZone diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/logbook/LogbookPdfExporter.kt b/android-app/app/src/main/kotlin/com/example/androidapp/logbook/LogbookPdfExporter.kt index ff8ce9a..78ea834 100644 --- a/android-app/app/src/main/kotlin/com/example/androidapp/logbook/LogbookPdfExporter.kt +++ b/android-app/app/src/main/kotlin/com/example/androidapp/logbook/LogbookPdfExporter.kt @@ -5,7 +5,7 @@ import android.graphics.Color import android.graphics.Paint import android.graphics.Typeface import android.graphics.pdf.PdfDocument -import com.example.androidapp.data.model.LogbookEntry +import org.terst.nav.data.model.LogbookEntry import java.io.OutputStream /** diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/routing/IsochroneRouter.kt b/android-app/app/src/main/kotlin/com/example/androidapp/routing/IsochroneRouter.kt index 25055a8..901fdbc 100644 --- a/android-app/app/src/main/kotlin/com/example/androidapp/routing/IsochroneRouter.kt +++ b/android-app/app/src/main/kotlin/com/example/androidapp/routing/IsochroneRouter.kt @@ -1,7 +1,7 @@ package com.example.androidapp.routing -import com.example.androidapp.data.model.BoatPolars -import com.example.androidapp.data.model.WindForecast +import org.terst.nav.data.model.BoatPolars +import org.terst.nav.data.model.WindForecast import kotlin.math.asin import kotlin.math.atan2 import kotlin.math.cos diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/safety/AnchorWatchState.kt b/android-app/app/src/main/kotlin/com/example/androidapp/safety/AnchorWatchState.kt index 507736e..f544f63 100644 --- a/android-app/app/src/main/kotlin/com/example/androidapp/safety/AnchorWatchState.kt +++ b/android-app/app/src/main/kotlin/com/example/androidapp/safety/AnchorWatchState.kt @@ -1,5 +1,7 @@ package com.example.androidapp.safety +import kotlin.math.sqrt + /** * Holds UI-facing state for the anchor watch setup screen and provides * the suggested watch-circle radius derived from depth and rode out. @@ -10,14 +12,13 @@ class AnchorWatchState { * Returns the recommended watch-circle radius (metres) for the given depth * and amount of rode deployed. * - * Uses the Pythagorean formula via [ScopeCalculator.watchCircleRadius] when - * the geometry is valid (rode > depth + freeboard). Falls back to [rodeOutM] - * itself as the maximum possible swing radius when the rode is too short to - * form a catenary angle. + * Uses the Pythagorean formula sqrt(rode² - vertical²) when the geometry is + * valid (rode > depth + freeboard). Falls back to [rodeOutM] itself as the + * maximum possible swing radius when the rode is too short to form a catenary angle. */ fun calculateRecommendedWatchCircleRadius(depthM: Double, rodeOutM: Double): Double { val vertical = depthM + 2.0 // 2 m default freeboard - return if (rodeOutM > vertical) ScopeCalculator.watchCircleRadius(rodeOutM, depthM) + return if (rodeOutM > vertical) sqrt(rodeOutM * rodeOutM - vertical * vertical) else rodeOutM } } diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/ui/anchorwatch/AnchorWatchHandler.kt b/android-app/app/src/main/kotlin/com/example/androidapp/ui/anchorwatch/AnchorWatchHandler.kt index bc82795..289a857 100644 --- a/android-app/app/src/main/kotlin/com/example/androidapp/ui/anchorwatch/AnchorWatchHandler.kt +++ b/android-app/app/src/main/kotlin/com/example/androidapp/ui/anchorwatch/AnchorWatchHandler.kt @@ -7,8 +7,8 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewGroup import androidx.fragment.app.Fragment -import com.example.androidapp.R -import com.example.androidapp.databinding.FragmentAnchorWatchBinding +import org.terst.nav.R +import org.terst.nav.databinding.FragmentAnchorWatchBinding import com.example.androidapp.safety.AnchorWatchState class AnchorWatchHandler : Fragment() { diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/wind/ApparentWind.kt b/android-app/app/src/main/kotlin/com/example/androidapp/wind/ApparentWind.kt new file mode 100644 index 0000000..01656a3 --- /dev/null +++ b/android-app/app/src/main/kotlin/com/example/androidapp/wind/ApparentWind.kt @@ -0,0 +1,3 @@ +package com.example.androidapp.wind + +data class ApparentWind(val speedKt: Double, val angleDeg: Double) diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/wind/TrueWindCalculator.kt b/android-app/app/src/main/kotlin/com/example/androidapp/wind/TrueWindCalculator.kt new file mode 100644 index 0000000..db32163 --- /dev/null +++ b/android-app/app/src/main/kotlin/com/example/androidapp/wind/TrueWindCalculator.kt @@ -0,0 +1,20 @@ +package com.example.androidapp.wind + +import kotlin.math.atan2 +import kotlin.math.cos +import kotlin.math.sin +import kotlin.math.sqrt + +class TrueWindCalculator { + fun update(apparent: ApparentWind, bsp: Double, hdgDeg: Double): TrueWindData { + val awaRad = Math.toRadians(apparent.angleDeg) + val awX = apparent.speedKt * cos(awaRad) + val awY = apparent.speedKt * sin(awaRad) + val twX = awX - bsp + val twY = awY + val tws = sqrt(twX * twX + twY * twY) + val twaDeg = Math.toDegrees(atan2(twY, twX)) + val twdDeg = ((hdgDeg + twaDeg) % 360 + 360) % 360 + return TrueWindData(speedKt = tws, directionDeg = twdDeg) + } +} diff --git a/android-app/app/src/main/kotlin/com/example/androidapp/wind/TrueWindData.kt b/android-app/app/src/main/kotlin/com/example/androidapp/wind/TrueWindData.kt new file mode 100644 index 0000000..78e9558 --- /dev/null +++ b/android-app/app/src/main/kotlin/com/example/androidapp/wind/TrueWindData.kt @@ -0,0 +1,3 @@ +package com.example.androidapp.wind + +data class TrueWindData(val speedKt: Double, val directionDeg: Double) diff --git a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt index d9dba73..61d8b9b 100644 --- a/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt +++ b/android-app/app/src/main/kotlin/org/terst/nav/MainActivity.kt @@ -55,6 +55,7 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener { override fun onResume() { super.onResume() + mapView?.onResume() if (pendingServiceStart) { pendingServiceStart = false startServices() @@ -288,7 +289,6 @@ class MainActivity : AppCompatActivity(), SafetyFragment.SafetyListener { } override fun onStart() { super.onStart(); mapView?.onStart() } - override fun onResume() { super.onResume(); mapView?.onResume() } override fun onPause() { super.onPause(); mapView?.onPause() } override fun onStop() { super.onStop(); mapView?.onStop() } override fun onDestroy() { super.onDestroy(); mapView?.onDestroy() } -- cgit v1.2.3