Mapview: added highlighting of selected aircraft

This commit is contained in:
Nick Foster 2013-07-18 09:45:09 -07:00
parent 7fef37d34d
commit b594fe2799
4 changed files with 60 additions and 63 deletions

View File

@ -118,8 +118,9 @@ class mainwindow(QtGui.QMainWindow):
self.ui.list_aircraft.selectionModel().currentRowChanged.connect(self.dashboard_mapper.setCurrentModelIndex)
self.ui.list_aircraft.selectionModel().currentRowChanged.connect(self.update_heading_widget)
self.ui.list_aircraft.selectionModel().currentRowChanged.connect(self.update_bearing_widget)
self.datamodel.dataChanged.connect(self.unmapped_widgets_dataChanged)
self.ui.list_aircraft.selectionModel().currentRowChanged.connect(self.update_rssi_widget)
self.ui.list_aircraft.selectionModel().currentRowChanged.connect(self.update_map_highlight)
self.datamodel.dataChanged.connect(self.unmapped_widgets_dataChanged)
#hook up live data text box update signal
self.live_data_changed_signal.connect(self.on_append_live_data)
@ -160,6 +161,12 @@ class mainwindow(QtGui.QMainWindow):
self.ui.line_reports.setText("%i" % self.num_reports)
self.num_reports = 0
def update_map_highlight(self, index):
if index.model() is not None:
icaostr = index.model().data(index.model().index(index.row(), self.datamodel._colnames.index("icao"))).toString()
icao = int(str(icaostr), 16)
self.jsonpgen.set_highlight(icao)
##################### dynamic option population ########################
#goes and gets valid antenna, sample rate options from the device and grays out appropriate things
def populate_source_options(self):

View File

@ -61,7 +61,8 @@ def html_template(my_position, json_file):
type: results[i].type,
ident: results[i].ident,
speed: results[i].speed,
vertical: results[i].vertical
vertical: results[i].vertical,
highlight: results[i].highlight
};
}
refreshIcons();
@ -69,8 +70,13 @@ def html_template(my_position, json_file):
function refreshIcons() {
for (var airplane in airplanes) {
if (airplanes[airplane].highlight != 0) {
icon_file = "http://www.nerdnetworks.org/~bistromath/airplane_sprite_highlight.png";
} else {
icon_file = "http://www.nerdnetworks.org/~bistromath/airplane_sprite.png";
};
var plane_icon = {
url: "http://www.nerdnetworks.org/~bistromath/airplane_sprite.png",
url: icon_file,
size: new google.maps.Size(128,128),
origin: new google.maps.Point(parseInt(airplanes[airplane].heading/10)*128,0),
anchor: new google.maps.Point(64,64),

View File

@ -173,6 +173,9 @@ class output_kml(threading.Thread):
#we just inherit from output_kml because we're doing the same thing, only in a different format.
class output_jsonp(output_kml):
def set_highlight(self, icao):
self.highlight = icao
def genkml(self):
retstr="""jsonp_callback(["""
@ -193,33 +196,6 @@ class output_jsonp(output_kml):
for icao in icaolist:
icao = icao[0]
#print "ICAO: %x" % icao
# q = "select * from positions where icao=%i and seen > datetime('now', '-2 hour') ORDER BY seen DESC limit 1" % icao
# self.locked_execute(c, q)
# pos = c.fetchall()
#print "Track length: %i" % len(track)
# if len(track) != 0:
# lat = track[0][3]
# if lat is None: lat = 0
# lon = track[0][4]
# if lon is None: lon = 0
# alt = track[0][2]
# if alt is None: alt = 0
# metric_alt = alt * 0.3048 #google earth takes meters, the commie bastards
# trackstr = ""
# for pos in track:
# trackstr += " %f,%f,%f" % (pos[4], pos[3], pos[2]*0.3048)
# trackstr = string.lstrip(trackstr)
# else:
# alt = 0
# metric_alt = 0
# lat = 0
# lon = 0
# trackstr = str("")
#now get metadata
q = "select ident, type from ident where icao=%i" % icao
@ -228,7 +204,9 @@ class output_jsonp(output_kml):
if len(r) != 0:
ident = r[0][0]
actype = r[0][1]
else: ident=""
else:
ident=""
actype = ""
if ident is None: ident = ""
#get most recent speed/heading/vertical
q = "select seen, speed, heading, vertical from vectors where icao=%i order by seen desc limit 1" % icao
@ -257,8 +235,14 @@ class output_jsonp(output_kml):
lat = 0
lon = 0
alt = 0
#now generate some KML
retstr+= """{"icao": "%.6x", "lat": %f, "lon": %f, "alt": %i, "hdg": %i, "speed": %i, "vertical": %i, "ident": "%s", "type": "%s"},""" % (icao, lat, lon, alt, heading, speed, vertical, ident, actype)
highlight = 0
if hasattr(self, 'highlight'):
if self.highlight == icao:
highlight = 1
#now generate some JSONP
retstr+= """{"icao": "%.6x", "lat": %f, "lon": %f, "alt": %i, "hdg": %i, "speed": %i, "vertical": %i, "ident": "%s", "type": "%s", "highlight": %i},""" % (icao, lat, lon, alt, heading, speed, vertical, ident, actype, highlight)
retstr+= """]);"""
return retstr