mirror of
https://github.com/atsunatsu/Look4Sat.git
synced 2026-10-02 03:15:37 +00:00
Fixed NPE in PassPredictor happening during satPass calculation
This commit is contained in:
1 parent
ad732bda79
commit
499febefcb
1 file changed
+1
-9
@@ -155,7 +155,6 @@ class PassPredictor(private val tle: TLE, private val qth: GroundStationPosition
|
|||||||
var maxElevation = 0.0
|
var maxElevation = 0.0
|
||||||
var elevation: Double
|
var elevation: Double
|
||||||
var prevPos: SatPos
|
var prevPos: SatPos
|
||||||
var tca: Date? = null
|
|
||||||
var polePassed = deadSpotNone
|
var polePassed = deadSpotNone
|
||||||
|
|
||||||
// get the current position
|
// get the current position
|
||||||
@@ -184,11 +183,9 @@ class PassPredictor(private val tle: TLE, private val qth: GroundStationPosition
|
|||||||
// now find the next time it comes above the horizon
|
// now find the next time it comes above the horizon
|
||||||
do {
|
do {
|
||||||
satPos = getPosition(cal, 60)
|
satPos = getPosition(cal, 60)
|
||||||
val now = cal.time
|
|
||||||
elevation = satPos.elevation
|
elevation = satPos.elevation
|
||||||
if (elevation > maxElevation) {
|
if (elevation > maxElevation) {
|
||||||
maxElevation = elevation
|
maxElevation = elevation
|
||||||
tca = now
|
|
||||||
}
|
}
|
||||||
} while (satPos.elevation < 0.0)
|
} while (satPos.elevation < 0.0)
|
||||||
|
|
||||||
@@ -196,11 +193,9 @@ class PassPredictor(private val tle: TLE, private val qth: GroundStationPosition
|
|||||||
cal.add(Calendar.SECOND, -60)
|
cal.add(Calendar.SECOND, -60)
|
||||||
do {
|
do {
|
||||||
satPos = getPosition(cal, 5)
|
satPos = getPosition(cal, 5)
|
||||||
val now = cal.time
|
|
||||||
elevation = satPos.elevation
|
elevation = satPos.elevation
|
||||||
if (elevation > maxElevation) {
|
if (elevation > maxElevation) {
|
||||||
maxElevation = elevation
|
maxElevation = elevation
|
||||||
tca = now
|
|
||||||
}
|
}
|
||||||
prevPos = satPos
|
prevPos = satPos
|
||||||
} while (satPos.elevation < 0.0)
|
} while (satPos.elevation < 0.0)
|
||||||
@@ -210,7 +205,6 @@ class PassPredictor(private val tle: TLE, private val qth: GroundStationPosition
|
|||||||
// now find when it goes below
|
// now find when it goes below
|
||||||
do {
|
do {
|
||||||
satPos = getPosition(cal, 30)
|
satPos = getPosition(cal, 30)
|
||||||
val now = cal.time
|
|
||||||
val currPolePassed = getPolePassed(prevPos, satPos)
|
val currPolePassed = getPolePassed(prevPos, satPos)
|
||||||
if (currPolePassed != deadSpotNone) {
|
if (currPolePassed != deadSpotNone) {
|
||||||
polePassed = currPolePassed
|
polePassed = currPolePassed
|
||||||
@@ -218,7 +212,6 @@ class PassPredictor(private val tle: TLE, private val qth: GroundStationPosition
|
|||||||
elevation = satPos.elevation
|
elevation = satPos.elevation
|
||||||
if (elevation > maxElevation) {
|
if (elevation > maxElevation) {
|
||||||
maxElevation = elevation
|
maxElevation = elevation
|
||||||
tca = now
|
|
||||||
}
|
}
|
||||||
prevPos = satPos
|
prevPos = satPos
|
||||||
} while (satPos.elevation > 0.0)
|
} while (satPos.elevation > 0.0)
|
||||||
@@ -227,16 +220,15 @@ class PassPredictor(private val tle: TLE, private val qth: GroundStationPosition
|
|||||||
cal.add(Calendar.SECOND, -30)
|
cal.add(Calendar.SECOND, -30)
|
||||||
do {
|
do {
|
||||||
satPos = getPosition(cal, 5)
|
satPos = getPosition(cal, 5)
|
||||||
val now = cal.time
|
|
||||||
elevation = satPos.elevation
|
elevation = satPos.elevation
|
||||||
if (elevation > maxElevation) {
|
if (elevation > maxElevation) {
|
||||||
maxElevation = elevation
|
maxElevation = elevation
|
||||||
tca = now
|
|
||||||
}
|
}
|
||||||
} while (satPos.elevation > 0.0)
|
} while (satPos.elevation > 0.0)
|
||||||
|
|
||||||
val endDate = satPos.time
|
val endDate = satPos.time
|
||||||
losAzimuth = (satPos.azimuth / (2.0 * Math.PI) * 360.0).toInt()
|
losAzimuth = (satPos.azimuth / (2.0 * Math.PI) * 360.0).toInt()
|
||||||
|
val tca = Date(startDate.time + (endDate.time - startDate.time) / 2)
|
||||||
|
|
||||||
return SatPassTime(
|
return SatPassTime(
|
||||||
startDate, endDate, tca, polePassed, aosAzimuth,
|
startDate, endDate, tca, polePassed, aosAzimuth,
|
||||||
|
|||||||
Reference in new issue
Block a user