[6.5.0] refactor: 优化通过公交站 逻辑;

This commit is contained in:
aibingbing
2024-07-08 14:42:01 +08:00
parent 3c727d7c31
commit d4410a92c6

View File

@@ -21,6 +21,7 @@ import com.mogo.map.entities.BusStation
import com.mogo.map.overlay.core.Level
import com.mogo.map.overlay.point.Point
import com.zhidaoauto.map.data.point.LonLatPoint
import kotlinx.coroutines.CoroutineExceptionHandler
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
@@ -30,6 +31,7 @@ import mogo.telematics.pad.MessagePad
import java.util.LinkedList
import java.util.UUID
import java.util.concurrent.atomic.AtomicBoolean
import kotlin.random.Random
/**
* 计算通过公交站点 管理类
@@ -38,8 +40,14 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener {
const val TAG = "PassBusStationEventManager"
private val coroutineExceptionHandler =
CoroutineExceptionHandler { coroutineContext, exception ->
Logger.e(TAG, "coroutineExceptionHandler --> Handle $exception in $coroutineContext")
isCalculateNearByStation.set(false)
}
private val mCoroutineScope: CoroutineScope =
CoroutineScope(SupervisorJob() + Dispatchers.IO)
CoroutineScope(SupervisorJob() + Dispatchers.IO + coroutineExceptionHandler)
// 距离当前车位置 X 米远的点集合用来查询根据点查询roadId, 然后用roadId查询路上的公交站点
private val farthestLocationList = ArrayList<LonLatPoint>()
@@ -120,9 +128,11 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener {
"removeNeedNotifiedBusStation --> ${it.toString()}"
)
if (HmiBuildConfig.isShowBusStationStrategyBorderPoint) {
mockOtherRetroGradeVehicleData(it.getBusStationPoint().longitude,
mockOtherRetroGradeVehicleData(
it.getBusStationPoint().longitude,
it.getBusStationPoint().latitude,
currentLocation.heading)
currentLocation.heading
)
}
}
}
@@ -237,7 +247,7 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener {
busStationHDMarkerStrategy()
}
MogoData.mogoMapData.get()?.also { iMogoData ->
val busStationList = iMogoData.getBusStation(farthestLocationList)
val busStationList = iMogoData.getBusStation(java.util.ArrayList(farthestLocationList.toMutableList()))
val filteredBusStationList = busStationList.filter {
it.busStationPoints.isNotEmpty() &&
DrivingDirectionUtils.getDegreeOfCar2Poi(
@@ -259,10 +269,12 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener {
)
synchronized(busStationNearByQueue) {
busStationNearByQueue.clear()
busStationNearByQueue.add(busStationList)
busStationNearByQueue.add(filteredBusStationList)
}
isCalculateNearByStation.set(false)
} ?: run {
isCalculateNearByStation.set(false)
}
isCalculateNearByStation.set(false)
}
}
@@ -308,7 +320,7 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener {
heading,
120.0
)
val event = MessagePad.Event.newBuilder().setEventId("123456")
val event = MessagePad.Event.newBuilder().setEventId(Random.nextLong().toString())
.setEventType(MessagePad.EventType.CONVERSE_RUNNING)
.setExts("{\"cameraIp\":\"172.18.7.40\"}")
.setGnssType(2)