Added ALTITUDE_UNIT

This commit is contained in:
tuffnerdstuff 2021-03-27 14:54:34 +01:00
parent 6b556c13a6
commit 8fd96ba436
4 changed files with 20 additions and 4 deletions

View file

@ -15,5 +15,6 @@ var MAX_POINTS = <?php echo json_encode(getConfig("max_shown_pts")); ?>;
var VELOCITY_DELTA_TIME = <?php echo json_encode(getConfig("v_data_points")); ?>;
var TRAIL_COLOR = <?php echo json_encode(getConfig("trail_color")); ?>;
var VELOCITY_UNIT = <?php echo json_encode(getConfig("velocity_unit")); ?>;
var ALTITUDE_UNIT = <?php echo json_encode(getConfig("altitude_unit")); ?>;
var OFFLINE_TIMEOUT = <?php echo json_encode(getConfig("offline_timeout")); ?>;
var REQUEST_TIMEOUT = <?php echo json_encode(getConfig("request_timeout")); ?>;

View file

@ -274,6 +274,10 @@
// KILOMETERS_PER_HOUR, MILES_PER_HOUR, METERS_PER_SECOND
"velocity_unit" => KILOMETERS_PER_HOUR,
// The unit of measurement of altitude. Valid are:
// METERS, FEET
"altitude_unit" => METERS,
// The publicly accessible URL to reach Hauk, with trailing slash.
"public_url" => 'https://example.com/'

View file

@ -59,6 +59,16 @@ const METERS_PER_SECOND = array(
"mpsMultiplier" => 1,
"unit" => "m/s"
);
const METERS = array(
// Absolute distance in meters
"metersMultiplier" => 1,
"unit" => "m"
);
const FEET = array(
// Absolute distance in feet
"metersMultiplier" => 3.280839895,
"unit" => "ft"
);
// Load fallback language.
include(__DIR__."/lang/en/texts.php");
@ -149,6 +159,7 @@ const DEFAULTS = array(
"v_data_points" => 2,
"trail_color" => '#d80037',
"velocity_unit" => KILOMETERS_PER_HOUR,
"altitude_unit" => METERS,
"public_url" => 'https://example.com/'
);

View file

@ -716,8 +716,8 @@ function processUpdate(data, init) {
VELOCITY_UNIT.unit +
' | </span>' +
'<span class="altitude">' +
// FIXME: add altitude unit
'<span id="altitude-' + shares[user].id + '">0.0</span> m' +
'<span id="altitude-' + shares[user].id + '">0.0</span> ' +
ALTITUDE_UNIT.unit +
'</span>' +
'<span class="offline" id="last-seen-' + shares[user].id + '">' +
'</span>' +
@ -793,8 +793,8 @@ function processUpdate(data, init) {
var eAltitude = document.getElementById("altitude-" + shares[user].id);
var alt = 0;
if (lastPoint !== null && lastPoint.alt !== null && eAltitude !== null) {
alt = lastPoint.alt
eAltitude.textContent = alt.toFixed(1)
alt = lastPoint.alt * ALTITUDE_UNIT.metersMultiplier;
eAltitude.textContent = alt.toFixed(1);
}
// Flag that the first location has been received, for map centering.