From 1cf08081431026161634be8da2bc345f2678afc6 Mon Sep 17 00:00:00 2001 From: renwj Date: Thu, 13 Oct 2022 17:09:16 +0800 Subject: [PATCH] =?UTF-8?q?[V2X][Road]=E7=AE=80=E5=8C=96=E8=BD=A6=E9=81=93?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E8=A7=A6=E5=8F=91=E6=9D=A1=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E4=B8=8E=E5=BC=B9=E7=AA=97=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../function/v2x/events/V2XEventManager.kt | 29 ++++----- .../scenario/scene/airoad/AiRoadMarker.kt | 11 ++-- .../scene/road/V2XAiRoadEventMarker.kt | 4 +- .../scene/road/V2XRoadEventMarker.java | 62 ++++++++++++++++++- 4 files changed, 80 insertions(+), 26 deletions(-) diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt index e5ba4009fd..616638f90e 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/V2XEventManager.kt @@ -464,9 +464,10 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.also { old -> l1.extras = HashMap>>().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().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? = 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? = 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() diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt index 236564ad45..7c5b9e3a66 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/airoad/AiRoadMarker.kt @@ -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>?, - var farthestPoint: Pair? = null, + val polygon: List>?, + var farthestPoint: androidx.core.util.Pair? = null, var entity: V2XRoadEventEntity? = null ) { diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt index 3442dafbfa..fc497bc807 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XAiRoadEventMarker.kt @@ -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(polygons.size) diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java index 442f547809..9ed04ecba2 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/road/V2XRoadEventMarker.java @@ -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 { -// private Pair> drawInfo; + private AiRoadMarker.Marker mMarker; @Override public void drawPOI(V2XRoadEventEntity entity) { @@ -26,7 +34,59 @@ public class V2XRoadEventMarker implements IV2XMarker { 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> polygons = new ArrayList<>(); + Pair 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) ((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); + } + + } } } }