Stylistic cleanups. Unify special squawk data.
This commit is contained in:
parent
feb8c55bac
commit
58e5485c2a
|
@ -1,4 +1,4 @@
|
||||||
var planeSvg = "M 0,0 " +
|
var PlaneSvg = "M 0,0 " +
|
||||||
"M 1.9565564,41.694305 C 1.7174505,40.497708 1.6419973,38.448747 " +
|
"M 1.9565564,41.694305 C 1.7174505,40.497708 1.6419973,38.448747 " +
|
||||||
"1.8096508,37.70494 1.8936398,37.332056 2.0796653,36.88191 2.222907,36.70461 " +
|
"1.8096508,37.70494 1.8936398,37.332056 2.0796653,36.88191 2.222907,36.70461 " +
|
||||||
"2.4497603,36.423844 4.087816,35.47248 14.917931,29.331528 l 12.434577," +
|
"2.4497603,36.423844 4.087816,35.47248 14.917931,29.331528 l 12.434577," +
|
||||||
|
@ -48,22 +48,25 @@ var planeObject = {
|
||||||
// Data packet numbers
|
// Data packet numbers
|
||||||
messages : null,
|
messages : null,
|
||||||
|
|
||||||
// Track history
|
// Track history as a series of line segments
|
||||||
tracklinesegs : [],
|
track_linesegs : [],
|
||||||
|
|
||||||
|
|
||||||
// When was this last updated (receiver timestamp)
|
// When was this last updated (receiver timestamp)
|
||||||
last_message_time : null,
|
last_message_time : null,
|
||||||
last_position_time : null,
|
last_position_time : null,
|
||||||
|
|
||||||
historySize : 0,
|
// When was this last updated (seconds before last update)
|
||||||
|
seen : null,
|
||||||
|
seen_pos : null,
|
||||||
|
|
||||||
|
history_size : 0,
|
||||||
visible : true,
|
visible : true,
|
||||||
|
|
||||||
// GMap Details
|
// GMap Details
|
||||||
marker : null,
|
marker : null,
|
||||||
icon : {
|
icon : {
|
||||||
strokeWeight: 1,
|
strokeWeight: 1,
|
||||||
path: planeSvg,
|
path: PlaneSvg,
|
||||||
scale: 0.4,
|
scale: 0.4,
|
||||||
fillColor: MarkerColor,
|
fillColor: MarkerColor,
|
||||||
fillOpacity: 0.9,
|
fillOpacity: 0.9,
|
||||||
|
@ -75,7 +78,7 @@ var planeObject = {
|
||||||
// Only useful for a long running browser session.
|
// Only useful for a long running browser session.
|
||||||
updateTrack : function() {
|
updateTrack : function() {
|
||||||
var here = new google.maps.LatLng(this.latitude, this.longitude);
|
var here = new google.maps.LatLng(this.latitude, this.longitude);
|
||||||
if (this.tracklinesegs.length == 0) {
|
if (this.track_linesegs.length == 0) {
|
||||||
// Brand new track
|
// Brand new track
|
||||||
//console.log(this.icao + " new track");
|
//console.log(this.icao + " new track");
|
||||||
var newseg = { track : new google.maps.MVCArray([here,here]),
|
var newseg = { track : new google.maps.MVCArray([here,here]),
|
||||||
|
@ -85,12 +88,12 @@ var planeObject = {
|
||||||
estimated : false,
|
estimated : false,
|
||||||
ground : (this.altitude === "ground")
|
ground : (this.altitude === "ground")
|
||||||
};
|
};
|
||||||
this.tracklinesegs.push(newseg);
|
this.track_linesegs.push(newseg);
|
||||||
this.historySize += 2;
|
this.history_size += 2;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastseg = this.tracklinesegs[this.tracklinesegs.length - 1];
|
var lastseg = this.track_linesegs[this.track_linesegs.length - 1];
|
||||||
var lastpos = lastseg.track.getAt(lastseg.track.getLength() - 1);
|
var lastpos = lastseg.track.getAt(lastseg.track.getLength() - 1);
|
||||||
var elapsed = (this.last_position_time - lastseg.head_update);
|
var elapsed = (this.last_position_time - lastseg.head_update);
|
||||||
|
|
||||||
|
@ -105,11 +108,11 @@ var planeObject = {
|
||||||
if (!lastseg.estimated) {
|
if (!lastseg.estimated) {
|
||||||
// >5s gap in data, create a new estimated segment
|
// >5s gap in data, create a new estimated segment
|
||||||
//console.log(this.icao + " switching to estimated");
|
//console.log(this.icao + " switching to estimated");
|
||||||
this.tracklinesegs.push({ track : new google.maps.MVCArray([lastpos, here]),
|
this.track_linesegs.push({ track : new google.maps.MVCArray([lastpos, here]),
|
||||||
line : null,
|
line : null,
|
||||||
head_update : this.last_position_time,
|
head_update : this.last_position_time,
|
||||||
estimated : true });
|
estimated : true });
|
||||||
this.historySize += 2;
|
this.history_size += 2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -117,20 +120,20 @@ var planeObject = {
|
||||||
//console.log(this.icao + " extending estimated (" + lastseg.track.getLength() + ")");
|
//console.log(this.icao + " extending estimated (" + lastseg.track.getLength() + ")");
|
||||||
lastseg.track.push(here);
|
lastseg.track.push(here);
|
||||||
lastseg.head_update = this.last_position_time;
|
lastseg.head_update = this.last_position_time;
|
||||||
this.historySize++;
|
this.history_size++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastseg.estimated) {
|
if (lastseg.estimated) {
|
||||||
// We are back to good data.
|
// We are back to good data.
|
||||||
//console.log(this.icao + " switching to good track");
|
//console.log(this.icao + " switching to good track");
|
||||||
this.tracklinesegs.push({ track : new google.maps.MVCArray([lastpos, here]),
|
this.track_linesegs.push({ track : new google.maps.MVCArray([lastpos, here]),
|
||||||
line : null,
|
line : null,
|
||||||
head_update : this.last_position_time,
|
head_update : this.last_position_time,
|
||||||
tail_update : this.last_position_time,
|
tail_update : this.last_position_time,
|
||||||
estimated : false,
|
estimated : false,
|
||||||
ground : (this.altitude === "ground") });
|
ground : (this.altitude === "ground") });
|
||||||
this.historySize += 2;
|
this.history_size += 2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,13 +144,13 @@ var planeObject = {
|
||||||
// assume the state changed halfway between the two points
|
// assume the state changed halfway between the two points
|
||||||
var midpoint = google.maps.geometry.spherical.interpolate(lastpos,here,0.5);
|
var midpoint = google.maps.geometry.spherical.interpolate(lastpos,here,0.5);
|
||||||
lastseg.track.push(midpoint);
|
lastseg.track.push(midpoint);
|
||||||
this.tracklinesegs.push({ track : new google.maps.MVCArray([midpoint,here,here]),
|
this.track_linesegs.push({ track : new google.maps.MVCArray([midpoint,here,here]),
|
||||||
line : null,
|
line : null,
|
||||||
head_update : this.last_position_time,
|
head_update : this.last_position_time,
|
||||||
tail_update : this.last_position_time,
|
tail_update : this.last_position_time,
|
||||||
estimated : false,
|
estimated : false,
|
||||||
ground : (this.altitude === "ground") });
|
ground : (this.altitude === "ground") });
|
||||||
this.historySize += 4;
|
this.history_size += 4;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +162,7 @@ var planeObject = {
|
||||||
//console.log(this.icao + " retain last point");
|
//console.log(this.icao + " retain last point");
|
||||||
lastseg.track.push(here);
|
lastseg.track.push(here);
|
||||||
lastseg.tail_update = lastseg.head_update;
|
lastseg.tail_update = lastseg.head_update;
|
||||||
this.historySize ++;
|
this.history_size ++;
|
||||||
} else {
|
} else {
|
||||||
// replace the last point with the current position
|
// replace the last point with the current position
|
||||||
lastseg.track.setAt(lastseg.track.getLength()-1, here);
|
lastseg.track.setAt(lastseg.track.getLength()-1, here);
|
||||||
|
@ -170,8 +173,8 @@ var planeObject = {
|
||||||
|
|
||||||
// This is to remove the line from the screen if we deselect the plane
|
// This is to remove the line from the screen if we deselect the plane
|
||||||
clearLines : function() {
|
clearLines : function() {
|
||||||
for (var i = 0; i < this.tracklinesegs.length; ++i) {
|
for (var i = 0; i < this.track_linesegs.length; ++i) {
|
||||||
var seg = this.tracklinesegs[i];
|
var seg = this.track_linesegs[i];
|
||||||
if (seg.line !== null) {
|
if (seg.line !== null) {
|
||||||
seg.line.setMap(null);
|
seg.line.setMap(null);
|
||||||
seg.line = null;
|
seg.line = null;
|
||||||
|
@ -192,11 +195,8 @@ var planeObject = {
|
||||||
|
|
||||||
// If the squawk code is one of the international emergency codes,
|
// If the squawk code is one of the international emergency codes,
|
||||||
// match the info window alert color.
|
// match the info window alert color.
|
||||||
var squawk_col = { '7500' : 'rgb(255, 85, 85)',
|
if (this.squawk in SpecialSquawks)
|
||||||
'7600' : 'rgb(0, 255, 255)',
|
col = SpecialSquawks[this.squawk].markerColor;
|
||||||
'7700' : 'rgb(255, 255, 0)' };
|
|
||||||
if (this.squawk in squawk_col)
|
|
||||||
col = squawk_col[this.squawk];
|
|
||||||
|
|
||||||
var weight = this.is_selected ? 2 : 1;
|
var weight = this.is_selected ? 2 : 1;
|
||||||
var rotation = (this.track === null ? 0 : this.track);
|
var rotation = (this.track === null ? 0 : this.track);
|
||||||
|
@ -316,8 +316,8 @@ var planeObject = {
|
||||||
if (!this.is_selected)
|
if (!this.is_selected)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (var i = 0; i < this.tracklinesegs.length; ++i) {
|
for (var i = 0; i < this.track_linesegs.length; ++i) {
|
||||||
var seg = this.tracklinesegs[i];
|
var seg = this.track_linesegs[i];
|
||||||
if (seg.line === null) {
|
if (seg.line === null) {
|
||||||
// console.log("create line for seg " + i + " with " + seg.track.getLength() + " points" + (seg.estimated ? " (estimated)" : ""));
|
// console.log("create line for seg " + i + " with " + seg.track.getLength() + " points" + (seg.estimated ? " (estimated)" : ""));
|
||||||
// for (var j = 0; j < seg.track.getLength(); j++) {
|
// for (var j = 0; j < seg.track.getLength(); j++) {
|
||||||
|
|
|
@ -4,24 +4,24 @@ var Planes = {};
|
||||||
var PlanesOrdered = [];
|
var PlanesOrdered = [];
|
||||||
var SelectedPlane = null;
|
var SelectedPlane = null;
|
||||||
|
|
||||||
var EmergencySquawks = {
|
var SpecialSquawks = {
|
||||||
'7500' : 'Aircraft Hijacking',
|
'7500' : { cssClass: 'squawk7500', markerColor: 'rgb(255, 85, 85)', text: 'Aircraft Hijacking' },
|
||||||
'7600' : 'Radio Failure',
|
'7600' : { cssClass: 'squawk7600', markerColor: 'rgb(0, 255, 255)', text: 'Radio Failure' },
|
||||||
'7700' : 'General Emergency'
|
'7700' : { cssClass: 'squawk7700', markerColor: 'rgb(255, 255, 0)', text: 'General Emergency' }
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get current map settings
|
// Get current map settings
|
||||||
CenterLat = Number(localStorage['CenterLat']) || CONST_CENTERLAT;
|
var CenterLat = Number(localStorage['CenterLat']) || CONST_CENTERLAT;
|
||||||
CenterLon = Number(localStorage['CenterLon']) || CONST_CENTERLON;
|
var CenterLon = Number(localStorage['CenterLon']) || CONST_CENTERLON;
|
||||||
ZoomLvl = Number(localStorage['ZoomLvl']) || CONST_ZOOMLVL;
|
var ZoomLvl = Number(localStorage['ZoomLvl']) || CONST_ZOOMLVL;
|
||||||
|
|
||||||
Dump1090Version = "unknown version";
|
var Dump1090Version = "unknown version";
|
||||||
RefreshInterval = 1000;
|
var RefreshInterval = 1000;
|
||||||
|
|
||||||
PlaneRowTemplate = null;
|
var PlaneRowTemplate = null;
|
||||||
|
|
||||||
TrackedAircraft = 0
|
var TrackedAircraft = 0;
|
||||||
TrackedPositions = 0
|
var TrackedPositions = 0;
|
||||||
|
|
||||||
function fetchData() {
|
function fetchData() {
|
||||||
$.getJSON('data/aircraft.json', function(data) {
|
$.getJSON('data/aircraft.json', function(data) {
|
||||||
|
@ -314,9 +314,9 @@ function refreshSelected() {
|
||||||
}
|
}
|
||||||
|
|
||||||
var emerg = document.getElementById('selected_emergency');
|
var emerg = document.getElementById('selected_emergency');
|
||||||
if (selected.squawk in EmergencySquawks) {
|
if (selected.squawk in SpecialSquawks) {
|
||||||
emerg.className = 'squawk' + selected.squawk;
|
emerg.className = SpecialSquawks[selected.squawk].cssClass;
|
||||||
emerg.textContent = '\u00a0Squawking: ' + EmergencySquawks[selected.squawk] + '\u00a0';
|
emerg.textContent = '\u00a0Squawking: ' + SpecialSquawks[selected.squawk].text + '\u00a0';
|
||||||
} else {
|
} else {
|
||||||
emerg.className = 'hidden';
|
emerg.className = 'hidden';
|
||||||
}
|
}
|
||||||
|
@ -433,7 +433,7 @@ function refreshTableInfo() {
|
||||||
|
|
||||||
for (var i = 0; i < PlanesOrdered.length; ++i) {
|
for (var i = 0; i < PlanesOrdered.length; ++i) {
|
||||||
var tableplane = PlanesOrdered[i];
|
var tableplane = PlanesOrdered[i];
|
||||||
TrackedHistorySize += tableplane.historySize;
|
TrackedHistorySize += tableplane.history_size;
|
||||||
if (!tableplane.visible) {
|
if (!tableplane.visible) {
|
||||||
tableplane.tr.className = "plane_table_row hidden";
|
tableplane.tr.className = "plane_table_row hidden";
|
||||||
} else {
|
} else {
|
||||||
|
@ -445,8 +445,8 @@ function refreshTableInfo() {
|
||||||
if (tableplane.icao == SelectedPlane)
|
if (tableplane.icao == SelectedPlane)
|
||||||
classes += " selected";
|
classes += " selected";
|
||||||
|
|
||||||
if (tableplane.squawk in EmergencySquawks) {
|
if (tableplane.squawk in SpecialSquawks) {
|
||||||
classes += (" squawk" + tableplane.squawk);
|
classes = classes + " " + SpecialSquawks[tableplane.squawk].cssClass;
|
||||||
show_squawk_warning = true;
|
show_squawk_warning = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue