fix bug of delete maker

This commit is contained in:
zhongchao
2022-06-20 16:12:58 +08:00
committed by liujing
parent 5d12cbbb34
commit 4f98be373d
2 changed files with 10 additions and 1 deletions

View File

@@ -111,6 +111,8 @@ class IdentifyOriginDataDrawer : Identify {
trafficDataUuidList.forEach(Consumer { uuid: String ->
mMarkersCaches.remove(uuid)
algoCache.remove(uuid)
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
.removeMarker(uuid)
})
val filterList = filterTrafficData(resultList)
if (filterList.size > 0) {

View File

@@ -5,6 +5,7 @@ import android.util.ArrayMap;
import android.util.Log;
import androidx.annotation.RequiresApi;
import androidx.collection.ArraySet;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
@@ -17,6 +18,7 @@ import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import mogo.telematics.pad.MessagePad;
@@ -49,7 +51,7 @@ public class TrackManager {
/**
* 记录每次实际绘制的交通元素UUID
*/
private final ArrayList<String> trafficDataUuidList = new ArrayList<>();
private final Set<String> trafficDataUuidList = new ArraySet<>();
/**
* 过滤后的数据集合
@@ -59,6 +61,7 @@ public class TrackManager {
public ArrayList<MessagePad.TrackedObject> filterTrafficData(List<MessagePad.TrackedObject> trafficData) {
//清空上次返回数据,做到缓存复用
mFilterTrafficData.clear();
trafficDataUuidList.clear();
//进入过滤机制的感知物体,首先从缓存队列中进行查找 uuid
for (MessagePad.TrackedObject data : trafficData) {
@@ -89,6 +92,7 @@ public class TrackManager {
}
cellIdCaches.forcePut(uuid, trackObj.getCellIdPos());
mMarkersCaches.put(uuid, trackObj);
Log.d("hy uuid : " + uuid, " 显示物体,塞入set");
trafficDataUuidList.add(uuid);
}
//todo 将上次没被删除掉物体加入集合,造成延迟删除,对运动物体不友好
@@ -121,8 +125,11 @@ public class TrackManager {
}
}
trafficDataUuidList.forEach(uuid -> {
Log.d("hy uuid : " + uuid, " 移除物体");
mMarkersCaches.remove(uuid);
cellIdCaches.remove(uuid);
MogoMarkerManager.getInstance(AbsMogoApplication.getApp())
.removeMarker(uuid);
});
//todo bus存在时间回溯将id重置会有id复用问题导致鹰眼展示元素缺少
// Iterator it = mMarkersCaches.keySet().iterator();