From 19f9f1d1ef2a871ea4ecfcfab328129e87b79bf9 Mon Sep 17 00:00:00 2001 From: zhongchao Date: Mon, 27 Feb 2023 19:06:03 +0800 Subject: [PATCH] [2.13.0-arch-opt] change the color of jiangshiche and opt tracker --- .../business/identify/CircleQueue.java | 12 ++-- .../business/identify/TrackManager.java | 19 ++++-- .../function/business/identify/TrackObj.java | 58 +++++-------------- .../identify/TrackerSourceColorHelper.kt | 2 +- .../business/identify/WarningHelper.kt | 6 ++ .../src/main/java/com/mogo/map/IMogoMap.java | 5 ++ .../mogo/map/marker/IMogoMarkerManager.java | 5 ++ .../main/java/com/mogo/map/AMapWrapper.java | 12 +++- .../java/com/mogo/map/MogoMarkerManager.java | 9 +++ 9 files changed, 68 insertions(+), 60 deletions(-) diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/CircleQueue.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/CircleQueue.java index 5f7b50180e..a4faef0d56 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/CircleQueue.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/CircleQueue.java @@ -24,18 +24,10 @@ public class CircleQueue { objQueue.add(obj); } - public void deleteObj(ObjQueue obj) { - objQueue.remove(obj); - } - public List getLastThreeFrame() { return objQueue.subList(objQueue.size() - 3, objQueue.size()); } - public List getLastFiveFrame() { - return objQueue.subList(objQueue.size() - 5, objQueue.size()); - } - public List getPreFrame() { return objQueue.subList(0, objQueue.size()); } @@ -44,6 +36,10 @@ public class CircleQueue { return objQueue.lastElement(); } + public void clear(){ + objQueue.clear(); + } + @Override public String toString() { return "CircleQueue{" + diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java index 907f04ce8d..b4d2daa6c6 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackManager.java @@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.business.identify; import android.annotation.SuppressLint; import android.os.Build; +import android.util.Log; import androidx.annotation.RequiresApi; @@ -50,7 +51,7 @@ public class TrackManager { * 记录每次实际绘制的交通元素UUID */ @SuppressLint("NewApi") - private final HashMap trafficDataUuid = new HashMap<>(); + private final ConcurrentHashMap trafficDataUuid = new ConcurrentHashMap<>(); /** * 过滤后的数据集合 @@ -101,7 +102,7 @@ public class TrackManager { trackObj = cacheTrack; MessagePad.TrackedObject cache = cacheTrack.getCache(); if (cache != null) { - //相对静止物体并且非obu数据,则不改变,为感知融合同位置物体,使用缓存数据做覆盖 + //相对静止物体 感知融合同位置物体,使用缓存数据做覆盖 if (cacheTrack.relativeStatic()) { if (data.getColor() != null && !data.getColor().isEmpty()) { cache = cache.toBuilder().setColor(data.getColor()).build(); @@ -112,10 +113,10 @@ public class TrackManager { uuid = findSameValue; trackObj.updateObj(data); } else { - trackObj = new TrackObj(data); + trackObj = new TrackObj(data,s2CellId,s2LatLng); } } else { - trackObj = new TrackObj(data); + trackObj = new TrackObj(data,s2CellId,s2LatLng); } } mFilterTrafficData.put(uuid, trackObj.getCache()); @@ -150,17 +151,23 @@ public class TrackManager { } public synchronized void removeKey(String key) { - mMarkersCaches.remove(key); cellIdCaches.remove(key); + mMarkersCaches.remove(key); + WarningHelper.INSTANCE.remove(key); MogoMarkerManager.getInstance(AbsMogoApplication.getApp()) .removeMarker(key); } @SuppressLint("NewApi") public void clearAll() { + MogoMarkerManager.getInstance(AbsMogoApplication.getApp()).clearAllMarker(); + cellIdCaches.clear(); trafficDataUuid.clear(); WarningHelper.INSTANCE.clear(); - mMarkersCaches.forEach((uuid, trackObj) -> removeKey(uuid)); + mMarkersCaches.forEach((uuid, trackObj) -> { + trackObj.clear(); + }); + mMarkersCaches.clear(); } } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackObj.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackObj.java index 0a1d3829b7..55ef457a88 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackObj.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackObj.java @@ -5,8 +5,6 @@ import static com.mogo.eagle.core.function.business.identify.TrackManager.LIMIT_ import android.annotation.SuppressLint; import com.mogo.eagle.core.data.enums.TrafficTypeEnum; -import com.mogo.eagle.core.data.map.CenterLine; -import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager; import com.mogo.eagle.core.utilcode.geometry.S2CellId; import com.mogo.eagle.core.utilcode.geometry.S2LatLng; import com.mogo.eagle.core.utilcode.util.CoordinateUtils; @@ -22,26 +20,18 @@ public class TrackObj { private final CircleQueue circleQueue = new CircleQueue(6); private S2CellId s2CellId; //s2 id权重 private S2LatLng s2LatLng; //s2 经纬度 - private double recentlyTime; //用于缓存帧数判断,暂定缓存1秒数据,中间如果有物体未出现,1秒后删除 - private double roadAngle; //道路航向 private int[] typeArray = new int[3]; private int typeWeight; //类型权重 private double lat; private double lon; private double speedAverage; - public TrackObj(MessagePad.TrackedObject data) { + public TrackObj(MessagePad.TrackedObject data, S2CellId cellId, S2LatLng latLng) { circleQueue.addQueue(new ObjQueue(data.getHeading(), data.getSpeed(), data.getLatitude(), data.getLongitude(), data.getType())); - recentlyTime = data.getSatelliteTime(); lat = data.getLatitude(); lon = data.getLongitude(); - s2LatLng = S2LatLng.fromDegrees(data.getLatitude(), data.getLongitude()); - s2CellId = S2CellId.fromLatLng(s2LatLng).parent(22); //需要验证22前后 - CenterLine centerLine = CallerMapUIServiceManager.INSTANCE.getMapUIController().getCenterLineInfo(lon, lat, -1); - if (centerLine != null && centerLine.getAngle() != 0) { - roadAngle = centerLine.getAngle(); - } - + s2LatLng = latLng; + s2CellId = cellId; //需要验证22前后 } private MessagePad.TrackedObject cacheData; @@ -50,14 +40,12 @@ public class TrackObj { public void updateObj(MessagePad.TrackedObject data) { cacheData = data; correct(); - recentlyTime = data.getSatelliteTime(); circleQueue.addQueue(new ObjQueue(cacheData.getHeading(), cacheData.getSpeed(), data.getLatitude(), data.getLongitude(), data.getType())); } private void correct() { calAverageSpeedAndType(); calLoc(); -// calHeading(); } @SuppressLint("NewApi") @@ -80,8 +68,10 @@ public class TrackObj { } speedAverage = cal / objQueueList.size(); } - typeArray = Arrays.stream(typeArray).sorted().toArray(); - typeWeight = typeArray[typeArray.length / 2] == 0 ? cacheData.getType() : typeArray[typeArray.length / 2]; + if(typeArray.length > 0){ + typeArray = Arrays.stream(typeArray).sorted().toArray(); + typeWeight = typeArray[typeArray.length / 2] == 0 ? cacheData.getType() : typeArray[typeArray.length / 2]; + } // 重新给静止物体赋值速度 if (relativeStatic()) { @@ -105,26 +95,6 @@ public class TrackObj { } } - private void calHeading() { - //更正数据,速度小于LIMIT_SPEED使用上一帧数据 -// if (relativeStatic()) { -// if (roadAngle != 0.0) { -// CenterLine centerLine = CallerHDMapManager.INSTANCE.getCenterLineInfo(lon, lat, -1); -// if (centerLine != null && centerLine.getAngle() != 0) { -// cacheData = cacheData.toBuilder().setHeading(centerLine.getAngle()).build(); -// } else { -// cacheData = cacheData.toBuilder().setHeading(circleQueue.getLastFrame().getHeading()).build(); -// } -// } else { -// cacheData = cacheData.toBuilder().setHeading(circleQueue.getLastFrame().getHeading()).build(); -// } -// } - } - - public double getRecentlyTime() { - return recentlyTime; - } - public long getCellIdPos() { return s2CellId.pos(); } @@ -167,12 +137,6 @@ public class TrackObj { } } - public boolean isFourWheelType() { - return typeWeight != TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE.getType() - && typeWeight != TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE.getType() - && typeWeight != TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO.getType(); - } - private double[] getCenterPoint(List objQueueList) { int total = objQueueList.size(); double X = 0, Y = 0, Z = 0; @@ -202,12 +166,18 @@ public class TrackObj { return d; } + public void clear(){ + circleQueue.clear(); + s2CellId = null; + s2LatLng = null; + typeArray = null; + } + @Override public String toString() { return "TrackObj{" + "circleQueue=" + circleQueue + ", s2CellId=" + s2CellId + - ", recentlyTime=" + recentlyTime + ", cacheData=" + cacheData + '}'; } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackerSourceColorHelper.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackerSourceColorHelper.kt index 489cce927c..d530f02c48 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackerSourceColorHelper.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/TrackerSourceColorHelper.kt @@ -64,7 +64,7 @@ object TrackerSourceColorHelper { //僵尸车 if(data.addAttribute == AdditionalAttribute.ATTR_ZOMBIE){ - color = "#8F9AADFF" + color = "#AE7887FF" } // pnc预警 diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/WarningHelper.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/WarningHelper.kt index 2d7a5c69a4..81f546cb3d 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/WarningHelper.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/identify/WarningHelper.kt @@ -139,6 +139,12 @@ object WarningHelper { } } + fun remove(key:String){ + pncWarningBeautyTrafficData.remove(key) + pncWarningOriginTrafficData.remove(key) + obuWarningTrafficData.remove(key) + } + fun clear() { pncWarningBeautyTrafficData.clear() pncWarningOriginTrafficData.clear() diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java index 07ba7245d8..5fad00ad88 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoMap.java @@ -46,6 +46,11 @@ public interface IMogoMap { */ IMogoMarker addMarker(String tag, MogoMarkerOptions options); + /** + * 清除所有marker + */ + void clearAllMarkers(); + /** * 批量更新锚点位置 * diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java index 8e7e2db59f..f4c23bb89b 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/marker/IMogoMarkerManager.java @@ -38,6 +38,11 @@ public interface IMogoMarkerManager { */ List addMarkers(String tag, ArrayList options, boolean moveToCenter); + /** + * 清除所有marker + */ + void clearAllMarker(); + /** * 批量更新锚点位置 * diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.java b/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.java index d471356be8..a517eca07a 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/AMapWrapper.java @@ -3,10 +3,10 @@ package com.mogo.map; import android.annotation.SuppressLint; import android.content.Context; import android.graphics.Point; +import android.util.Log; import android.util.Pair; import com.mogo.eagle.core.data.config.FunctionBuildConfig; -import com.mogo.eagle.core.data.map.MogoLatLng; import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger; import com.mogo.map.center.CenterLine; import com.mogo.map.marker.AMapInfoWindowAdapter; @@ -108,6 +108,13 @@ public class AMapWrapper implements IMogoMap { return mogoMarker; } + @Override + public void clearAllMarkers() { + if (sAMap != null) { + sAMap.clearAllMarkers(); + } + } + @SuppressLint("NewApi") @Override public void updateBatchMarkerPosition(HashMap optionsArrayList) { @@ -119,6 +126,9 @@ public class AMapWrapper implements IMogoMap { MarkerSimpleData markerOptions = ObjectUtils.fromTrafficData(trackedObject); if (markerOptions != null) { markerOptionsArrayList.add(markerOptions); + if(markerOptions.id == 65061){ + Log.i("emArrow","time :" + markerOptions.time + " , lat : " + markerOptions.lat + " , lon : " + markerOptions.lon); + } } }); long time = markerOptionsArrayList.get(0).getTime(); diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java index ceb1a65a6b..db9333517e 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMarkerManager.java @@ -71,6 +71,15 @@ public class MogoMarkerManager implements IMogoMarkerManager { } } + @Override + public void clearAllMarker() { + try{ + MogoMap.getInstance().getMogoMap().clearAllMarkers(); + }catch (Exception e){ + e.printStackTrace(); + } + } + @Override public void updateBatchMarkerPosition(HashMap optionsArrayList) { try {