Removed redundant StationPos.kt class

This commit is contained in:
Arty Bishop committed 2021-09-16 10:14:18 +01:00
1 parent a82915c0ca
commit 673474a51f
8 files changed
+28 -53

No files matched your search

@@ -17,15 +17,15 @@
*/
package com.rtbishop.look4sat.data
import com.rtbishop.look4sat.domain.StationPos
import com.rtbishop.look4sat.domain.GeoPos
interface PreferencesSource {
fun positionToQTH(lat: Double, lon: Double): String?
fun loadStationPosition(): StationPos
fun loadStationPosition(): GeoPos
fun saveStationPosition(pos: StationPos)
fun saveStationPosition(pos: GeoPos)
fun updatePositionFromGPS(): Boolean
@@ -17,4 +17,4 @@
*/
package com.rtbishop.look4sat.domain
data class GeoPos(val latitude: Double, val longitude: Double)
data class GeoPos(val latitude: Double, val longitude: Double, val altitude: Double = 0.0)
@@ -30,12 +30,12 @@ class Predictor(private val predictorDispatcher: CoroutineDispatcher) {
private var selectedSatIds = emptyList<Int>()
val passes: SharedFlow<List<SatPass>> = _passes
suspend fun getSatPos(sat: Satellite, pos: StationPos, date: Date): SatPos =
suspend fun getSatPos(sat: Satellite, pos: GeoPos, date: Date): SatPos =
withContext(predictorDispatcher) {
return@withContext sat.getPosition(pos, date.time)
}
suspend fun getSatTrack(sat: Satellite, pos: StationPos, start: Date, end: Date): List<SatPos> =
suspend fun getSatTrack(sat: Satellite, pos: GeoPos, start: Date, end: Date): List<SatPos> =
withContext(predictorDispatcher) {
val positions = mutableListOf<SatPos>()
var currentTime = start.time
@@ -48,7 +48,7 @@ class Predictor(private val predictorDispatcher: CoroutineDispatcher) {
suspend fun triggerCalculation(
satellites: List<Satellite>,
pos: StationPos,
pos: GeoPos,
date: Date = Date(),
hoursAhead: Int = 8,
minElevation: Double = 16.0
@@ -65,7 +65,7 @@ class Predictor(private val predictorDispatcher: CoroutineDispatcher) {
suspend fun forceCalculation(
satellites: List<Satellite>,
pos: StationPos,
pos: GeoPos,
date: Date = Date(),
hoursAhead: Int = 8,
minElevation: Double = 16.0
@@ -84,7 +84,7 @@ class Predictor(private val predictorDispatcher: CoroutineDispatcher) {
}
}
private fun Satellite.getPasses(pos: StationPos, date: Date, hours: Int): List<SatPass> {
private fun Satellite.getPasses(pos: GeoPos, date: Date, hours: Int): List<SatPass> {
val passes = mutableListOf<SatPass>()
val endDate = Date(date.time + hours * 60L * 60L * 1000L)
val quarterOrbitMin = (this.orbitalPeriod / 4.0).toInt()
@@ -117,7 +117,7 @@ class Predictor(private val predictorDispatcher: CoroutineDispatcher) {
.sortedBy { it.aosTime }
}
private fun getGeoPass(sat: Satellite, pos: StationPos, date: Date): SatPass {
private fun getGeoPass(sat: Satellite, pos: GeoPos, date: Date): SatPass {
val satPos = sat.getPosition(pos, date.time)
val aos = Date(date.time - 24 * 60L * 60L * 1000L).time
val los = Date(date.time + 24 * 60L * 60L * 1000L).time
@@ -128,7 +128,7 @@ class Predictor(private val predictorDispatcher: CoroutineDispatcher) {
return SatPass(aos, az, los, az, tca, az, alt, elev, sat)
}
private fun getLeoPass(sat: Satellite, pos: StationPos, date: Date, rewind: Boolean): SatPass {
private fun getLeoPass(sat: Satellite, pos: GeoPos, date: Date, rewind: Boolean): SatPass {
val quarterOrbitMin = (sat.orbitalPeriod / 4.0).toInt()
val calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")).apply {
clear()
@@ -42,7 +42,7 @@ abstract class Satellite(val params: TLE) {
var qoms24 = 0.0
var s4 = 0.0
fun willBeSeen(pos: StationPos): Boolean {
fun willBeSeen(pos: GeoPos): Boolean {
return if (params.meanmo < 1e-8) false
else {
val sma = 331.25 * exp(ln(1440.0 / params.meanmo) * (2.0 / 3.0))
@@ -53,7 +53,7 @@ abstract class Satellite(val params: TLE) {
}
}
fun getPosition(pos: StationPos, time: Long): SatPos {
fun getPosition(pos: GeoPos, time: Long): SatPos {
val satPos = SatPos()
// Date/time at which the position and velocity were calculated
val julUTC = calcCurrentDaynum(time) + 2444238.5
@@ -116,7 +116,7 @@ abstract class Satellite(val params: TLE) {
julianUTC: Double,
positionVector: Vector4,
velocityVector: Vector4,
gsPos: StationPos,
gsPos: GeoPos,
squintVector: Vector4,
satPos: SatPos
) {
@@ -158,7 +158,7 @@ abstract class Satellite(val params: TLE) {
// Returns the ECI position and velocity of the observer
private fun calculateUserPosVel(
time: Double,
gsPos: StationPos,
gsPos: GeoPos,
gsPosTheta: AtomicReference<Double>,
obsPos: Vector4,
obsVel: Vector4
@@ -1,25 +0,0 @@
/*
* Look4Sat. Amateur radio satellite tracker and pass predictor.
* Copyright (C) 2019-2021 Arty Bishop (bishop.arty@gmail.com)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.rtbishop.look4sat.domain
data class StationPos(
val latitude: Double,
val longitude: Double,
val altitude: Double,
val name: String = "default"
)