Prevent negative heading values.

This commit is contained in:
Philip Abbey
2024-08-29 21:00:50 +01:00
parent 63bc127aec
commit 17a5d89998

View File

@ -112,7 +112,11 @@ class BackgroundServiceDelegate extends System.ServiceDelegate {
data.put("speed", Math.round(position.speed));
}
if (position.heading != null) {
data.put("course", Math.round(position.heading * 180 / Math.PI));
var heading = Math.round(position.heading * 180 / Math.PI);
while (heading < 0) {
heading += 360;
}
data.put("course", heading);
}
if (position.altitude != null) {
data.put("altitude", Math.round(position.altitude));