Skip to content

Commit

Permalink
fix: reset device heading offset and use speed in combination with st…
Browse files Browse the repository at this point in the history
…raight line check
  • Loading branch information
afonsosousah committed Jun 11, 2024
1 parent 21c9fbb commit 32af6a4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions scripts/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,8 @@ function getLocation(zoom = true) {
//map.getView().setCenter(ol.proj.fromLonLat(pos));
}

// Use GPS heading if user is ruffly in a straight line for the last 5 seconds
if (gpsHeading && inStraightLine) {
// Use GPS heading if user is ruffly in a straight line for the last 5 seconds and over 12kph
if (gpsHeading && inStraightLine && speed >= (12 * 1000) / (60 * 60)) {
// Calculate offset between gps heading and compass heading
deviceHeadingOffset = Math.PI - Math.abs(Math.abs(gpsHeading - compassHeading) - Math.PI);

Expand Down Expand Up @@ -504,14 +504,14 @@ function startLocationDotRotation() {
if (!pos) return;

// Reset offset if there is not using gps heading
/*if (!(gpsHeading && inStraightLine)) {
if (!(gpsHeading && inStraightLine && speed >= (12 * 1000) / (60 * 60))) {
// Reset offset
deviceHeadingOffset = 0;

// Dev info
document.getElementById("headingSource").innerHTML = "Compass";
document.getElementById("headingSource").style.backgroundColor = "lightblue";
}*/
}

// Calculate final heading
heading = compassHeading + deviceHeadingOffset;
Expand Down

0 comments on commit 32af6a4

Please sign in to comment.