Skip to content

Satellite tracker and pass predictor for Android, inspired by Gpredict

Fixed recalculating Radar track on station position change (#235)

atsunatsubf25292bf8af
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 @@
<string name="prefs_updated_title">更新:%s</string>
<string name="prefs_updated_time">yyyy MMM d - HH:mm:ss</string>
- <string name="prefs_loc_title">站位</string>
+ <string name="prefs_loc_title">站点位置</string>
<string name="prefs_loc_gps_title">GPS 定位</string>
<string name="prefs_loc_gps_error">检查您的位置权限</string>
<string name="prefs_loc_input_title">输入位置</string>
@@ -95,11 +95,11 @@
<string name="prefs_loc_qth_title">QTH 网格</string>
<string name="prefs_loc_qth_error">无效的 QTH 网格</string>
<string name="prefs_loc_success">位置更新成功</string>
- <string name="prefs_station_title">站位</string>
- <string name="prefs_station_lat_text">站位纬度</string>
- <string name="prefs_station_lon_text">站位经度</string>
+ <string name="prefs_station_title">站点位置</string>
+ <string name="prefs_station_lat_text">站点纬度</string>
+ <string name="prefs_station_lon_text">站点经度</string>
<string name="prefs_locator_title">QTH 定位</string>
- <string name="prefs_locator_text">通过 QTH 设置站位</string>
+ <string name="prefs_locator_text">通过 QTH 设置站点位置</string>
<string name="prefs_data_title">卫星数据更新</string>
<string name="prefs_data_entries">卫星:%s</string>
@@ -155,6 +155,8 @@
<string name="prefs_other_switch_sweep">雷达扫描动画</string>
<string name="prefs_other_switch_sensors">传感器控制雷达</string>
<string name="prefs_other_switch_night_mode">红色夜间模式</string>
+ <string name="prefs_other_compass_offset">雷达罗盘水平偏移量</string>
+ <string name="prefs_other_compass_offset_elev">雷达罗盘俯仰偏移量</string>
<string name="prefs_highlight_title">仰角高亮</string>
<string name="prefs_highlight_low">低 &lt; %1$d°</string>
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<SatRadio> = 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() {