Add ability to filter planes by altitude
This commit is contained in:
parent
e243a2bf1a
commit
6b2c238a54
5 changed files with 122 additions and 15 deletions
|
|
@ -41,6 +41,7 @@ function PlaneObject(icao) {
|
|||
this.markerIcon = null;
|
||||
this.markerStyleKey = null;
|
||||
this.markerSvgKey = null;
|
||||
this.filter = {};
|
||||
|
||||
// request metadata
|
||||
this.registration = null;
|
||||
|
|
@ -60,6 +61,18 @@ function PlaneObject(icao) {
|
|||
}.bind(this));
|
||||
}
|
||||
|
||||
PlaneObject.prototype.isFiltered = function() {
|
||||
if (this.filter.minAltitude !== undefined && this.filter.maxAltitude !== undefined) {
|
||||
if (this.altitude === null || this.altitude === undefined) {
|
||||
return true;
|
||||
}
|
||||
var planeAltitude = this.altitude === "ground" ? 0 : convert_altitude(this.altitude, this.filter.altitudeUnits);
|
||||
return planeAltitude < this.filter.minAltitude || planeAltitude > this.filter.maxAltitude;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Appends data to the running track so we can get a visual tail on the plane
|
||||
// Only useful for a long running browser session.
|
||||
PlaneObject.prototype.updateTrack = function(estimate_time) {
|
||||
|
|
@ -413,7 +426,7 @@ PlaneObject.prototype.clearMarker = function() {
|
|||
|
||||
// Update our marker on the map
|
||||
PlaneObject.prototype.updateMarker = function(moved) {
|
||||
if (!this.visible || this.position == null) {
|
||||
if (!this.visible || this.position == null || this.isFiltered()) {
|
||||
this.clearMarker();
|
||||
return;
|
||||
}
|
||||
|
|
@ -466,9 +479,10 @@ PlaneObject.prototype.updateLines = function() {
|
|||
var lastfixed = lastseg.fixed.getCoordinateAt(1.0);
|
||||
var geom = new ol.geom.LineString([lastfixed, ol.proj.fromLonLat(this.position)]);
|
||||
var feature = new ol.Feature(geom);
|
||||
lastseg.feature = feature;
|
||||
feature.setStyle(this.altitude === 'ground' ? groundStyle : airStyle);
|
||||
|
||||
if (PlaneTrailFeatures.length == 0) {
|
||||
if (PlaneTrailFeatures.getLength() == 0) {
|
||||
PlaneTrailFeatures.push(feature);
|
||||
} else {
|
||||
PlaneTrailFeatures.setAt(0, feature);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue