kopia lustrzana https://github.com/rt-bishop/Look4Sat
Fixed satellite track show issue, minor Map fixes
rodzic
6f8db0b9b1
commit
a8b43ca3fb
|
@ -32,9 +32,6 @@ interface SatelliteDao {
|
|||
@Query("SELECT catNum, name, isSelected FROM entries ORDER BY name ASC")
|
||||
fun getAllSatItems(): Flow<List<SatItem>>
|
||||
|
||||
@Query("SELECT tle FROM entries WHERE isSelected = 1")
|
||||
fun getSelectedSatellitesFlow(): Flow<List<Satellite>>
|
||||
|
||||
@Query("SELECT * FROM transmitters WHERE isAlive = 1 ORDER BY mode ASC")
|
||||
fun getAllTransmitters(): Flow<List<SatTrans>>
|
||||
|
||||
|
|
|
@ -52,10 +52,6 @@ class SatelliteRepo @Inject constructor(
|
|||
return satelliteDao.getAllSatItems()
|
||||
}
|
||||
|
||||
fun getSelectedSatellitesFlow(): Flow<List<Satellite>> {
|
||||
return satelliteDao.getSelectedSatellitesFlow()
|
||||
}
|
||||
|
||||
fun getAllTransmitters(): Flow<List<SatTrans>> {
|
||||
return satelliteDao.getAllTransmitters()
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import com.rtbishop.look4sat.data.repository.SatelliteRepo
|
|||
import com.rtbishop.look4sat.utility.*
|
||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import org.osmdroid.util.GeoPoint
|
||||
import org.osmdroid.views.overlay.FolderOverlay
|
||||
import org.osmdroid.views.overlay.Overlay
|
||||
|
@ -77,21 +76,16 @@ class MapViewModel @Inject constructor(
|
|||
|
||||
init {
|
||||
viewModelScope.launch {
|
||||
satelliteRepo.getSelectedSatellitesFlow().collect { satellites ->
|
||||
if (satellites.isNotEmpty()) {
|
||||
filteredSats = satellites
|
||||
selectedSat = satellites.first()
|
||||
try {
|
||||
while (true) {
|
||||
ensureActive()
|
||||
dateNow.time = System.currentTimeMillis()
|
||||
_selectedSat.value = getDataForSelSatellite(selectedSat)
|
||||
_satMarkers.value = getDataForAllSatellites(filteredSats)
|
||||
delay(2000)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
val satellites = satelliteRepo.getSelectedSatellites()
|
||||
if (satellites.isNotEmpty()) {
|
||||
filteredSats = satellites
|
||||
selectedSat = satellites.first()
|
||||
while (true) {
|
||||
ensureActive()
|
||||
dateNow.time = System.currentTimeMillis()
|
||||
_selectedSat.value = getDataForSelSatellite(selectedSat)
|
||||
_satMarkers.value = getDataForAllSatellites(filteredSats)
|
||||
delay(2000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -147,7 +141,7 @@ class MapViewModel @Inject constructor(
|
|||
}
|
||||
|
||||
private fun getSatTrack(satellite: Satellite): Overlay {
|
||||
val positions = satellite.getPredictor(gsp).getPositions(dateNow, 20, 5, 2)
|
||||
val positions = satellite.getPredictor(gsp).getPositions(dateNow, 15, 3, 3.2)
|
||||
val trackOverlay = FolderOverlay()
|
||||
val trackPoints = mutableListOf<GeoPoint>()
|
||||
var oldLon = 0.0
|
||||
|
|
|
@ -42,14 +42,15 @@ class PassPredictor(private val satellite: Satellite, private val qth: GroundSta
|
|||
return satellite.getPosition(qth, date)
|
||||
}
|
||||
|
||||
fun getPositions(refDate: Date, stepSeconds: Int, minBefore: Int, minAfter: Int): List<SatPos> {
|
||||
fun getPositions(refDate: Date, stepSec: Int, minBefore: Int, orbits: Double): List<SatPos> {
|
||||
val positions = mutableListOf<SatPos>()
|
||||
val endDate = Date(refDate.time + minAfter * 60L * 1000L)
|
||||
val orbitalPeriod = 24 * 60 / satellite.tle.meanmo
|
||||
val endDate = Date(refDate.time + (orbitalPeriod * orbits * 60L * 1000L).toLong())
|
||||
val startDate = Date(refDate.time - minBefore * 60L * 1000L)
|
||||
var currentDate = startDate
|
||||
while (currentDate.before(endDate)) {
|
||||
positions.add(getSatPos(currentDate))
|
||||
currentDate = Date(currentDate.time + stepSeconds * 1000)
|
||||
currentDate = Date(currentDate.time + stepSec * 1000)
|
||||
}
|
||||
return positions
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue