Skip to content

Commit

Permalink
clean up some data source stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
wiedehopf committed Apr 5, 2021
1 parent 5651e3a commit 58005d7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 36 deletions.
2 changes: 2 additions & 0 deletions html/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ let tableColors = {
modeS: "#d8d8ff",
tisb: "#ffd8e6",
unknown: "#dcdcdc",
other: "#dcdcdc",
},
selected: {
adsb: "#88DDFF",
Expand All @@ -322,6 +323,7 @@ let tableColors = {
modeS: "#BEBEFF",
tisb: "#FFC1D8",
unknown: "#bcbcbc",
other: "#bcbcbc",
},
special: {
7500: "#ff5555",
Expand Down
44 changes: 12 additions & 32 deletions html/planeObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -561,51 +561,29 @@ PlaneObject.prototype.clearLines = function() {
};

PlaneObject.prototype.getDataSourceNumber = function() {
// MLAT
if (this.dataSource == "modeS")
return 5;
if (this.dataSource == "adsc")
return 6;
if (this.dataSource == "mlat") {
if (this.dataSource == "mlat")
return 3;
}

if (this.dataSource == "uat" || (this.addrtype && this.addrtype.substring(0,4) == "adsr"))
return 2; // UAT

// Not MLAT, but position reported - ADSB or letiants
if (this.dataSource == "tisb")
return 4; // TIS-B
if (this.dataSource == "adsb")
return 1;

// Otherwise Mode S
return 7;
if (this.dataSource == "other")
return 7;

// TODO: add support for Mode A/C
return 8;
};

PlaneObject.prototype.getDataSource = function() {
// MLAT
if (this.dataSource == "mlat") {
return 'mlat';
}
if (this.dataSource == "uat" && this.dataSource != "tisb")
return 'uat';

if (this.addrtype) {
return this.addrtype;
}

if (this.dataSource == "adsb")
return "adsb_icao";

if (this.dataSource == "tisb")
return "tisb";

// Otherwise Mode S
return 'modeS';

// TODO: add support for Mode A/C
return this.dataSource;
};

PlaneObject.prototype.getMarkerColor = function(options) {
Expand Down Expand Up @@ -1329,11 +1307,11 @@ PlaneObject.prototype.updateData = function(now, last, data, init) {
this.dataSource = "adsr";
} else if ((lat != null && type == null) || (type && (type.substring(0,4) == "adsb"))) {
this.dataSource = "adsb";
}

if (type == 'adsc') {
} else if (type == 'adsc') {
this.dataSource = "adsc";
} else if (type == 'unknown' || type == 'other') {
} else if (type == 'other') {
this.dataSource = "other";
} else if (type == 'unknown') {
this.dataSource = "unknown";
}

Expand Down Expand Up @@ -2186,6 +2164,8 @@ PlaneObject.prototype.updateTraceData = function(state, _now) {
this.dataSource = "tisb";
} else if (data.type == 'adsc') {
this.dataSource = "adsc";
} else if (data.type == 'other') {
this.dataSource = "other";
} else if (data.type == 'unknown') {
this.dataSource = "unknown";
}
Expand Down
8 changes: 4 additions & 4 deletions html/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ let debugCounter = 0;
let pathName = null;
let icaoFilter = null;
let sourcesFilter = null;
let sources = ['adsb', ['uat', 'adsr'], 'mlat', 'tisb', ['modeS', 'unknown'], 'adsc'];
let sources = ['adsb', ['uat', 'adsr'], 'mlat', 'tisb', ['modeS', 'other'], 'adsc'];
let flagFilter = null;
let flagFilterValues = ['military', 'pia', 'ladd'];
let showTrace = false;
Expand Down Expand Up @@ -1059,7 +1059,7 @@ function initLegend(colors) {
if (!globeIndex)
html += '<div class="legendTitle" style="background-color:' + colors['modeS'] + ';">Mode-S</div>';
if (globeIndex)
html += '<div class="legendTitle" style="background-color:' + colors['unknown'] + ';">Unknown</div>';
html += '<div class="legendTitle" style="background-color:' + colors['other'] + ';">Other</div>';

document.getElementById('legend').innerHTML = html;
}
Expand All @@ -1079,7 +1079,7 @@ function initSourceFilter(colors) {
if (!globeIndex)
html += createFilter(colors['modeS'], 'Mode-S');
if (globeIndex)
html += createFilter(colors['unknown'], 'Unknown');
html += createFilter(colors['other'], 'Other');

if (globeIndex)
html += createFilter(colors['uat'], 'ADS-C');
Expand Down Expand Up @@ -2436,7 +2436,7 @@ function refreshSelected() {
if (selected.position && SitePosition) {
selected.sitedist = ol.sphere.getDistance(SitePosition, selected.position);
}
$('#selected_source').text(format_data_source(selected.getDataSource()));
$('#selected_source').text(format_data_source(selected.dataSource));
$('#selected_category').text(selected.category ? selected.category : "n/a");
$('#selected_sitedist1').text(format_distance_long(selected.sitedist, DisplayUnits));
$('#selected_sitedist2').text(format_distance_long(selected.sitedist, DisplayUnits));
Expand Down

0 comments on commit 58005d7

Please sign in to comment.