From 7bdf1a42f10e9ca53095369f273e9a338e32a5f0 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Thu, 22 May 2025 14:28:24 +0800 Subject: [PATCH] =?UTF-8?q?[8.0.0][Opt]=E5=87=8F=E5=B0=91=E9=A2=84?= =?UTF-8?q?=E6=B5=8B=E6=B8=B2=E6=9F=93=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../identify/MapIdentifySubscriber.kt | 12 +- .../routeoverlay/PredictionOverlayDrawer.java | 123 ++++-------------- 2 files changed, 37 insertions(+), 98 deletions(-) diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt index 9647930691..a681a4bdc5 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/MapIdentifySubscriber.kt @@ -12,8 +12,9 @@ import com.mogo.eagle.core.function.business.routeoverlay.PredictionOverlayDrawe import com.mogo.eagle.core.function.business.routeoverlay.PredictionOverlayDrawer2 import com.mogo.eagle.core.function.business.routeoverlay.PredictionOverlayDrawer3 import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager -import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84 import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager.getLocationHeading +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager.getWgs84Lat +import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager.getWgs84Lon import com.mogo.eagle.core.function.call.obu.CallerObuWarningListenerManager import com.mogo.eagle.core.utilcode.util.ThreadUtils import com.mogo.map.MogoMap @@ -85,6 +86,7 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber, val mogoMap = mapInstance.getMogoMap(MogoMap.DEFAULT) val pointsList: ArrayList> = ArrayList() var arr: DoubleArray? + var point: geometry.Geometry.Point // 渲染自车 predictionObjects.objsAppList.forEach { preObj -> val points = ArrayList() @@ -113,8 +115,14 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber, MogoIdentifyManager.getInstance().updateGps(location2!!, MogoMap.SMALL_PRED_MAP3) } else { if (preObj.predictionTrajectoryList.isNullOrEmpty() || mogoMap == null) return@forEach + point = preObj.predictionTrajectoryList[0].trajectoryPointsList[0] + arr = mogoMap.switchData(point.x, point.y, false) + arr?.let { lonLatArr -> + val distance = com.mogo.eagle.core.utilcode.util.LocationUtils.getDistance(getWgs84Lat(), getWgs84Lon(), lonLatArr[1], lonLatArr[0]) + if (distance > 25) return@forEach + } preObj.predictionTrajectoryList[0].trajectoryPointsList.forEachIndexed { index, point -> - if (index % 2 == 0) {// 步长为2,减少点 + if (index > 9 && index % 2 == 0) {// 步长为2,减少点 arr = mogoMap.switchData(point.x, point.y, false) arr?.let { lonLatArr -> points.add(MogoLatLng(lonLatArr[1], lonLatArr[0])) diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/PredictionOverlayDrawer.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/PredictionOverlayDrawer.java index f5abb30460..560f1d737f 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/PredictionOverlayDrawer.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/routeoverlay/PredictionOverlayDrawer.java @@ -12,7 +12,6 @@ import androidx.core.util.Pools; import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.data.map.MogoLatLng; -import com.mogo.eagle.core.data.map.MogoLocation; import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager; import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager; import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager; @@ -76,19 +75,14 @@ public class PredictionOverlayDrawer { private class RenderTask implements Runnable { // 对象池 - private final Pools.Pool pools; - private double bearing; - +// private final Pools.Pool pools; private Polyline.Options mPolylineOptions; private volatile List> mPredPointsList; - private final List> mPointsList; private List mLineOptList; public RenderTask() { - this.pools = new Pools.SimplePool<>(1000); - this.mPointsList = new ArrayList<>(); - +// this.pools = new Pools.SimplePool<>(1000); mPolylineOptions = new Polyline.Options.Builder("pred_overlay", Level.GUIDE_ROUTE_LINE) .setUseGps(true) .setWidth(10) @@ -98,7 +92,6 @@ public class PredictionOverlayDrawer { public void setPreDataList(List> data, double bearing) { mPredPointsList = data; - this.bearing = bearing; } @SuppressLint("LongLogTag") @@ -108,12 +101,8 @@ public class PredictionOverlayDrawer { if (overlayManager == null) { return; } - List> poiList = mPointsList; - List> ppsList = new ArrayList<>(); - boolean isExcept = false; int total; - poiList.clear(); List> routes1 = this.mPredPointsList; if (mLineOptList == null) { mLineOptList = new ArrayList<>(); @@ -122,9 +111,8 @@ public class PredictionOverlayDrawer { if (latLngList == null || (total = latLngList.size()) < 2) { return; } - LinkedList pps = null; + ArrayList pps = new ArrayList<>(); try { - pps = new LinkedList<>(); for (int i = 0; i < total; i++) { MogoLatLng route = null; try { @@ -139,97 +127,40 @@ public class PredictionOverlayDrawer { //数组越界了,结束循环 break; } - MogoLatLng acquire = pools.acquire(); + MogoLatLng acquire; double latitude = route.getLat(); double longitude = route.getLon(); - if (acquire == null) { - acquire = new MogoLatLng(latitude, longitude); - } else { - acquire.lon = longitude; - acquire.lat = latitude; - } + acquire = new MogoLatLng(latitude, longitude); acquire.acc = 0.0;// 加速度 acquire.speed = 0.0;// 速度 pps.add(acquire); } - ppsList.add(pps); - MogoLocation location = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84(); - double lon = location.getLongitude(); - double lat = location.getLatitude(); - if (!pps.isEmpty()) { - MogoLatLng top = null; - while (!pps.isEmpty()) { - MogoLatLng first = pps.peek(); - if (first == null) { - continue; - } - if (first == top) { - break; - } - lon = location.getLongitude(); - lat = location.getLatitude(); - long angle = isPointOnCarFront(lon, lat, bearing, first.lon, first.lat); - if (angle >= 90) { - pools.release(first); - pps.poll(); - } - top = first; - } - if (pps.isEmpty()) { - isExcept = true; - return; - } - MogoLatLng self = pools.acquire(); - if (self == null) { - self = new MogoLatLng(lat, lon); - } else { - self.lat = lat; - self.lon = lon; - } - pps.addFirst(self); - // 线的配置 - Polyline.Options.Builder builder; - if (mPolylineOptions == null) { - builder = new Polyline.Options.Builder("pred_overlay", Level.GUIDE_ROUTE_LINE) - .setUseGps(true) - .setWidth(5) - .setIsGradient(true); - } else { - builder = mPolylineOptions.builder(); - } - builder.color(Color.rgb(196, 196, 196)); - builder.setIsGradient(false); - builder.setLightOn(false); - builder.setIsDottedLine(true); - builder.isShowArrow(false); - builder.points(pps); - builder.setVisible(true); - Polyline.Options options = builder.build(); - if (mPolylineOptions == null) { - mPolylineOptions = options; - } - if (FunctionBuildConfig.isDrawPreIdentifyData && CallerMapIdentifyManager.INSTANCE.isPreViewLoaded()) { - overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP); - } + // 线的配置 + Polyline.Options.Builder builder; + if (mPolylineOptions == null) { + builder = new Polyline.Options.Builder("pred_overlay", Level.GUIDE_ROUTE_LINE) + .setUseGps(true) + .setWidth(5) + .setIsGradient(true); } else { - isExcept = true; + builder = mPolylineOptions.builder(); + } + builder.color(Color.rgb(196, 196, 196)); + builder.setIsGradient(false); + builder.setLightOn(false); + builder.setIsDottedLine(false); + builder.isShowArrow(false); + builder.points(pps); + builder.setVisible(true); + Polyline.Options options = builder.build(); + if (mPolylineOptions == null) { + mPolylineOptions = options; + } + if (FunctionBuildConfig.isDrawPreIdentifyData && CallerMapIdentifyManager.INSTANCE.isPreViewLoaded()) { + overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP); } - poiList.add(pps); } catch (Throwable t) { t.printStackTrace(); - } finally { - if (isExcept) { - setVisible(false); - } - if (pps != null && !pps.isEmpty()) { - for (int i = 0; i < pps.size(); i++) { - MogoLatLng latLng = pps.get(i); - if (latLng == null) { - continue; - } - pools.release(latLng); - } - } } } }