diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-06-30 18:45:07 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-06-30 18:45:07 +0000 |
| commit | 32c98f8ae06f2ceb8fc020d5a63662a07c2d63fb (patch) | |
| tree | 806d827f52e538ab0ef67d4aa7ede062554cdaff | |
| parent | 23163f67deb71f4cc4e53d670254a45b59fd4f6b (diff) | |
feat(fishing): FishingModeManager with target zone computation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
| -rw-r--r-- | android-app/app/src/main/kotlin/org/terst/nav/ui/fishing/FishingModeManager.kt | 32 | ||||
| -rw-r--r-- | android-app/app/src/test/kotlin/org/terst/nav/ui/fishing/FishingModeManagerTest.kt | 16 |
2 files changed, 48 insertions, 0 deletions
diff --git a/android-app/app/src/main/kotlin/org/terst/nav/ui/fishing/FishingModeManager.kt b/android-app/app/src/main/kotlin/org/terst/nav/ui/fishing/FishingModeManager.kt new file mode 100644 index 0000000..7ab1089 --- /dev/null +++ b/android-app/app/src/main/kotlin/org/terst/nav/ui/fishing/FishingModeManager.kt @@ -0,0 +1,32 @@ +package org.terst.nav.ui.fishing + +import android.content.Context + +class FishingModeManager(private val context: Context? = null) { + + private val prefs get() = context?.getSharedPreferences("fishing_mode", Context.MODE_PRIVATE) + + var isActive: Boolean + get() = prefs?.getBoolean("active", false) ?: false + set(v) { prefs?.edit()?.putBoolean("active", v)?.apply() } + + fun computeTarget( + boatLat: Double, boatLon: Double, boatCogDeg: Double, + tempC: Double, currentKt: Double, currentDirDeg: Double + ): FishingTarget? { + if (currentKt < 0.1) return null + + val crossCurrentBearing = (currentDirDeg + 90.0) % 360.0 + val estimatedDistNm = (3.0 + currentKt * 2.5).coerceIn(3.0, 8.0) + val rig = RigAdvisor.recommend(tempC, currentKt, windKt = 0.0) + val tempF = tempC * 9.0 / 5.0 + 32.0 + val zoneDesc = "%.0f°F water, %.1f kt current — steer to color edge".format(tempF, currentKt) + + return FishingTarget( + bearingDeg = crossCurrentBearing, + distanceNm = estimatedDistNm, + zoneDescription = zoneDesc, + rig = rig + ) + } +} diff --git a/android-app/app/src/test/kotlin/org/terst/nav/ui/fishing/FishingModeManagerTest.kt b/android-app/app/src/test/kotlin/org/terst/nav/ui/fishing/FishingModeManagerTest.kt new file mode 100644 index 0000000..7840b52 --- /dev/null +++ b/android-app/app/src/test/kotlin/org/terst/nav/ui/fishing/FishingModeManagerTest.kt @@ -0,0 +1,16 @@ +package org.terst.nav.ui.fishing + +import org.junit.Assert.* +import org.junit.Test + +class FishingModeManagerTest { + @Test fun `target zone computed from current bearing and temp break`() { + val mgr = FishingModeManager() + val target = mgr.computeTarget( + boatLat = 19.5, boatLon = -156.0, boatCogDeg = 270.0, + tempC = 25.0, currentKt = 1.2, currentDirDeg = 180.0 + ) + assertNotNull(target) + assertTrue(target!!.distanceNm in 0.5..20.0) + } +} |
