From bf25292bf8af5d35db43daffe079659a3c8814b4 Mon Sep 17 00:00:00 2001 From: atsunatsu <1017079775@qq.com> Date: Sat, 8 Aug 2026 20:10:55 +0800 Subject: [PATCH] Fixed recalculating Radar track on station position change (#235) Co-authored-by: atsunatsu Co-authored-by: wty2019wty <74123961+wty2019wty@users.noreply.github.com> --- .gitignore | 1 + .../src/main/res/values-zh/strings.xml | 12 +++++----- .../look4sat/feature/radar/RadarViewModel.kt | 22 +++++++++++++++++-- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index d4338562..3034a19c 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ fastlane/readme.md /app/release/output-metadata.json /app/release/ /.kotlin/sessions/ +.hermes/ diff --git a/core/presentation/src/main/res/values-zh/strings.xml b/core/presentation/src/main/res/values-zh/strings.xml index 42507759..024915d0 100644 --- a/core/presentation/src/main/res/values-zh/strings.xml +++ b/core/presentation/src/main/res/values-zh/strings.xml @@ -87,7 +87,7 @@ 更新:%s yyyy MMM d - HH:mm:ss - 站位 + 站点位置 GPS 定位 检查您的位置权限 输入位置 @@ -95,11 +95,11 @@ QTH 网格 无效的 QTH 网格 位置更新成功 - 站位 - 站位纬度 - 站位经度 + 站点位置 + 站点纬度 + 站点经度 QTH 定位 - 通过 QTH 设置站位 + 通过 QTH 设置站点位置 卫星数据更新 卫星:%s @@ -155,6 +155,8 @@ 雷达扫描动画 传感器控制雷达 红色夜间模式 + 雷达罗盘水平偏移量 + 雷达罗盘俯仰偏移量 仰角高亮 低 < %1$d° diff --git a/feature/radar/src/main/java/com/rtbishop/look4sat/feature/radar/RadarViewModel.kt b/feature/radar/src/main/java/com/rtbishop/look4sat/feature/radar/RadarViewModel.kt index be89d4b6..6ddd57d2 100644 --- a/feature/radar/src/main/java/com/rtbishop/look4sat/feature/radar/RadarViewModel.kt +++ b/feature/radar/src/main/java/com/rtbishop/look4sat/feature/radar/RadarViewModel.kt @@ -65,8 +65,8 @@ class RadarViewModel( private val showToast: IShowToast ) : ViewModel() { - private val stationPos = settingsRepo.stationPosition.value - private val magDeclination = sensorsRepo.getMagDeclination(stationPos) + private var stationPos = settingsRepo.stationPosition.value + private var magDeclination = sensorsRepo.getMagDeclination(stationPos) private var compassOffset = settingsRepo.otherSettings.value.radarCompassOffset private var compassOffsetElev = settingsRepo.otherSettings.value.radarCompassOffsetElev private var transponders: List = emptyList() @@ -92,6 +92,7 @@ class RadarViewModel( init { collectSettingsChanges() // also handles initial sensor subscription + collectStationPositionChanges() collectPassAndStartTickLoop() collectRadioTrackingState() } @@ -138,6 +139,23 @@ class RadarViewModel( } } + private fun collectStationPositionChanges() { + viewModelScope.launch { + settingsRepo.stationPosition.collect { newPos -> + if (stationPos != newPos) { + stationPos = newPos + magDeclination = sensorsRepo.getMagDeclination(stationPos) + lastCelestialUpdateMs = 0L // force celestial recompute on next tick + val pass = _uiState.value.currentPass ?: return@collect + if (!pass.isDeepSpace) { + val track = satelliteRepo.getTrack(pass.orbitalObject, stationPos, pass.aosTime, pass.losTime) + _uiState.update { it.copy(satTrack = track) } + } + } + } + } + } + // --- Pass loading split into focused functions --- private fun collectPassAndStartTickLoop() {