From 87c65d812474b3b2abf52db83e38534f34571032 Mon Sep 17 00:00:00 2001 From: David Rollinson Date: Fri, 25 Dec 2020 09:47:01 +0800 Subject: [PATCH] Added values into example config file and set fallbacks in config.py --- chasemapper/config.py | 23 +++++++++++++++++------ horusmapper.cfg.example | 27 +++++++++++++++++++++++++++ static/js/tables.js | 5 ++--- 3 files changed, 46 insertions(+), 9 deletions(-) diff --git a/chasemapper/config.py b/chasemapper/config.py index da4574b..bd794ec 100644 --- a/chasemapper/config.py +++ b/chasemapper/config.py @@ -52,6 +52,17 @@ default_config = { 'bearing_weight': 1.0, 'bearing_color': 'black', 'bearing_custom_color': '#FF0000', + + # Unit selection + 'unitselection': 'metric', + 'm_to_ft': 3.28084, + 'km_to_miles' : 0.6213171, + 'secs_to_mins' : 0.016666, + 'ms_to_knots' : 1.94384, + 'switch_miles_feet' : 400, + + + } @@ -141,12 +152,12 @@ def parse_config_file(filename): # Unit Selection - chase_config['unitselection'] = config.get('units', 'unitselection') - chase_config['m_to_ft'] = config.get('units', 'm_to_ft') - chase_config['km_to_miles'] = config.get('units', 'km_to_miles') - chase_config['secs_to_mins'] = config.get('units', 'secs_to_mins') - chase_config['ms_to_knots'] = config.get('units', 'ms_to_knots') - chase_config['switch_miles_feet'] = config.get('units', 'switch_miles_feet') + chase_config['unitselection'] = config.get('units', 'unitselection', fallback='metric') + chase_config['m_to_ft'] = config.get('units', 'm_to_ft', fallback = '3.28084') + chase_config['km_to_miles'] = config.get('units', 'km_to_miles', fallback = '0.621371') + chase_config['secs_to_mins'] = config.get('units', 'secs_to_mins', fallback = '0.016666') + chase_config['ms_to_knots'] = config.get('units', 'ms_to_knots', fallback = '1.94384') + chase_config['switch_miles_feet'] = config.get('units', 'switch_miles_feet', fallback = '400') logging.info("Units: " + chase_config['unitselection']) logging.info("m_to_f: " + chase_config['m_to_ft']) diff --git a/horusmapper.cfg.example b/horusmapper.cfg.example index 6b02eb1..20f332d 100644 --- a/horusmapper.cfg.example +++ b/horusmapper.cfg.example @@ -200,3 +200,30 @@ bearing_color = black # Custom bearing color, in hexadecimal #RRGGBB bearing_custom_color = #FF0000 + + + +[units] + +# unitselection allows choice of metric - the default or imperial1 - horizontal miles and feet for short distances, horizontal miles per hour, vertical feet, vertical feet per minute + +unitselection = metric +# unitselection = imperial1 + + +# Imperial conversion factors + +m_to_ft = 3.28084 +km_to_miles = 0.621371 +secs_to_mins = 0.016666 +ms_to_knots = 1.94384 + +# Sensible choice of unit selection (all thresholds set in metric) + +# This is the threshold for switching from miles to feet, set in meters. +switch_miles_feet = 400 + + + + + diff --git a/static/js/tables.js b/static/js/tables.js index ad1a164..7c482a6 100644 --- a/static/js/tables.js +++ b/static/js/tables.js @@ -266,7 +266,7 @@ function initTablesImperial1(){ function updateTelemetryTable(){ var telem_data = []; - if (chase_config['unitselection'] == "imperial1") {initTablesImperial1() ; return ; } // else do everything in metric + if (chase_config['unitselection'] == "imperial1") {updateTelemetryTableImperial1() ; return ; } // else do everything in metric if (jQuery.isEmptyObject(balloon_positions)){ telem_data = [{callsign:'None'}]; }else{ @@ -277,7 +277,7 @@ function updateTelemetryTable(){ // Modify some of the fields to fixed point values. balloon_call_data.lat = balloon_call_data.position[0].toFixed(5); balloon_call_data.lon = balloon_call_data.position[1].toFixed(5); - balloon_call_data.alt = balloon_call_data.position[2].toFixed(1) + " (" + balloon_call_data.max_alt.toFixed(0) + ")" ; + balloon_call_data.alt = balloon_call_data.position[2].toFixed(0) + " (" + balloon_call_data.max_alt.toFixed(0) + ")" ; balloon_call_data.vel_v = balloon_call_data.vel_v.toFixed(1); // Add in any extra data to the aux field. @@ -308,7 +308,6 @@ function updateTelemetryTable(){ function updateTelemetryTableImperial1(){ var telem_data = []; - if (chase_config['unitselection'] == "imperial1") {initTablesImperial1() ; return ; } // else do everything in metric if (jQuery.isEmptyObject(balloon_positions)){ telem_data = [{callsign:'None'}]; }else{