Merge branch '2.15.0_merge_master' into dev_minibus-d_230425_3.2.0
This commit is contained in:
@@ -16,6 +16,7 @@ import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.obu.*
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.datacenter.obu.drawer.*
|
||||
import com.mogo.eagle.core.function.datacenter.obu.utils.TrafficDataConvertUtilsNew
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_OBU
|
||||
@@ -324,8 +325,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
// 更新数据,模型变色的时候是不是update,如果不是更新,可能导致模型不变色,(add的时候,是否有level高的) TODO
|
||||
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(rsmWarningData)
|
||||
?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,13 +338,11 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
?.let {
|
||||
// 事件结束,还原交通参与者颜色
|
||||
it.threatLevel = 0x01
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
|
||||
//删除弱势交通元素
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.removeCvxRvInfoIndInfo(rsmWarningData.participant.ptcId.toString())
|
||||
TrafficMarkerDrawer.removeCvxRvInfoIndInfo(rsmWarningData.participant.ptcId.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,8 +361,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
rsmWarningData
|
||||
)
|
||||
?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
|
||||
if (alertContent.isEmpty() || ttsContent.isEmpty()) {
|
||||
@@ -381,8 +378,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuWarningRsiListener
|
||||
// 关闭警告红边
|
||||
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
|
||||
//删除弱势交通元素
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.removeCvxRvInfoIndInfo(rsmWarningData.participant.ptcId.toString())
|
||||
TrafficMarkerDrawer.removeCvxRvInfoIndInfo(rsmWarningData.participant.ptcId.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
|
||||
import com.mogo.eagle.core.function.call.obu.*
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
|
||||
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
|
||||
import com.mogo.eagle.core.function.datacenter.obu.drawer.*
|
||||
import com.mogo.eagle.core.function.datacenter.obu.utils.TrafficDataConvertUtilsNew
|
||||
import com.mogo.eagle.core.utilcode.breakpoint.Config
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
@@ -309,8 +310,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
data.vehBasicsMsg?.let {
|
||||
TrafficDataConvertUtilsNew.cvxRvInfoIndInfo2TrafficData(it)
|
||||
?.let { data ->
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficLocationInfo(data)
|
||||
TrafficMarkerDrawer.updateITrafficLocationInfo(data)
|
||||
}
|
||||
}.also {
|
||||
CallerLogger.e(
|
||||
@@ -570,8 +570,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
// 更新数据
|
||||
TrafficDataConvertUtilsNew.cvxRtiThreatIndInfo2TrafficData(data)
|
||||
?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -584,8 +583,8 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
?.let {
|
||||
// 事件结束,还原车辆颜色
|
||||
it.threatLevel = 0x01
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficInfo(it)
|
||||
|
||||
TrafficMarkerDrawer.updateITrafficInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -641,8 +640,8 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
// 更新数据,模型变色的时候是不是update,如果不是更新,可能导致模型不变色,(add的时候,是否有level高的) TODO
|
||||
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)
|
||||
?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -655,13 +654,11 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
?.let {
|
||||
// 事件结束,还原交通参与者颜色
|
||||
it.threatLevel = 0x01
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
|
||||
//删除弱势交通元素
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
|
||||
TrafficMarkerDrawer.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -677,8 +674,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
//更新模型的颜色
|
||||
TrafficDataConvertUtilsNew.cvxPtcThreatIndInfo2TrafficData(data)
|
||||
?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
}
|
||||
|
||||
if (alertContent.isEmpty() || ttsContent.isEmpty()) {
|
||||
@@ -695,8 +691,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
// 关闭警告红边
|
||||
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
|
||||
//删除弱势交通元素
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
|
||||
TrafficMarkerDrawer.removeCvxRvInfoIndInfo(data.participant.ptcId.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -953,8 +948,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色 ,UUID不需要匹配了
|
||||
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
CallerObuWarningListenerManager.invokeTrackerWarningInfo(it)
|
||||
}
|
||||
}
|
||||
@@ -965,8 +959,7 @@ class MogoPrivateObuNewManager private constructor() : OnUpgradeListener {
|
||||
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
|
||||
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
|
||||
it.threatLevel = 0x01
|
||||
CallerMapUIServiceManager.getMarkerService()
|
||||
?.updateITrafficThreatLevelInfo(it)
|
||||
TrafficMarkerDrawer.updateITrafficThreatLevelInfo(it)
|
||||
CallerObuWarningListenerManager.removeTrackerWarningInfo(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.mogo.eagle.core.function.datacenter.obu.const
|
||||
|
||||
class ObuConst {
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
val OBU_MARKER_OWNER = "obu_new_marker_owner"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,239 @@
|
||||
package com.mogo.eagle.core.function.datacenter.obu.drawer
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import android.text.TextUtils
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.constants.DataTypes
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.data.traffic.threatLevelColor
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.function.datacenter.obu.const.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler
|
||||
import com.mogo.map.overlay.core.Level.MAP_MARKER
|
||||
import com.mogo.map.overlay.point.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* 此类用于obu/v2x预警绘制交通元素 2D\3D绘制
|
||||
* obu:与其进行调试单独展示,与debugview上感知开关相关联
|
||||
* v2x:绘制云端预警marker,不会做感知控制管理,后续根据注解的方式来控制v2x业务
|
||||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object TrafficMarkerDrawer {
|
||||
|
||||
private const val TAG = "TrafficMarkerDrawer"
|
||||
|
||||
private var mContext: Context? = null
|
||||
|
||||
// 动画持续时间
|
||||
private const val stepTime = 150L
|
||||
|
||||
// 维护Obu识别的他车集合
|
||||
private val mTrafficMap = ConcurrentHashMap<String, TrafficData>()
|
||||
|
||||
// 地图内部资源md5缓存,便于资源复用
|
||||
private val mMarkerCachesResMd5Values = ConcurrentHashMap<String, String>()
|
||||
|
||||
// 上一帧数据的缓存,用来做移动动画
|
||||
private val mMarkersCaches = ConcurrentHashMap<String, Point?>()
|
||||
|
||||
// 维护一个线程定时轮询数据进行地图绘制
|
||||
private val mDrawerHandler: Handler =
|
||||
object : Handler(WorkThreadHandler.newInstance("other_traffic_drawer").looper) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
if (FunctionBuildConfig.debugTrackerProvider == 1) {
|
||||
drawerTrafficInfo()
|
||||
}
|
||||
// 延时50毫秒重复发送自己,定时轮询进行车辆绘制,可以及时将已经不存在车辆删除
|
||||
sendEmptyMessageDelayed(0, 50L)
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
mContext = AbsMogoApplication.getApp()
|
||||
mDrawerHandler.sendEmptyMessageDelayed(1, 0L)
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新识别数据,V2V预警的时候需要修改车辆颜色
|
||||
*/
|
||||
fun updateITrafficInfo(trafficData: TrafficData) {
|
||||
if (trafficData.uuid != null) {
|
||||
mTrafficMap[trafficData.uuid!!] = trafficData
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新识别数据位置
|
||||
*/
|
||||
fun updateITrafficLocationInfo(trafficData: TrafficData) {
|
||||
CallerLogger.d(TAG, "updateITrafficLocationInfo trafficData = $trafficData")
|
||||
CallerLogger.d(TAG,
|
||||
"trafficData.type = " + trafficData.type + "---trafficData.threatLevel = " + trafficData.threatLevel + "----FunctionBuildConfig.debugTrackerProvider = " + FunctionBuildConfig.debugTrackerProvider)
|
||||
if (FunctionBuildConfig.debugTrackerProvider != 1) {
|
||||
return
|
||||
}
|
||||
val tempTraffic = mTrafficMap[trafficData.uuid]
|
||||
if (tempTraffic != null) {
|
||||
tempTraffic.lat = trafficData.lat
|
||||
tempTraffic.lon = trafficData.lon
|
||||
tempTraffic.heading = trafficData.heading
|
||||
if (trafficData.uuid != null) {
|
||||
mTrafficMap[trafficData.uuid!!] = tempTraffic
|
||||
}
|
||||
} else {
|
||||
if (trafficData.uuid != null) {
|
||||
mTrafficMap[trafficData.uuid!!] = trafficData
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新识别数据颜色
|
||||
*/
|
||||
fun updateITrafficThreatLevelInfo(trafficData: TrafficData) {
|
||||
CallerLogger.d(TAG,
|
||||
"trafficData.type = " + trafficData.type + "---trafficData.threatLevel = " + trafficData.threatLevel + "----FunctionBuildConfig.debugTrackerProvider = " + FunctionBuildConfig.debugTrackerProvider)
|
||||
if (FunctionBuildConfig.debugTrackerProvider != 1) {
|
||||
return
|
||||
}
|
||||
if (!TextUtils.isEmpty(trafficData.uuid)) {
|
||||
val tempTraffic = mTrafficMap[trafficData.uuid]
|
||||
if (tempTraffic != null) {
|
||||
tempTraffic.lat = trafficData.lat
|
||||
tempTraffic.lon = trafficData.lon
|
||||
tempTraffic.heading = trafficData.heading
|
||||
tempTraffic.threatLevel = trafficData.threatLevel
|
||||
if (trafficData.uuid != null) {
|
||||
mTrafficMap[trafficData.uuid!!] = tempTraffic
|
||||
}
|
||||
} else {
|
||||
if (trafficData.uuid != null) {
|
||||
mTrafficMap[trafficData.uuid!!] = trafficData
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除识别的数据
|
||||
*/
|
||||
fun removeCvxRvInfoIndInfo(key: String) {
|
||||
if (mTrafficMap.containsKey(key)) {
|
||||
mTrafficMap.remove(key)
|
||||
mMarkersCaches[key]?.let {
|
||||
it.delegate?.remove()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制
|
||||
*/
|
||||
private fun drawerTrafficInfo() {
|
||||
// 数据为空的时候清除所有数据
|
||||
if (mTrafficMap.isEmpty()) {
|
||||
mMarkersCaches.forEach { it ->
|
||||
it.value?.also { CallerMapUIServiceManager.getOverlayManager()?.removePoint(it) }
|
||||
}
|
||||
mMarkersCaches.clear()
|
||||
} else {
|
||||
// 循环绘制识别的数据
|
||||
mTrafficMap.forEach {
|
||||
|
||||
// 如果数据已经存在 Marker,取出做动画
|
||||
if (mMarkersCaches[it.key] != null) {
|
||||
mMarkersCaches[it.key]?.let { marker ->
|
||||
changeDynamicMarker(marker, it.value)
|
||||
}
|
||||
}
|
||||
// 不存在的添加Marker绘制
|
||||
else {
|
||||
drawObuRecognizedDataMarker(it.value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 绘制单条
|
||||
*/
|
||||
private fun drawObuRecognizedDataMarker(trafficData: TrafficData) {
|
||||
CallerLogger.d(
|
||||
TAG,
|
||||
"drawObuRecognizedDataMarker trafficData.type = " + trafficData.type + "---trafficData.threatLevel = " + trafficData.threatLevel
|
||||
)
|
||||
val resId: Int = trafficData.type.traffic3DIconId
|
||||
val resIdVal = resId.toString() + ""
|
||||
val builder = Point.Options.Builder(DataTypes.TYPE_MARKER_ADAS, MAP_MARKER)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.isUseGps(true)
|
||||
.controlAngle(true)
|
||||
.resName(mMarkerCachesResMd5Values[resIdVal])
|
||||
.icon3DRes(resId)
|
||||
.rotate(trafficData.heading.toFloat())
|
||||
.longitude(trafficData.lon)
|
||||
.latitude(trafficData.lat)
|
||||
if (trafficData.type != TrafficTypeEnum.TYPE_TRAFFIC_ID_SPECIAL_VEHICLE) {
|
||||
// 修改颜色
|
||||
mMarkersCaches[trafficData.uuid]?.also {
|
||||
CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(it.option.builder().anchorColor(trafficData.threatLevelColor()).build())
|
||||
}
|
||||
}
|
||||
|
||||
val options = builder.build()
|
||||
val point = CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(options) // val marker = MogoMarkerManager.getInstance(mContext)
|
||||
// .addMarker(DataTypes.TYPE_MARKER_OBU_DATA, options)
|
||||
|
||||
// 缓存3D资源
|
||||
mMarkerCachesResMd5Values[resIdVal] = options.resName ?: "" // 缓存数据
|
||||
if (trafficData.uuid != null) {
|
||||
mMarkersCaches[trafficData.uuid!!] = point
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 带动画的修改Marker
|
||||
*/
|
||||
private fun changeDynamicMarker(
|
||||
marker: Point,
|
||||
trafficData: TrafficData
|
||||
) {
|
||||
CallerLogger.d(
|
||||
TAG,
|
||||
"changeDynamicMarker trafficData.type = " + trafficData.type + "---trafficData.threatLevel = " + trafficData.threatLevel
|
||||
)
|
||||
if (trafficData.type != TrafficTypeEnum.TYPE_TRAFFIC_ID_SPECIAL_VEHICLE) {
|
||||
mMarkersCaches[trafficData.uuid]?.also {
|
||||
CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(it.option.builder().anchorColor(trafficData.threatLevelColor()).build())
|
||||
}
|
||||
}
|
||||
try {
|
||||
marker.delegate?.addDynamicAnchorPosition(
|
||||
com.mogo.eagle.core.data.map.MogoLatLng(
|
||||
trafficData.lat,
|
||||
trafficData.lon
|
||||
),
|
||||
trafficData.heading.toFloat(),
|
||||
stepTime
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
try {
|
||||
drawObuRecognizedDataMarker(trafficData)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user