Skip to content

Commit 7a2e3a3

Browse files
committed
Add option to isplay horizontal distance in hours
The Horus team found that horizontal distances in m/s were hard to get an intuition for, particularly as the speed across land is often used for calculating if a car can travel to the landing site in time. This change adds a selectable option that modifies the horizontal speed to be calculated in km/h, or m/h if the user has selected imperial units. The default behaviour is still to use distance per second. Signed-off-by: Joel Stanley <[email protected]>
1 parent 356a924 commit 7a2e3a3

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,13 @@ <h2>Settings</h2>
7777
<input type="checkbox" id="opt_imperial">
7878
</div>
7979
</div>
80+
<div class="row option">
81+
<span><b>Horizontal speed in hours</b></span>
82+
<div class="switch off" id="sw_haxis_hours">
83+
<span class="thumb hourswitch"></span>
84+
<input type="checkbox" id="opt_haxis_hours">
85+
</div>
86+
</div>
8087
<div class="row option">
8188
<span><b>Availability offline</b></span>
8289
<div class="switch off" id="sw_offline">

js/app.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ $(window).ready(function() {
389389
if(offline.get('opt_daylight')) $('#sw_daylight').removeClass('off').addClass('on');
390390

391391
// offline and mobile
392-
$('#sw_offline, #sw_station, #sw_imperial').click(function() {
392+
$('#sw_offline, #sw_station, #sw_imperial, #sw_haxis_hours').click(function() {
393393
var e = $(this);
394394
var name = e.attr('id').replace('sw', 'opt');
395395
var on;
@@ -403,12 +403,13 @@ $(window).ready(function() {
403403
}
404404

405405
offline.set(name, on);
406-
if(name == "opt_imperial") refreshUI();
406+
if(name == "opt_imperial" || name == "opt_haxis_hours") refreshUI();
407407
});
408408

409409
if(offline.get('opt_offline')) $('#sw_offline').removeClass('off').addClass('on');
410410
if(offline.get('opt_station')) $('#sw_station').removeClass('off').addClass('on');
411411
if(offline.get('opt_imperial')) $('#sw_imperial').removeClass('off').addClass('on');
412+
if(offline.get('opt_haxis_hours')) $('#sw_haxis_hours').removeClass('off').addClass('on');
412413

413414
// force re-cache
414415
$('#sw_cache').click(function() {

js/tracker.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,11 @@ function updateVehicleInfo(index, position) {
358358

359359
var imp = offline.get('opt_imperial');
360360
var ascent_text = imp ? (vehicles[index].ascent_rate * 196.850394).toFixed(1) + ' ft/min' : vehicles[index].ascent_rate.toFixed(1) + ' m/s';
361-
var hrate_text = imp ? (vehicles[index].horizontal_rate * 196.850394).toFixed(1) + ' ft/min' : vehicles[index].horizontal_rate.toFixed(1) + ' m/s';
361+
if (offline.get('opt_haxis_hours')) {
362+
var hrate_text = imp ? (vehicles[index].horizontal_rate * 2.23693629).toFixed(1) + ' mph' : (vehicles[index].horizontal_rate * 3.6).toFixed(1) + ' km/h';
363+
} else {
364+
var hrate_text = imp ? (vehicles[index].horizontal_rate * 196.850394).toFixed(1) + ' ft/min' : vehicles[index].horizontal_rate.toFixed(1) + ' m/s';
365+
}
362366

363367
var coords_text;
364368
var ua = navigator.userAgent.toLowerCase();
@@ -816,7 +820,7 @@ function addPosition(position) {
816820
- convert_time(vehicle.curr_position.gps_time);
817821

818822
if(dt != 0) {
819-
// calcualte vertical rate
823+
// calculate vertical rate
820824
var rate = (position.gps_alt - vehicle.curr_position.gps_alt) / dt;
821825
vehicle.ascent_rate = 0.7 * rate
822826
+ 0.3 * vehicle.ascent_rate;

0 commit comments

Comments
 (0)