[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

@@ -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)
)
}