diff --git a/feature/mutual/src/main/java/com/rtbishop/look4sat/feature/mutual/MutualViewModel.kt b/feature/mutual/src/main/java/com/rtbishop/look4sat/feature/mutual/MutualViewModel.kt index 5b69fff0..87c2334e 100644 --- a/feature/mutual/src/main/java/com/rtbishop/look4sat/feature/mutual/MutualViewModel.kt +++ b/feature/mutual/src/main/java/com/rtbishop/look4sat/feature/mutual/MutualViewModel.kt @@ -85,7 +85,7 @@ class MutualViewModel( val state = _uiState.value // Resolve positions from lat/lon or grid - val posA = resolvePosition(state.stationALat, state.stationALon, state.stationAGrid) + var posA = resolvePosition(state.stationALat, state.stationALon, state.stationAGrid) val posB = resolvePosition(state.stationBLat, state.stationBLon, state.stationBGrid) if (posA == null || posB == null) { @@ -93,6 +93,15 @@ class MutualViewModel( return } + // When station A's grid matches the pre-filled grid (user hasn't changed it), + // use the exact station position from settings so the pass times and elevation + // curves are consistent with the main Passes page. + val stationPos = settingsRepo.stationPosition.value + val prefillGrid = latLonToGrid(stationPos.latitude, stationPos.longitude) + if (state.stationAGrid.trim().uppercase() == prefillGrid) { + posA = stationPos + } + val satellites = satelliteRepo.satellites.value if (satellites.isEmpty()) { _uiState.update { it.copy(errorMessage = "没有卫星数据,请先在卫星列表中选择卫星") } @@ -221,16 +230,6 @@ class MutualViewModel( ): List { val endTime = time + hours * 60L * 60L * 1000L val sampleInterval = 5_000L - - // Priority: reuse the main page's pass list (calculated by getLeoPass) - // so mutual pass times match the main page exactly. - val existingPasses = satelliteRepo.passes.value - val results = findMutualPassesFromList(existingPasses, satellites, posA, posB, - minElevADeg, minElevBDeg, time, endTime, sampleInterval) - if (results.isNotEmpty()) return results - - // Fallback: if the main pass list is empty or the common window is too narrow, - // search independently (same algorithm as before, with 0° horizon boundary). return findMutualPassesFallback(satellites, posA, posB, minElevADeg, minElevBDeg, time, endTime, sampleInterval) }