[2.13.0]优化十字路口视角触发关闭逻辑
This commit is contained in:
@@ -55,12 +55,14 @@ dependencies {
|
||||
implementation rootProject.ext.dependencies.mogo_core_utils
|
||||
implementation rootProject.ext.dependencies.mogo_core_function_api
|
||||
implementation rootProject.ext.dependencies.mogoserviceapi
|
||||
implementation rootProject.ext.dependencies.mogocommons
|
||||
} else {
|
||||
implementation project(':libraries:mogo-adas')
|
||||
implementation project(':core:mogo-core-data')
|
||||
implementation project(':core:mogo-core-utils')
|
||||
implementation project(':core:mogo-core-function-api')
|
||||
implementation project(':services:mogo-service-api')
|
||||
implementation project(':foudations:mogo-commons')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import androidx.lifecycle.Lifecycle.Event
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
|
||||
import androidx.lifecycle.LifecycleEventObserver
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
|
||||
@@ -64,39 +65,48 @@ object CallerVisualAngleManager {
|
||||
|
||||
private val beginLocation = AtomicReference<MogoLocation>()
|
||||
|
||||
private val distanceOfCarToStopLine = AtomicReference<Double>()
|
||||
|
||||
private val listener = object : OnRoadListener {
|
||||
private var roadId = ""
|
||||
|
||||
|
||||
override fun onRoadIdInfo(roadId: String) {
|
||||
|
||||
val oldRoadId = this.roadId
|
||||
Log.d("RWJ", "-- onRoadIdInfo --: prev: ${this.roadId} -> curr: $roadId")
|
||||
if (oldRoadId != roadId) {
|
||||
if (hasCrossRoad) {
|
||||
Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.roadId} -> curr: $roadId")
|
||||
val startLoc = beginLocation.get()
|
||||
val currLoc = CallerMapLocationListenerManager.getCurrentLocation()
|
||||
var triggerClose = false
|
||||
val distance = distanceOfCarToStopLine.get()
|
||||
if (hasCrossRoad && distance > 0 && oldRoadId != roadId && startLoc != null && currLoc != null && CoordinateUtils.calculateLineDistance(startLoc.longitude, startLoc.latitude, currLoc.longitude, currLoc.latitude).also {
|
||||
Log.d(TAG, "d1: $it, d2: $distance")
|
||||
} >= distance) {
|
||||
distanceOfCarToStopLine.set(0.0)
|
||||
hasCrossRoad = false
|
||||
Log.d(TAG, "-- onRoadIdInfo --: trigger close --")
|
||||
triggerClose = true
|
||||
}
|
||||
if (!triggerClose && hasCrossRoad && oldRoadId == roadId) {
|
||||
val beginLoc = beginLocation.get()
|
||||
val endLoc = CallerMapLocationListenerManager.getCurrentLocation()
|
||||
if (beginLoc != null && endLoc != null && abs(beginLoc.bearing - endLoc.bearing) >= 170) {
|
||||
Log.d(TAG, "-- onRoadIdInfo --: trigger close 2 --")
|
||||
triggerClose = true
|
||||
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) {
|
||||
Log.d("RWJ", "-- onRoadIdInfo XX--: prev: ${this.roadId} -> curr: $roadId")
|
||||
hasCrossRoad = false
|
||||
changeVisualAngle(CrossRoad(false))
|
||||
}
|
||||
beginLocation.set(null)
|
||||
}
|
||||
}
|
||||
if (triggerClose) {
|
||||
changeVisualAngle(CrossRoad(false))
|
||||
}
|
||||
this.roadId = roadId
|
||||
}
|
||||
|
||||
|
||||
override fun onStopLineInfo(info: StopLine) {
|
||||
Log.d("RWJ", "-- onStopLineInfo --: ${info.distanceOfCarToStopLine}")
|
||||
Log.d(TAG, "-- onStopLineInfo --: ${info.distanceOfCarToStopLine}")
|
||||
if (!hasCrossRoad && info.distanceOfCarToStopLine <= 30.0) {
|
||||
hasCrossRoad = true
|
||||
distanceOfCarToStopLine.set(info.distanceOfCarToStopLine)
|
||||
beginLocation.set(CallerMapLocationListenerManager.getCurrentLocation())
|
||||
changeVisualAngle(CrossRoad(true))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user