From a5af953b151a12e883ef192821fbb11d22a62339 Mon Sep 17 00:00:00 2001 From: renwj Date: Mon, 30 May 2022 20:08:03 +0800 Subject: [PATCH] =?UTF-8?q?[RoutingOpt]=E7=A7=BB=E9=99=A4=E6=9C=80?= =?UTF-8?q?=E5=B0=8F=E7=A7=BB=E9=99=A4=E7=82=B9=E6=95=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit [RoutingOpt]移除最小移除点数限制 [RoutingOpt]逻辑优化 --- .../data/autopilot/AutopilotStatusInfo.kt | 4 +++ .../CallerAutoPilotStatusListenerManager.kt | 1 + .../routeoverlay/RouteOverlayDrawer.java | 30 ++++++++++--------- 3 files changed, 21 insertions(+), 14 deletions(-) diff --git a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt index 3761d94822..5704674cdb 100644 --- a/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt +++ b/core/mogo-core-data/src/main/java/com/mogo/eagle/core/data/autopilot/AutopilotStatusInfo.kt @@ -36,7 +36,11 @@ open class AutopilotStatusInfo : Serializable, Cloneable { * 定位是否可用 */ var locationStatus = false + + @Volatile var locationLat = 0.0 + + @Volatile var locationLon = 0.0 var satelliteTime = 0L diff --git a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt index 19a899eddc..090160f922 100644 --- a/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt +++ b/core/mogo-core-function-call/src/main/java/com/mogo/eagle/core/function/call/autopilot/CallerAutoPilotStatusListenerManager.kt @@ -18,6 +18,7 @@ import java.util.concurrent.ConcurrentHashMap object CallerAutoPilotStatusListenerManager : CallerBase() { // 存储最后一次回调的数据,当有新当位置注册了监听将此数据回调过去,防止有些模块注册顺序问题导致无法获取最新状态 + @Volatile private var mAutopilotStatusInfo: AutopilotStatusInfo = AutopilotStatusInfo() // 存储所有注册了监听的对象,invokeXXXX进行遍历回调,将信息同步 diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteOverlayDrawer.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteOverlayDrawer.java index b54dbb29c6..f3d145dcd8 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteOverlayDrawer.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/routeoverlay/RouteOverlayDrawer.java @@ -152,7 +152,6 @@ public class RouteOverlayDrawer { this.routeList = routeList; } - @SuppressLint("LongLogTag") @Override public void run() { @@ -192,19 +191,12 @@ public class RouteOverlayDrawer { } points.add(acquire); } - MogoLocation location = this.location; double lon = CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon(); double lat = CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat(); - if (lon == 0.0 || lat == 0.0) { - isExcept = true; - return; - } - if (location != null && points.size() > 0) { - int i = 0; - int max = Math.min(20, points.size() / 2); + int removeCount = 0; + if (points.size() > 0) { MogoLatLng top = null; - long angle; - while (i++ < max) { + while (points.size() != 0) { MogoLatLng first = points.peek(); if (first == null) { continue; @@ -212,12 +204,22 @@ public class RouteOverlayDrawer { if (first == top) { break; } - angle = isPointOnCarFront(lon, lat, location.getBearing(), first.lon, first.lat); + lon = CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon(); + lat = CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat(); + long angle = isPointOnCarFront(lon, lat, location.getBearing(), first.lon, first.lat); if (angle >= 90) { + removeCount++; + pools.release(first); points.poll(); } top = first; } + + if (points.size() == 0) { + isExcept = true; + return; + } + MogoLatLng self = pools.acquire(); if (self == null) { self = new MogoLatLng(lat, lon); @@ -236,11 +238,11 @@ public class RouteOverlayDrawer { if (mMoGoPolyline != null && !mMoGoPolyline.isDestroyed() && !mMoGoPolyline.isVisible()) { mMoGoPolyline.setVisible(true); } - } else { + } else { isExcept = true; } long drawEnd = SystemClock.elapsedRealtime(); - CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG, "drawTrajectoryList cost : " + (drawEnd - drawStart) + "ms and isExcept:" + isExcept); + CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG, "drawTrajectoryList cost : " + (drawEnd - drawStart) + "ms and isExcept:" + isExcept + "::removeCount:" + removeCount + "::total:" + total); } catch (Throwable t) { CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG, "drawTrajectoryList error (isExcept: "+isExcept+") : " + t); } finally {