From f7a96294bbfb8db9aecbd50e6c28d82c9bba1438 Mon Sep 17 00:00:00 2001 From: Helium314 Date: Thu, 22 Feb 2024 12:01:09 +0100 Subject: [PATCH] store/restore rotation correctly --- .../westnordost/streetcomplete/screens/main/MainFragment.kt | 4 ++-- .../streetcomplete/screens/main/map/MainMapFragment.kt | 2 +- .../screens/main/map/tangram/CameraManager.kt | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainFragment.kt index 5f370f1b96..15583bf0d1 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/main/MainFragment.kt @@ -876,9 +876,9 @@ class MainFragment : binding.locationPointerPin.isGone = intersectionPosition == null if (intersectionPosition != null) { val angleAtIntersection = position.initialBearingTo(intersectionPosition) - binding.locationPointerPin.pinRotation = angleAtIntersection.toFloat() + (180 * rotation / PI).toFloat() + binding.locationPointerPin.pinRotation = (angleAtIntersection + rotation).toFloat() - val a = angleAtIntersection * PI / 180f + rotation + val a = (angleAtIntersection + rotation) * PI / 180f val offsetX = (sin(a) / 2.0 + 0.5) * binding.locationPointerPin.width val offsetY = (-cos(a) / 2.0 + 0.5) * binding.locationPointerPin.height binding.locationPointerPin.x = intersection.x - offsetX.toFloat() diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/MainMapFragment.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/MainMapFragment.kt index c6093463fa..7c27359cef 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/MainMapFragment.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/MainMapFragment.kt @@ -169,7 +169,7 @@ class MainMapFragment : LocationAwareMapFragment(), ShowsGeometryMarkers { // is it definitely a maplibre issue? or maybe some map change listener? // any way tp get useful stack traces from maplibre? often it just starts at Handler.dispatchMessage, so no idea which line of SC triggered it // re-arrange things so things can be added via mapController instead of doing everything here and with MainActivity - // rotation not stored / restored correctly on startup (but location is) + // when tilt is used and map is scrolled up far enough, pointer pin points 180° wrong // gps and user tracks not working (why?) // created features seem correct, but also not added to other layers (e.g. putting into geometrySource) // downloadedAreaMapComponent not working (why?) diff --git a/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/tangram/CameraManager.kt b/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/tangram/CameraManager.kt index e8e58dec36..0eee64424c 100644 --- a/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/tangram/CameraManager.kt +++ b/app/src/main/java/de/westnordost/streetcomplete/screens/main/map/tangram/CameraManager.kt @@ -53,8 +53,8 @@ class CameraManager(private val mapboxMap: MapboxMap, private val contentResolve class CameraUpdate { var position: LatLon? = null - var rotation: Double? = null - var tilt: Double? = null + var rotation: Double? = null // degrees + var tilt: Double? = null // degrees var zoom: Double? = null var zoomBy: Double? = null @@ -70,7 +70,7 @@ data class ScCameraPosition( ) { constructor(p: CameraPosition) : this( p.target?.toLatLon() ?: LatLon(0.0, 0.0), - -p.bearing * PI / 180.0, + -p.bearing, p.tilt, p.zoom )