[V2X][Road]简化车道标记触发条件,改为与弹窗展示逻辑一致
This commit is contained in:
@@ -464,9 +464,10 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.also { old ->
|
||||
l1.extras = HashMap<String, List<Pair<Double, Double>>>().also { extra ->
|
||||
extra["polygon"] = old.map { d ->
|
||||
val p = CoordinateUtils.transformWgsToGcj(d.lat, d.lon)
|
||||
Pair(p[0], p[1])
|
||||
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 ->
|
||||
@@ -479,27 +480,19 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
l4.lat = p[1]
|
||||
l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0
|
||||
}
|
||||
|
||||
AiRoadMarker.enqueue(Marker(
|
||||
this.roadwork?.center?.point?.lat ?: 0.0,
|
||||
this.roadwork?.center?.point?.lon ?: 0.0,
|
||||
this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0,
|
||||
this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.map { d -> android.util.Pair(d.lon, d.lat) },
|
||||
null,
|
||||
buildRoadEntity(l3, l1.extras)))
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun buildRoadEntity(e: V2XMarkerExploreWay, extra: Map<String, Any>? = null): V2XRoadEventEntity { // 记录道路事件
|
||||
val v2XRoadEventEntity = V2XRoadEventEntity()
|
||||
v2XRoadEventEntity.location = e.location.toMarkerLocation() // 探路目前只有上报拥堵
|
||||
v2XRoadEventEntity.poiType = EventTypeEnum.AI_ROAD_WORK.poiType
|
||||
v2XRoadEventEntity.noveltyInfo = e.toMarkExploreWay(extra)
|
||||
v2XRoadEventEntity.expireTime = 20000
|
||||
return v2XRoadEventEntity
|
||||
}
|
||||
// private fun buildRoadEntity(e: V2XMarkerExploreWay, extra: Map<String, Any>? = null): V2XRoadEventEntity { // 记录道路事件
|
||||
// val v2XRoadEventEntity = V2XRoadEventEntity()
|
||||
// v2XRoadEventEntity.location = e.location.toMarkerLocation() // 探路目前只有上报拥堵
|
||||
// v2XRoadEventEntity.poiType = EventTypeEnum.AI_ROAD_WORK.poiType
|
||||
// v2XRoadEventEntity.noveltyInfo = e.toMarkExploreWay(extra)
|
||||
// v2XRoadEventEntity.expireTime = 20000
|
||||
// return v2XRoadEventEntity
|
||||
// }
|
||||
|
||||
private fun handleWarningTargetEvent(data: V2XWarningTarget) {
|
||||
val v2xMessageEntity = V2XMessageEntity<V2XWarningTarget>()
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad
|
||||
import android.animation.*
|
||||
import android.content.*
|
||||
import android.graphics.*
|
||||
import android.util.*
|
||||
import android.view.animation.*
|
||||
import androidx.core.util.Pair
|
||||
import androidx.lifecycle.*
|
||||
import androidx.lifecycle.Lifecycle.Event
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_CREATE
|
||||
@@ -140,7 +140,6 @@ object AiRoadMarker {
|
||||
|
||||
private val onLocationListener = object : IMoGoMapLocationListener {
|
||||
|
||||
|
||||
override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) {
|
||||
if (location == null || !isGps) {
|
||||
return
|
||||
@@ -188,7 +187,7 @@ object AiRoadMarker {
|
||||
}
|
||||
}
|
||||
|
||||
private fun marker(marker: Marker) {
|
||||
fun marker(marker: Marker) {
|
||||
val location = carLocation.get() ?: return
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.third.toFloat(), 300f)
|
||||
@@ -275,7 +274,7 @@ object AiRoadMarker {
|
||||
}
|
||||
}
|
||||
|
||||
private fun unMarker(marker: Marker) {
|
||||
fun unMarker(marker: Marker) {
|
||||
markers -= marker
|
||||
removeLine()
|
||||
V2XAiRoadEventMarker.removeMarkers(null)
|
||||
@@ -294,8 +293,8 @@ object AiRoadMarker {
|
||||
val poi_lat: Double,
|
||||
val poi_lon: Double,
|
||||
val poi_angle: Double,
|
||||
val polygon: List<Pair<Double, Double>>?,
|
||||
var farthestPoint: Pair<Double, Double>? = null,
|
||||
val polygon: List<androidx.core.util.Pair<Double, Double>>?,
|
||||
var farthestPoint: androidx.core.util.Pair<Double, Double>? = null,
|
||||
var entity: V2XRoadEventEntity? = null
|
||||
) {
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.road
|
||||
|
||||
import android.util.*
|
||||
import com.mogo.cloud.commons.utils.*
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.context
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.v2xMarker
|
||||
@@ -47,7 +48,8 @@ object V2XAiRoadEventMarker {
|
||||
if (first !is Double || second !is Double) {
|
||||
continue
|
||||
}
|
||||
polygons.add(androidx.core.util.Pair.create(first, second))
|
||||
val xx = CoordinateUtils.transformWgsToGcj(second, first)
|
||||
polygons.add(androidx.core.util.Pair.create(xx[0], xx[1]))
|
||||
}
|
||||
if (polygons.size > 0) {
|
||||
val markers = ArrayList<IMogoMarker>(polygons.size)
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.road;
|
||||
|
||||
import androidx.core.util.Pair;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi;
|
||||
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.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.common.enums.EventTypeEnum;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -15,7 +23,7 @@ import java.util.Objects;
|
||||
public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
|
||||
|
||||
// private Pair<IMogoPolyline, List<IMogoMarker>> drawInfo;
|
||||
private AiRoadMarker.Marker mMarker;
|
||||
|
||||
@Override
|
||||
public void drawPOI(V2XRoadEventEntity entity) {
|
||||
@@ -26,7 +34,59 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
marker.clearAlarmPOI();
|
||||
if (entity != null) {
|
||||
if (!Objects.equals(entity.getPoiType(), EventTypeEnum.AI_ROAD_WORK.getPoiType())) {
|
||||
AiRoadMarker.Marker prev = mMarker;
|
||||
if (prev != null) {
|
||||
AiRoadMarker.INSTANCE.unMarker(prev);
|
||||
mMarker = null;
|
||||
}
|
||||
marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null);
|
||||
} else {
|
||||
AiRoadMarker.Marker prev = mMarker;
|
||||
if (prev != null) {
|
||||
AiRoadMarker.INSTANCE.unMarker(prev);
|
||||
mMarker = null;
|
||||
}
|
||||
MarkerExploreWay noveltyInfo = entity.getNoveltyInfo();
|
||||
if (noveltyInfo != null && noveltyInfo.extras != null) {
|
||||
List<Pair<Double, Double>> polygons = new ArrayList<>();
|
||||
Pair<Double, Double> gpsLocation = null;
|
||||
if (noveltyInfo.extras.containsKey("polygon")) {
|
||||
Object extra = noveltyInfo.extras.get("polygon");
|
||||
if (extra instanceof List) {
|
||||
List l = (List) extra;
|
||||
if (l.size() > 0) {
|
||||
for (int i = 0; i < l.size(); i++) {
|
||||
Object o = l.get(i);
|
||||
if (!(o instanceof Pair)) {
|
||||
continue;
|
||||
}
|
||||
Pair p = (Pair) o;
|
||||
Object first = p.first;
|
||||
Object second = p.second;
|
||||
if (first == null || second == null) {
|
||||
continue;
|
||||
}
|
||||
if (!(first instanceof Double) || !(second instanceof Double)) {
|
||||
continue;
|
||||
}
|
||||
polygons.add(Pair.create((Double) first, (Double) second));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (noveltyInfo.extras.containsKey("gps_location")) {
|
||||
gpsLocation = (Pair<Double, Double>) ((List)(noveltyInfo.extras.get("gps_location"))).get(0);
|
||||
}
|
||||
|
||||
if (!polygons.isEmpty() && gpsLocation != null) {
|
||||
MarkerLocation location = noveltyInfo.getLocation();
|
||||
AiRoadMarker.Marker m = new AiRoadMarker.Marker(gpsLocation.second, gpsLocation.first, location.getAngle(), polygons, null, entity);
|
||||
mMarker = m;
|
||||
AiRoadMarker.INSTANCE.marker(m);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user