mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-05 03:57:24 +00:00
Bumped SDK version, further changes to predict4kotlin
This commit is contained in:
1 parent
60a67f86b6
commit
c38fe8b10f
6 files changed
+54
-243
No files matched your search
+3
-3
@@ -6,14 +6,14 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 30
|
compileSdkVersion 31
|
||||||
buildToolsVersion "30.0.3"
|
buildToolsVersion "31.0.0"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.rtbishop.look4sat"
|
applicationId "com.rtbishop.look4sat"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
resConfigs "en,ru"
|
resConfigs "en,ru"
|
||||||
targetSdkVersion 30
|
targetSdkVersion 31
|
||||||
versionCode 253
|
versionCode 253
|
||||||
versionName "2.5.3"
|
versionName "2.5.3"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
package="com.rtbishop.look4sat">
|
package="com.rtbishop.look4sat">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||||
|
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
|
|||||||
+2
-1
@@ -23,6 +23,7 @@ import com.rtbishop.look4sat.data.SatDataRepository
|
|||||||
import com.rtbishop.look4sat.domain.predict4kotlin.Position
|
import com.rtbishop.look4sat.domain.predict4kotlin.Position
|
||||||
import com.rtbishop.look4sat.domain.predict4kotlin.Satellite
|
import com.rtbishop.look4sat.domain.predict4kotlin.Satellite
|
||||||
import com.rtbishop.look4sat.domain.predict4kotlin.StationPosition
|
import com.rtbishop.look4sat.domain.predict4kotlin.StationPosition
|
||||||
|
import com.rtbishop.look4sat.domain.predict4kotlin.getRangeCircle
|
||||||
import com.rtbishop.look4sat.framework.model.SatData
|
import com.rtbishop.look4sat.framework.model.SatData
|
||||||
import com.rtbishop.look4sat.injection.DefaultDispatcher
|
import com.rtbishop.look4sat.injection.DefaultDispatcher
|
||||||
import dagger.hilt.android.lifecycle.HiltViewModel
|
import dagger.hilt.android.lifecycle.HiltViewModel
|
||||||
@@ -154,7 +155,7 @@ class SatMapViewModel @Inject constructor(
|
|||||||
|
|
||||||
private suspend fun setSelectedSatFootprint(sat: Satellite, gsp: StationPosition, date: Date) {
|
private suspend fun setSelectedSatFootprint(sat: Satellite, gsp: StationPosition, date: Date) {
|
||||||
withContext(defaultDispatcher) {
|
withContext(defaultDispatcher) {
|
||||||
val satFootprint = sat.getPredictor(gsp).getRangeCircle(date).map { rangePos ->
|
val satFootprint = sat.getPosition(gsp, date).getRangeCircle().map { rangePos ->
|
||||||
val osmLat = clipLat(rangePos.latitude)
|
val osmLat = clipLat(rangePos.latitude)
|
||||||
val osmLon = clipLon(rangePos.longitude)
|
val osmLon = clipLon(rangePos.longitude)
|
||||||
Position(osmLat, osmLon)
|
Position(osmLat, osmLon)
|
||||||
|
|||||||
@@ -24,44 +24,6 @@ class PassPredictor(private val satellite: Satellite, private val stationPos: St
|
|||||||
|
|
||||||
private val oneQuarterOrbitMin = (24.0 * 60.0 / satellite.tle.meanmo / 4.0).toInt()
|
private val oneQuarterOrbitMin = (24.0 * 60.0 / satellite.tle.meanmo / 4.0).toInt()
|
||||||
private val speedOfLight = 2.99792458E8
|
private val speedOfLight = 2.99792458E8
|
||||||
private val earthRadiusKm = 6378.16
|
|
||||||
|
|
||||||
fun getRangeCircle(date: Date): List<Position> {
|
|
||||||
val satPos = getSatPos(date)
|
|
||||||
val positions = mutableListOf<Position>()
|
|
||||||
val lat = satPos.latitude
|
|
||||||
val lon = satPos.longitude
|
|
||||||
// rangeCircleRadiusKm
|
|
||||||
// earthRadiusKm * acos(earthRadiusKm / (earthRadiusKm + satPos.altitude))
|
|
||||||
val beta = acos(earthRadiusKm / (earthRadiusKm + satPos.altitude))
|
|
||||||
var tempAzimuth = 0
|
|
||||||
while (tempAzimuth < 360) {
|
|
||||||
val azimuth = tempAzimuth / 360.0 * 2.0 * Math.PI
|
|
||||||
var rangelat = asin(sin(lat) * cos(beta) + cos(azimuth) * sin(beta) * cos(lat))
|
|
||||||
val num = (cos(beta) - (sin(lat) * sin(rangelat)))
|
|
||||||
val den = cos(lat) * cos(rangelat)
|
|
||||||
var rangelon = if (tempAzimuth == 0 && (beta > ((Math.PI / 2.0) - lat))) {
|
|
||||||
lon + Math.PI
|
|
||||||
} else if (tempAzimuth == 180 && (beta > ((Math.PI / 2.0) - lat))) {
|
|
||||||
lon + Math.PI
|
|
||||||
} else if (abs(num / den) > 1.0) {
|
|
||||||
lon
|
|
||||||
} else {
|
|
||||||
if ((180 - tempAzimuth) >= 0) {
|
|
||||||
lon - acos(num / den)
|
|
||||||
} else {
|
|
||||||
lon + acos(num / den)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while (rangelon < 0.0) rangelon += Math.PI * 2.0
|
|
||||||
while (rangelon > Math.PI * 2.0) rangelon -= Math.PI * 2.0
|
|
||||||
rangelat = Math.toDegrees(rangelat)
|
|
||||||
rangelon = Math.toDegrees(rangelon)
|
|
||||||
positions.add(Position(rangelat, rangelon))
|
|
||||||
tempAzimuth += 1
|
|
||||||
}
|
|
||||||
return positions
|
|
||||||
}
|
|
||||||
|
|
||||||
fun getDownlinkFreq(freq: Long, date: Date): Long {
|
fun getDownlinkFreq(freq: Long, date: Date): Long {
|
||||||
val rangeRate = getSatPos(date).rangeRate
|
val rangeRate = getSatPos(date).rangeRate
|
||||||
|
|||||||
@@ -18,6 +18,10 @@
|
|||||||
package com.rtbishop.look4sat.domain.predict4kotlin
|
package com.rtbishop.look4sat.domain.predict4kotlin
|
||||||
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
|
import kotlin.math.*
|
||||||
|
|
||||||
|
const val earthRadiusKm = 6378.16
|
||||||
|
const val speedOfLight = 2.99792458E8
|
||||||
|
|
||||||
data class SatPos(
|
data class SatPos(
|
||||||
var azimuth: Double = 0.0,
|
var azimuth: Double = 0.0,
|
||||||
@@ -30,3 +34,47 @@ data class SatPos(
|
|||||||
var theta: Double = 0.0,
|
var theta: Double = 0.0,
|
||||||
var time: Date = Date()
|
var time: Date = Date()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fun SatPos.getDownlinkFreq(freq: Long): Long {
|
||||||
|
return (freq.toDouble() * (speedOfLight - this.rangeRate * 1000.0) / speedOfLight).toLong()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun SatPos.getUplinkFreq(freq: Long): Long {
|
||||||
|
return (freq.toDouble() * (speedOfLight + this.rangeRate * 1000.0) / speedOfLight).toLong()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun SatPos.getRangeCircle(): List<Position> {
|
||||||
|
val positions = mutableListOf<Position>()
|
||||||
|
val lat = this.latitude
|
||||||
|
val lon = this.longitude
|
||||||
|
// rangeCircleRadiusKm
|
||||||
|
// earthRadiusKm * acos(earthRadiusKm / (earthRadiusKm + satPos.altitude))
|
||||||
|
val beta = acos(earthRadiusKm / (earthRadiusKm + this.altitude))
|
||||||
|
var tempAzimuth = 0
|
||||||
|
while (tempAzimuth < 360) {
|
||||||
|
val azimuth = tempAzimuth / 360.0 * 2.0 * Math.PI
|
||||||
|
var rangelat = asin(sin(lat) * cos(beta) + cos(azimuth) * sin(beta) * cos(lat))
|
||||||
|
val num = (cos(beta) - (sin(lat) * sin(rangelat)))
|
||||||
|
val den = cos(lat) * cos(rangelat)
|
||||||
|
var rangelon = if (tempAzimuth == 0 && (beta > ((Math.PI / 2.0) - lat))) {
|
||||||
|
lon + Math.PI
|
||||||
|
} else if (tempAzimuth == 180 && (beta > ((Math.PI / 2.0) - lat))) {
|
||||||
|
lon + Math.PI
|
||||||
|
} else if (abs(num / den) > 1.0) {
|
||||||
|
lon
|
||||||
|
} else {
|
||||||
|
if ((180 - tempAzimuth) >= 0) {
|
||||||
|
lon - acos(num / den)
|
||||||
|
} else {
|
||||||
|
lon + acos(num / den)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (rangelon < 0.0) rangelon += Math.PI * 2.0
|
||||||
|
while (rangelon > Math.PI * 2.0) rangelon -= Math.PI * 2.0
|
||||||
|
rangelat = Math.toDegrees(rangelat)
|
||||||
|
rangelon = Math.toDegrees(rangelon)
|
||||||
|
positions.add(Position(rangelat, rangelon))
|
||||||
|
tempAzimuth += 1
|
||||||
|
}
|
||||||
|
return positions
|
||||||
|
}
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
package com.rtbishop.look4sat.domain.predict4kotlin
|
|
||||||
|
|
||||||
import java.util.*
|
|
||||||
import kotlin.math.*
|
|
||||||
//
|
|
||||||
//const val speedOfLight = 2.99792458E8
|
|
||||||
//const val earthRadiusKm = 6378.16
|
|
||||||
//
|
|
||||||
//fun Satellite.getQuarterOrbitMin(): Int {
|
|
||||||
// return (24.0 * 60.0 / this.tle.meanmo / 4.0).toInt()
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//fun SatPos.getRangeCircle(): List<Position> {
|
|
||||||
// val positions = mutableListOf<Position>()
|
|
||||||
// val lat = this.latitude
|
|
||||||
// val lon = this.longitude
|
|
||||||
// // rangeCircleRadiusKm
|
|
||||||
// // earthRadiusKm * acos(earthRadiusKm / (earthRadiusKm + satPos.altitude))
|
|
||||||
// val beta = acos(earthRadiusKm / (earthRadiusKm + this.altitude))
|
|
||||||
// var tempAzimuth = 0
|
|
||||||
// while (tempAzimuth < 360) {
|
|
||||||
// val azimuth = tempAzimuth / 360.0 * 2.0 * Math.PI
|
|
||||||
// var rangelat = asin(sin(lat) * cos(beta) + cos(azimuth) * sin(beta) * cos(lat))
|
|
||||||
// val num = (cos(beta) - (sin(lat) * sin(rangelat)))
|
|
||||||
// val den = cos(lat) * cos(rangelat)
|
|
||||||
// var rangelon = if (tempAzimuth == 0 && (beta > ((Math.PI / 2.0) - lat))) {
|
|
||||||
// lon + Math.PI
|
|
||||||
// } else if (tempAzimuth == 180 && (beta > ((Math.PI / 2.0) - lat))) {
|
|
||||||
// lon + Math.PI
|
|
||||||
// } else if (abs(num / den) > 1.0) {
|
|
||||||
// lon
|
|
||||||
// } else {
|
|
||||||
// if ((180 - tempAzimuth) >= 0) {
|
|
||||||
// lon - acos(num / den)
|
|
||||||
// } else {
|
|
||||||
// lon + acos(num / den)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// while (rangelon < 0.0) rangelon += Math.PI * 2.0
|
|
||||||
// while (rangelon > Math.PI * 2.0) rangelon -= Math.PI * 2.0
|
|
||||||
// rangelat = Math.toDegrees(rangelat)
|
|
||||||
// rangelon = Math.toDegrees(rangelon)
|
|
||||||
// positions.add(Position(rangelat, rangelon))
|
|
||||||
// tempAzimuth += 1
|
|
||||||
// }
|
|
||||||
// return positions
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//fun SatPos.getDownlinkFreq(freq: Long): Long {
|
|
||||||
// return (freq.toDouble() * (speedOfLight - this.rangeRate * 1000.0) / speedOfLight).toLong()
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//fun SatPos.getUplinkFreq(freq: Long): Long {
|
|
||||||
// return (freq.toDouble() * (speedOfLight + this.rangeRate * 1000.0) / speedOfLight).toLong()
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//fun Satellite.getSatPos(date: Date): SatPos {
|
|
||||||
// return this.getPosition(stationPos, date)
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//fun Satellite.getPositions(date: Date, stepSec: Int, minBefore: Int, orbits: Double): List<SatPos> {
|
|
||||||
// val positions = mutableListOf<SatPos>()
|
|
||||||
// val orbitalPeriod = 24 * 60 / this.tle.meanmo
|
|
||||||
// val endDate = Date(date.time + (orbitalPeriod * orbits * 60L * 1000L).toLong())
|
|
||||||
// val startDate = Date(date.time - minBefore * 60L * 1000L)
|
|
||||||
// var currentDate = startDate
|
|
||||||
// while (currentDate.before(endDate)) {
|
|
||||||
// positions.add(getSatPos(currentDate))
|
|
||||||
// currentDate = Date(currentDate.time + stepSec * 1000)
|
|
||||||
// }
|
|
||||||
// return positions
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//fun Satellite.getPasses(refDate: Date, hoursAhead: Int, windBack: Boolean): List<SatPass> {
|
|
||||||
// val passes = mutableListOf<SatPass>()
|
|
||||||
// val oneQuarterOrbitMin = this.getQuarterOrbitMin()
|
|
||||||
// val endDate = Date(refDate.time + hoursAhead * 60L * 60L * 1000L)
|
|
||||||
// var startDate = refDate
|
|
||||||
// var shouldWindBack = windBack
|
|
||||||
// var lastAosDate: Date
|
|
||||||
// var count = 0
|
|
||||||
// if (this.willBeSeen(stationPos)) {
|
|
||||||
// if (this.tle.isDeepspace) {
|
|
||||||
// passes.add(nextDeepSpacePass(refDate))
|
|
||||||
// } else {
|
|
||||||
// do {
|
|
||||||
// if (count > 0) shouldWindBack = false
|
|
||||||
// val pass = nextNearEarthPass(startDate, shouldWindBack)
|
|
||||||
// lastAosDate = pass.aosDate
|
|
||||||
// passes.add(pass)
|
|
||||||
// startDate =
|
|
||||||
// Date(pass.losDate.time + (oneQuarterOrbitMin * 3) * 60L * 1000L)
|
|
||||||
// count++
|
|
||||||
// } while (lastAosDate < endDate)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return passes
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//private fun Satellite.nextDeepSpacePass(refDate: Date): SatPass {
|
|
||||||
// val satPos = getSatPos(refDate)
|
|
||||||
// val id = this.tle.catnum
|
|
||||||
// val name = this.tle.name
|
|
||||||
// val isDeep = this.tle.isDeepspace
|
|
||||||
// val aos = Date(refDate.time - 24 * 60L * 60L * 1000L).time
|
|
||||||
// val los = Date(refDate.time + 24 * 60L * 60L * 1000L).time
|
|
||||||
// val tca = Date((aos + los) / 2).time
|
|
||||||
// val az = Math.toDegrees(satPos.azimuth)
|
|
||||||
// val elev = Math.toDegrees(satPos.elevation)
|
|
||||||
// val alt = satPos.altitude
|
|
||||||
// return SatPass(id, name, isDeep, aos, az, los, az, tca, az, alt, elev, this)
|
|
||||||
//}
|
|
||||||
//
|
|
||||||
//private fun Satellite.nextNearEarthPass(refDate: Date, windBack: Boolean = false): SatPass {
|
|
||||||
// val oneQuarterOrbitMin = this.getQuarterOrbitMin()
|
|
||||||
// val calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")).apply {
|
|
||||||
// clear()
|
|
||||||
// timeInMillis = refDate.time
|
|
||||||
// }
|
|
||||||
// val id = this.tle.catnum
|
|
||||||
// val name = this.tle.name
|
|
||||||
// val isDeep = this.tle.isDeepspace
|
|
||||||
//
|
|
||||||
// var elevation: Double
|
|
||||||
// var maxElevation = 0.0
|
|
||||||
// var alt = 0.0
|
|
||||||
// var tcaAz = 0.0
|
|
||||||
//
|
|
||||||
// // wind back time 1/4 of an orbit
|
|
||||||
// if (windBack) calendar.add(Calendar.MINUTE, -oneQuarterOrbitMin)
|
|
||||||
// var satPos = getSatPos(calendar.time)
|
|
||||||
//
|
|
||||||
// if (satPos.elevation > 0.0) {
|
|
||||||
// // move forward in 30 second intervals until the sat goes below the horizon
|
|
||||||
// do {
|
|
||||||
// calendar.add(Calendar.SECOND, 30)
|
|
||||||
// satPos = getSatPos(calendar.time)
|
|
||||||
// } while (satPos.elevation > 0.0)
|
|
||||||
// // move forward 3/4 of an orbit
|
|
||||||
// calendar.add(Calendar.MINUTE, oneQuarterOrbitMin * 3)
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// // find the next time sat comes above the horizon
|
|
||||||
// do {
|
|
||||||
// calendar.add(Calendar.SECOND, 60)
|
|
||||||
// satPos = getSatPos(calendar.time)
|
|
||||||
// elevation = satPos.elevation
|
|
||||||
// if (elevation > maxElevation) {
|
|
||||||
// maxElevation = elevation
|
|
||||||
// alt = satPos.altitude
|
|
||||||
// tcaAz = Math.toDegrees(satPos.azimuth)
|
|
||||||
// }
|
|
||||||
// } while (satPos.elevation < 0.0)
|
|
||||||
//
|
|
||||||
// // refine to 3 seconds
|
|
||||||
// calendar.add(Calendar.SECOND, -60)
|
|
||||||
// do {
|
|
||||||
// calendar.add(Calendar.SECOND, 3)
|
|
||||||
// satPos = getSatPos(calendar.time)
|
|
||||||
// elevation = satPos.elevation
|
|
||||||
// if (elevation > maxElevation) {
|
|
||||||
// maxElevation = elevation
|
|
||||||
// alt = satPos.altitude
|
|
||||||
// tcaAz = Math.toDegrees(satPos.azimuth)
|
|
||||||
// }
|
|
||||||
// } while (satPos.elevation < 0.0)
|
|
||||||
//
|
|
||||||
// val aos = satPos.time.time
|
|
||||||
// val aosAz = Math.toDegrees(satPos.azimuth)
|
|
||||||
//
|
|
||||||
// // find when sat goes below
|
|
||||||
// do {
|
|
||||||
// calendar.add(Calendar.SECOND, 30)
|
|
||||||
// satPos = getSatPos(calendar.time)
|
|
||||||
// elevation = satPos.elevation
|
|
||||||
// if (elevation > maxElevation) {
|
|
||||||
// maxElevation = elevation
|
|
||||||
// alt = satPos.altitude
|
|
||||||
// tcaAz = Math.toDegrees(satPos.azimuth)
|
|
||||||
// }
|
|
||||||
// } while (satPos.elevation > 0.0)
|
|
||||||
//
|
|
||||||
// // refine to 3 seconds
|
|
||||||
// calendar.add(Calendar.SECOND, -30)
|
|
||||||
// do {
|
|
||||||
// calendar.add(Calendar.SECOND, 3)
|
|
||||||
// satPos = getSatPos(calendar.time)
|
|
||||||
// elevation = satPos.elevation
|
|
||||||
// if (elevation > maxElevation) {
|
|
||||||
// maxElevation = elevation
|
|
||||||
// alt = satPos.altitude
|
|
||||||
// tcaAz = Math.toDegrees(satPos.azimuth)
|
|
||||||
// }
|
|
||||||
// } while (satPos.elevation > 0.0)
|
|
||||||
//
|
|
||||||
// val los = satPos.time.time
|
|
||||||
// val losAz = Math.toDegrees(satPos.azimuth)
|
|
||||||
// val tca = Date((aos + los) / 2).time
|
|
||||||
// val elev = Math.toDegrees(maxElevation)
|
|
||||||
// return SatPass(id, name, isDeep, aos, aosAz, los, losAz, tca, tcaAz, alt, elev, this)
|
|
||||||
//}
|
|
||||||
Reference in new issue
Block a user