Removing emitter-centered local decoding from the CPR parser. Using only global decoding.

This commit is contained in:
Nick Foster
2012-10-14 17:56:01 -07:00
parent 85da74b43a
commit 3c8c60f57f
2 changed files with 8 additions and 23 deletions

View File

@@ -172,7 +172,6 @@ def range_bearing(loc_a, loc_b):
class cpr_decoder:
def __init__(self, my_location):
self.my_location = my_location
self.lkplist = {}
self.evenlist = {}
self.oddlist = {}
@@ -180,9 +179,9 @@ class cpr_decoder:
self.my_location = new_location
def weed_poslists(self):
for poslist in [self.lkplist, self.evenlist, self.oddlist]:
for poslist in [self.evenlist, self.oddlist]:
for key, item in poslist.items():
if time.time() - item[2] > 900:
if time.time() - item[2] > 10:
del poslist[key]
def decode(self, icao24, encoded_lat, encoded_lon, cpr_format, surface):
@@ -194,30 +193,14 @@ class cpr_decoder:
[decoded_lat, decoded_lon] = [None, None]
#okay, let's traverse the lists and weed out those entries that are older than 15 minutes, as they're unlikely to be useful.
#okay, let's traverse the lists and weed out those entries that are older than 10 seconds
self.weed_poslists()
if icao24 in self.lkplist:
#do emitter-centered local decoding
[decoded_lat, decoded_lon] = cpr_resolve_local(self.lkplist[icao24][0:2], [encoded_lat, encoded_lon], cpr_format, surface)
self.lkplist[icao24] = [decoded_lat, decoded_lon, time.time()] #update the local position for next time
elif (icao24 in self.evenlist) \
and (icao24 in self.oddlist) \
and (abs(self.evenlist[icao24][2] - self.oddlist[icao24][2]) < 10) \
and (surface == 0):
if (icao24 in self.evenlist) \
and (icao24 in self.oddlist):
newer = (self.oddlist[icao24][2] - self.evenlist[icao24][2]) > 0 #figure out which report is newer
[decoded_lat, decoded_lon] = cpr_resolve_global(self.evenlist[icao24][0:2], self.oddlist[icao24][0:2], newer, surface) #do a global decode
self.lkplist[icao24] = [decoded_lat, decoded_lon, time.time()]
#so we really can't guarantee that local decoding will work unless you are POSITIVE that you can't hear more than 180nm out.
#this will USUALLY work, but you can't guarantee it!
#elif surface == 1 and self.my_location is not None:
# [local_lat, local_lon] = cpr_resolve_local(self.my_location, [encoded_lat, encoded_lon], cpr_format, surface) #try local decoding
# [rnge, bearing] = range_bearing(self.my_location, [local_lat, local_lon])
# if rnge < validrange: #if the local decoding can be guaranteed valid
# self.lkplist[icao24] = [local_lat, local_lon, time.time()] #update the local position for next time
# [decoded_lat, decoded_lon] = [local_lat, local_lon]
else:
raise CPRNoPositionError

View File

@@ -69,7 +69,9 @@ class output_print(air_modes.parse):
pass
def output(self, msg):
print self.parse(msg)
parsed = self.parse(msg)
if parsed is not None:
print self.parse(msg)
def print0(self, shortdata, ecc):
[vs, cc, sl, ri, altitude] = self.parse0(shortdata)