[2.13.2]新增V2N事件
This commit is contained in:
@@ -106,7 +106,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
V2XManager.init(V2XConfig.Builder().also {
|
||||
it.aiCloudConfig(MoGoAiCloudClientConfig.getInstance())
|
||||
it.context(context)
|
||||
it.loggable(false)
|
||||
it.loggable(true)
|
||||
it.distanceForTriggerRefresh(200f) //行驶超过200(包含)米,刷新道路周边信息(短链请求)
|
||||
it.durationForTriggerRefresh(
|
||||
60,
|
||||
@@ -364,7 +364,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
)
|
||||
if (v2XRoadEventEntity != null) {
|
||||
val distance = v2XRoadEventEntity.distance
|
||||
val min = if (EventTypeEnumNew.AI_ROAD_WORK.poiType == v2XRoadEventEntity.poiType) 0 else 5
|
||||
val min = if (EventTypeEnumNew.isCloudSocketEvent(v2XRoadEventEntity.poiType)) 0 else 5
|
||||
CallerLogger.d(
|
||||
"$M_V2X$TAG",
|
||||
"--- trigger show before ---:data=>[${location.longitude}, ${location.latitude}, ${location.speed}], distance: $distance, minDistance: $min, poiType: ${v2XRoadEventEntity.poiType}"
|
||||
@@ -448,6 +448,10 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
}
|
||||
handleRoadMarkerEvent(event.data.toRoadMarker())
|
||||
}
|
||||
|
||||
is V2XEvent.RoadEventX -> {
|
||||
handleRoadMarkerEvent(event.data.toRoadMarker())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -466,7 +470,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
// 1004 -> { //V2N_RSM,静止事件,包括异常停车、异常静止障碍物
|
||||
// }
|
||||
1005 -> { //V2N_RSI,施工事件,包括锥桶或者挡板围城的施工场景,是个多边形包围区域
|
||||
EventTypeEnumNew.AI_ROAD_WORK.poiType
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType
|
||||
}
|
||||
1007 -> { //三角牌
|
||||
EventTypeEnumNew.FOURS_ACCIDENT_04.poiType
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.alarm;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.facebook.common.logging.LoggingDelegate;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
@@ -24,7 +27,7 @@ import io.netty.util.internal.ConcurrentSet;
|
||||
public class V2XAlarmServer {
|
||||
|
||||
// 记录道路播报的事件
|
||||
private static ConcurrentSet<V2XRoadEventEntity> showedEvents = new ConcurrentSet<>();
|
||||
private static final ConcurrentSet<V2XRoadEventEntity> showedEvents = new ConcurrentSet<>();
|
||||
/**
|
||||
* 获取当前车辆前方距离最近的道路事件
|
||||
*/
|
||||
@@ -32,6 +35,7 @@ public class V2XAlarmServer {
|
||||
CopyOnWriteArrayList<V2XRoadEventEntity> v2XRoadEventEntityList,
|
||||
MogoLocation currentLocation) {
|
||||
try {
|
||||
Log.d("RWJ", "getDriveFrontAlarmEvent --- 1 ---" + currentLocation );
|
||||
if (!showedEvents.isEmpty()) {
|
||||
Iterator<V2XRoadEventEntity> iterator = showedEvents.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
@@ -48,15 +52,18 @@ public class V2XAlarmServer {
|
||||
}
|
||||
}
|
||||
}
|
||||
Log.d("RWJ", "getDriveFrontAlarmEvent --- 2 ---" + currentLocation);
|
||||
if (currentLocation != null && v2XRoadEventEntityList != null) {
|
||||
// 因为集合是按照距离排序后的所以这里检索出来第一个就发出警告
|
||||
for (V2XRoadEventEntity v2XRoadEventEntity : v2XRoadEventEntityList) {
|
||||
// 0、道路事件必须有朝向,角度>=0;
|
||||
Log.d("RWJ", "entity:" + v2XRoadEventEntity.getLocation());
|
||||
if (v2XRoadEventEntity.getLocation().getAngle() >= 0) {
|
||||
// 计算车辆距离指定气泡的距离
|
||||
MarkerLocation eventLocation = v2XRoadEventEntity.getLocation();
|
||||
// 1、判断是否到达了触发距离,20 ~ 500,
|
||||
double distance = v2XRoadEventEntity.getDistance();
|
||||
Log.d("RWJ", "distance:" + distance);
|
||||
if (distance <= 500) {
|
||||
if (EventTypeEnumNew.GHOST_PROBE.getPoiType().equals(v2XRoadEventEntity.getPoiType())) {
|
||||
if (distance > 25) {
|
||||
@@ -67,6 +74,7 @@ public class V2XAlarmServer {
|
||||
double carBearing = currentLocation.getBearing();
|
||||
double eventBearing = eventLocation.getAngle();
|
||||
double diffAngle = DrivingDirectionUtils.getAngleDiff(carBearing, eventBearing);
|
||||
Log.d("RWJ", "car_bearing:" + carBearing + ",eventBearing:" + eventBearing + ",diffAngle:" + diffAngle);
|
||||
if (diffAngle < 20) {
|
||||
// 3、计算当前车辆行驶方向与事件位置之间夹角《20度,保证道路事件在车辆前方
|
||||
double eventAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
@@ -76,6 +84,8 @@ public class V2XAlarmServer {
|
||||
eventLocation.getLat(),
|
||||
(int) currentLocation.getBearing()
|
||||
);
|
||||
|
||||
Log.d("RWJ", "eventAngle:" + eventAngle);
|
||||
if (0 <= eventAngle && eventAngle <= 20) {
|
||||
if (showedEvents.contains(v2XRoadEventEntity)) {
|
||||
return null;
|
||||
@@ -90,6 +100,7 @@ public class V2XAlarmServer {
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.w("RWJ", "error: " + e.getMessage());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -36,9 +36,4 @@ public class SurroundingConstruction implements Serializable {
|
||||
construtList.add(item);
|
||||
}
|
||||
|
||||
public String getTypeNameTTS(String type) {
|
||||
String typeName = "请查看周边的";
|
||||
typeName += EventTypeEnumNew.getTypeNameTTS(type);
|
||||
return typeName + "信息";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ class TestPanelBroadcastReceiver : BroadcastReceiver() {
|
||||
val v2XMessageEntity = V2XMessageEntity<V2XRoadEventEntity>()
|
||||
v2XMessageEntity.type = V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING
|
||||
v2XMessageEntity.content =
|
||||
trackedObj.toRoadMarker(EventTypeEnumNew.AI_ROAD_WORK.poiType).toV2XRoadEventEntity()
|
||||
trackedObj.toRoadMarker(EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType).toV2XRoadEventEntity()
|
||||
v2XMessageEntity.isShowState = true
|
||||
V2XScenarioManager.getInstance().handlerMessage(v2XMessageEntity)
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.mogo.map.overlay.*
|
||||
import io.netty.util.internal.*
|
||||
import java.lang.Runnable
|
||||
import java.util.*
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.atomic.*
|
||||
import kotlin.collections.ArrayList
|
||||
|
||||
@@ -59,27 +58,13 @@ object AiRoadMarker {
|
||||
val poi = this.marker.get()
|
||||
val car = this.carLocation.get()
|
||||
if (poi != null && car != null) {
|
||||
val distance = DrivingDirectionUtils.distance(car.first, car.second, poi.poi_lon, poi.poi_lat) * 10000
|
||||
val distance = CoordinateUtils.calculateLineDistance(car.first, car.second, poi.poi_lon, poi.poi_lat)
|
||||
if (distance < 500) {
|
||||
unMarker(poi)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val checkV2NExpiredTask = Runnable {
|
||||
val poi = this.marker.get()
|
||||
val car = this.carLocation.get()
|
||||
if (poi != null && car != null) {
|
||||
val distance = CoordinateUtils.calculateLineDistance(car.first, car.second, poi.poi_lon, poi.poi_lat)
|
||||
Logger.d(TAG, "receive --- checkV2N --- distance: $distance")
|
||||
if (distance > 200) {
|
||||
unMarker(poi)
|
||||
}else{
|
||||
checkV2NExpired()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val onClearAllMarker = object : OnClearAllMarker {
|
||||
|
||||
override fun onClearAllMarkers() {
|
||||
@@ -125,28 +110,6 @@ object AiRoadMarker {
|
||||
})
|
||||
}
|
||||
|
||||
private val onRoadListener = object : OnRoadListener {
|
||||
private var roadId = ""
|
||||
private var hasCrossRoad = false
|
||||
|
||||
override fun onRoadIdInfo(roadId: String) {
|
||||
Logger.d(TAG, "--- onRoadInfo --- roadId: $roadId")
|
||||
val oldRoadId = this.roadId
|
||||
if (oldRoadId != roadId) {
|
||||
if (hasCrossRoad) {
|
||||
hasCrossRoad = false
|
||||
}
|
||||
}
|
||||
this.roadId = roadId
|
||||
}
|
||||
override fun onStopLineInfo(info: StopLine) {
|
||||
Logger.d(TAG, "--- onStopLineInfo --- info: $info")
|
||||
if (!hasCrossRoad) {
|
||||
hasCrossRoad = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val onLocationListener = object : IMoGoMapLocationListener {
|
||||
|
||||
override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) {
|
||||
@@ -163,102 +126,105 @@ object AiRoadMarker {
|
||||
}
|
||||
|
||||
private fun onCreate() {
|
||||
CallerMapRoadListenerManager.registerRoadListener(TAG, onRoadListener)
|
||||
CallMarkersClearManager.addAllMarkersClearListener(TAG, onClearAllMarker)
|
||||
CallerMapLocationListenerManager.addListener(TAG, onLocationListener, true)
|
||||
}
|
||||
|
||||
private fun onDestroy() {
|
||||
CallerMapRoadListenerManager.unRegisterRoadListener(TAG)
|
||||
CallMarkersClearManager.removeAllMarkersClearListener(TAG)
|
||||
CallerMapLocationListenerManager.removeListener(TAG, true)
|
||||
removeLine()
|
||||
}
|
||||
|
||||
fun marker(marker: Marker, drawMarker: Boolean) {
|
||||
fun marker(marker: Marker, drawMarker: Boolean, drawRoadLine: Boolean = false) {
|
||||
handler.removeCallbacks(checkExpiredTask)
|
||||
val location = carLocation.get() ?: return
|
||||
if (markers.contains(marker)) {
|
||||
Logger.d(TAG, "--- enqueue --- cache hit ---")
|
||||
Logger.d(TAG, "--- maker --- cache hit ---")
|
||||
return
|
||||
}
|
||||
Logger.d(TAG, "--- marker ---:${marker}")
|
||||
synchronized(markers) {
|
||||
markers += marker
|
||||
}
|
||||
this.marker.set(marker)
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.third.toFloat(), 300f)
|
||||
//施工中心点后方的自车行驶方向上300米距离
|
||||
Logger.d(TAG, "--- marker --- 3 --- l1: $l1")
|
||||
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.third.toFloat(), -300f)
|
||||
if (l1.points.isEmpty() || l2.points.isEmpty()) {
|
||||
Logger.d(TAG, "--- marker --- 3 --- return ----")
|
||||
synchronized(markers) {
|
||||
markers.remove(marker)
|
||||
}
|
||||
return
|
||||
}
|
||||
Logger.d(TAG, "--- marker --- 4 --- l2: $l2")
|
||||
val points = LinkedList<MogoLatLng>()
|
||||
if (l2 != null && l2.points.isNotEmpty()) {
|
||||
points.addAll(l2.points.reversed().map {
|
||||
MogoLatLng(it.second, it.first)
|
||||
})
|
||||
}
|
||||
val centerX= marker.poi_lon
|
||||
val centerY = marker.poi_lat
|
||||
Logger.d(TAG, "--- marker --- 5 --- marker: $marker")
|
||||
val farthestPoint = marker.polygon?.let {
|
||||
var find: Pair<Double, Double> = Pair(centerX, centerY)
|
||||
var min = Long.MAX_VALUE
|
||||
for (p in it) {
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(centerX, centerY, p.first, p.second, location.third)
|
||||
if (angle < min) {
|
||||
min = angle
|
||||
find = p
|
||||
}
|
||||
}
|
||||
MogoLatLng(find.second, find.first)
|
||||
} ?: MogoLatLng(centerY, centerX)
|
||||
marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat)
|
||||
Logger.d(TAG, "--- marker --- 6 --- marker: $marker")
|
||||
if (l1 != null && l1.points.isNotEmpty()) {
|
||||
for (l in l1.points) {
|
||||
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(farthestPoint.lon, farthestPoint.lat, l.first, l.second, location.third + 180) < 90L) {
|
||||
points.add(l.let { MogoLatLng(it.second, it.first) })
|
||||
}
|
||||
}
|
||||
}
|
||||
if (points.size <= 1) {
|
||||
synchronized(markers) {
|
||||
markers.remove(marker)
|
||||
}
|
||||
return
|
||||
}
|
||||
removeLine()
|
||||
if (drawMarker) {
|
||||
marker.entity?.apply { V2XAiRoadEventMarker.drawMarkers(this) }
|
||||
}
|
||||
val evaluator = ArgbEvaluator()
|
||||
val interceptor = DecelerateInterpolator(1.5f)
|
||||
val total = points.size
|
||||
val colors = ArrayList<Int>()
|
||||
(0..total).forEach { i ->
|
||||
colors += evaluator.evaluate(interceptor.getInterpolation(i * 1f / total), START_COLOR, END_COLOR) as Int
|
||||
}
|
||||
var line = line.get()
|
||||
options.points(points)
|
||||
options.colorValues(colors)
|
||||
Logger.d(TAG, "--- marker --- 7 --- points: ${points.size}")
|
||||
if (line == null || line.isDestroyed) {
|
||||
val l = overlayManager.addPolyline(options)
|
||||
this.line.set(l)
|
||||
line = l
|
||||
if (drawRoadLine) {
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.third.toFloat(), 300f)
|
||||
//施工中心点后方的自车行驶方向上300米距离
|
||||
Logger.d(TAG, "--- marker --- 3 --- l1: $l1")
|
||||
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.third.toFloat(), -300f)
|
||||
if (l1.points.isEmpty() || l2.points.isEmpty()) {
|
||||
Logger.d(TAG, "--- marker --- 3 --- return ----")
|
||||
synchronized(markers) {
|
||||
markers.remove(marker)
|
||||
}
|
||||
return
|
||||
}
|
||||
Logger.d(TAG, "--- marker --- 4 --- l2: $l2")
|
||||
val points = LinkedList<MogoLatLng>()
|
||||
if (l2 != null && l2.points.isNotEmpty()) {
|
||||
points.addAll(l2.points.reversed().map {
|
||||
MogoLatLng(it.second, it.first)
|
||||
})
|
||||
}
|
||||
val centerX= marker.poi_lon
|
||||
val centerY = marker.poi_lat
|
||||
Logger.d(TAG, "--- marker --- 5 --- marker: $marker")
|
||||
val farthestPoint = marker.polygon?.let {
|
||||
var find: Pair<Double, Double> = Pair(centerX, centerY)
|
||||
var min = Long.MAX_VALUE
|
||||
for (p in it) {
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(centerX, centerY, p.first, p.second, location.third)
|
||||
if (angle < min) {
|
||||
min = angle
|
||||
find = p
|
||||
}
|
||||
}
|
||||
MogoLatLng(find.second, find.first)
|
||||
} ?: MogoLatLng(centerY, centerX)
|
||||
marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat)
|
||||
Logger.d(TAG, "--- marker --- 6 --- marker: $marker")
|
||||
if (l1 != null && l1.points.isNotEmpty()) {
|
||||
for (l in l1.points) {
|
||||
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(farthestPoint.lon, farthestPoint.lat, l.first, l.second, location.third + 180) < 90L) {
|
||||
points.add(l.let { MogoLatLng(it.second, it.first) })
|
||||
}
|
||||
}
|
||||
}
|
||||
if (points.size <= 1) {
|
||||
synchronized(markers) {
|
||||
markers.remove(marker)
|
||||
}
|
||||
return
|
||||
}
|
||||
removeLine()
|
||||
val evaluator = ArgbEvaluator()
|
||||
val interceptor = DecelerateInterpolator(1.5f)
|
||||
val total = points.size
|
||||
val colors = ArrayList<Int>()
|
||||
(0..total).forEach { i ->
|
||||
colors += evaluator.evaluate(interceptor.getInterpolation(i * 1f / total), START_COLOR, END_COLOR) as Int
|
||||
}
|
||||
var line = line.get()
|
||||
options.points(points)
|
||||
options.colorValues(colors)
|
||||
Logger.d(TAG, "--- marker --- 7 --- points: ${points.size}")
|
||||
if (line == null || line.isDestroyed) {
|
||||
val l = overlayManager.addPolyline(options)
|
||||
this.line.set(l)
|
||||
line = l
|
||||
} else {
|
||||
line.setOption(options)
|
||||
}
|
||||
if (!line.isVisible) {
|
||||
line.isVisible = true
|
||||
}
|
||||
} else {
|
||||
line.setOption(options)
|
||||
}
|
||||
if (!line.isVisible) {
|
||||
line.isVisible = true
|
||||
removeLine()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +253,7 @@ object AiRoadMarker {
|
||||
val poi = this.marker.get()
|
||||
val car = this.carLocation.get()
|
||||
if (poi != null && car != null) {
|
||||
val distance = DrivingDirectionUtils.distance(car.first, car.second, marker.poi_lon, marker.poi_lat) * 10000
|
||||
val distance = CoordinateUtils.calculateLineDistance(car.first, car.second, marker.poi_lon, marker.poi_lat)
|
||||
Logger.d(TAG, "receive --- 2 ---:car:[${car.first}, ${car.second}] -> poi:[${marker.poi_lon}, ${marker.poi_lat}] --> distance:$distance")
|
||||
if (distance < 500) {
|
||||
checkExpired()
|
||||
@@ -306,32 +272,13 @@ object AiRoadMarker {
|
||||
handler.postDelayed(checkExpiredTask, 10000)
|
||||
}
|
||||
|
||||
fun receiveV2N(marker: Marker) {
|
||||
Logger.d(TAG, "receive --- 1 ---")
|
||||
val car = this.carLocation.get()
|
||||
if (car != null) {
|
||||
val distance = DrivingDirectionUtils.distance(car.first, car.second, marker.poi_lon, marker.poi_lat) * 10000
|
||||
Logger.d(TAG, "receive --- 2 ---:car:[${car.first}, ${car.second}] -> poi:[${marker.poi_lon}, ${marker.poi_lat}] --> distance:$distance")
|
||||
if (distance < 500) {
|
||||
checkV2NExpired()
|
||||
} else {
|
||||
handler.removeCallbacks(checkV2NExpiredTask)
|
||||
}
|
||||
} else {
|
||||
checkV2NExpired()
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkV2NExpired() {
|
||||
handler.removeCallbacks(checkV2NExpiredTask)
|
||||
handler.postDelayed(checkV2NExpiredTask, 5000)
|
||||
}
|
||||
|
||||
data class Marker(
|
||||
val id: String,
|
||||
val poiType: String,
|
||||
val poi_lat: Double,
|
||||
val poi_lon: Double,
|
||||
val poi_angle: Double,
|
||||
val polygon: List<Pair<Double, Double>>?,
|
||||
val polygon: List<Pair<Double, Double>>? = null,
|
||||
var farthestPoint: Pair<Double, Double>? = null,
|
||||
var entity: V2XRoadEventEntity? = null
|
||||
) {
|
||||
@@ -340,15 +287,12 @@ object AiRoadMarker {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
other as Marker
|
||||
if (poi_lat != other.poi_lat) return false
|
||||
if (poi_lon != other.poi_lon) return false
|
||||
if (id != other.id) return false
|
||||
return true
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
var result = poi_lat.hashCode()
|
||||
result = 31 * result + poi_lon.hashCode()
|
||||
return result
|
||||
return id.hashCode()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.road;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.util.Pair;
|
||||
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
@@ -11,6 +13,8 @@ import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XPolylineManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.AiRoadMarker;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -31,8 +35,12 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
if (marker != null) {
|
||||
marker.clearAlarmPOI();
|
||||
if (entity != null) {
|
||||
if (!Objects.equals(entity.getPoiType(), EventTypeEnumNew.AI_ROAD_WORK.getPoiType())
|
||||
&& !Objects.equals(entity.getPoiType(), EventTypeEnumNew.FOURS_ACCIDENT_04.getPoiType())) {
|
||||
Log.d("RWJ", "V2XRoadEventMarker:" + entity.getPoiType());
|
||||
if (!Objects.equals(entity.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType())
|
||||
&& !Objects.equals(entity.getPoiType(), EventTypeEnumNew.FOURS_ACCIDENT_04.getPoiType())
|
||||
&& !Objects.equals(entity.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.getPoiType())
|
||||
&& !Objects.equals(entity.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.getPoiType())
|
||||
&& !Objects.equals(entity.getPoiType(), EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType())) {
|
||||
AiRoadMarker.Marker prev = mMarker;
|
||||
if (prev != null) {
|
||||
AiRoadMarker.INSTANCE.unMarker(prev);
|
||||
@@ -46,6 +54,7 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
mMarker = null;
|
||||
}
|
||||
MarkerExploreWay noveltyInfo = entity.getNoveltyInfo();
|
||||
Log.d("RWJ", "V2XRoadEventMarker -> noveltyInfo:" + noveltyInfo);
|
||||
if (noveltyInfo != null && noveltyInfo.extras != null) {
|
||||
List<Pair<Double, Double>> polygons = new ArrayList<>();
|
||||
Pair<Double, Double> gpsLocation = null;
|
||||
@@ -80,11 +89,10 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
|
||||
if (!polygons.isEmpty() && gpsLocation != null) {
|
||||
MarkerLocation location = noveltyInfo.getLocation();
|
||||
AiRoadMarker.Marker m = new AiRoadMarker.Marker(gpsLocation.second, gpsLocation.first, location.getAngle(), polygons, null, entity);
|
||||
AiRoadMarker.Marker m = new AiRoadMarker.Marker(noveltyInfo.getInfoId(), noveltyInfo.getPoiType(), gpsLocation.second, gpsLocation.first, location.getAngle(), polygons, null, entity);
|
||||
mMarker = m;
|
||||
AiRoadMarker.INSTANCE.marker(m, true);
|
||||
AiRoadMarker.INSTANCE.marker(m, true, isDrawRoadLine(m.getPoiType()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -94,6 +102,10 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isDrawRoadLine(String poiType) {
|
||||
return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType().equals(poiType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPOI() {
|
||||
// 移除线
|
||||
|
||||
@@ -4,10 +4,13 @@ import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.analytics.AnalyticsUtils;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.enums.WarningDirectionEnum;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
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.V2XMessageEntity;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxBean;
|
||||
@@ -15,6 +18,7 @@ import com.mogo.eagle.core.data.msgbox.MsgBoxType;
|
||||
import com.mogo.eagle.core.data.msgbox.V2XMsg;
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager;
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst;
|
||||
@@ -44,7 +48,7 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
@Override
|
||||
public void init(V2XMessageEntity<V2XRoadEventEntity> v2XMessageEntity) {
|
||||
try {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "v2XMessageEntity:" + GsonUtil.jsonFromObject(v2XMessageEntity));
|
||||
Log.d(TAG, "v2XMessageEntity:" + GsonUtil.jsonFromObject(v2XMessageEntity));
|
||||
V2XRoadEventEntity v2XRoadEventEntity = v2XMessageEntity.getContent();
|
||||
if (v2XRoadEventEntity != null) {
|
||||
if (v2XMessageEntity.isShowState()) {
|
||||
@@ -99,20 +103,39 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
V2XRoadEventEntity content = entity != null ? entity.getContent() : null;
|
||||
if (content != null) {
|
||||
// //显示警告红边
|
||||
if (content.getAlarmContent() == null || content.getAlarmContent().isEmpty()
|
||||
|| content.getTts() == null || content.getTts().isEmpty()) {
|
||||
String alarmText = content.getAlarmContent();
|
||||
String ttsText = content.getTts();
|
||||
if (alarmText == null || alarmText.isEmpty()
|
||||
|| ttsText == null || ttsText.isEmpty()) {
|
||||
Log.d("MsgBox-V2XRoadScenario", "alertContent或ttsContent为空!");
|
||||
}
|
||||
String poiType = content.getPoiType();
|
||||
if (EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType().equals(poiType) ||
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.getPoiType().equals(poiType) ||
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.getPoiType().equals(poiType) ||
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType().equals(poiType)) {
|
||||
MogoLocation carLocation = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
|
||||
MarkerExploreWay noveltyInfo = content.getNoveltyInfo();
|
||||
if (carLocation != null && noveltyInfo != null) {
|
||||
MarkerLocation eventLocation = noveltyInfo.getLocation();
|
||||
if (eventLocation != null) {
|
||||
double distance = CoordinateUtils.calculateLineDistance(carLocation.getLongitude(), carLocation.getLatitude(), eventLocation.getLon(), eventLocation.getLat());
|
||||
alarmText = String.format(alarmText, distance + "");
|
||||
ttsText = String.format(ttsText, distance + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CallerMsgBoxManager.INSTANCE.saveMsgBox(
|
||||
new MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
new V2XMsg(content.getPoiType(),
|
||||
content.getAlarmContent(),
|
||||
content.getTts())
|
||||
new V2XMsg(poiType,
|
||||
alarmText,
|
||||
ttsText)
|
||||
)
|
||||
);
|
||||
CallerHmiManager.INSTANCE.warningV2X(content.getPoiType(), content.getAlarmContent(),
|
||||
content.getTts(), TAG, this, !entity.isOnlyShow(),
|
||||
CallerHmiManager.INSTANCE.warningV2X(poiType, alarmText,
|
||||
ttsText, TAG, this, !entity.isOnlyShow(),
|
||||
TimeUnit.SECONDS.toMillis(5));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoMapL
|
||||
private WarningDirectionEnum mDirection;
|
||||
|
||||
public V2XFrontWarningScenario() {
|
||||
setV2XMarker(sV2XWarningMarker);
|
||||
//setV2XMarker(sV2XWarningMarker);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.utils
|
||||
|
||||
import androidx.core.util.Pair
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew.Companion.isRoadEvent
|
||||
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.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.AiRoadMarker
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.MarkerExploreWayItem
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerCardResult
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerExploreWay
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerLocation
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerUserInfo
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.*
|
||||
import com.mogo.map.MogoMap
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import roadwork.Road
|
||||
@@ -82,6 +79,9 @@ fun Road.RW_PB.toRoadMarker(): V2XMarkerCardResult =
|
||||
)
|
||||
}
|
||||
}
|
||||
val centerX = this.roadwork?.center?.point?.lon ?: 0.0
|
||||
val centerY = this.roadwork?.center?.point?.lat ?: 0.0
|
||||
val id = "${centerX}_${centerY}"
|
||||
l1.exploreWay = ArrayList<V2XMarkerExploreWay>().also { l2 ->
|
||||
l2.add(V2XMarkerExploreWay().also { l3 ->
|
||||
l3.poiType = this.roadwork?.poiType?.toString()
|
||||
@@ -95,17 +95,54 @@ fun Road.RW_PB.toRoadMarker(): V2XMarkerCardResult =
|
||||
l4.lat = p.lat
|
||||
l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0
|
||||
}
|
||||
l3.infoId = id
|
||||
})
|
||||
}
|
||||
|
||||
AiRoadMarker.receive(
|
||||
AiRoadMarker.Marker(id, EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType,
|
||||
this.roadwork?.center?.point?.lat ?: 0.0,
|
||||
this.roadwork?.center?.point?.lon ?: 0.0,
|
||||
this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
fun V2XRoadXData.toRoadMarker(): V2XMarkerCardResult =
|
||||
V2XMarkerCardResult().also { l1 ->
|
||||
this.polygon?.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.center?.lon ?: 0.0, this.center?.lat ?: 0.0))
|
||||
}
|
||||
}
|
||||
|
||||
l1.exploreWay = ArrayList<V2XMarkerExploreWay>().also { l2 ->
|
||||
l2.add(V2XMarkerExploreWay().also { l3 ->
|
||||
l3.poiType = this.poiType
|
||||
l3.generateTime = this.detectTime ?: 0L
|
||||
l3.location = V2XMarkerLocation().also { l4 ->
|
||||
val p = MogoMap.getInstance().mogoMap.switchLonLat(
|
||||
this.center?.lon ?: 0.0,
|
||||
this.center?.lat ?: 0.0
|
||||
)
|
||||
l4.lon = p.lon
|
||||
l4.lat = p.lat
|
||||
l4.angle = this.centerRoad?.bearing ?: 0.0
|
||||
}
|
||||
l3.infoId = this.index
|
||||
})
|
||||
}
|
||||
|
||||
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
|
||||
this.index.toString(),
|
||||
this.poiType ?: "",
|
||||
this.center?.lat ?: 0.0,
|
||||
this.center?.lon ?: 0.0,
|
||||
this.centerRoad?.bearing ?: 0.0
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -118,6 +155,7 @@ fun MessagePad.TrackedObject.toRoadMarker(poiType: String): V2XMarkerCardResult
|
||||
extra["gps_location"] = listOf(Pair(this.longitude, this.latitude))
|
||||
}
|
||||
}
|
||||
val id = "${this.longitude}_${this.latitude}"
|
||||
l1.exploreWay = ArrayList<V2XMarkerExploreWay>().also { l2 ->
|
||||
l2.add(V2XMarkerExploreWay().also { l3 ->
|
||||
l3.poiType = poiType
|
||||
@@ -129,11 +167,11 @@ fun MessagePad.TrackedObject.toRoadMarker(poiType: String): V2XMarkerCardResult
|
||||
l4.lat = p.lat
|
||||
l4.angle = this.heading
|
||||
}
|
||||
l3.infoId = id
|
||||
})
|
||||
}
|
||||
|
||||
AiRoadMarker.receiveV2N(
|
||||
AiRoadMarker.Marker(this.latitude, this.longitude, this.heading, null, null, null)
|
||||
AiRoadMarker.receive(
|
||||
AiRoadMarker.Marker(id, poiType, this.latitude, this.longitude, this.heading, null, null, null)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,11 @@ import com.mogo.eagle.core.function.v2x.internal.event.V2XEvent
|
||||
import com.mogo.eagle.core.function.v2x.internal.http.V2XRefreshModel
|
||||
import com.mogo.eagle.core.function.v2x.internal.http.callback.IV2XRefreshCallback
|
||||
import com.mogo.eagle.core.function.v2x.internal.logger.Logger
|
||||
import com.mogo.eagle.core.function.v2x.internal.socket.*
|
||||
import com.mogo.eagle.core.function.v2x.internal.socket.V2XMessageListener_401012
|
||||
import com.mogo.eagle.core.function.v2x.internal.socket.V2XMessageListener_401018
|
||||
import com.mogo.eagle.core.function.v2x.internal.socket.V2XMessageListener_402000
|
||||
import com.mogo.eagle.core.function.v2x.internal.socket.V2XMessageListener_404000
|
||||
import com.mogo.eagle.core.function.v2x.internal.socket.V2XMessageListener_503000
|
||||
import com.mogo.eagle.core.function.v2x.internal.utils.DistanceUtils
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
@@ -131,7 +131,8 @@ object V2XManager {
|
||||
SocketManager.getInstance().registerOnMessageListener(401018, V2XMessageListener_401018(cbs))
|
||||
SocketManager.getInstance().registerOnMessageListener(402000, V2XMessageListener_402000(cbs))
|
||||
SocketManager.getInstance().registerOnMessageListener(404000, V2XMessageListener_404000(cbs))
|
||||
SocketManager.getInstance().registerOnMessageListener(503000, V2XMessageListener_503000(cbs))
|
||||
//SocketManager.getInstance().registerOnMessageListener(503000, V2XMessageListener_503000(cbs))
|
||||
SocketManager.getInstance().registerOnMessageListener(70001, V2XMessageListener_70001(cbs))
|
||||
handler.post(refreshTask)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.mogo.eagle.core.function.v2x.internal.data
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
|
||||
@Keep
|
||||
data class V2XRoadXData(
|
||||
val poiType: String? = null,
|
||||
val center: Point? = null,
|
||||
val centerRoad: CenterRoad? = null,
|
||||
val congestionLanes: List<Congestion>? = null,
|
||||
val coordinateType: Int? = -1,
|
||||
val id: String? = null,
|
||||
val index: String? = null,
|
||||
val obstacles: List<Obstacle>? = null,
|
||||
val polygon: List<Point>? = null,
|
||||
val type: Int? = 0,
|
||||
val detectTime: Long? = 0L
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class CenterRoad(
|
||||
val bearing: Double? = 0.0,
|
||||
val laneNo: Int? = null,
|
||||
val roadId: String? = null,
|
||||
val roadName: String? = null,
|
||||
val tileId: Int? = 0
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class Congestion(
|
||||
val laneId: Int? = null,
|
||||
val level: Int? = null
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class Obstacle(
|
||||
val boundBox: List<PointX>? = null,
|
||||
val center: Point? = null,
|
||||
val id: Int? = null,
|
||||
val polygon: List<Point>? = null,
|
||||
val score: Double? = null,
|
||||
val type: Int? = null
|
||||
)
|
||||
|
||||
|
||||
@Keep
|
||||
data class Point(
|
||||
val lon: Double? = null,
|
||||
val lat: Double? = null
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class PointX(
|
||||
val x: Double? = null,
|
||||
val y: Double? = null
|
||||
)
|
||||
@@ -1,10 +1,6 @@
|
||||
package com.mogo.eagle.core.function.v2x.internal.event
|
||||
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XAdvanceWarning
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerCardResult
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XMarkerResponse
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XOptimalRoute
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XWarningTarget
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.*
|
||||
import roadwork.Road.RW_PB
|
||||
|
||||
sealed class V2XEvent {
|
||||
@@ -65,4 +61,15 @@ sealed class V2XEvent {
|
||||
return "Marker(data=$data)"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 长链-道路事件扩展数据结构
|
||||
*/
|
||||
class RoadEventX(val type: Int = 70001, val data: V2XRoadXData): V2XEvent() {
|
||||
|
||||
override fun toString(): String {
|
||||
return "RoadEventX(type=$type, data=$data)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.eagle.core.function.v2x.internal.socket
|
||||
|
||||
import com.mogo.cloud.socket.IMogoCloudSocketOnMessageListener
|
||||
import com.mogo.eagle.core.function.v2x.internal.V2XManager
|
||||
import com.mogo.eagle.core.function.v2x.internal.callback.IV2XCallback
|
||||
import com.mogo.eagle.core.function.v2x.internal.data.V2XRoadXData
|
||||
import com.mogo.eagle.core.function.v2x.internal.event.V2XEvent
|
||||
import com.mogo.eagle.core.function.v2x.internal.logger.Logger
|
||||
|
||||
internal class V2XMessageListener_70001(val cbs: Iterable<IV2XCallback>?): IMogoCloudSocketOnMessageListener<V2XRoadXData> {
|
||||
|
||||
override fun target(msgType: Int): Class<V2XRoadXData> = V2XRoadXData::class.java
|
||||
|
||||
override fun onMsgReceived(msgType: Int, data: V2XRoadXData?) {
|
||||
if (msgType != 70001) {
|
||||
return
|
||||
}
|
||||
if (data == null) {
|
||||
Logger.i(V2XManager.TAG, "V2XMessageListener_70001:message is null!")
|
||||
return
|
||||
}
|
||||
Logger.i(V2XManager.TAG, "V2XMessageListener_70001:$data")
|
||||
cbs?.forEach {
|
||||
it.onAck(V2XEvent.RoadEventX(data = data))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user