Skip to content

Commit c5afdc1

Browse files
shenkirossengeorgiev
authored andcommitted
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 b5d2190 commit c5afdc1

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

cache.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CACHE MANIFEST
2-
# version 219
2+
# version 220
33

44
# gogole maps files
55
http://maps.google.com/maps/api/js?v=3.10&sensor=false&language=en_us&key=AIzaSyCOqkcNey4CCyG4X0X5qxHAhCgD8g5DwXg

index.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,13 @@ <h2><i class="icon-settings rfloat"></i>Settings</h2>
105105
<input type="checkbox" id="opt_imperial">
106106
</div>
107107
</div>
108+
<div class="row option">
109+
<span><b>Horizontal speed in hours</b></span>
110+
<div class="switch off" id="sw_haxis_hours">
111+
<span class="thumb hourswitch"></span>
112+
<input type="checkbox" id="opt_haxis_hours">
113+
</div>
114+
</div>
108115
<div class="row option">
109116
<span><b>Availability offline</b></span>
110117
<div class="switch off" id="sw_offline">

js/app.js

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

453453
// offline and mobile
454-
$('#sw_offline, #sw_station, #sw_imperial').click(function() {
454+
$('#sw_offline, #sw_station, #sw_imperial, #sw_haxis_hours').click(function() {
455455
var e = $(this);
456456
var name = e.attr('id').replace('sw', 'opt');
457457
var on;
@@ -465,12 +465,13 @@ $(window).ready(function() {
465465
}
466466

467467
offline.set(name, on);
468-
if(name == "opt_imperial") refreshUI();
468+
if(name == "opt_imperial" || name == "opt_haxis_hours") refreshUI();
469469
});
470470

471471
if(offline.get('opt_offline')) $('#sw_offline').removeClass('off').addClass('on');
472472
if(offline.get('opt_station')) $('#sw_station').removeClass('off').addClass('on');
473473
if(offline.get('opt_imperial')) $('#sw_imperial').removeClass('off').addClass('on');
474+
if(offline.get('opt_haxis_hours')) $('#sw_haxis_hours').removeClass('off').addClass('on');
474475

475476
// force re-cache
476477
$('#sw_cache').click(function() {

js/tracker.js

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

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

362366
var coords_text;
363367
var ua = navigator.userAgent.toLowerCase();
@@ -815,7 +819,7 @@ function addPosition(position) {
815819
- convert_time(vehicle.curr_position.gps_time);
816820

817821
if(dt != 0) {
818-
// calcualte vertical rate
822+
// calculate vertical rate
819823
var rate = (position.gps_alt - vehicle.curr_position.gps_alt) / dt;
820824
vehicle.ascent_rate = 0.7 * rate
821825
+ 0.3 * vehicle.ascent_rate;

0 commit comments

Comments
 (0)