Satellite tracker and pass predictor for Android, inspired by Gpredict
Kotlin amsatcelestrakgpsham-radiohamlibhamradiokotlinnasaradiosatellitesatellite-datasatellite-positionsatellite-predictionsatellitessatnogssdrspacespacexstarlink
Fixed satellite track show issue, minor Map fixes
Arty Bishopa8b43ca3fba2
diff --git a/app/src/main/java/com/rtbishop/look4sat/data/database/SatelliteDao.kt b/app/src/main/java/com/rtbishop/look4sat/data/database/SatelliteDao.ktindex 14e7d2b1..82eec9b2 100644--- a/app/src/main/java/com/rtbishop/look4sat/data/database/SatelliteDao.kt+++ b/app/src/main/java/com/rtbishop/look4sat/data/database/SatelliteDao.kt@@ -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>>diff --git a/app/src/main/java/com/rtbishop/look4sat/data/repository/SatelliteRepo.kt b/app/src/main/java/com/rtbishop/look4sat/data/repository/SatelliteRepo.ktindex dfa5034d..707c2d16 100644--- a/app/src/main/java/com/rtbishop/look4sat/data/repository/SatelliteRepo.kt+++ b/app/src/main/java/com/rtbishop/look4sat/data/repository/SatelliteRepo.kt@@ -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()}diff --git a/app/src/main/java/com/rtbishop/look4sat/ui/mapScreen/MapViewModel.kt b/app/src/main/java/com/rtbishop/look4sat/ui/mapScreen/MapViewModel.ktindex 4825c165..2d3d70d1 100644--- a/app/src/main/java/com/rtbishop/look4sat/ui/mapScreen/MapViewModel.kt+++ b/app/src/main/java/com/rtbishop/look4sat/ui/mapScreen/MapViewModel.kt@@ -29,7 +29,6 @@ import com.rtbishop.look4sat.data.repository.SatelliteRepoimport com.rtbishop.look4sat.utility.*import dagger.hilt.android.lifecycle.HiltViewModelimport kotlinx.coroutines.*-import kotlinx.coroutines.flow.collectimport org.osmdroid.util.GeoPointimport org.osmdroid.views.overlay.FolderOverlayimport 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.0diff --git a/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.kt b/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.ktindex ef130225..b1b2755e 100644--- a/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.kt+++ b/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.kt@@ -42,14 +42,15 @@ class PassPredictor(private val satellite: Satellite, private val qth: GroundStareturn 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 = startDatewhile (currentDate.before(endDate)) {positions.add(getSatPos(currentDate))- currentDate = Date(currentDate.time + stepSeconds * 1000)+ currentDate = Date(currentDate.time + stepSec * 1000)}return positions}