Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Distance filter - issue #191 #249

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion public_html/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,6 @@ ExtendedData = false;
DefaultMaxAltitudeFilter = 65000
DefaultMinAltitudeFilter = 0
DefaultMaxSpeedFilter = 1000
DefaultMinSpeedFilter = 0
DefaultMinSpeedFilter = 0
DefaultMaxDistanceFilter = 200
DefaultMinDistanceFilter = 0
31 changes: 31 additions & 0 deletions public_html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,17 @@
</div>
<div id="speed_slider"></div>
</div>
<div class="group">
<label><span class="infoBlockTitleText">Filter by Distance</span></label>
<div class="align_right">
<span id="minDistanceText" class="infoBlockTitleText"></span>
<label for="minDistance" class="distanceUnit"></label>
<span> to </span>
<span id="maxDistanceText" class="infoBlockTitleText"></span>
<label for="maxDistance" class="distanceUnit"></label>
</div>
<div id="distance_slider"></div>
</div>
<div class="group">
<form id="aircraft_type_filter_form">
<label><span class="infoBlockTitleText">Filter by Aircraft Type</span></label>
Expand All @@ -274,6 +285,26 @@
</div>
</form>
</div>
<div class="group">
<form id="distance_alert_beep_form">
<label><span class="infoBlockTitleText">Alert Distance</span></label>
<div class="align_right">
<input id="distance_alert_beep" name="distanceAlertBeep" type="number" step="0.01" class="aircraftFilterInput" maxlength="6">
<button type="submit">Filter</button>
<button id="distance_alert_beep_reset_button">Reset</button>
</div>
</form>
</div>
<div class="group">
<form id="altitude_alert_beep_form">
<label><span class="infoBlockTitleText">Alert Altitude</span></label>
<div class="align_right">
<input id="altitude_alert_beep" name="altitudeAlertBeep" type="number" step="100" class="aircraftFilterInput" maxlength="6">
<button type="submit">Filter</button>
<button id="altitude_alert_beep_reset_button">Reset</button>
</div>
</form>
</div>
</div>
<div id="column_select_panel" class="panel">
<div class="columnOptionSelectAllContainer">
Expand Down
32 changes: 31 additions & 1 deletion public_html/planeObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ function PlaneObject(icao) {
this.nav_modes = null;
this.nav_qnh = null;
this.rc = null;
this.nac_p = null;
this.nac_v = null;
this.nic_baro = null;
Expand Down Expand Up @@ -111,9 +111,11 @@ function PlaneObject(icao) {
if (this.selected) {
refreshSelected();
}

}.bind(this));
}


PlaneObject.prototype.isFiltered = function() {
// aircraft type filter
if (this.filter.aircraftTypeCode) {
Expand All @@ -129,6 +131,22 @@ PlaneObject.prototype.isFiltered = function() {
}
}

// distance alert filter
if (this.filter.distanceAlert) {
var warndistance = document.getElementById('distance_alert_beep')
if (this.sitedist < Number(warndistance)) {
return true;
}
}

// altitude alert filter
if (this.filter.altitudeAlert) {
var warnaltitude = document.getElementById('altitude_alert_beep')
if (this.nav_altitude < Number(warnaltitude)) {
return true;
}
}

var dataSource = this.getDataSource();
if (dataSource === 'uat') {
if (!this.filter.UAT) return true;
Expand Down Expand Up @@ -165,6 +183,18 @@ PlaneObject.prototype.isFiltered = function() {
}
}

if (this.filter.minDistanceFilter !== undefined && this.filter.maxDistanceFilter !== undefined) {
if (this.sitedist === null || this.sitedist === undefined) {
return true;
}

var convertedDistance = convert_distance(this.sitedist, this.filter.distanceUnits)
var isFilteredByDistance = convertedDistance < this.filter.minDistanceFilter || convertedDistance > this.filter.maxDistanceFilter;
if (isFilteredByDistance) {
return true;
}
}

// filter out ground vehicles
if (typeof this.filter.groundVehicles !== 'undefined' && this.filter.groundVehicles === 'filtered') {
if (typeof this.category === 'string' && this.category.startsWith('C')) {
Expand Down
Loading