diff --git a/html/planeObject.js b/html/planeObject.js
index f49d617..025d3cb 100644
--- a/html/planeObject.js
+++ b/html/planeObject.js
@@ -150,6 +150,8 @@ const estimateStyle = new ol.style.Style({
})
});
+const nullStyle = new ol.style.Style({});
+
const badDot = new ol.style.Style({
image: new ol.style.Circle({
radius: 3.5,
@@ -191,15 +193,8 @@ PlaneObject.prototype.isFiltered = function() {
return true;
}
- if (this.filter.minAltitude != undefined && this.filter.maxAltitude != undefined) {
- if (this.altitude == null) {
+ if (!filterTracks && this.altFiltered(this.altitude))
return true;
- }
- var planeAltitude = this.altitude === "ground" ? 0 : convert_altitude(this.altitude, this.filter.altitudeUnits);
- if (planeAltitude < this.filter.minAltitude || planeAltitude > this.filter.maxAltitude) {
- return true;
- }
- }
// filter out ground vehicles
if (typeof this.filter.groundVehicles !== 'undefined' && this.filter.groundVehicles === 'filtered') {
@@ -218,6 +213,20 @@ PlaneObject.prototype.isFiltered = function() {
return false;
}
+
+PlaneObject.prototype.altFiltered = function(altitude) {
+ if (this.filter.minAltitude == null || this.filter.maxAltitude == null)
+ return false;
+ if (altitude == null) {
+ return true;
+ }
+ const planeAltitude = altitude === "ground" ? 0 : altitude;
+ if (planeAltitude < this.filter.minAltitude || planeAltitude > this.filter.maxAltitude) {
+ return true;
+ }
+ return false;
+}
+
PlaneObject.prototype.updateTail = function() {
this.tail_update = this.prev_time;
@@ -913,7 +922,7 @@ PlaneObject.prototype.updateData = function(now, last, data, init) {
if (this.flight && this.flight.trim()) {
this.name = this.flight;
- } else if (this.registration && this.registration != "UNKN") {
+ } else if (this.registration) {
this.name = '_' + this.registration;
} else {
this.name = '_' + this.icao.toUpperCase();
@@ -1050,15 +1059,15 @@ PlaneObject.prototype.updateLines = function() {
if (this.track_linesegs.length == 0)
return;
-
-
// create the new elastic band feature
var lastseg = this.track_linesegs[this.track_linesegs.length - 1];
var lastfixed = lastseg.fixed.getCoordinateAt(1.0);
var geom = new ol.geom.LineString([lastfixed, ol.proj.fromLonLat(this.position)]);
this.elastic_feature = new ol.Feature(geom);
- if (lastseg.estimated) {
- this.elastic_feature.setStyle(noVanish ? new ol.style.Style({}) : estimateStyle);
+ if (filterTracks && this.altFiltered(lastseg.altitude)) {
+ this.elastic_feature.setStyle(nullStyle);
+ } else if (lastseg.estimated) {
+ this.elastic_feature.setStyle(noVanish ? nullStyle : estimateStyle);
} else {
this.elastic_feature.setStyle(this.altitudeLines(lastseg.altitude));
}
@@ -1073,17 +1082,20 @@ PlaneObject.prototype.updateLines = function() {
if (seg.feature && (!trackLabels || seg.label))
break;
- if (!seg.feature) {
+ if (filterTracks && this.altFiltered(seg.altitude)) {
+ } else if (!seg.feature) {
seg.feature = new ol.Feature(seg.fixed);
if (seg.estimated) {
- seg.feature.setStyle(noVanish ? new ol.style.Style({}) : estimateStyle);
+ seg.feature.setStyle(noVanish ? nullStyle : estimateStyle);
} else {
seg.feature.setStyle(this.altitudeLines(seg.altitude));
}
seg.feature.hex = this.icao;
this.trail_features.push(seg.feature);
}
- if (trackLabels && !seg.label && seg.alt_real != null) {
+
+ if (filterTracks && this.altFiltered(seg.altitude)) {
+ } else if (trackLabels && !seg.label && seg.alt_real != null) {
seg.label = new ol.Feature(new ol.geom.Point(seg.fixed.getFirstCoordinate()));
const text = seg.alt_real == "ground" ? "" :
(Number(seg.speed).toFixed(0).toString().padStart(6, NBSP) + " \n" + seg.alt_real.toString().padStart(6, NBSP)) + " ";
diff --git a/html/script.js b/html/script.js
index 0d8c6e4..0baf2a3 100644
--- a/html/script.js
+++ b/html/script.js
@@ -54,6 +54,7 @@ var debugJump = false;
var noMLAT = false;
var noVanish = false;
var sidebarVisible = true;
+var filterTracks = false;
var SpecialSquawks = {
'7500' : { cssClass: 'squawk7500', markerColor: 'rgb(255, 85, 85)', text: 'Aircraft Hijacking' },
@@ -393,6 +394,7 @@ function initialize() {
if (localStorage['noVanish'] == "true") {
noVanish = true;
+ filterTracks = noVanish;
//localStorage['noVanish'] = "false";
}
@@ -1097,6 +1099,7 @@ function initialize_map() {
break;
case "V":
noVanish = !noVanish;
+ filterTracks = noVanish;
localStorage['noVanish'] = noVanish;
console.log('noVanish = ' + noVanish);
for (var i in PlanesOrdered) {
@@ -2510,9 +2513,19 @@ function updatePlaneFilter() {
if (maxAltitude < -1e6 || maxAltitude > 1e6 || isNaN(maxAltitude))
maxAltitude = 1e6;
- PlaneFilter.minAltitude = minAltitude;
- PlaneFilter.maxAltitude = maxAltitude;
- PlaneFilter.altitudeUnits = DisplayUnits;
+ if (DisplayUnits == "metric") {
+ PlaneFilter.minAltitude = minAltitude * 3.2808;
+ PlaneFilter.maxAltitude = maxAltitude * 3.2808;
+ } else {
+ PlaneFilter.minAltitude = minAltitude;
+ PlaneFilter.maxAltitude = maxAltitude;
+ }
+
+ if (filterTracks) {
+ for (var i in PlanesOrdered) {
+ PlanesOrdered[i].remakeTrail();
+ }
+ }
for (var i in PlanesOrdered) {
var plane = PlanesOrdered[i];