[3.4.0][视角] 优化远景视角旋转动画;将到路口触发近景视角逻辑加回来

This commit is contained in:
renwj
2023-07-14 12:01:21 +08:00
parent e210a10d96
commit 1e192b633a
3 changed files with 98 additions and 10 deletions

View File

@@ -8,13 +8,19 @@ import androidx.lifecycle.Lifecycle.Event
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.data.map.*
import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
import com.mogo.eagle.core.function.api.map.angle.*
import com.mogo.eagle.core.function.api.map.angle.Scene
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.function.call.map.*
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener
import com.mogo.eagle.core.utilcode.kotlin.*
import com.zhidaoauto.map.sdk.open.tools.*
import kotlinx.coroutines.*
import kotlinx.coroutines.android.*
import java.util.*
import java.util.concurrent.atomic.*
@Route(path = MogoServicePaths.PATH_VISUAL_ANGLE)
class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
@@ -23,8 +29,14 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
private const val TAG = "VisualAngleChange"
}
private val triggerLocation = AtomicReference<MogoLocation>()
private val distanceOfCarToStopLine = AtomicReference(0.0)
private val travelled by lazy { AtomicReference(0.0) }
@Volatile
private var roadEventFlag: Boolean = false
private var roadEventFlag = false
/**
* 业务实体,不对外暴露
@@ -43,6 +55,52 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
PriorityQueue<Record>()
}
private val listener = object : OnRoadListener {
private val roadId = AtomicReference<String>()
private val triggerRoadId = AtomicReference<String>()
override fun onRoadIdInfo(roadId: String) {
this.roadId.set(roadId)
Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.triggerRoadId.get()} -> curr: $roadId")
val loc = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
var triggerClose = false
val distance = distanceOfCarToStopLine.get() + 5
if (hasCrossRoad && distance > 0) {
val prev = triggerLocation.get()
if (prev != null) {
travelled.set(MapTools.distance(loc.longitude, loc.latitude, prev.longitude, prev.latitude) + travelled.get())
triggerLocation.set(loc)
}
val oldRoadId = triggerRoadId.get()
Log.d(TAG, "-- onRoadIdInfo --: travelled --: ${travelled.get()}")
if ((travelled.get() > distance) && oldRoadId != roadId) {
distanceOfCarToStopLine.set(0.0)
hasCrossRoad = false
triggerRoadId.set(null)
travelled.set(0.0)
triggerLocation.set(null)
Log.d(TAG, "-- onRoadIdInfo --: trigger close --")
triggerClose = true
}
}
if (triggerClose) {
changeAngle(CrossRoad(false))
}
}
override fun onStopLineInfo(info: StopLine) {
Log.d(TAG, "-- onStopLineInfo --: ${info.distanceOfCarToStopLine}")
if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) {
hasCrossRoad = true
triggerRoadId.set(this.roadId.get())
distanceOfCarToStopLine.set(info.distanceOfCarToStopLine)
triggerLocation.set(CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02())
changeAngle(CrossRoad(true))
}
}
}
override fun init(context: Context?) {
if (Thread.currentThread() != Looper.getMainLooper().thread) {
scope.launch {
@@ -62,8 +120,13 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
}
}
})
CallerMapRoadListenerManager.registerRoadListener("VisualAngleChange", listener)
}
@Volatile
private var hasCrossRoad = false
private var scope: CoroutineScope = acquireScope()
@Synchronized
get() {
@@ -204,7 +267,7 @@ class MoGoVisualAngleChangeProvider: IMoGoVisualAngleChangeProvider {
it.setLockMode(false)
roadEventFlag = true
scope.launch {
it.animateTo(0.0 ,0.0,1f, 0f ,11.5f,28f,3000,true)
it.animateTo(0.0 ,0.0,1f, - record.target.poi_angle.toFloat(),11.5f,28f,3000,record.target.isGps)
}
} else {