Skip to content

Commit

Permalink
Implement altitude accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
NightScript370 committed Jul 29, 2024
1 parent ebaa308 commit a99d584
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions assets/js/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ async function updateList(event) {

/** @type {Omit<GeolocationPosition, 'coords'> & { coords: Partial<GeolocationCoordinates>}} */
const params = { timestamp: new Date().getTime(), coords: { latitude: lat, longitude: lng } }
if (elements.manual.elevationInput.value)
if (elements.manual.elevationInput.value) {
params.coords.altitude = parseFloat(elements.manual.elevationInput.value);
params.coords.altitudeAccuracy = true
}

await setLatLong(params, !elements.manual.timezoneSelect.value);
openCalendarWithLocationInfo();
Expand Down Expand Up @@ -420,7 +422,7 @@ async function setLatLong (position, manual=false) {
geoLocation.lat = position.coords.latitude
geoLocation.long = position.coords.longitude

if ('altitude' in position.coords && position.coords.altitude !== null) {
if ('altitude' in position.coords && position.coords.altitude !== null && 'altitudeAccuracy' in position.coords && position.coords.altitudeAccuracy) {
geoLocation.elevation = position.coords.altitude
} else {
geoLocation.elevation = await getAverageElevation(position.coords.latitude, position.coords.longitude);
Expand Down

0 comments on commit a99d584

Please sign in to comment.