From 09d23df9501f8a94a65fde99f7184f9424c78822 Mon Sep 17 00:00:00 2001 From: renwj Date: Mon, 12 Dec 2022 19:50:44 +0800 Subject: [PATCH] =?UTF-8?q?[2.13.0]=E4=BF=AE=E6=AD=A3=E5=8D=81=E5=AD=97?= =?UTF-8?q?=E8=B7=AF=E5=8F=A3=E8=A7=86=E8=A7=92=E5=88=87=E6=8D=A2=E5=90=8E?= =?UTF-8?q?=E6=9C=AA=E6=81=A2=E5=A4=8D=E5=88=B0=E9=BB=98=E8=AE=A4=E8=A7=86?= =?UTF-8?q?=E8=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../call/map/CallerVisualAngleManager.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt index c412fee003..3762bc0104 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/map/CallerVisualAngleManager.kt @@ -9,6 +9,7 @@ import androidx.lifecycle.Lifecycle.Event.ON_DESTROY import androidx.lifecycle.LifecycleEventObserver import androidx.lifecycle.LifecycleOwner import com.mogo.eagle.core.data.config.FunctionBuildConfig +import com.mogo.eagle.core.data.map.* import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.* @@ -24,6 +25,8 @@ import kotlinx.coroutines.internal.synchronized import java.util.* import java.util.concurrent.TimeUnit import java.util.concurrent.TimeUnit.SECONDS +import java.util.concurrent.atomic.* +import kotlin.math.* /** * 高精地图视角管理类 @@ -59,6 +62,9 @@ object CallerVisualAngleManager { val displayThreshold: Long //最大展示时长 > 0; 表示最长展示多长时间, -1 表示,一直展示,直到触发默认视角, 0: 默认视角专用值, } + private val beginLocation = AtomicReference() + + private val listener = object : OnRoadListener { private var roadId = "" override fun onRoadIdInfo(roadId: String) { @@ -68,13 +74,24 @@ object CallerVisualAngleManager { hasCrossRoad = false changeVisualAngle(CrossRoad(false)) } + } else { + if (hasCrossRoad) { + val beginLoc = beginLocation.get() + val endLoc = CallerMapLocationListenerManager.getCurrentLocation() + if (beginLoc != null && endLoc != null && abs(beginLoc.bearing - endLoc.bearing) >= 170) { + hasCrossRoad = false + changeVisualAngle(CrossRoad(false)) + } + } } this.roadId = roadId } + override fun onStopLineInfo(info: StopLine) { if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) { hasCrossRoad = true + beginLocation.set(CallerMapLocationListenerManager.getCurrentLocation()) changeVisualAngle(CrossRoad(true)) } }