Speed filter and white space cleanup
This commit is contained in:
parent
22e02dbc62
commit
930d2534a2
|
|
@ -234,6 +234,17 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="altitude_slider"></div>
|
<div id="altitude_slider"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="group">
|
||||||
|
<label><span class="infoBlockTitleText">Filter by Speed</span></label>
|
||||||
|
<div class="align_right">
|
||||||
|
<span id="minSpeedText" class="infoBlockTitleText"></span>
|
||||||
|
<label for="minSpeed" class="speedUnit"></label>
|
||||||
|
<span> to </span>
|
||||||
|
<span id="maxSpeedText" class="infoBlockTitleText"></span>
|
||||||
|
<label for="maxSpeed" class="speedUnit"></label>
|
||||||
|
</div>
|
||||||
|
<div id="speed_slider"></div>
|
||||||
|
</div>
|
||||||
<div class="group">
|
<div class="group">
|
||||||
<form id="aircraft_type_filter_form">
|
<form id="aircraft_type_filter_form">
|
||||||
<label><span class="infoBlockTitleText">Filter by Aircraft Type</span></label>
|
<label><span class="infoBlockTitleText">Filter by Aircraft Type</span></label>
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ function PlaneObject(icao) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.selected) {
|
if (this.selected) {
|
||||||
refreshSelected();
|
refreshSelected();
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
}
|
}
|
||||||
|
|
@ -112,7 +112,7 @@ PlaneObject.prototype.isFiltered = function() {
|
||||||
// aircraft type filter
|
// aircraft type filter
|
||||||
if (this.filter.aircraftTypeCode) {
|
if (this.filter.aircraftTypeCode) {
|
||||||
if (this.icaotype === null || (typeof this.icaotype === 'string' && !this.icaotype.toUpperCase().trim().match(this.filter.aircraftTypeCode))) {
|
if (this.icaotype === null || (typeof this.icaotype === 'string' && !this.icaotype.toUpperCase().trim().match(this.filter.aircraftTypeCode))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -136,23 +136,38 @@ PlaneObject.prototype.isFiltered = function() {
|
||||||
|
|
||||||
if (this.filter.minAltitude !== undefined && this.filter.maxAltitude !== undefined) {
|
if (this.filter.minAltitude !== undefined && this.filter.maxAltitude !== undefined) {
|
||||||
if (this.altitude === null || this.altitude === undefined) {
|
if (this.altitude === null || this.altitude === undefined) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
var planeAltitude = this.altitude === "ground" ? 0 : convert_altitude(this.altitude, this.filter.altitudeUnits);
|
var planeAltitude = this.altitude === "ground" ? 0 : convert_altitude(this.altitude, this.filter.altitudeUnits);
|
||||||
return planeAltitude < this.filter.minAltitude || planeAltitude > this.filter.maxAltitude;
|
var isFilteredByAltitude = planeAltitude < this.filter.minAltitude || planeAltitude > this.filter.maxAltitude;
|
||||||
|
if (isFilteredByAltitude) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.filter.minSpeedFilter !== undefined && this.filter.maxSpeedFilter !== undefined) {
|
||||||
|
if (this.speed === null || this.speed === undefined) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
var convertedSpeed = convert_speed(this.speed, this.filter.speedUnits)
|
||||||
|
var isFilteredBySpeed = convertedSpeed < this.filter.minSpeedFilter || convertedSpeed > this.filter.maxSpeedFilter;
|
||||||
|
if (isFilteredBySpeed) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter out ground vehicles
|
// filter out ground vehicles
|
||||||
if (typeof this.filter.groundVehicles !== 'undefined' && this.filter.groundVehicles === 'filtered') {
|
if (typeof this.filter.groundVehicles !== 'undefined' && this.filter.groundVehicles === 'filtered') {
|
||||||
if (typeof this.category === 'string' && this.category.startsWith('C')) {
|
if (typeof this.category === 'string' && this.category.startsWith('C')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter out blocked MLAT flights
|
// filter out blocked MLAT flights
|
||||||
if (typeof this.filter.blockedMLAT !== 'undefined' && this.filter.blockedMLAT === 'filtered') {
|
if (typeof this.filter.blockedMLAT !== 'undefined' && this.filter.blockedMLAT === 'filtered') {
|
||||||
if (typeof this.icao === 'string' && this.icao.startsWith('~')) {
|
if (typeof this.icao === 'string' && this.icao.startsWith('~')) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -483,17 +498,16 @@ PlaneObject.prototype.updateIcon = function() {
|
||||||
|
|
||||||
// Update our data
|
// Update our data
|
||||||
PlaneObject.prototype.updateData = function(receiver_timestamp, data) {
|
PlaneObject.prototype.updateData = function(receiver_timestamp, data) {
|
||||||
// Update all of our data
|
// Update all of our data
|
||||||
this.messages = data.messages;
|
this.messages = data.messages;
|
||||||
this.rssi = data.rssi;
|
this.rssi = data.rssi;
|
||||||
this.last_message_time = receiver_timestamp - data.seen;
|
this.last_message_time = receiver_timestamp - data.seen;
|
||||||
|
|
||||||
// simple fields
|
// simple fields
|
||||||
|
|
||||||
var fields = ["alt_baro", "alt_geom", "gs", "ias", "tas", "track",
|
var fields = ["alt_baro", "alt_geom", "gs", "ias", "tas", "track",
|
||||||
"track_rate", "mag_heading", "true_heading", "mach",
|
"track_rate", "mag_heading", "true_heading", "mach",
|
||||||
"roll", "nav_heading", "nav_modes",
|
"roll", "nav_heading", "nav_modes",
|
||||||
"nac_p", "nac_v", "nic_baro", "sil_type", "sil",
|
"nac_p", "nac_v", "nic_baro", "sil_type", "sil",
|
||||||
"nav_qnh", "baro_rate", "geom_rate", "rc",
|
"nav_qnh", "baro_rate", "geom_rate", "rc",
|
||||||
"squawk", "category", "version"];
|
"squawk", "category", "version"];
|
||||||
|
|
||||||
|
|
@ -580,38 +594,38 @@ PlaneObject.prototype.updateTick = function(receiver_timestamp, last_timestamp)
|
||||||
this.seen = receiver_timestamp - this.last_message_time;
|
this.seen = receiver_timestamp - this.last_message_time;
|
||||||
this.seen_pos = (this.last_position_time === null ? null : receiver_timestamp - this.last_position_time);
|
this.seen_pos = (this.last_position_time === null ? null : receiver_timestamp - this.last_position_time);
|
||||||
|
|
||||||
// If no packet in over 58 seconds, clear the plane.
|
// If no packet in over 58 seconds, clear the plane.
|
||||||
if (this.seen > 58) {
|
if (this.seen > 58) {
|
||||||
if (this.visible) {
|
if (this.visible) {
|
||||||
//console.log("hiding " + this.icao);
|
//console.log("hiding " + this.icao);
|
||||||
this.clearMarker();
|
this.clearMarker();
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
if (SelectedPlane == this.icao)
|
if (SelectedPlane == this.icao)
|
||||||
selectPlaneByHex(null,false);
|
selectPlaneByHex(null,false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (this.position !== null && (this.selected || this.seen_pos < 60)) {
|
if (this.position !== null && (this.selected || this.seen_pos < 60)) {
|
||||||
this.visible = true;
|
this.visible = true;
|
||||||
if (this.updateTrack(receiver_timestamp, last_timestamp)) {
|
if (this.updateTrack(receiver_timestamp, last_timestamp)) {
|
||||||
this.updateLines();
|
this.updateLines();
|
||||||
this.updateMarker(true);
|
this.updateMarker(true);
|
||||||
} else {
|
} else {
|
||||||
this.updateMarker(false); // didn't move
|
this.updateMarker(false); // didn't move
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.clearMarker();
|
this.clearMarker();
|
||||||
this.visible = false;
|
this.visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
PlaneObject.prototype.clearMarker = function() {
|
PlaneObject.prototype.clearMarker = function() {
|
||||||
if (this.marker) {
|
if (this.marker) {
|
||||||
PlaneIconFeatures.remove(this.marker);
|
PlaneIconFeatures.remove(this.marker);
|
||||||
PlaneIconFeatures.remove(this.markerStatic);
|
PlaneIconFeatures.remove(this.markerStatic);
|
||||||
/* FIXME google.maps.event.clearListeners(this.marker, 'click'); */
|
/* FIXME google.maps.event.clearListeners(this.marker, 'click'); */
|
||||||
this.marker = this.markerStatic = null;
|
this.marker = this.markerStatic = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update our marker on the map
|
// Update our marker on the map
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,7 @@ var layers;
|
||||||
var layerGroup;
|
var layerGroup;
|
||||||
|
|
||||||
var altitude_slider = null;
|
var altitude_slider = null;
|
||||||
|
var speed_slider = null;
|
||||||
|
|
||||||
// piaware vs flightfeeder
|
// piaware vs flightfeeder
|
||||||
var isFlightFeeder = false;
|
var isFlightFeeder = false;
|
||||||
|
|
@ -342,6 +343,44 @@ function initialize() {
|
||||||
customAltitudeColors = false;
|
customAltitudeColors = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
speed_slider = document.getElementById('speed_slider');
|
||||||
|
|
||||||
|
noUiSlider.create(speed_slider, {
|
||||||
|
start: [0, 1000],
|
||||||
|
connect: true,
|
||||||
|
range: {
|
||||||
|
'min': 0,
|
||||||
|
'max': 1000
|
||||||
|
},
|
||||||
|
step: 5,
|
||||||
|
format: {
|
||||||
|
// 'to' the formatted value. Receives a number.
|
||||||
|
to: function (value) {
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
// 'from' the formatted value.
|
||||||
|
// Receives a string, should return a number.
|
||||||
|
from: function (value) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var minSpeedInput = document.getElementById('minSpeedText'),
|
||||||
|
maxSpeedInput = document.getElementById('maxSpeedText');
|
||||||
|
|
||||||
|
speed_slider.noUiSlider.on('update', function (values, handle) {
|
||||||
|
if (handle) {
|
||||||
|
maxSpeedInput.innerHTML = values[handle];
|
||||||
|
} else {
|
||||||
|
minSpeedInput.innerHTML = values[handle];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
speed_slider.noUiSlider.on('set', function (values, handle) {
|
||||||
|
onFilterBySpeed();
|
||||||
|
});
|
||||||
|
|
||||||
$("#aircraft_type_filter_form").submit(onFilterByAircraftType);
|
$("#aircraft_type_filter_form").submit(onFilterByAircraftType);
|
||||||
$("#aircraft_type_filter_reset_button").click(onResetAircraftTypeFilter);
|
$("#aircraft_type_filter_reset_button").click(onResetAircraftTypeFilter);
|
||||||
|
|
||||||
|
|
@ -2037,6 +2076,11 @@ function onFilterByAltitude() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onFilterBySpeed() {
|
||||||
|
updatePlaneFilter();
|
||||||
|
refreshTableInfo();
|
||||||
|
}
|
||||||
|
|
||||||
function onFilterByAircraftType(e) {
|
function onFilterByAircraftType(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
updatePlaneFilter();
|
updatePlaneFilter();
|
||||||
|
|
@ -2128,21 +2172,29 @@ function toggleAltitudeChart(switchToggle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updatePlaneFilter() {
|
function updatePlaneFilter() {
|
||||||
|
// Get min/max altitude values from slider
|
||||||
var minAltitude = document.getElementById('minAltitudeText').innerHTML.trim();
|
var minAltitude = document.getElementById('minAltitudeText').innerHTML.trim();
|
||||||
var maxAltitude = document.getElementById('maxAltitudeText').innerHTML.trim();
|
var maxAltitude = document.getElementById('maxAltitudeText').innerHTML.trim();
|
||||||
|
|
||||||
console.log("minAltitude: " + minAltitude);
|
|
||||||
console.log("maxAltitude: " + maxAltitude);
|
|
||||||
|
|
||||||
PlaneFilter.minAltitude = minAltitude;
|
PlaneFilter.minAltitude = minAltitude;
|
||||||
PlaneFilter.maxAltitude = maxAltitude;
|
PlaneFilter.maxAltitude = maxAltitude;
|
||||||
PlaneFilter.altitudeUnits = DisplayUnits;
|
PlaneFilter.altitudeUnits = DisplayUnits;
|
||||||
|
|
||||||
|
// Get min/max speed values from slider
|
||||||
|
var minSpeedFilter = document.getElementById('minSpeedText').innerHTML.trim();
|
||||||
|
var maxSpeedFilter = document.getElementById('maxSpeedText').innerHTML.trim();
|
||||||
|
|
||||||
|
PlaneFilter.minSpeedFilter = minSpeedFilter;
|
||||||
|
PlaneFilter.maxSpeedFilter = maxSpeedFilter;
|
||||||
|
PlaneFilter.speedUnits = DisplayUnits;
|
||||||
|
|
||||||
|
// Get aircraft type code filter from input box
|
||||||
var aircraftTypeCode = $("#aircraft_type_filter").val().trim().toUpperCase()
|
var aircraftTypeCode = $("#aircraft_type_filter").val().trim().toUpperCase()
|
||||||
if (aircraftTypeCode === "") {
|
if (aircraftTypeCode === "") {
|
||||||
aircraftTypeCode = undefined
|
aircraftTypeCode = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get aircraft ident filter from input box
|
||||||
var aircraftIdent = $("#aircraft_ident_filter").val().trim().toUpperCase()
|
var aircraftIdent = $("#aircraft_ident_filter").val().trim().toUpperCase()
|
||||||
if (aircraftIdent === "") {
|
if (aircraftIdent === "") {
|
||||||
aircraftIdent = undefined
|
aircraftIdent = undefined
|
||||||
|
|
|
||||||
|
|
@ -888,7 +888,7 @@ select.error, textarea.error, input.error {
|
||||||
grid-template-columns: repeat(3, 1fr);
|
grid-template-columns: repeat(3, 1fr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#altitude_slider {
|
#altitude_slider, #speed_slider {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: block;
|
display: block;
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue