diff --git a/chasemapper/config.py b/chasemapper/config.py index 6e1f23b..f782546 100644 --- a/chasemapper/config.py +++ b/chasemapper/config.py @@ -53,6 +53,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, + + + } @@ -143,12 +154,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 2b85597..f461266 100644 --- a/horusmapper.cfg.example +++ b/horusmapper.cfg.example @@ -211,3 +211,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 6efa107..d98767e 100644 --- a/static/js/tables.js +++ b/static/js/tables.js @@ -273,7 +273,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{ @@ -284,7 +284,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. @@ -315,7 +315,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{