mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
fix: use independent search algorithm directly, no passes list reuse
The passes list AOS/LOS times can be stale or computed for a different station position, causing elevation curves to show -60° at pass start. The independent search (refineEdge + sampleMutualPass) always computes elevation for the actual positions. With posA now set to the exact station position, the pass times should match the main page.
This commit is contained in:
1 parent
a0279bac17
commit
df083840ac
1 file changed
+10
-11
+10
-11
@@ -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<MutualPass> {
|
||||
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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user