From 499febefcbe2e8fbad8913c05440f76d491b69cb Mon Sep 17 00:00:00 2001 From: Arty Bishop Date: Sat, 25 Apr 2020 12:17:00 +0100 Subject: [PATCH] Fixed NPE in PassPredictor happening during satPass calculation --- .../com/rtbishop/look4sat/utility/PassPredictor.kt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.kt b/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.kt index fde89fe5..e41f2c1e 100644 --- a/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.kt +++ b/app/src/main/java/com/rtbishop/look4sat/utility/PassPredictor.kt @@ -155,7 +155,6 @@ class PassPredictor(private val tle: TLE, private val qth: GroundStationPosition var maxElevation = 0.0 var elevation: Double var prevPos: SatPos - var tca: Date? = null var polePassed = deadSpotNone // 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 do { satPos = getPosition(cal, 60) - val now = cal.time elevation = satPos.elevation if (elevation > maxElevation) { maxElevation = elevation - tca = now } } while (satPos.elevation < 0.0) @@ -196,11 +193,9 @@ class PassPredictor(private val tle: TLE, private val qth: GroundStationPosition cal.add(Calendar.SECOND, -60) do { satPos = getPosition(cal, 5) - val now = cal.time elevation = satPos.elevation if (elevation > maxElevation) { maxElevation = elevation - tca = now } prevPos = satPos } 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 do { satPos = getPosition(cal, 30) - val now = cal.time val currPolePassed = getPolePassed(prevPos, satPos) if (currPolePassed != deadSpotNone) { polePassed = currPolePassed @@ -218,7 +212,6 @@ class PassPredictor(private val tle: TLE, private val qth: GroundStationPosition elevation = satPos.elevation if (elevation > maxElevation) { maxElevation = elevation - tca = now } prevPos = satPos } while (satPos.elevation > 0.0) @@ -227,16 +220,15 @@ class PassPredictor(private val tle: TLE, private val qth: GroundStationPosition cal.add(Calendar.SECOND, -30) do { satPos = getPosition(cal, 5) - val now = cal.time elevation = satPos.elevation if (elevation > maxElevation) { maxElevation = elevation - tca = now } } while (satPos.elevation > 0.0) val endDate = satPos.time losAzimuth = (satPos.azimuth / (2.0 * Math.PI) * 360.0).toInt() + val tca = Date(startDate.time + (endDate.time - startDate.time) / 2) return SatPassTime( startDate, endDate, tca, polePassed, aosAzimuth,