[2.15.0] 优化移除逻辑

This commit is contained in:
renwj
2023-03-28 21:02:47 +08:00
parent 95645bf397
commit f32c5a3b2b
3 changed files with 10 additions and 5 deletions

View File

@@ -13,7 +13,6 @@ import com.mogo.eagle.core.function.api.map.angle.*
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.function.call.hmi.*
import com.mogo.eagle.core.function.call.map.*
import com.mogo.eagle.core.function.call.msgbox.*
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager.saveMsgBox
import com.mogo.eagle.core.utilcode.mogo.logger.*
import com.mogo.eagle.core.utilcode.util.*
@@ -46,11 +45,12 @@ internal object V2NIdentifyDrawer {
return@Callback true
}
filtered.forEach { itx ->
AiRoadMarker.aiMakers.getOrPut(itx.uuid.toString()) {
val id = itx.uuid.toString()
AiRoadMarker.aiMakers.getOrPut(id) {
AiRoadMarker().apply {
val poiType = getPoiType(itx.type).poiType
val polygon = itx.polygonList.map { Pair.create(it.longitude, it.latitude) }
marker(Marker(itx.strUuid, poiType, itx.longitude, itx.latitude, itx.heading, polygon, null,
marker(Marker(id, poiType, itx.longitude, itx.latitude, itx.heading, polygon, null,
V2XRoadEventEntity().also { e ->
e.poiType = poiType
e.location = MarkerLocation().also { l ->

View File

@@ -17,7 +17,7 @@ import java.util.concurrent.atomic.AtomicBoolean
import java.util.concurrent.atomic.AtomicReference
data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val coordinateType: Int, var markers: ArrayList<IMogoMarker>? = null, var lines: ArrayList<IMogoPolyline>? = null) {
data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val coordinateType: Int, var markers: ArrayList<IMogoMarker>? = null, var lines: ArrayList<IMogoPolyline>? = null, var onRemoved:((id: String) -> Unit)? = null) {
fun addLine(line: IMogoPolyline) {
var ll = this.lines
@@ -108,7 +108,7 @@ object MarkerRemoveManager {
elapsed += delta
}
Log.d(TAG, "--- checkTask --- 5 ---:delta:$delta, elapsed:${elapsed}, id: ${marker.id}")
if (elapsed >= 200) {
if (elapsed >= 100) {
var removeMarkerError = false
marker.markers?.forEach {
try {
@@ -137,6 +137,7 @@ object MarkerRemoveManager {
toRemove.remove()
synchronized(elapsedDistances) {
elapsedDistances.remove(marker)
marker.onRemoved?.invoke(marker.id)
}
}
} else {

View File

@@ -148,6 +148,9 @@ class AiRoadMarker {
wrapper.addLine(line)
}
}
wrapper.onRemoved = { id ->
aiMakers.remove(id)
}
MarkerRemoveManager.addMarker(wrapper)
}
@@ -168,6 +171,7 @@ class AiRoadMarker {
removeLine()
roadMarker.removeMarkers()
handler.removeCallbacks(checkExpiredTask)
aiMakers.remove(marker.id)
}
fun receive() {