调整null判断逻辑
This commit is contained in:
@@ -21,7 +21,7 @@ import java.util.concurrent.ConcurrentHashMap
|
||||
* @author xiaoyuzhou
|
||||
* @date 2021/8/9 11:08 上午
|
||||
*/
|
||||
class ObuRecognizedResultDrawer() {
|
||||
class ObuRecognizedResultDrawer {
|
||||
|
||||
private val TAG = "ObuRecognizedResultDrawer"
|
||||
|
||||
@@ -116,7 +116,6 @@ class ObuRecognizedResultDrawer() {
|
||||
cvxRvInfoIndInfo.threat_infos = threatInfos
|
||||
}
|
||||
|
||||
|
||||
mCvxRvInfoIndInfoMap[cvxV2vThreatIndInfo.vehicle_id] = cvxRvInfoIndInfo
|
||||
}
|
||||
}
|
||||
@@ -189,53 +188,56 @@ class ObuRecognizedResultDrawer() {
|
||||
/**
|
||||
* 绘制单条
|
||||
*/
|
||||
private fun drawObuRecognizedDataMarker(cvxRvInfoIndInfo: CvxRvInfoIndInfo): IMogoMarker {
|
||||
val resId: Int = R.raw.tachexiaoche
|
||||
val resIdVal = resId.toString() + ""
|
||||
private fun drawObuRecognizedDataMarker(cvxRvInfoIndInfo: CvxRvInfoIndInfo) {
|
||||
if (cvxRvInfoIndInfo.basic_info != null && cvxRvInfoIndInfo.basic_info.position != null) {
|
||||
val resId: Int = R.raw.tachexiaoche
|
||||
val resIdVal = resId.toString() + ""
|
||||
|
||||
val options = MogoMarkerOptions()
|
||||
.owner(DataTypes.TYPE_MARKER_ADAS)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.gps(true)
|
||||
.controlAngle(true)
|
||||
.resName(mMarkerCachesResMd5Values[resIdVal])
|
||||
.icon3DRes(resId)
|
||||
.rotate(if (cvxRvInfoIndInfo.basic_info != null) cvxRvInfoIndInfo.basic_info.heading.toFloat() else 0f)
|
||||
.position(
|
||||
MogoLatLng(
|
||||
if (cvxRvInfoIndInfo.basic_info != null && cvxRvInfoIndInfo.basic_info.position != null) cvxRvInfoIndInfo.basic_info.position.latitude else 0.0,
|
||||
if (cvxRvInfoIndInfo.basic_info != null && cvxRvInfoIndInfo.basic_info.position != null) cvxRvInfoIndInfo.basic_info.position.longitude else 0.0
|
||||
val options = MogoMarkerOptions()
|
||||
.owner(DataTypes.TYPE_MARKER_ADAS)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.gps(true)
|
||||
.controlAngle(true)
|
||||
.resName(mMarkerCachesResMd5Values[resIdVal])
|
||||
.icon3DRes(resId)
|
||||
.rotate(cvxRvInfoIndInfo.basic_info.heading.toFloat())
|
||||
.position(
|
||||
MogoLatLng(
|
||||
cvxRvInfoIndInfo.basic_info.position.latitude,
|
||||
cvxRvInfoIndInfo.basic_info.position.longitude
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
// 判断车辆V2X预警级别,调整车辆颜色
|
||||
if (!cvxRvInfoIndInfo.threat_infos.isNullOrEmpty() && options != null) {
|
||||
// 修改颜色
|
||||
when (cvxRvInfoIndInfo.threat_infos.first().threat_level) {
|
||||
1 -> {
|
||||
options.anchorColor("#D8D8D8FF")
|
||||
}
|
||||
2 -> {
|
||||
options.anchorColor("#FFD53EFF")
|
||||
}
|
||||
3 -> {
|
||||
options.anchorColor("#FF3C45FF")
|
||||
}
|
||||
else -> {
|
||||
options.anchorColor("#D8D8D8FF")
|
||||
// 判断车辆V2X预警级别,调整车辆颜色
|
||||
if (!cvxRvInfoIndInfo.threat_infos.isNullOrEmpty() && options != null) {
|
||||
// 修改颜色
|
||||
when (cvxRvInfoIndInfo.threat_infos.first().threat_level) {
|
||||
1 -> {
|
||||
options.anchorColor("#D8D8D8FF")
|
||||
}
|
||||
2 -> {
|
||||
options.anchorColor("#FFD53EFF")
|
||||
}
|
||||
3 -> {
|
||||
options.anchorColor("#FF3C45FF")
|
||||
}
|
||||
else -> {
|
||||
options.anchorColor("#D8D8D8FF")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val marker = MogoApisHandler.getInstance().apis
|
||||
.mapServiceApi
|
||||
.getMarkerManager(mContext)
|
||||
.addMarker(DataTypes.TYPE_MARKER_OBU_DATA, options)
|
||||
|
||||
// 缓存3D资源
|
||||
mMarkerCachesResMd5Values[resIdVal] = marker.markerResName
|
||||
// 缓存数据
|
||||
mMarkersCaches[cvxRvInfoIndInfo.vehicle_id] = marker
|
||||
}
|
||||
|
||||
val marker = MogoApisHandler.getInstance().apis.mapServiceApi.getMarkerManager(mContext)
|
||||
.addMarker(DataTypes.TYPE_MARKER_OBU_DATA, options)
|
||||
|
||||
// 缓存3D资源
|
||||
mMarkerCachesResMd5Values[resIdVal] = marker.markerResName
|
||||
// 缓存数据
|
||||
mMarkersCaches[cvxRvInfoIndInfo.vehicle_id] = marker
|
||||
return marker
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -244,20 +246,19 @@ class ObuRecognizedResultDrawer() {
|
||||
private fun changeDynamicMarker(
|
||||
marker: IMogoMarker,
|
||||
cvxRvInfoIndInfo: CvxRvInfoIndInfo
|
||||
): IMogoMarker {
|
||||
) {
|
||||
if (cvxRvInfoIndInfo.basic_info != null && cvxRvInfoIndInfo.basic_info.position != null) {
|
||||
val renderLoc = MogoLatLng(
|
||||
cvxRvInfoIndInfo.basic_info.position.latitude,
|
||||
cvxRvInfoIndInfo.basic_info.position.longitude
|
||||
)
|
||||
|
||||
val renderLoc = MogoLatLng(
|
||||
cvxRvInfoIndInfo.basic_info.position.latitude,
|
||||
cvxRvInfoIndInfo.basic_info.position.longitude
|
||||
)
|
||||
|
||||
marker.addDynamicAnchorPosition(
|
||||
renderLoc,
|
||||
cvxRvInfoIndInfo.basic_info.heading.toFloat(),
|
||||
stepTime
|
||||
)
|
||||
|
||||
return marker
|
||||
marker.addDynamicAnchorPosition(
|
||||
renderLoc,
|
||||
cvxRvInfoIndInfo.basic_info.heading.toFloat(),
|
||||
stepTime
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -95,51 +95,54 @@ class ObuVulnerableGroupsDrawer {
|
||||
/**
|
||||
* 绘制单条
|
||||
*/
|
||||
private fun drawObuRecognizedDataMarker(cvxPtcInfoIndInfo: CvxPtcInfoIndInfo): IMogoMarker {
|
||||
var resId: Int = R.raw.people
|
||||
when (cvxPtcInfoIndInfo.ptc_type) {
|
||||
// 未知
|
||||
0x0 -> {
|
||||
resId = R.raw.tache
|
||||
private fun drawObuRecognizedDataMarker(cvxPtcInfoIndInfo: CvxPtcInfoIndInfo) {
|
||||
if ((cvxPtcInfoIndInfo.ptc_type == 0x1 || cvxPtcInfoIndInfo.ptc_type == 0x2) &&
|
||||
(cvxPtcInfoIndInfo.basic_info != null && cvxPtcInfoIndInfo.basic_info.position != null)
|
||||
) {
|
||||
var resId: Int = R.raw.people
|
||||
when (cvxPtcInfoIndInfo.ptc_type) {
|
||||
// 未知
|
||||
0x0 -> {
|
||||
resId = R.raw.tache
|
||||
}
|
||||
// 非机动车
|
||||
0x1 -> {
|
||||
resId = R.raw.motorbike
|
||||
}
|
||||
// 行人
|
||||
0x2 -> {
|
||||
resId = R.raw.people
|
||||
}
|
||||
// RSU
|
||||
0x3 -> {
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
// 非机动车
|
||||
0x1 -> {
|
||||
resId = R.raw.motorbike
|
||||
}
|
||||
// 行人
|
||||
0x2 -> {
|
||||
resId = R.raw.people
|
||||
}
|
||||
// RSU
|
||||
0x3 -> {
|
||||
}
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
|
||||
val resIdVal = resId.toString() + ""
|
||||
val resIdVal = resId.toString() + ""
|
||||
|
||||
val options = MogoMarkerOptions()
|
||||
.owner(DataTypes.TYPE_MARKER_ADAS)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.gps(true)
|
||||
.controlAngle(true)
|
||||
.resName(mMarkerCachesResMd5Values[resIdVal])
|
||||
.icon3DRes(resId)
|
||||
.rotate(cvxPtcInfoIndInfo.basic_info.heading.toFloat())
|
||||
.position(
|
||||
MogoLatLng(
|
||||
cvxPtcInfoIndInfo.basic_info.position.latitude,
|
||||
cvxPtcInfoIndInfo.basic_info.position.longitude
|
||||
val options = MogoMarkerOptions()
|
||||
.owner(DataTypes.TYPE_MARKER_ADAS)
|
||||
.anchor(0.5f, 0.5f)
|
||||
.set3DMode(true)
|
||||
.gps(true)
|
||||
.controlAngle(true)
|
||||
.resName(mMarkerCachesResMd5Values[resIdVal])
|
||||
.icon3DRes(resId)
|
||||
.rotate(cvxPtcInfoIndInfo.basic_info.heading.toFloat())
|
||||
.position(
|
||||
MogoLatLng(
|
||||
cvxPtcInfoIndInfo.basic_info.position.latitude,
|
||||
cvxPtcInfoIndInfo.basic_info.position.longitude
|
||||
)
|
||||
)
|
||||
)
|
||||
val marker = MogoApisHandler.getInstance().apis.mapServiceApi.getMarkerManager(mContext)
|
||||
.addMarker(DataTypes.TYPE_MARKER_OBU_DATA, options)
|
||||
val marker = MogoApisHandler.getInstance().apis.mapServiceApi.getMarkerManager(mContext)
|
||||
.addMarker(DataTypes.TYPE_MARKER_OBU_DATA, options)
|
||||
|
||||
// 缓存数据
|
||||
mMarkersCaches[cvxPtcInfoIndInfo.id] = marker
|
||||
return marker
|
||||
// 缓存数据
|
||||
mMarkersCaches[cvxPtcInfoIndInfo.id] = marker
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,20 +151,21 @@ class ObuVulnerableGroupsDrawer {
|
||||
private fun changeDynamicMarker(
|
||||
marker: IMogoMarker,
|
||||
cvxPtcInfoIndInfo: CvxPtcInfoIndInfo
|
||||
): IMogoMarker {
|
||||
) {
|
||||
if ((cvxPtcInfoIndInfo.ptc_type == 0x1 || cvxPtcInfoIndInfo.ptc_type == 0x2) &&
|
||||
(cvxPtcInfoIndInfo.basic_info != null && cvxPtcInfoIndInfo.basic_info.position != null)
|
||||
) {
|
||||
val renderLoc = MogoLatLng(
|
||||
cvxPtcInfoIndInfo.basic_info.position.latitude,
|
||||
cvxPtcInfoIndInfo.basic_info.position.longitude
|
||||
)
|
||||
|
||||
val renderLoc = MogoLatLng(
|
||||
cvxPtcInfoIndInfo.basic_info.position.latitude,
|
||||
cvxPtcInfoIndInfo.basic_info.position.longitude
|
||||
)
|
||||
|
||||
marker.addDynamicAnchorPosition(
|
||||
renderLoc,
|
||||
cvxPtcInfoIndInfo.basic_info.heading.toFloat(),
|
||||
stepTime
|
||||
)
|
||||
|
||||
return marker
|
||||
marker.addDynamicAnchorPosition(
|
||||
renderLoc,
|
||||
cvxPtcInfoIndInfo.basic_info.heading.toFloat(),
|
||||
stepTime
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user