From a707c592e12fa52893020d0ab2da660b13620cd1 Mon Sep 17 00:00:00 2001 From: V999TEC Date: Mon, 11 Jul 2022 11:26:29 +0100 Subject: [PATCH 01/11] Add elevation column --- public_html/formatter.js | 49 +++++++++++++++++ public_html/index.html | 19 +++++++ public_html/planeObject.js | 19 +++++++ public_html/script.js | 109 ++++++++++++++++++++++++++++++++++++- 4 files changed, 195 insertions(+), 1 deletion(-) diff --git a/public_html/formatter.js b/public_html/formatter.js index 3ae74205c..0051bec79 100644 --- a/public_html/formatter.js +++ b/public_html/formatter.js @@ -307,3 +307,52 @@ function format_nac_v (value) { return "n/a"; } } + +//// + +function format_elevation(siteAltFeet, siteDistMetres, altitudeFeet) { + + var ftHeight = 'ground' == altitudeFeet ? 0 : altitudeFeet; + + if( ftHeight < 0 ) { + + return 93; // it happens + } + + if( null == siteDistMetres) { + + return 92; // invalid angle + } + + if( null == altitudeFeet ) { + + return 91; // invalid angle + } + + if( 0 == siteDistMetres ) { // craft overhead + + return 90; + } + + var ftDistance = siteDistMetres*3.28084; + + var ftDiff = ftHeight - siteAltFeet; + + // make approximation for 2 * Earth radius in ft + + var radiansAngularDrop = ftDistance / 41784593; + + var radians = ftDiff / ftDistance; + + var elevAngleRadians = Math.atan( radians - radiansAngularDrop); + + var elevAngleDegrees = 57.29577951308232 * elevAngleRadians; + + var result = Math.round( 1000*elevAngleDegrees) / 1000; + + var result3dp = Number.parseFloat(result).toFixed(3); + + return result3dp; +} + +//// diff --git a/public_html/index.html b/public_html/index.html index 422f0013a..fd5bff1db 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -107,6 +107,19 @@ +
+
+
+
+ + +
+
+ +
+
+
+
Overlay Toggles
@@ -359,6 +372,10 @@
Photos
+
+
+
+
Elevation
@@ -388,6 +405,7 @@ Airframes.org FlightAware Photos + Elevation @@ -412,6 +430,7 @@ AIRFRAMES_MODE_S_LINK FLIGHTAWARE_MODE_S_LINK FLIGHTAWARE_PHOTO_LINK + ELEVATION diff --git a/public_html/planeObject.js b/public_html/planeObject.js index 5e0c5d64f..cff8f6315 100644 --- a/public_html/planeObject.js +++ b/public_html/planeObject.js @@ -2,6 +2,8 @@ function PlaneObject(icao) { // Info about the plane + this.count = 0; //// + this.icao = icao; this.icaorange = findICAORange(icao); this.flight = null; @@ -348,6 +350,23 @@ PlaneObject.prototype.getMarkerColor = function() { if (this.squawk in SpecialSquawks) return SpecialSquawks[this.squawk].markerColor; + //// + this.count ++; + + for( let index=0; index < SpecialElevations.length; index++) { + + if( this.elevation < SpecialElevations[index].exceptional ) { + + if( 0 == parseInt(this.count)%2 ) { + + return SpecialElevations[index].markerColor; + } + + break; + } + } + //// + var h, s, l; var colorArr = this.getAltitudeColor(); diff --git a/public_html/script.js b/public_html/script.js index d9812dc8e..e605ca4e5 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -2,6 +2,19 @@ "use strict"; // Define our global variables + +var DefaultSiteElevationAsl =0; //// +var SiteElevationAsl //// will be set from LocalStorage +var LowestElevationAngle = 90.0; //// +var HighestElevationAngle= 0.0; //// +var SpecialElevations = [ { exceptional: -0.5, markerColor: 'rgb(255, 0, 0)', logColour: "yellow"}, + { exceptional: -1.0, markerColor: 'rgb(0, 255, 0)', logColour: "orange"}, + { exceptional: -1.5, markerColor: 'rgb(0, 0, 255)', logColour: "pink"} ] ; //// +var MaximumMessageRate = 0.0 //// +var MaximumTrackedAircraft = 0; //// +var MaximumTrackedAircraftPositions = 0; //// +var logTime=0; //// + var OLMap = null; var StaticFeatures = new ol.Collection(); var SiteCircleFeatures = new ol.Collection(); @@ -88,7 +101,7 @@ var checkbox_div_map = new Map ([ ['#airframes_col_checkbox', '#airframes_mode_s_link'], ['#fa_modes_link_checkbox', '#flightaware_mode_s_link'], ['#fa_photo_link_checkbox', '#flightaware_photo_link'], - + ['#elevation_col_checkbox', '#elevation'], //// ]); var DefaultMinMaxFilters = { @@ -1101,6 +1114,8 @@ function initialize_map() { toggleLayer('#acpositions_checkbox', 'ac_positions'); }); + $('#elevation_asl_button').click(onSetElevationAsl); + // Add home marker if requested if (SitePosition) { var markerStyle = new ol.style.Style({ @@ -1431,6 +1446,7 @@ function refreshSelected() { $('#selected_sitedist').text(format_distance_long(selected.sitedist, DisplayUnits)); $('#selected_rssi').text(selected.rssi.toFixed(1) + ' dBFS'); $('#selected_message_count').text(selected.messages); + $('#selected_elevation').text(selected.elevation); //// $('#selected_photo_link').html(getFlightAwarePhotoLink(selected.registration)); $('#selected_altitude_geom').text(format_altitude_long(selected.alt_geom, selected.geom_rate, DisplayUnits)); $('#selected_mag_heading').text(format_track_long(selected.mag_heading)); @@ -1734,10 +1750,100 @@ function refreshTableInfo() { tableplane.tr.cells[17].innerHTML = getAirframesModeSLink(tableplane.icao); tableplane.tr.cells[18].innerHTML = getFlightAwareModeSLink(tableplane.icao, tableplane.flight); tableplane.tr.cells[19].innerHTML = getFlightAwarePhotoLink(tableplane.registration); + +//// + + var elevationAngle = format_elevation(SiteAltFeet, tableplane.sitedist, tableplane.altitude, tableplane.gs); + tableplane.elevation = elevationAngle; + + if( elevationAngle > 90 ) { + + tableplane.tr.cells[20].textContent = ''; + } + else { + tableplane.tr.cells[20].textContent = tableplane.elevation+'\u00b0'; + + // OPTIONAL: log the ident of the lowest and highest elevation angles seen so far + + let timestamp = new Date(); + let secondsNow= (Date.now() / 1000) >> 0; //// ms to integer seconds + + if( secondsNow > logTime ) { //// ensures no more than once a second + + logTime = secondsNow; + + let log=false; + + if( compareNumeric( elevationAngle, LowestElevationAngle) < 0 && null != tableplane.track ) { + + LowestElevationAngle = elevationAngle; + log=true; + } + + if( compareNumeric( elevationAngle, HighestElevationAngle) > 0 && null != tableplane.track ) { + + HighestElevationAngle = elevationAngle; + log=true; + } + + if( true == log ) { + + let ml = Number.parseFloat(tableplane.sitedist/1609.34).toFixed(1); // metres in imperial mile + let nm = Number.parseFloat(tableplane.sitedist/1852).toFixed(1); // metres in nautical mile + let km = Number.parseFloat(tableplane.sitedist/1000).toFixed(3); // metres in Km + + let identity = null == flight ? ( null == tableplane.registration ? + '?' : '('+tableplane.registration+')' ) : tableplane.flight; + + console.log(timestamp.toLocaleString()+" "+tableplane.tr.cells[20].textContent+" -> "+ + km+" Km @ ("+ tableplane.altitude+" - "+ SiteAltFeet+" ft) "+ + identity +" ("+ml+" ml / "+nm+" NM)"); + } + } + } + + //// + tableplane.tr.className = classes; } } + //// OPTIONAL: log highest message rates & # aircraft + + let log=false; + let colour="background: white;"; + + if( null != MessageRate ) { + + if( MessageRate > MaximumMessageRate ) { + + MaximumMessageRate = MessageRate; + colour="background: LightGreen;"; + log=true; + } + + if( TrackedAircraft > MaximumTrackedAircraft ) { + + MaximumTrackedAircraft = TrackedAircraft; + log=true; + } + + if( TrackedAircraftPositions > MaximumTrackedAircraftPositions ) { + + MaximumTrackedAircraftPositions = TrackedAircraftPositions; + log=true; + } + + if( true == log ) { + + console.log("%c%s",colour,timestamp.toLocaleString()+" ADS-B Message Rate: "+MessageRate.toFixed(1)+"/sec(max="+ + MaximumMessageRate.toFixed(1)+") Aircraft: "+TrackedAircraft+"(max="+MaximumTrackedAircraft+ + ") Positions: " +TrackedAircraftPositions+"(max="+MaximumTrackedAircraftPositions+")"); + } + } + + //// + if (show_squawk_warning) { $("#SpecialSquawkWarning").css('display','block'); } else { @@ -1783,6 +1889,7 @@ function sortByRssi() { sortBy('rssi', compareNumeric, function(x) { retu function sortByLatitude() { sortBy('lat', compareNumeric, function(x) { return (x.position !== null ? x.position[1] : null) }); } function sortByLongitude() { sortBy('lon', compareNumeric, function(x) { return (x.position !== null ? x.position[0] : null) }); } function sortByDataSource() { sortBy('data_source', compareAlpha, function(x) { return x.getDataSource() } ); } +function sortByElevation() { sortBy('elevation', compareNumeric, function(x) { return x.elevation; }); } //// var sortId = ''; var sortCompare = null; From d30cf14f51bb05d6025be40b6112bb5653bb0b08 Mon Sep 17 00:00:00 2001 From: V999TEC Date: Mon, 11 Jul 2022 12:09:17 +0100 Subject: [PATCH 02/11] Update script.js --- public_html/script.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/public_html/script.js b/public_html/script.js index e605ca4e5..295c9d84a 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -5,6 +5,7 @@ var DefaultSiteElevationAsl =0; //// var SiteElevationAsl //// will be set from LocalStorage +const SiteAltFeet = 0; //// var LowestElevationAngle = 90.0; //// var HighestElevationAngle= 0.0; //// var SpecialElevations = [ { exceptional: -0.5, markerColor: 'rgb(255, 0, 0)', logColour: "yellow"}, @@ -1756,6 +1757,8 @@ function refreshTableInfo() { var elevationAngle = format_elevation(SiteAltFeet, tableplane.sitedist, tableplane.altitude, tableplane.gs); tableplane.elevation = elevationAngle; + + if( elevationAngle > 90 ) { tableplane.tr.cells[20].textContent = ''; @@ -1764,7 +1767,6 @@ function refreshTableInfo() { tableplane.tr.cells[20].textContent = tableplane.elevation+'\u00b0'; // OPTIONAL: log the ident of the lowest and highest elevation angles seen so far - let timestamp = new Date(); let secondsNow= (Date.now() / 1000) >> 0; //// ms to integer seconds @@ -1836,6 +1838,7 @@ function refreshTableInfo() { if( true == log ) { + let timestamp = new Date(); console.log("%c%s",colour,timestamp.toLocaleString()+" ADS-B Message Rate: "+MessageRate.toFixed(1)+"/sec(max="+ MaximumMessageRate.toFixed(1)+") Aircraft: "+TrackedAircraft+"(max="+MaximumTrackedAircraft+ ") Positions: " +TrackedAircraftPositions+"(max="+MaximumTrackedAircraftPositions+")"); @@ -2793,6 +2796,28 @@ function onSetRangeRings() { createSiteCircleFeatures(); } + +//// functions to support configuration of global SiteElevationAsl +function setElevationAsl(val) { + localStorage['SiteElevationAsl'] = val; + setElevation(); +} + +function setElevation() { + + SiteElevationAsl = Number(localStorage['SiteElevationAsl']) || DefaultSiteElevationAsl; + // Populate text field with current value + $('#elevation_asl').val(SiteElevationAsl); +} + +function onSetElevationAsl() { + // Save state to localStorage + localStorage.setItem('SiteElevationAsl', parseFloat($("#elevation_asl").val().trim())); + setElevation(); +} +//// + + function toggleColumn(div, checkbox, toggled) { if (typeof localStorage[checkbox] === 'undefined') { localStorage.setItem(checkbox, 'deselected'); From 85a9cd3b20c433f98f6b843e1e35517b7afac58c Mon Sep 17 00:00:00 2001 From: V999TEC Date: Mon, 11 Jul 2022 12:31:08 +0100 Subject: [PATCH 03/11] elevation persistence --- public_html/index.html | 42 ++++++++++++++++++++++-------------------- public_html/script.js | 5 ++--- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/public_html/index.html b/public_html/index.html index fd5bff1db..4a65642b2 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -99,26 +99,28 @@
-
- - -
-
-
-
-
- - -
-
- -
-
-
+
+
+ + +
+
+
+
+
+ + +
+
+ +
+
+
+
diff --git a/public_html/script.js b/public_html/script.js index 295c9d84a..234900a3c 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -5,7 +5,6 @@ var DefaultSiteElevationAsl =0; //// var SiteElevationAsl //// will be set from LocalStorage -const SiteAltFeet = 0; //// var LowestElevationAngle = 90.0; //// var HighestElevationAngle= 0.0; //// var SpecialElevations = [ { exceptional: -0.5, markerColor: 'rgb(255, 0, 0)', logColour: "yellow"}, @@ -1754,7 +1753,7 @@ function refreshTableInfo() { //// - var elevationAngle = format_elevation(SiteAltFeet, tableplane.sitedist, tableplane.altitude, tableplane.gs); + var elevationAngle = format_elevation(SiteElevationAsl, tableplane.sitedist, tableplane.altitude, tableplane.gs); tableplane.elevation = elevationAngle; @@ -1798,7 +1797,7 @@ function refreshTableInfo() { '?' : '('+tableplane.registration+')' ) : tableplane.flight; console.log(timestamp.toLocaleString()+" "+tableplane.tr.cells[20].textContent+" -> "+ - km+" Km @ ("+ tableplane.altitude+" - "+ SiteAltFeet+" ft) "+ + km+" Km @ ("+ tableplane.altitude+" - "+ SiteElevationAsl+" ft) "+ identity +" ("+ml+" ml / "+nm+" NM)"); } } From cfac2326e8cefd27afe2e83e108bad67e5ff90dc Mon Sep 17 00:00:00 2001 From: V999TEC Date: Mon, 11 Jul 2022 12:35:47 +0100 Subject: [PATCH 04/11] elevation stuff --- public_html/formatter.js | 137 +++++++++++++++++++++------------- public_html/index.html | 69 +++++++++++------ public_html/planeObject.js | 41 ++++++++--- public_html/script.js | 147 ++++++++++++++++++++++++------------- 4 files changed, 261 insertions(+), 133 deletions(-) diff --git a/public_html/formatter.js b/public_html/formatter.js index 0051bec79..8b34b5d98 100644 --- a/public_html/formatter.js +++ b/public_html/formatter.js @@ -18,6 +18,94 @@ var UnitLabels = { // formatting helpers + +//// + +function format_elevation(siteAltFeet, siteDistMetres, altitudeFeet) { + + + + var ftHeight = 'ground' == altitudeFeet ? 0 : altitudeFeet; + + + + if( ftHeight < 0 ) { + + + + return 93; // it happens + + } + + + + if( null == siteDistMetres) { + + + + return 92; // invalid angle + + } + + + + if( null == altitudeFeet ) { + + + + return 91; // invalid angle + + } + + + + if( 0 == siteDistMetres ) { // craft overhead + + + + return 90; + + } + + + + var ftDistance = siteDistMetres*3.28084; + + var ftDiff = ftHeight - siteAltFeet; + + + +// make approximation for 2 * Earth radius in ft + + var radiansAngularDrop = ftDistance / 41784593; + + var radians = ftDiff / ftDistance; + + + + var elevAngleRadians = Math.atan( radians - radiansAngularDrop); + + + + var elevAngleDegrees = 57.29577951308232 * elevAngleRadians; + + + + var result = Math.round( 1000*elevAngleDegrees) / 1000; + + + + var result3dp = Number.parseFloat(result).toFixed(3); + + + + return result3dp; + +} + +//// + + function get_unit_label(quantity, systemOfMeasurement) { var labels = UnitLabels[quantity]; if (labels !== undefined && labels[systemOfMeasurement] !== undefined) { @@ -307,52 +395,3 @@ function format_nac_v (value) { return "n/a"; } } - -//// - -function format_elevation(siteAltFeet, siteDistMetres, altitudeFeet) { - - var ftHeight = 'ground' == altitudeFeet ? 0 : altitudeFeet; - - if( ftHeight < 0 ) { - - return 93; // it happens - } - - if( null == siteDistMetres) { - - return 92; // invalid angle - } - - if( null == altitudeFeet ) { - - return 91; // invalid angle - } - - if( 0 == siteDistMetres ) { // craft overhead - - return 90; - } - - var ftDistance = siteDistMetres*3.28084; - - var ftDiff = ftHeight - siteAltFeet; - - // make approximation for 2 * Earth radius in ft - - var radiansAngularDrop = ftDistance / 41784593; - - var radians = ftDiff / ftDistance; - - var elevAngleRadians = Math.atan( radians - radiansAngularDrop); - - var elevAngleDegrees = 57.29577951308232 * elevAngleRadians; - - var result = Math.round( 1000*elevAngleDegrees) / 1000; - - var result3dp = Number.parseFloat(result).toFixed(3); - - return result3dp; -} - -//// diff --git a/public_html/index.html b/public_html/index.html index 4a65642b2..300fdb081 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -2,7 +2,7 @@ - + @@ -17,15 +17,15 @@ - - - - - - - - - + + + + + + + + + PiAware SkyAware @@ -99,16 +99,23 @@
+
-
- - +
+ +
+ + +
+
+
+
@@ -120,8 +127,11 @@
+
-
+ +
+
Overlay Toggles
@@ -172,6 +182,8 @@
Show Aircraft Labels
+ +
Range Rings
@@ -374,11 +386,20 @@
Photos
-
-
-
-
Elevation
+ + + +
+ +
+ +
Elevation
+ +
+ + +
@@ -407,7 +428,9 @@ Airframes.org FlightAware Photos + Elevation + @@ -432,7 +455,9 @@ AIRFRAMES_MODE_S_LINK FLIGHTAWARE_MODE_S_LINK FLIGHTAWARE_PHOTO_LINK + ELEVATION + diff --git a/public_html/planeObject.js b/public_html/planeObject.js index cff8f6315..74ee361ba 100644 --- a/public_html/planeObject.js +++ b/public_html/planeObject.js @@ -2,8 +2,9 @@ function PlaneObject(icao) { // Info about the plane - this.count = 0; //// - + +this.count = 0; //// + this.icao = icao; this.icaorange = findICAORange(icao); this.flight = null; @@ -350,22 +351,38 @@ PlaneObject.prototype.getMarkerColor = function() { if (this.squawk in SpecialSquawks) return SpecialSquawks[this.squawk].markerColor; - //// - this.count ++; + +//// + + this.count ++; + + for( let index=0; index < SpecialElevations.length; index++) { - if( this.elevation < SpecialElevations[index].exceptional ) { - if( 0 == parseInt(this.count)%2 ) { - return SpecialElevations[index].markerColor; - } + if( this.elevation < SpecialElevations[index].exceptional ) { + + + + if( 0 == parseInt(this.count)%2 ) { + + + + return SpecialElevations[index].markerColor; + + } + + + + break; + + } + + } - break; - } - } - //// +//// var h, s, l; diff --git a/public_html/script.js b/public_html/script.js index 234900a3c..7b92a525d 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -5,14 +5,27 @@ var DefaultSiteElevationAsl =0; //// var SiteElevationAsl //// will be set from LocalStorage + +//const SiteAltFeet = 361; //// + var LowestElevationAngle = 90.0; //// + var HighestElevationAngle= 0.0; //// + var SpecialElevations = [ { exceptional: -0.5, markerColor: 'rgb(255, 0, 0)', logColour: "yellow"}, + { exceptional: -1.0, markerColor: 'rgb(0, 255, 0)', logColour: "orange"}, + { exceptional: -1.5, markerColor: 'rgb(0, 0, 255)', logColour: "pink"} ] ; //// + + + var MaximumMessageRate = 0.0 //// + var MaximumTrackedAircraft = 0; //// + var MaximumTrackedAircraftPositions = 0; //// + var logTime=0; //// var OLMap = null; @@ -101,7 +114,9 @@ var checkbox_div_map = new Map ([ ['#airframes_col_checkbox', '#airframes_mode_s_link'], ['#fa_modes_link_checkbox', '#flightaware_mode_s_link'], ['#fa_photo_link_checkbox', '#flightaware_photo_link'], - ['#elevation_col_checkbox', '#elevation'], //// + +['#elevation_col_checkbox', '#elevation'], //// + ]); var DefaultMinMaxFilters = { @@ -482,6 +497,8 @@ function initialize() { }); // Initialize settings from local storage + setElevation(); //// + filterGroundVehicles(false); filterBlockedMLAT(false); toggleAltitudeChart(false); @@ -869,6 +886,10 @@ function applyUrlQueryStrings() { if (params.get('ringInterval')) { setRingInterval(params.get('ringInterval')); } + + if (params.get('siteElevation')) { + setSiteElevation(params.get('siteElevation')); + } } // Make a LineString with 'points'-number points @@ -1114,7 +1135,8 @@ function initialize_map() { toggleLayer('#acpositions_checkbox', 'ac_positions'); }); - $('#elevation_asl_button').click(onSetElevationAsl); + +$('#elevation_asl_button').click(onSetElevationAsl); // Add home marker if requested if (SitePosition) { @@ -1446,8 +1468,10 @@ function refreshSelected() { $('#selected_sitedist').text(format_distance_long(selected.sitedist, DisplayUnits)); $('#selected_rssi').text(selected.rssi.toFixed(1) + ' dBFS'); $('#selected_message_count').text(selected.messages); - $('#selected_elevation').text(selected.elevation); //// $('#selected_photo_link').html(getFlightAwarePhotoLink(selected.registration)); + +$('#selected_elevation').text(selected.elevation); //// + $('#selected_altitude_geom').text(format_altitude_long(selected.alt_geom, selected.geom_rate, DisplayUnits)); $('#selected_mag_heading').text(format_track_long(selected.mag_heading)); $('#selected_true_heading').text(format_track_long(selected.true_heading)); @@ -1750,101 +1774,112 @@ function refreshTableInfo() { tableplane.tr.cells[17].innerHTML = getAirframesModeSLink(tableplane.icao); tableplane.tr.cells[18].innerHTML = getFlightAwareModeSLink(tableplane.icao, tableplane.flight); tableplane.tr.cells[19].innerHTML = getFlightAwarePhotoLink(tableplane.registration); - -//// + + + //// var elevationAngle = format_elevation(SiteElevationAsl, tableplane.sitedist, tableplane.altitude, tableplane.gs); + + + tableplane.elevation = elevationAngle; - - - if( elevationAngle > 90 ) { + + + if( elevationAngle > 90 ) { tableplane.tr.cells[20].textContent = ''; + } + else { - tableplane.tr.cells[20].textContent = tableplane.elevation+'\u00b0'; + + tableplane.tr.cells[20].textContent = tableplane.elevation+'\u00b0'; + + // OPTIONAL: log the ident of the lowest and highest elevation angles seen so far + + + let timestamp = new Date(); + let secondsNow= (Date.now() / 1000) >> 0; //// ms to integer seconds + + if( secondsNow > logTime ) { //// ensures no more than once a second + + logTime = secondsNow; + + let log=false; + + if( compareNumeric( elevationAngle, LowestElevationAngle) < 0 && null != tableplane.track ) { + + LowestElevationAngle = elevationAngle; + log=true; + } + + if( compareNumeric( elevationAngle, HighestElevationAngle) > 0 && null != tableplane.track ) { + + HighestElevationAngle = elevationAngle; + log=true; + } + + if( true == log ) { + + let ml = Number.parseFloat(tableplane.sitedist/1609.34).toFixed(1); // metres in imperial mile + let nm = Number.parseFloat(tableplane.sitedist/1852).toFixed(1); // metres in nautical mile + let km = Number.parseFloat(tableplane.sitedist/1000).toFixed(3); // metres in Km - let identity = null == flight ? ( null == tableplane.registration ? - '?' : '('+tableplane.registration+')' ) : tableplane.flight; - console.log(timestamp.toLocaleString()+" "+tableplane.tr.cells[20].textContent+" -> "+ - km+" Km @ ("+ tableplane.altitude+" - "+ SiteElevationAsl+" ft) "+ - identity +" ("+ml+" ml / "+nm+" NM)"); - } - } - } - //// - - tableplane.tr.className = classes; - } - } + let identity = null == flight ? ( null == tableplane.registration ? - //// OPTIONAL: log highest message rates & # aircraft + '?' : '('+tableplane.registration+')' ) : tableplane.flight; - let log=false; - let colour="background: white;"; - if( null != MessageRate ) { - if( MessageRate > MaximumMessageRate ) { + console.log(timestamp.toLocaleString()+" "+tableplane.tr.cells[20].textContent+" -> "+ - MaximumMessageRate = MessageRate; - colour="background: LightGreen;"; - log=true; - } + km+" Km @ ("+ tableplane.altitude+" - "+ SiteElevationAsl+" ft) "+ - if( TrackedAircraft > MaximumTrackedAircraft ) { + identity +" ("+ml+" ml / "+nm+" NM)"); - MaximumTrackedAircraft = TrackedAircraft; - log=true; - } + } - if( TrackedAircraftPositions > MaximumTrackedAircraftPositions ) { + } - MaximumTrackedAircraftPositions = TrackedAircraftPositions; - log=true; - } + } - if( true == log ) { + //// - let timestamp = new Date(); - console.log("%c%s",colour,timestamp.toLocaleString()+" ADS-B Message Rate: "+MessageRate.toFixed(1)+"/sec(max="+ - MaximumMessageRate.toFixed(1)+") Aircraft: "+TrackedAircraft+"(max="+MaximumTrackedAircraft+ - ") Positions: " +TrackedAircraftPositions+"(max="+MaximumTrackedAircraftPositions+")"); - } - } - //// + tableplane.tr.className = classes; + } + } if (show_squawk_warning) { $("#SpecialSquawkWarning").css('display','block'); @@ -1891,6 +1926,7 @@ function sortByRssi() { sortBy('rssi', compareNumeric, function(x) { retu function sortByLatitude() { sortBy('lat', compareNumeric, function(x) { return (x.position !== null ? x.position[1] : null) }); } function sortByLongitude() { sortBy('lon', compareNumeric, function(x) { return (x.position !== null ? x.position[0] : null) }); } function sortByDataSource() { sortBy('data_source', compareAlpha, function(x) { return x.getDataSource() } ); } + function sortByElevation() { sortBy('elevation', compareNumeric, function(x) { return x.elevation; }); } //// var sortId = ''; @@ -2146,6 +2182,7 @@ function resetMap() { localStorage['ZoomLvl'] = ZoomLvl = DefaultZoomLvl; // Reset to default range rings + localStorage['SiteCirclesElevation'] = SiteCirclesElevation = DefaultSiteCirclesElevation; localStorage['SiteCirclesCount'] = SiteCirclesCount = DefaultSiteCirclesCount; localStorage['SiteCirclesBaseDistance'] = SiteCirclesBaseDistance = DefaultSiteCirclesBaseDistance; localStorage['SiteCirclesInterval'] = SiteCirclesInterval = DefaultSiteCirclesInterval; @@ -2154,7 +2191,7 @@ function resetMap() { // Set and refresh OLMap.getView().setZoom(ZoomLvl); - OLMap.getView().setCenter(ol.proj.fromLonLat([CenterLon, CenterLat])); + OLMap.getView().setCenter(ol.proj.fromLonLat([CenterLon, CenterLat])); selectPlaneByHex(null,false); } @@ -2231,6 +2268,7 @@ function setColumnVisibility() { ] // Show default columns if checkboxes have not been set + for (var i=0; i < defaultCheckBoxes.length; i++) { var checkBoxdiv = defaultCheckBoxes[i]; var columnDiv = checkbox_div_map.get(checkBoxdiv) @@ -2241,6 +2279,7 @@ function setColumnVisibility() { showColumn(infoTable, columnDiv, true); } } + // Now check local storage checkbox status checkbox_div_map.forEach(function (div, checkbox) { @@ -2750,6 +2789,7 @@ function setRangeRingVisibility (showhide) { }); } + // simple function to set range ring count function setRingCount(val) { localStorage['SiteCirclesCount'] = val; @@ -2773,11 +2813,13 @@ function setRingInterval(val) { // Set range ring globals and populate form values function setRangeRings() { + SiteCirclesCount = Number(localStorage['SiteCirclesCount']) || DefaultSiteCirclesCount; SiteCirclesBaseDistance = Number(localStorage['SiteCirclesBaseDistance']) || DefaultSiteCirclesBaseDistance; SiteCirclesInterval = Number(localStorage['SiteCirclesInterval']) || DefaultSiteCirclesInterval; // Populate text fields with current values + $('#range_ring_count').val(SiteCirclesCount); $('#range_ring_base').val(SiteCirclesBaseDistance); $('#range_ring_interval').val(SiteCirclesInterval); @@ -2786,6 +2828,7 @@ function setRangeRings() { // redraw range rings with form values function onSetRangeRings() { // Save state to localStorage + localStorage.setItem('SiteCirclesCount', parseFloat($("#range_ring_count").val().trim())); localStorage.setItem('SiteCirclesBaseDistance', parseFloat($("#range_ring_base").val().trim())); localStorage.setItem('SiteCirclesInterval', parseFloat($("#range_ring_interval").val().trim())); @@ -2795,8 +2838,8 @@ function onSetRangeRings() { createSiteCircleFeatures(); } - //// functions to support configuration of global SiteElevationAsl + function setElevationAsl(val) { localStorage['SiteElevationAsl'] = val; setElevation(); @@ -2805,17 +2848,21 @@ function setElevationAsl(val) { function setElevation() { SiteElevationAsl = Number(localStorage['SiteElevationAsl']) || DefaultSiteElevationAsl; + // Populate text field with current value + $('#elevation_asl').val(SiteElevationAsl); } function onSetElevationAsl() { // Save state to localStorage + localStorage.setItem('SiteElevationAsl', parseFloat($("#elevation_asl").val().trim())); + setElevation(); } -//// +//// function toggleColumn(div, checkbox, toggled) { if (typeof localStorage[checkbox] === 'undefined') { From 662daf56a1ab4fefdca011262449369684ad9e56 Mon Sep 17 00:00:00 2001 From: V999TEC Date: Mon, 11 Jul 2022 13:08:23 +0100 Subject: [PATCH 05/11] formatting --- public_html/formatter.js | 48 +---------- public_html/index.html | 8 -- public_html/planeObject.js | 39 +++------ public_html/script.js | 171 ++++++++++++------------------------- 4 files changed, 65 insertions(+), 201 deletions(-) diff --git a/public_html/formatter.js b/public_html/formatter.js index 8b34b5d98..7d6cddb98 100644 --- a/public_html/formatter.js +++ b/public_html/formatter.js @@ -20,89 +20,43 @@ var UnitLabels = { //// - function format_elevation(siteAltFeet, siteDistMetres, altitudeFeet) { - - var ftHeight = 'ground' == altitudeFeet ? 0 : altitudeFeet; - - if( ftHeight < 0 ) { - - return 93; // it happens - } - - if( null == siteDistMetres) { - - return 92; // invalid angle - } - - if( null == altitudeFeet ) { - - return 91; // invalid angle - } - - if( 0 == siteDistMetres ) { // craft overhead - - return 90; - } - - var ftDistance = siteDistMetres*3.28084; - var ftDiff = ftHeight - siteAltFeet; - - -// make approximation for 2 * Earth radius in ft + // make approximation for 2 * Earth radius in ft var radiansAngularDrop = ftDistance / 41784593; - var radians = ftDiff / ftDistance; - - - var elevAngleRadians = Math.atan( radians - radiansAngularDrop); - - - var elevAngleDegrees = 57.29577951308232 * elevAngleRadians; - - - var result = Math.round( 1000*elevAngleDegrees) / 1000; - - - var result3dp = Number.parseFloat(result).toFixed(3); - - - return result3dp; - } - //// diff --git a/public_html/index.html b/public_html/index.html index 300fdb081..c23c10d1c 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -99,10 +99,8 @@
-
-
-
-
-
@@ -127,11 +122,8 @@
-
-
-
Overlay Toggles
diff --git a/public_html/planeObject.js b/public_html/planeObject.js index 74ee361ba..c5728b36d 100644 --- a/public_html/planeObject.js +++ b/public_html/planeObject.js @@ -3,7 +3,7 @@ function PlaneObject(icao) { // Info about the plane -this.count = 0; //// + this.count = 0; //// this.icao = icao; this.icaorange = findICAORange(icao); @@ -351,38 +351,21 @@ PlaneObject.prototype.getMarkerColor = function() { if (this.squawk in SpecialSquawks) return SpecialSquawks[this.squawk].markerColor; - -//// - - this.count ++; - - + //// + this.count ++; for( let index=0; index < SpecialElevations.length; index++) { + if( this.elevation < SpecialElevations[index].exceptional ) { + if( 0 == parseInt(this.count)%2 ) { - if( this.elevation < SpecialElevations[index].exceptional ) { - - - - if( 0 == parseInt(this.count)%2 ) { - - - - return SpecialElevations[index].markerColor; - - } - - - - break; - - } - - } - -//// + return SpecialElevations[index].markerColor; + } + break; + } + } + //// var h, s, l; diff --git a/public_html/script.js b/public_html/script.js index 7b92a525d..d6859bb3f 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -5,27 +5,14 @@ var DefaultSiteElevationAsl =0; //// var SiteElevationAsl //// will be set from LocalStorage - -//const SiteAltFeet = 361; //// - var LowestElevationAngle = 90.0; //// - var HighestElevationAngle= 0.0; //// - var SpecialElevations = [ { exceptional: -0.5, markerColor: 'rgb(255, 0, 0)', logColour: "yellow"}, - { exceptional: -1.0, markerColor: 'rgb(0, 255, 0)', logColour: "orange"}, - { exceptional: -1.5, markerColor: 'rgb(0, 0, 255)', logColour: "pink"} ] ; //// - - - var MaximumMessageRate = 0.0 //// - var MaximumTrackedAircraft = 0; //// - var MaximumTrackedAircraftPositions = 0; //// - var logTime=0; //// var OLMap = null; @@ -114,9 +101,7 @@ var checkbox_div_map = new Map ([ ['#airframes_col_checkbox', '#airframes_mode_s_link'], ['#fa_modes_link_checkbox', '#flightaware_mode_s_link'], ['#fa_photo_link_checkbox', '#flightaware_photo_link'], - -['#elevation_col_checkbox', '#elevation'], //// - + ['#elevation_col_checkbox', '#elevation'], //// ]); var DefaultMinMaxFilters = { @@ -1470,7 +1455,7 @@ function refreshSelected() { $('#selected_message_count').text(selected.messages); $('#selected_photo_link').html(getFlightAwarePhotoLink(selected.registration)); -$('#selected_elevation').text(selected.elevation); //// + $('#selected_elevation').text(selected.elevation); //// $('#selected_altitude_geom').text(format_altitude_long(selected.alt_geom, selected.geom_rate, DisplayUnits)); $('#selected_mag_heading').text(format_track_long(selected.mag_heading)); @@ -1757,128 +1742,78 @@ function refreshTableInfo() { tableplane.tr.cells[2].className = ""; } - tableplane.tr.cells[3].textContent = (tableplane.registration !== null ? tableplane.registration : ""); - tableplane.tr.cells[4].textContent = (tableplane.icaotype !== null ? tableplane.icaotype : ""); - tableplane.tr.cells[5].textContent = (tableplane.squawk !== null ? tableplane.squawk : ""); - tableplane.tr.cells[6].innerHTML = format_altitude_brief(tableplane.altitude, tableplane.vert_rate, DisplayUnits); - tableplane.tr.cells[7].textContent = format_speed_brief(tableplane.gs, DisplayUnits); - tableplane.tr.cells[8].textContent = format_vert_rate_brief(tableplane.vert_rate, DisplayUnits); - tableplane.tr.cells[9].textContent = format_distance_brief(tableplane.sitedist, DisplayUnits); - tableplane.tr.cells[10].textContent = format_track_brief(tableplane.track); - tableplane.tr.cells[11].textContent = tableplane.messages; - tableplane.tr.cells[12].textContent = tableplane.seen.toFixed(0); - tableplane.tr.cells[13].textContent = (tableplane.rssi !== null ? tableplane.rssi : ""); - tableplane.tr.cells[14].textContent = (tableplane.position !== null ? tableplane.position[1].toFixed(4) : ""); - tableplane.tr.cells[15].textContent = (tableplane.position !== null ? tableplane.position[0].toFixed(4) : ""); - tableplane.tr.cells[16].textContent = format_data_source(tableplane.getDataSource()); - tableplane.tr.cells[17].innerHTML = getAirframesModeSLink(tableplane.icao); - tableplane.tr.cells[18].innerHTML = getFlightAwareModeSLink(tableplane.icao, tableplane.flight); - tableplane.tr.cells[19].innerHTML = getFlightAwarePhotoLink(tableplane.registration); - - - //// - - var elevationAngle = format_elevation(SiteElevationAsl, tableplane.sitedist, tableplane.altitude, tableplane.gs); - - - - tableplane.elevation = elevationAngle; - - - - if( elevationAngle > 90 ) { - - tableplane.tr.cells[20].textContent = ''; - - } - - else { - - tableplane.tr.cells[20].textContent = tableplane.elevation+'\u00b0'; - - - - // OPTIONAL: log the ident of the lowest and highest elevation angles seen so far - - - - let timestamp = new Date(); - - let secondsNow= (Date.now() / 1000) >> 0; //// ms to integer seconds - - - - if( secondsNow > logTime ) { //// ensures no more than once a second - - - - logTime = secondsNow; - - + tableplane.tr.cells[3].textContent = (tableplane.registration !== null ? tableplane.registration : ""); + tableplane.tr.cells[4].textContent = (tableplane.icaotype !== null ? tableplane.icaotype : ""); + tableplane.tr.cells[5].textContent = (tableplane.squawk !== null ? tableplane.squawk : ""); + tableplane.tr.cells[6].innerHTML = format_altitude_brief(tableplane.altitude, tableplane.vert_rate, DisplayUnits); + tableplane.tr.cells[7].textContent = format_speed_brief(tableplane.gs, DisplayUnits); + tableplane.tr.cells[8].textContent = format_vert_rate_brief(tableplane.vert_rate, DisplayUnits); + tableplane.tr.cells[9].textContent = format_distance_brief(tableplane.sitedist, DisplayUnits); + tableplane.tr.cells[10].textContent = format_track_brief(tableplane.track); + tableplane.tr.cells[11].textContent = tableplane.messages; + tableplane.tr.cells[12].textContent = tableplane.seen.toFixed(0); + tableplane.tr.cells[13].textContent = (tableplane.rssi !== null ? tableplane.rssi : ""); + tableplane.tr.cells[14].textContent = (tableplane.position !== null ? tableplane.position[1].toFixed(4) : ""); + tableplane.tr.cells[15].textContent = (tableplane.position !== null ? tableplane.position[0].toFixed(4) : ""); + tableplane.tr.cells[16].textContent = format_data_source(tableplane.getDataSource()); + tableplane.tr.cells[17].innerHTML = getAirframesModeSLink(tableplane.icao); + tableplane.tr.cells[18].innerHTML = getFlightAwareModeSLink(tableplane.icao, tableplane.flight); + tableplane.tr.cells[19].innerHTML = getFlightAwarePhotoLink(tableplane.registration); + + + //// + var elevationAngle = format_elevation(SiteElevationAsl, tableplane.sitedist, tableplane.altitude, tableplane.gs); + tableplane.elevation = elevationAngle; + + if( elevationAngle > 90 ) { + + tableplane.tr.cells[20].textContent = ''; + } + else { - let log=false; + tableplane.tr.cells[20].textContent = tableplane.elevation+'\u00b0'; + // OPTIONAL: log the ident of the lowest and highest elevation angles seen so far + let timestamp = new Date(); + let secondsNow= (Date.now() / 1000) >> 0; //// ms to integer seconds - if( compareNumeric( elevationAngle, LowestElevationAngle) < 0 && null != tableplane.track ) { + if( secondsNow > logTime ) { //// ensures no more than once a second + logTime = secondsNow; + let log=false; + if( compareNumeric( elevationAngle, LowestElevationAngle) < 0 && null != tableplane.track ) { LowestElevationAngle = elevationAngle; - log=true; - } - - if( compareNumeric( elevationAngle, HighestElevationAngle) > 0 && null != tableplane.track ) { - - - HighestElevationAngle = elevationAngle; - - log=true; - + HighestElevationAngle = elevationAngle; + log=true; } + if( true == log ) { + let ml = Number.parseFloat(tableplane.sitedist/1609.34).toFixed(1); // metres in imperial mile + let nm = Number.parseFloat(tableplane.sitedist/1852).toFixed(1); // metres in nautical mile + let km = Number.parseFloat(tableplane.sitedist/1000).toFixed(3); // metres in Km - if( true == log ) { - - - - let ml = Number.parseFloat(tableplane.sitedist/1609.34).toFixed(1); // metres in imperial mile - - let nm = Number.parseFloat(tableplane.sitedist/1852).toFixed(1); // metres in nautical mile - - let km = Number.parseFloat(tableplane.sitedist/1000).toFixed(3); // metres in Km - - - - let identity = null == flight ? ( null == tableplane.registration ? - - '?' : '('+tableplane.registration+')' ) : tableplane.flight; - - - - console.log(timestamp.toLocaleString()+" "+tableplane.tr.cells[20].textContent+" -> "+ - - km+" Km @ ("+ tableplane.altitude+" - "+ SiteElevationAsl+" ft) "+ - - identity +" ("+ml+" ml / "+nm+" NM)"); - - } + let identity = null == flight ? ( null == tableplane.registration ? + '?' : '('+tableplane.registration+')' ) : tableplane.flight; + console.log(timestamp.toLocaleString()+" "+tableplane.tr.cells[20].textContent+" -> "+ + km+" Km @ ("+ tableplane.altitude+" - "+ SiteElevationAsl+" ft) "+ + identity +" ("+ml+" ml / "+nm+" NM)"); + } + } } + //// + tableplane.tr.className = classes; } - - //// - - - tableplane.tr.className = classes; - } } if (show_squawk_warning) { From 56592bacbf49ad1b75a85e22f9d6b19c5b022950 Mon Sep 17 00:00:00 2001 From: V999TEC Date: Mon, 11 Jul 2022 13:12:03 +0100 Subject: [PATCH 06/11] Update index.html --- public_html/index.html | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/public_html/index.html b/public_html/index.html index c23c10d1c..edc8852d4 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -2,7 +2,7 @@ - + @@ -17,15 +17,15 @@ - - - - - - - - - + + + + + + + + + PiAware SkyAware From fff5236050ce57964687ff109af7395beff1cf7e Mon Sep 17 00:00:00 2001 From: V999TEC Date: Mon, 11 Jul 2022 14:02:26 +0100 Subject: [PATCH 07/11] persistent storage for negative angle --- public_html/index.html | 9 +++++ public_html/planeObject.js | 17 +++++---- public_html/script.js | 78 ++++++++++++++++---------------------- 3 files changed, 52 insertions(+), 52 deletions(-) diff --git a/public_html/index.html b/public_html/index.html index edc8852d4..d090e8f9c 100644 --- a/public_html/index.html +++ b/public_html/index.html @@ -121,6 +121,15 @@
+
+
+ + +
+
+ +
+
diff --git a/public_html/planeObject.js b/public_html/planeObject.js index c5728b36d..7f13c8ec9 100644 --- a/public_html/planeObject.js +++ b/public_html/planeObject.js @@ -353,17 +353,20 @@ PlaneObject.prototype.getMarkerColor = function() { //// this.count ++; + + if( this.elevation < SiteNegativeAngle ) { - for( let index=0; index < SpecialElevations.length; index++) { + for( let index=0; index < SpecialElevations.length; index++) { - if( this.elevation < SpecialElevations[index].exceptional ) { + if( this.elevation < SpecialElevations[index].exceptional ) { - if( 0 == parseInt(this.count)%2 ) { + if( 0 == parseInt(this.count)%2 ) { - return SpecialElevations[index].markerColor; - } - break; - } + return SpecialElevations[index].markerColor; + } + break; + } + } } //// diff --git a/public_html/script.js b/public_html/script.js index d6859bb3f..67a15a164 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -4,12 +4,13 @@ // Define our global variables var DefaultSiteElevationAsl =0; //// +var DefaultSiteNegativeAngle= -0.5 //// var SiteElevationAsl //// will be set from LocalStorage -var LowestElevationAngle = 90.0; //// -var HighestElevationAngle= 0.0; //// -var SpecialElevations = [ { exceptional: -0.5, markerColor: 'rgb(255, 0, 0)', logColour: "yellow"}, - { exceptional: -1.0, markerColor: 'rgb(0, 255, 0)', logColour: "orange"}, - { exceptional: -1.5, markerColor: 'rgb(0, 0, 255)', logColour: "pink"} ] ; //// +var SiteNegativeAngle //// will be set from LocalStorage + +var SpecialElevations = [ { exceptional: -0.0, markerColor: 'rgb(255, 0, 0)'}, + { exceptional: -1.0, markerColor: 'rgb(0, 255, 0)'}, + { exceptional: -1.5, markerColor: 'rgb(0, 0, 255)'} ] ; //// var MaximumMessageRate = 0.0 //// var MaximumTrackedAircraft = 0; //// var MaximumTrackedAircraftPositions = 0; //// @@ -483,6 +484,7 @@ function initialize() { // Initialize settings from local storage setElevation(); //// + setNegativeAngle();//// filterGroundVehicles(false); filterBlockedMLAT(false); @@ -1120,8 +1122,10 @@ function initialize_map() { toggleLayer('#acpositions_checkbox', 'ac_positions'); }); - -$('#elevation_asl_button').click(onSetElevationAsl); + //// + $('#elevation_asl_button').click(onSetElevationAsl); + $('#negative_angle_button').click(onSetNegativeAngle); + //// // Add home marker if requested if (SitePosition) { @@ -1772,43 +1776,6 @@ function refreshTableInfo() { else { tableplane.tr.cells[20].textContent = tableplane.elevation+'\u00b0'; - - // OPTIONAL: log the ident of the lowest and highest elevation angles seen so far - - let timestamp = new Date(); - let secondsNow= (Date.now() / 1000) >> 0; //// ms to integer seconds - - if( secondsNow > logTime ) { //// ensures no more than once a second - - logTime = secondsNow; - let log=false; - - if( compareNumeric( elevationAngle, LowestElevationAngle) < 0 && null != tableplane.track ) { - - LowestElevationAngle = elevationAngle; - log=true; - } - - if( compareNumeric( elevationAngle, HighestElevationAngle) > 0 && null != tableplane.track ) { - - HighestElevationAngle = elevationAngle; - log=true; - } - - if( true == log ) { - - let ml = Number.parseFloat(tableplane.sitedist/1609.34).toFixed(1); // metres in imperial mile - let nm = Number.parseFloat(tableplane.sitedist/1852).toFixed(1); // metres in nautical mile - let km = Number.parseFloat(tableplane.sitedist/1000).toFixed(3); // metres in Km - - let identity = null == flight ? ( null == tableplane.registration ? - '?' : '('+tableplane.registration+')' ) : tableplane.flight; - - console.log(timestamp.toLocaleString()+" "+tableplane.tr.cells[20].textContent+" -> "+ - km+" Km @ ("+ tableplane.altitude+" - "+ SiteElevationAsl+" ft) "+ - identity +" ("+ml+" ml / "+nm+" NM)"); - } - } } //// @@ -2773,7 +2740,7 @@ function onSetRangeRings() { createSiteCircleFeatures(); } -//// functions to support configuration of global SiteElevationAsl +//// functions to support configuration of global SiteElevationAsl & SiteNegativeAngle function setElevationAsl(val) { localStorage['SiteElevationAsl'] = val; @@ -2797,6 +2764,27 @@ function onSetElevationAsl() { setElevation(); } +function setNegativeAngle(val) { + localStorage['SiteNegativeAngle'] = val; + setAngle(); +} + +function setAngle() { + + SiteNegativeAngle = Number(localStorage['SiteNegativeAngle']) || DefaultSiteNegativeAngle; + + // Populate text field with current value + + $('#negative_angle').val(SiteNegativeAngle); +} + +function onSetNegativeAngle() { + // Save state to localStorage + + localStorage.setItem('SiteNegativeAngle', parseFloat($("#negative_angle").val().trim())); + + setAngle(); +} //// function toggleColumn(div, checkbox, toggled) { From e8c11c213494433c11c0fd20c074f3464fe09d01 Mon Sep 17 00:00:00 2001 From: V999TEC Date: Mon, 11 Jul 2022 14:15:40 +0100 Subject: [PATCH 08/11] Update script.js --- public_html/script.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public_html/script.js b/public_html/script.js index 67a15a164..064bceb08 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -2781,7 +2781,8 @@ function setAngle() { function onSetNegativeAngle() { // Save state to localStorage - localStorage.setItem('SiteNegativeAngle', parseFloat($("#negative_angle").val().trim())); + var desiredNegativeAngle = parseFloat($("#negative_angle").val().trim()); + localStorage.setItem('SiteNegativeAngle', desiredNegativeAngle < 0 ? desiredNegativeAngle : DefaultSiteNegativeAngle); setAngle(); } From 2a4cb197e2a62409de4b207ae31b55aad7642dd1 Mon Sep 17 00:00:00 2001 From: V999TEC Date: Tue, 12 Jul 2022 08:42:36 +0100 Subject: [PATCH 09/11] Update script.js Remove unused variables --- public_html/script.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/public_html/script.js b/public_html/script.js index 064bceb08..3829d2e1b 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -11,11 +11,7 @@ var SiteNegativeAngle //// will be set from LocalStorage var SpecialElevations = [ { exceptional: -0.0, markerColor: 'rgb(255, 0, 0)'}, { exceptional: -1.0, markerColor: 'rgb(0, 255, 0)'}, { exceptional: -1.5, markerColor: 'rgb(0, 0, 255)'} ] ; //// -var MaximumMessageRate = 0.0 //// -var MaximumTrackedAircraft = 0; //// -var MaximumTrackedAircraftPositions = 0; //// -var logTime=0; //// - + var OLMap = null; var StaticFeatures = new ol.Collection(); var SiteCircleFeatures = new ol.Collection(); From a7710838170832d4333a57cb90e9195ee45eecd4 Mon Sep 17 00:00:00 2001 From: V999TEC Date: Thu, 14 Jul 2022 10:06:48 +0100 Subject: [PATCH 10/11] Update script.js Fix the initialisation/persistence to localStorage for SiteNegativeAngle --- public_html/script.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/public_html/script.js b/public_html/script.js index 3829d2e1b..79fc9decb 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -480,7 +480,7 @@ function initialize() { // Initialize settings from local storage setElevation(); //// - setNegativeAngle();//// + setAngle();//// filterGroundVehicles(false); filterBlockedMLAT(false); @@ -2086,6 +2086,9 @@ function resetMap() { localStorage['SiteCirclesInterval'] = SiteCirclesInterval = DefaultSiteCirclesInterval; setRangeRings(); createSiteCircleFeatures(); + + localStorage['SiteElevationAsl'] = SiteElevationAsl = DefaultSiteElevationAsl; //// + localStorage['SiteNegativeAngle'] = SiteNegativeAngle = DefaultSiteNegativeAngle; //// // Set and refresh OLMap.getView().setZoom(ZoomLvl); From f817391d31b7c63249fd9e0ca8ee9f276d15e3ae Mon Sep 17 00:00:00 2001 From: V999TEC Date: Thu, 14 Jul 2022 15:46:31 +0100 Subject: [PATCH 11/11] Update script.js Reset Map causing exception due to DefaultSiteCirclesElevation This meant other initialisation was not occurring --- public_html/script.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public_html/script.js b/public_html/script.js index 79fc9decb..e958cc4cd 100644 --- a/public_html/script.js +++ b/public_html/script.js @@ -2080,7 +2080,7 @@ function resetMap() { localStorage['ZoomLvl'] = ZoomLvl = DefaultZoomLvl; // Reset to default range rings - localStorage['SiteCirclesElevation'] = SiteCirclesElevation = DefaultSiteCirclesElevation; +//// localStorage['SiteCirclesElevation'] = SiteCirclesElevation = DefaultSiteCirclesElevation; localStorage['SiteCirclesCount'] = SiteCirclesCount = DefaultSiteCirclesCount; localStorage['SiteCirclesBaseDistance'] = SiteCirclesBaseDistance = DefaultSiteCirclesBaseDistance; localStorage['SiteCirclesInterval'] = SiteCirclesInterval = DefaultSiteCirclesInterval;