[2.13.2]fix bug of road marker remoce
This commit is contained in:
@@ -136,7 +136,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
private fun registerListener() {
|
||||
V2XManager.addCallback(this)
|
||||
CallerMapLocationListenerManager.addListener(TAG, this, false)
|
||||
BridgeApi.registerCenter()?.let {
|
||||
BridgeApi.registerCenter()?.let { it->
|
||||
it.registerMogoMapListener(MODULE_NAME, this)
|
||||
it.registerMogoMarkerClickListener(
|
||||
CARD_TYPE_ROAD_CONDITION,
|
||||
@@ -157,7 +157,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
private fun unRegisterListener() {
|
||||
V2XManager.removeCallback(this)
|
||||
CallerMapLocationListenerManager.removeListener(TAG, false)
|
||||
BridgeApi.registerCenter()?.let {
|
||||
BridgeApi.registerCenter()?.let { it->
|
||||
it.unregisterMogoMapListener(MODULE_NAME)
|
||||
it.unregisterMogoMarkerClickListener(CARD_TYPE_ROAD_CONDITION)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import androidx.lifecycle.*
|
||||
import androidx.lifecycle.Lifecycle.Event
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_CREATE
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils
|
||||
import com.mogo.commons.utils.DrivingDirectionUtils
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
|
||||
@@ -69,6 +70,20 @@ object AiRoadMarker {
|
||||
}
|
||||
}
|
||||
|
||||
private val checkV2NExpiredTask = Runnable {
|
||||
val poi = this.marker.get()
|
||||
val car = this.carLocation.get()
|
||||
if (poi != null && car != null) {
|
||||
val distance = CoordinateUtils.calculateLineDistance(car.first, car.second, poi.poi_lon, poi.poi_lat)
|
||||
Logger.d(TAG, "receive --- checkV2N --- distance: $distance")
|
||||
if (distance > 200) {
|
||||
unMarker(poi)
|
||||
}else{
|
||||
checkV2NExpired()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val onClearAllMarker = object : OnClearAllMarker {
|
||||
|
||||
override fun onClearAllMarkers() {
|
||||
@@ -355,6 +370,27 @@ object AiRoadMarker {
|
||||
handler.postDelayed(checkExpiredTask, 10000)
|
||||
}
|
||||
|
||||
fun receiveV2N(marker: Marker) {
|
||||
Logger.d(TAG, "receive --- 1 ---")
|
||||
val car = this.carLocation.get()
|
||||
if (car != null) {
|
||||
val distance = DrivingDirectionUtils.distance(car.first, car.second, marker.poi_lon, marker.poi_lat) * 10000
|
||||
Logger.d(TAG, "receive --- 2 ---:car:[${car.first}, ${car.second}] -> poi:[${marker.poi_lon}, ${marker.poi_lat}] --> distance:$distance")
|
||||
if (distance < 500) {
|
||||
checkV2NExpired()
|
||||
} else {
|
||||
handler.removeCallbacks(checkV2NExpiredTask)
|
||||
}
|
||||
} else {
|
||||
checkV2NExpired()
|
||||
}
|
||||
}
|
||||
|
||||
private fun checkV2NExpired() {
|
||||
handler.removeCallbacks(checkV2NExpiredTask)
|
||||
handler.postDelayed(checkV2NExpiredTask, 5000)
|
||||
}
|
||||
|
||||
data class Marker(
|
||||
val poi_lat: Double,
|
||||
val poi_lon: Double,
|
||||
|
||||
@@ -79,6 +79,7 @@ object V2XAiRoadEventMarker {
|
||||
options.zIndex(75000f)
|
||||
options.maxIndex(800000f)
|
||||
val line = overlayManager.addPolyline(options)
|
||||
current.set(Pair(line, null))
|
||||
if (line != null) {
|
||||
line.isVisible = true
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.utils
|
||||
|
||||
import androidx.core.util.Pair
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnum.Companion.isRoadEvent
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation
|
||||
@@ -84,7 +83,10 @@ fun Road.RW_PB.toRoadMarker(): V2XMarkerCardResult =
|
||||
l3.poiType = this.roadwork?.poiType?.toString()
|
||||
l3.generateTime = this.roadwork?.detectTime ?: 0L
|
||||
l3.location = V2XMarkerLocation().also { l4 ->
|
||||
val p = MogoMap.getInstance().mogoMap.switchLonLat(this.roadwork?.center?.point?.lon ?: 0.0,this.roadwork?.center?.point?.lat ?: 0.0)
|
||||
val p = MogoMap.getInstance().mogoMap.switchLonLat(
|
||||
this.roadwork?.center?.point?.lon ?: 0.0,
|
||||
this.roadwork?.center?.point?.lat ?: 0.0
|
||||
)
|
||||
l4.lon = p.lon
|
||||
l4.lat = p.lat
|
||||
l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0
|
||||
@@ -117,13 +119,18 @@ fun MessagePad.TrackedObject.toRoadMarker(poiType: String): V2XMarkerCardResult
|
||||
l3.poiType = poiType
|
||||
l3.generateTime = 0L
|
||||
l3.location = V2XMarkerLocation().also { l4 ->
|
||||
val p = MogoMap.getInstance().mogoMap.switchLonLat(this.longitude,this.latitude)
|
||||
val p =
|
||||
MogoMap.getInstance().mogoMap.switchLonLat(this.longitude, this.latitude)
|
||||
l4.lon = p.lon
|
||||
l4.lat = p.lat
|
||||
l4.angle = this.heading
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
AiRoadMarker.receiveV2N(
|
||||
AiRoadMarker.Marker(this.latitude, this.longitude, this.heading, null, null, null)
|
||||
)
|
||||
}
|
||||
|
||||
fun V2XMarkerCardResult.toV2XRoadEventEntity(): V2XRoadEventEntity =
|
||||
|
||||
Reference in New Issue
Block a user