[6.5.0][Marker] Marker清除逻辑添加走过事件点之后跟离和时长的设置
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
package com.mogo.functions.test
|
||||
|
||||
import android.text.TextUtils
|
||||
import android.util.Log
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerV2nNioEventListenerManager
|
||||
import com.mogo.eagle.core.function.main.MainLauncherActivity
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.MapDataWrapper
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import mogo.telematics.pad.MessagePad.V2nCrossSpeed
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@LargeTest
|
||||
class GreenWaveTest {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "RoadInfoTest"
|
||||
}
|
||||
|
||||
lateinit var launch: ActivityScenario<MainLauncherActivity>
|
||||
|
||||
@Before
|
||||
fun before() {
|
||||
launch = ActivityScenario.launch(MainLauncherActivity::class.java)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testGreenWave(): Unit = runBlocking {
|
||||
val arguments = InstrumentationRegistry.getArguments()
|
||||
val millis = arguments.getString("delay", "0").toLong()
|
||||
if (millis > 0) {
|
||||
delay(millis)
|
||||
}
|
||||
var location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
val distance = arguments.getString("distance", "0").toDouble()
|
||||
var newPoint = DrivingDirectionUtils.calculateNewPoint(location.longitude, location.latitude, location.heading, distance)
|
||||
var crossInfo = MapDataWrapper.getCrossRoad(newPoint.first, newPoint.second, location.heading)
|
||||
while (crossInfo == null || TextUtils.isEmpty(crossInfo.cross_id) || TextUtils.isEmpty(crossInfo.cross_id_end)) {
|
||||
Log.d(TAG, "获取到的路口数据无效, 5秒后重试")
|
||||
delay(TimeUnit.SECONDS.toMillis(5))
|
||||
Log.d(TAG, "5秒时间到,开始计算新的路口数据")
|
||||
location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
newPoint = DrivingDirectionUtils.calculateNewPoint(location.longitude, location.latitude, location.heading, distance)
|
||||
crossInfo = MapDataWrapper.getCrossRoad(newPoint.first, newPoint.second, location.heading)
|
||||
}
|
||||
Log.d(TAG, "获取到路口数据...")
|
||||
FunctionBuildConfig.isNewV2NData = true
|
||||
FunctionBuildConfig.v2nMainSwitch = true
|
||||
CallerV2nNioEventListenerManager.invokeV2nNioGreenWavePassageEvent(
|
||||
V2nCrossSpeed.getDefaultInstance().toBuilder()
|
||||
.setSpeedLeftMin(0)
|
||||
.setSpeedLeftMax(0)
|
||||
.setSpeedRightMin(0)
|
||||
.setSpeedRightMax(0)
|
||||
.setSpeedStraightMin(30)
|
||||
.setSpeedStraightMax(54)
|
||||
.setMaxSpeed(0)
|
||||
.setMaxStatus(0)
|
||||
.setLng(newPoint.first)
|
||||
.setLat(newPoint.second)
|
||||
.build())
|
||||
delay(TimeUnit.MINUTES.toMillis(10))
|
||||
}
|
||||
}
|
||||
@@ -462,7 +462,8 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
|
||||
}
|
||||
|
||||
private fun computeCrossCountBetween(start: kotlin.Triple<Double, Double, Double>, end: kotlin.Pair<Double, Double>): Int {
|
||||
val points = V2NUtils.generateIntermediatePoints(kotlin.Pair(start.first, start.second), end, 10.0 * 1e-7)
|
||||
val points = V2NUtils.generateIntermediatePoints(kotlin.Pair(start.first, start.second), end, 50.0 * 1e-7)
|
||||
V2XBizTrace.onAck(points, "computeCrossCountBetween", true)
|
||||
var crossId = MapDataWrapper.getCrossRoad(start.first, start.second, start.third)?.cross_id_end
|
||||
val angle = start.third
|
||||
var count = 1
|
||||
@@ -494,7 +495,8 @@ internal object V2NIdentifyDrawer: IEventDismissListener {
|
||||
}
|
||||
|
||||
private fun isDrawRoadLine(poiType: String): Boolean {
|
||||
return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType == poiType
|
||||
// return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.poiType == poiType
|
||||
return false
|
||||
}
|
||||
|
||||
private fun getPoiType(type: Int): EventTypeEnumNew =
|
||||
|
||||
@@ -18,7 +18,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<Point>? = null, var lines: ArrayList<Polyline>? = null, var onRemoved:((id: String) -> Unit)? = null) {
|
||||
data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val coordinateType: Int, var markers: ArrayList<Point>? = null, var lines: ArrayList<Polyline>? = null, var elapsedDistance: Int = 500, var elapsedDuration: Long = -1, var onRemoved:((id: String) -> Unit)? = null) {
|
||||
|
||||
fun addLine(line: Polyline) {
|
||||
var ll = this.lines
|
||||
@@ -41,12 +41,8 @@ data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val c
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
if (javaClass != other?.javaClass) return false
|
||||
|
||||
other as MarkerWrapper
|
||||
|
||||
if (id != other.id) return false
|
||||
|
||||
return true
|
||||
return id == other.id
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
@@ -108,35 +104,10 @@ object MarkerRemoveManager {
|
||||
elapsed += delta
|
||||
}
|
||||
Log.d(TAG, "--- checkTask --- 5 ---:delta:$delta, elapsed:${elapsed}, id: ${marker.id}")
|
||||
if (elapsed >= 500) {
|
||||
var removeMarkerError = false
|
||||
marker.markers?.forEach {
|
||||
try {
|
||||
Log.e(TAG, "--- checkTask --- remove marker: $it, id: ${marker.id}")
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removePoint(it.id)
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
removeMarkerError = true
|
||||
Log.e(TAG, "--- checkTask --- remove marker error:${t.message}, id: ${marker.id}")
|
||||
}
|
||||
}
|
||||
var removeLineError = false
|
||||
marker.lines?.forEach {
|
||||
try {
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removeLine(it)
|
||||
Log.e(TAG, "--- checkTask --- remove line : $it, id:${marker.id}")
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
removeLineError = true
|
||||
Log.e(TAG, "--- checkTask --- remove line error:${t.message}, id: ${marker.id}")
|
||||
}
|
||||
}
|
||||
if (!removeLineError && !removeMarkerError) {
|
||||
if (elapsed >= marker.elapsedDistance) {
|
||||
val result = removeMarker(marker)
|
||||
if (result) {
|
||||
toRemove.remove()
|
||||
synchronized(elapsedDistances) {
|
||||
elapsedDistances.remove(marker)
|
||||
marker.onRemoved?.invoke(marker.id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
elapsedDistances[marker] = elapsed
|
||||
@@ -162,6 +133,18 @@ object MarkerRemoveManager {
|
||||
iterator.remove()
|
||||
synchronized(toRemoveMakers) {
|
||||
toRemoveMakers.offer(marker)
|
||||
val elapsedDuration = marker.elapsedDuration
|
||||
if (elapsedDuration > 0) {
|
||||
handler.postDelayed(Runnable {
|
||||
try {
|
||||
while (removeMarker(marker)) {
|
||||
toRemoveMakers.remove(marker)
|
||||
}
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}, elapsedDuration)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -178,6 +161,39 @@ object MarkerRemoveManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeMarker(marker: MarkerWrapper): Boolean {
|
||||
var removeMarkerError = false
|
||||
marker.markers?.forEach {
|
||||
try {
|
||||
Log.e(TAG, "--- checkTask --- remove marker: $it, id: ${marker.id}")
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removePoint(it.id)
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
removeMarkerError = true
|
||||
Log.e(TAG, "--- checkTask --- remove marker error:${t.message}, id: ${marker.id}")
|
||||
}
|
||||
}
|
||||
var removeLineError = false
|
||||
marker.lines?.forEach {
|
||||
try {
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removeLine(it)
|
||||
Log.e(TAG, "--- checkTask --- remove line : $it, id:${marker.id}")
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
removeLineError = true
|
||||
Log.e(TAG, "--- checkTask --- remove line error:${t.message}, id: ${marker.id}")
|
||||
}
|
||||
}
|
||||
if (!removeLineError && !removeMarkerError) {
|
||||
synchronized(elapsedDistances) {
|
||||
elapsedDistances.remove(marker)
|
||||
marker.onRemoved?.invoke(marker.id)
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
private val handler by lazy {
|
||||
val thread = HandlerThread("check_marker_expired")
|
||||
thread.start()
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.os.HandlerThread
|
||||
import android.os.Looper
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import androidx.core.util.Pair
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
@@ -25,6 +26,7 @@ import com.mogo.map.overlay.line.Polyline
|
||||
import com.zhidaoauto.map.data.road.CenterLine
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
@@ -86,12 +88,20 @@ class AiRoadMarker {
|
||||
v2nDrawHandler.post {
|
||||
val location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
this.marker.set(marker)
|
||||
val wrapper = MarkerWrapper(marker.id, marker.poi_lon, marker.poi_lat, 1, null, null)
|
||||
var elapsedDistance = 500
|
||||
if (marker.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_GREE_WAVE.poiType) {
|
||||
elapsedDistance = 10
|
||||
}
|
||||
var elapsedDuration = -1L
|
||||
if (marker.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_GREE_WAVE.poiType) {
|
||||
elapsedDuration = TimeUnit.SECONDS.toMillis(3)
|
||||
}
|
||||
val wrapper = MarkerWrapper(marker.id, marker.poi_lon, marker.poi_lat, 1, elapsedDistance = elapsedDistance, elapsedDuration = elapsedDuration)
|
||||
if (drawMarker) {
|
||||
marker.entity?.apply { roadMarker.drawMarkers(this, wrapper) }
|
||||
}
|
||||
if (drawRoadLine) {
|
||||
/* //施工中心点前方的自车行驶方向上300米距离
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
var l1: CenterLine? = null
|
||||
var l2: CenterLine? = null
|
||||
mogoMapData.get()?.getCenterLineRangeInfo(
|
||||
@@ -118,13 +128,23 @@ class AiRoadMarker {
|
||||
}
|
||||
countDown.incrementAndGet()
|
||||
realMark(marker, wrapper, l1, l2, location.heading)
|
||||
})*/
|
||||
} else {
|
||||
wrapper.onRemoved = { id ->
|
||||
aiMakers.remove(id)
|
||||
}
|
||||
MarkerRemoveManager.addMarker(wrapper)
|
||||
})
|
||||
}
|
||||
|
||||
if (marker.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_GREE_WAVE.poiType) {
|
||||
val builder = Polyline.Options.Builder(V2XConst.V2X_MARKER_OWNER, ROAD_CENTER_LINE)
|
||||
builder.colors(listOf(Color.parseColor("#996DFED0"), Color.parseColor("#CC6DFED0"), Color.parseColor("#C76DFED0"), Color.parseColor("#006DFED0")))
|
||||
.setWidth(5f)
|
||||
.setUseGps(true)
|
||||
.points(listOf(MogoLatLng(location.latitude, location.longitude), MogoLatLng(marker.poi_lat, marker.poi_lon)))
|
||||
.setIsGradient(true)
|
||||
.isShowArrow(true)
|
||||
CallerMapUIServiceManager.getOverlayManager()?.showOrUpdateLine(builder.build())?.also { wrapper.addLine(it) }
|
||||
}
|
||||
wrapper.onRemoved = { id ->
|
||||
aiMakers.remove(id)
|
||||
}
|
||||
MarkerRemoveManager.addMarker(wrapper)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
ArrayList<Point> markers = new ArrayList<>();
|
||||
markers.add(point);
|
||||
String id = entity.getLocation().getLon() + "_" + entity.getLocation().getLat();
|
||||
MarkerRemoveManager.INSTANCE.addMarker(new MarkerWrapper(id, entity.getLocation().getLon(), entity.getLocation().getLat(), 0, markers, null, null));
|
||||
MarkerRemoveManager.INSTANCE.addMarker(new MarkerWrapper(id, entity.getLocation().getLon(), entity.getLocation().getLat(), 0, markers, null, 500, -1L, null));
|
||||
} else {
|
||||
CallerLogger.d(M_V2X + "RWJ", "V2XRoadEventMarker:" + entity.getPoiType() + "--- return empty marker");
|
||||
}
|
||||
@@ -89,6 +89,7 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
}
|
||||
|
||||
private boolean isDrawRoadLine(String poiType) {
|
||||
return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType().equals(poiType);
|
||||
// return EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGONG.getPoiType().equals(poiType);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ import com.mogo.eagle.core.function.hmi.ui.utils.HmiActionLog
|
||||
import com.mogo.eagle.core.function.hmi.ui.widget.StatusBarView
|
||||
import com.mogo.eagle.core.function.hmi.xiaozhi.XiaoZhiStateManager
|
||||
import com.mogo.eagle.core.utilcode.floating.MoGoPopWindow
|
||||
import com.mogo.eagle.core.utilcode.kotlin.lifeCycleScope
|
||||
import com.mogo.eagle.core.utilcode.kotlin.safeCancel
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
@@ -410,23 +411,25 @@ class MoGoHmiProvider : IMoGoHmiProvider {
|
||||
|
||||
override fun showGreenWave(min: Int, max: Int, cross: Int) {
|
||||
val activity = AppStateManager.currentActivity() ?: return
|
||||
greenWave.get()?.hide()
|
||||
val content = GreenWaveView(activity)
|
||||
MoGoPopWindow.Builder()
|
||||
.contentView(content)
|
||||
.width(WindowManager.LayoutParams.WRAP_CONTENT)
|
||||
.height(WindowManager.LayoutParams.WRAP_CONTENT)
|
||||
.attachToActivity(activity)
|
||||
.gravityInActivity(Gravity.END)
|
||||
.onDismissed {
|
||||
greenWave.set(null)
|
||||
}
|
||||
.onShowed {
|
||||
content.bind(min, max, cross)
|
||||
}
|
||||
.build().also {
|
||||
greenWave.set(it)
|
||||
}.show()
|
||||
activity.lifeCycleScope.launch {
|
||||
greenWave.get()?.hide()
|
||||
val content = GreenWaveView(activity)
|
||||
MoGoPopWindow.Builder()
|
||||
.contentView(content)
|
||||
.width(WindowManager.LayoutParams.WRAP_CONTENT)
|
||||
.height(WindowManager.LayoutParams.WRAP_CONTENT)
|
||||
.attachToActivity(activity)
|
||||
.gravityInActivity(Gravity.CENTER)
|
||||
.onDismissed {
|
||||
greenWave.set(null)
|
||||
}
|
||||
.onShowed {
|
||||
content.bind(min, max, cross)
|
||||
}
|
||||
.build().also {
|
||||
greenWave.set(it)
|
||||
}.show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun dismissGreenWave() {
|
||||
|
||||
@@ -25,8 +25,4 @@ enum class Level(val zIndex: Int) {
|
||||
*/
|
||||
MAP_POLYGON(76000),
|
||||
|
||||
/**
|
||||
* 围栏区域底色
|
||||
*/
|
||||
MAP_POLYGON_SOLID(75500)
|
||||
}
|
||||
Reference in New Issue
Block a user