From 051307478106e325d350dd63132392efe0bca9c0 Mon Sep 17 00:00:00 2001 From: "Travis.Cobbs" <77415528+tcobbs-bentley@users.noreply.github.com> Date: Fri, 29 Mar 2024 16:53:25 -0700 Subject: [PATCH] Make [0.0, 360.0) heading clamp more reliable --- .../com/github/itwin/mobilesdk/ITMGeolocationManager.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mobile-sdk/src/main/java/com/github/itwin/mobilesdk/ITMGeolocationManager.kt b/mobile-sdk/src/main/java/com/github/itwin/mobilesdk/ITMGeolocationManager.kt index 17d7898..6d99c02 100644 --- a/mobile-sdk/src/main/java/com/github/itwin/mobilesdk/ITMGeolocationManager.kt +++ b/mobile-sdk/src/main/java/com/github/itwin/mobilesdk/ITMGeolocationManager.kt @@ -514,7 +514,12 @@ class ITMGeolocationManager(private var context: Context) { } private fun clampHeading(heading: Double?): Double? = if (heading != null) { - (heading + 360.0) % 360.0 + val clamp = heading % 360.0 + if (clamp < 0.0) { + clamp + 360.0 + } else { + clamp + } } else { null }