[2.13.2-v2x] add new func of road event from telemetics

This commit is contained in:
zhongchao
2022-12-19 18:11:57 +08:00
parent 00ba93371e
commit 2842782f82
11 changed files with 201 additions and 94 deletions

View File

@@ -15,4 +15,6 @@ interface Identify {
}
fun clearOldMarker()
fun getIdentifyObj(uuid: String):TrackedObject?
}

View File

@@ -61,5 +61,9 @@ class IdentifyBeautifyDataDrawer : Identify {
TrackManager.getInstance().clearAll()
}
override fun getIdentifyObj(uuid: String): TrackedObject? {
return TrackManager.getInstance().getIdentifyObj(uuid)
}
}

View File

@@ -105,6 +105,10 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener {
mDrawerHandler.sendMessage(message)
}
override fun getIdentifyObj(uuid: String): TrackedObject? {
return identify?.getIdentifyObj(uuid)
}
override fun updateTrackerWarningInfo(trafficData: TrafficData) {
super.updateTrackerWarningInfo(trafficData)
val message = Message.obtain()

View File

@@ -136,4 +136,8 @@ class IdentifyOriginDataDrawer : Identify {
WarningHelper.clear()
}
override fun getIdentifyObj(uuid: String): TrackedObject? {
return mMarkersCaches[uuid]
}
}

View File

@@ -1,8 +1,11 @@
package com.mogo.eagle.core.function.business.identify
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.constants.MogoServicePaths.PATH_IDENTIFY
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
import com.mogo.eagle.core.function.api.base.IMoGoSubscriber
import com.mogo.eagle.core.function.api.map.marker.IMoGoIdentifyListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
import com.mogo.eagle.core.utilcode.util.ThreadUtils
import mogo.telematics.pad.MessagePad
@@ -14,7 +17,8 @@ import mogo.telematics.pad.MessagePad.TrackedObject
*
* @author donghongyu
*/
class MapIdentifySubscriber private constructor() : IMoGoSubscriber,
@Route(path = PATH_IDENTIFY)
class MapIdentifySubscriber private constructor() :IMoGoIdentifyListener, IMoGoSubscriber,
IMoGoAutopilotIdentifyListener {
private val TAG = "MapIdentifySubscriber"
@@ -67,4 +71,8 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber,
}
}
override fun getIdentifyObj(uuid: String): TrackedObject? {
return IdentifyFactory.getIdentifyObj(uuid)
}
}

View File

@@ -163,4 +163,13 @@ public class TrackManager {
mMarkersCaches.forEach((uuid, trackObj) -> removeKey(uuid));
}
public MessagePad.TrackedObject getIdentifyObj(String uuid) {
TrackObj trackObj = mMarkersCaches.get(uuid);
if (trackObj != null && trackObj.getCache() != null) {
return trackObj.getCache();
} else {
return null;
}
}
}

View File

@@ -444,56 +444,20 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
handleWarningTargetEvent(event.data)
}
is V2XEvent.RoadAI -> {
handleRoadMarkerEvent(event.data.toRoadMarker)
handleRoadMarkerEvent(event.data.toRoadMarker())
}
}
}
private val RW_PB.toRoadMarker: V2XMarkerCardResult
get() = V2XMarkerCardResult().also { l1 ->
this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.also { old ->
l1.extras = HashMap<String, List<Pair<Double, Double>>>().also { extra ->
extra["polygon"] = old.map { d ->
Pair(d.lon, d.lat)
}
extra["gps_location"] = listOf(
Pair(
this.roadwork?.center?.point?.lon ?: 0.0,
this.roadwork?.center?.point?.lat ?: 0.0
)
)
}
}
l1.exploreWay = ArrayList<V2XMarkerExploreWay>().also { l2 ->
l2.add(V2XMarkerExploreWay().also { l3 ->
l3.poiType = this.roadwork?.poiType?.toString()
l3.generateTime = this.roadwork?.detectTime ?: 0L
l3.location = V2XMarkerLocation().also { l4 ->
val p = CoordinateUtils.transformWgsToGcj(
this.roadwork?.center?.point?.lat ?: 0.0,
this.roadwork?.center?.point?.lon ?: 0.0
)
l4.lon = p[0]
l4.lat = p[1]
l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0
}
})
}
AiRoadMarker.receive(
Marker(
this.roadwork?.center?.point?.lat ?: 0.0,
this.roadwork?.center?.point?.lon ?: 0.0,
this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0,
null,
null,
null
)
)
}
@SuppressLint("NewApi")
@ChainLog(
linkChainLog = CHAIN_LINK_LOG_CLOUD_V2N,
linkCode = CHAIN_LINK_CLOUD,
endpoint = TracingConstants.Endpoint.PAD,
nodeAliasCode = CHAIN_ALIAS_CODE_CLOUD_V2N,
paramIndexes = [0],
clientPkFileName = "sn"
)
override fun onAutopilotIdentifyPlanningObj(planningObjects: List<MessagePad.PlanningObject>?) {
super.onAutopilotIdentifyPlanningObj(planningObjects)
planningObjects?.let {
@@ -501,12 +465,18 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
val first = it.stream()
.filter { planningObj: MessagePad.PlanningObject -> planningObj.type >= 1000 }
.findFirst()
if(first.isPresent){
when(first.get().type){
if (first.isPresent) {
when (first.get().type) {
// 1004 -> { //V2N_RSM,静止事件,包括异常停车、异常静止障碍物
//
// }
1005 -> { //V2N_RSI,施工事件,包括锥桶或者挡板围城的施工场景,是个多边形包围区域
val trackedObj =
CallerMapIdentifyManager.getIdentifyObj(first.get().uuid.toString())
trackedObj?.let { t ->
handleRoadMarkerEvent(t.toRoadMarker())
}
}
1007 -> { //三角牌
}
}

View File

@@ -1,55 +1,132 @@
package com.mogo.eagle.core.function.v2x.events.utils
import androidx.core.util.Pair
import com.mogo.cloud.commons.utils.CoordinateUtils
import com.mogo.eagle.core.data.enums.EventTypeEnum
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay
import com.mogo.eagle.core.data.map.entity.MarkerLocation
import com.mogo.eagle.core.data.map.entity.MarkerUserInfo
import com.mogo.v2x.data.MarkerExploreWayItem
import com.mogo.v2x.data.V2XMarkerExploreWay
import com.mogo.v2x.data.V2XMarkerLocation
import com.mogo.v2x.data.V2XMarkerUserInfo
import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.AiRoadMarker
import com.mogo.v2x.data.*
import mogo.telematics.pad.MessagePad
import roadwork.Road
fun V2XMarkerLocation?.toMarkerLocation(): MarkerLocation? = if (this == null) null else MarkerLocation().also {
it.lon = this.lon
it.lat = this.lat
it.address = this.address
it.angle = this.angle
}
fun V2XMarkerLocation?.toMarkerLocation(): MarkerLocation? =
if (this == null) null else MarkerLocation().also {
it.lon = this.lon
it.lat = this.lat
it.address = this.address
it.angle = this.angle
}
fun MarkerExploreWayItem?.toMarkerExploreWayItem(): com.mogo.eagle.core.data.map.entity.MarkerExploreWayItem? = if (this == null) null else com.mogo.eagle.core.data.map.entity.MarkerExploreWayItem().also {
it.illegalCount = this.illegalCount
it.content = this.content
it.url = this.url
it.thumbnail = this.thumbnail
}
fun MarkerExploreWayItem?.toMarkerExploreWayItem(): com.mogo.eagle.core.data.map.entity.MarkerExploreWayItem? =
if (this == null) null else com.mogo.eagle.core.data.map.entity.MarkerExploreWayItem().also {
it.illegalCount = this.illegalCount
it.content = this.content
it.url = this.url
it.thumbnail = this.thumbnail
}
fun V2XMarkerUserInfo?.toMarkerUserInfo(): MarkerUserInfo? = if (this == null) null else MarkerUserInfo().also {
it.safeLabelType = this.safeLabelType
it.safeLabel = this.safeLabel
it.lastActiveweekAvgscore = this.lastActiveweekAvgscore
it.gender = this.gender
it.userHead = this.userHead
it.userName = this.userName
it.setAge(this.age)
}
fun V2XMarkerUserInfo?.toMarkerUserInfo(): MarkerUserInfo? =
if (this == null) null else MarkerUserInfo().also {
it.safeLabelType = this.safeLabelType
it.safeLabel = this.safeLabel
it.lastActiveweekAvgscore = this.lastActiveweekAvgscore
it.gender = this.gender
it.userHead = this.userHead
it.userName = this.userName
it.setAge(this.age)
}
fun V2XMarkerExploreWay.toMarkExploreWay(extras: Map<String, Any>? = null): MarkerExploreWay = MarkerExploreWay().also {
it.items = this.items?.map { itx -> itx.toMarkerExploreWayItem() }
it.userInfo = this.userInfo?.toMarkerUserInfo()
it.distance = this.distance
it.cityName = this.cityName
it.setGenerateTime(this.generateTime)
it.infoId = this.infoId
it.setFileType(this.fileType)
it.setDirection(this.direction)
it.location = this.location?.toMarkerLocation()
it.sn = this.sn
it.canLive = this.canLive != "0"
it.poiType = this.poiType
it.type = this.type
it.infoCheckNode = this.infoCheckNode
it.isFabulous = this.isFabulous
it.uploadType = this.uploadType
it.isCanLive = this.canLive != "0"
it.extras = extras
}
fun V2XMarkerExploreWay.toMarkExploreWay(extras: Map<String, Any>? = null): MarkerExploreWay =
MarkerExploreWay().also {
it.items = this.items?.map { itx -> itx.toMarkerExploreWayItem() }
it.userInfo = this.userInfo?.toMarkerUserInfo()
it.distance = this.distance
it.cityName = this.cityName
it.setGenerateTime(this.generateTime)
it.infoId = this.infoId
it.setFileType(this.fileType)
it.setDirection(this.direction)
it.location = this.location?.toMarkerLocation()
it.sn = this.sn
it.canLive = this.canLive != "0"
it.poiType = this.poiType
it.type = this.type
it.infoCheckNode = this.infoCheckNode
it.isFabulous = this.isFabulous
it.uploadType = this.uploadType
it.isCanLive = this.canLive != "0"
it.extras = extras
}
fun Road.RW_PB.toRoadMarker(): V2XMarkerCardResult =
V2XMarkerCardResult().also { l1 ->
this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.also { old ->
l1.extras = HashMap<String, List<Pair<Double, Double>>>().also { extra ->
extra["polygon"] = old.map { d ->
Pair(d.lon, d.lat)
}
extra["gps_location"] = listOf(
Pair(
this.roadwork?.center?.point?.lon ?: 0.0,
this.roadwork?.center?.point?.lat ?: 0.0
)
)
}
}
l1.exploreWay = ArrayList<V2XMarkerExploreWay>().also { l2 ->
l2.add(V2XMarkerExploreWay().also { l3 ->
l3.poiType = this.roadwork?.poiType?.toString()
l3.generateTime = this.roadwork?.detectTime ?: 0L
l3.location = V2XMarkerLocation().also { l4 ->
val p = CoordinateUtils.transformWgsToGcj(
this.roadwork?.center?.point?.lat ?: 0.0,
this.roadwork?.center?.point?.lon ?: 0.0
)
l4.lon = p[0]
l4.lat = p[1]
l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0
}
})
}
AiRoadMarker.receive(
AiRoadMarker.Marker(
this.roadwork?.center?.point?.lat ?: 0.0,
this.roadwork?.center?.point?.lon ?: 0.0,
this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0,
null,
null,
null
)
)
}
fun MessagePad.TrackedObject.toRoadMarker(): V2XMarkerCardResult =
V2XMarkerCardResult().also { l1 ->
this.polygonList?.takeIf { it.isNotEmpty() }?.also { old ->
l1.extras = HashMap<String, List<Pair<Double, Double>>>().also { extra ->
extra["polygon"] = old.map { d -> Pair(d.longitude, d.latitude) }
extra["gps_location"] = listOf(Pair(this.longitude, this.latitude))
}
}
l1.exploreWay = ArrayList<V2XMarkerExploreWay>().also { l2 ->
l2.add(V2XMarkerExploreWay().also { l3 ->
l3.poiType = EventTypeEnum.AI_ROAD_WORK.poiType
l3.generateTime = 0L
l3.location = V2XMarkerLocation().also { l4 ->
val p = CoordinateUtils.transformWgsToGcj(this.latitude, this.longitude)
l4.lon = p[0]
l4.lat = p[1]
l4.angle = this.heading
}
})
}
AiRoadMarker.receive(
AiRoadMarker.Marker(this.latitude, this.longitude, this.heading, null, null, null)
)
}