[V2X][Road]城市占道气泡与道路标记逻辑一致,与弹窗和语音提示触发条件隔离
This commit is contained in:
@@ -1,93 +1,77 @@
|
||||
package com.mogo.eagle.core.function.v2x.events
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.IntentFilter
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.content.*
|
||||
import android.os.*
|
||||
import android.provider.Settings.System
|
||||
import android.util.*
|
||||
import androidx.core.util.Pair
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import androidx.localbroadcastmanager.content.*
|
||||
import com.mogo.cloud.commons.utils.*
|
||||
import com.mogo.cloud.passport.IMoGoTokenCallback
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClient
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
|
||||
import com.mogo.commons.network.ParamsUtil
|
||||
import com.mogo.cloud.passport.*
|
||||
import com.mogo.commons.network.*
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_V2N
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_CLOUD_SHOW
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CLOUD_V2N
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
import com.mogo.eagle.core.data.enums.*
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
|
||||
import com.mogo.eagle.core.data.traffic.*
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.*
|
||||
import com.mogo.eagle.core.function.api.map.listener.*
|
||||
import com.mogo.eagle.core.function.call.hmi.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Default
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.TooClose
|
||||
import com.mogo.eagle.core.function.v2x.events.alarm.V2XAlarmServer
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi
|
||||
import com.mogo.eagle.core.function.v2x.events.alarm.*
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.*
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.context
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst.BROADCAST_SCENE_EXTRA_KEY
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst.BROADCAST_SCENE_HANDLER_ACTION
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst.MODULE_NAME
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst.V2X_ACC_OFF_TIME_STR
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst.V2X_STRATEGY_PUSH
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.net.V2XSeekHelpRes
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.net.V2XStrategyPushRes
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.V2XStatusManager
|
||||
import com.mogo.eagle.core.function.v2x.events.network.V2XRefreshCallback
|
||||
import com.mogo.eagle.core.function.v2x.events.observer.V2XOptimalRouteObserver
|
||||
import com.mogo.eagle.core.function.v2x.events.receiver.SceneBroadcastReceiver
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.impl.V2XScenarioManager
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.*
|
||||
import com.mogo.eagle.core.function.v2x.events.consts.V2XConst.*
|
||||
import com.mogo.eagle.core.function.v2x.events.entity.net.*
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.*
|
||||
import com.mogo.eagle.core.function.v2x.events.network.*
|
||||
import com.mogo.eagle.core.function.v2x.events.observer.*
|
||||
import com.mogo.eagle.core.function.v2x.events.receiver.*
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.impl.*
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.*
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.airoad.AiRoadMarker.Marker
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.road.*
|
||||
import com.mogo.eagle.core.function.v2x.events.utils.*
|
||||
import com.mogo.eagle.core.function.v2x.events.voice.V2XVoiceManager
|
||||
import com.mogo.eagle.core.network.utils.GsonUtil
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.function.v2x.events.utils.MapUtils
|
||||
import com.mogo.eagle.core.function.v2x.events.voice.*
|
||||
import com.mogo.eagle.core.network.utils.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.eagle.core.utilcode.util.TimeUtils
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.map.listener.IMogoMapListener
|
||||
import com.mogo.map.marker.IMogoMarker
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener
|
||||
import com.mogo.module.common.ModuleNames
|
||||
import com.mogo.module.common.drawer.TrafficMarkerDrawer
|
||||
import com.mogo.map.listener.*
|
||||
import com.mogo.map.marker.*
|
||||
import com.mogo.module.common.*
|
||||
import com.mogo.module.common.drawer.*
|
||||
import com.mogo.module.common.entity.*
|
||||
import com.mogo.module.common.entity.V2XMessageEntity.V2XTypeEnum
|
||||
import com.mogo.module.common.enums.EventTypeEnum
|
||||
import com.mogo.module.common.enums.EventTypeHelper
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener
|
||||
import com.mogo.service.statusmanager.StatusDescriptor
|
||||
import com.mogo.module.common.enums.*
|
||||
import com.mogo.service.statusmanager.*
|
||||
import com.mogo.service.statusmanager.StatusDescriptor.ACC_STATUS
|
||||
import com.mogo.service.statusmanager.StatusDescriptor.SEEK_HELPING
|
||||
import com.mogo.v2x.V2XManager
|
||||
import com.mogo.v2x.callback.IV2XCallback
|
||||
import com.mogo.v2x.config.V2XConfig
|
||||
import com.mogo.v2x.*
|
||||
import com.mogo.v2x.callback.*
|
||||
import com.mogo.v2x.config.*
|
||||
import com.mogo.v2x.data.*
|
||||
import com.mogo.v2x.event.V2XEvent
|
||||
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
||||
import com.shuyu.gsyvideoplayer.cache.CacheFactory
|
||||
import com.shuyu.gsyvideoplayer.cache.ProxyCacheManager
|
||||
import com.shuyu.gsyvideoplayer.model.VideoOptionModel
|
||||
import com.shuyu.gsyvideoplayer.player.IjkPlayerManager
|
||||
import com.shuyu.gsyvideoplayer.player.PlayerFactory
|
||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants
|
||||
import com.mogo.v2x.event.*
|
||||
import com.shuyu.gsyvideoplayer.*
|
||||
import com.shuyu.gsyvideoplayer.cache.*
|
||||
import com.shuyu.gsyvideoplayer.model.*
|
||||
import com.shuyu.gsyvideoplayer.player.*
|
||||
import com.shuyu.gsyvideoplayer.utils.*
|
||||
import com.zhjt.service.chain.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.android.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.android.*
|
||||
import roadwork.Road.RW_PB
|
||||
import tv.danmaku.ijk.media.player.IjkMediaPlayer
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import tv.danmaku.ijk.media.player.*
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.atomic.*
|
||||
|
||||
|
||||
object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallback,
|
||||
@@ -345,6 +329,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
|
||||
private fun refreshCarState(location: MogoLocation) {
|
||||
V2XStatusManager.getInstance().location = location
|
||||
// V2XAiRoadEventMarker.onLocationChanged(location)
|
||||
// 只有车速大于 5 的时候进行计算
|
||||
if (location.speed < 5) return
|
||||
val v2xPolyline = BridgeApi.v2xPolyline()?.mogoPolyline
|
||||
@@ -476,21 +461,6 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
|
||||
private val RW_PB.toRoadMarker: V2XMarkerCardResult
|
||||
get() = V2XMarkerCardResult().also { l1 ->
|
||||
l1.exploreWay = ArrayList<V2XMarkerExploreWay>().also { l2 ->
|
||||
l2.add(V2XMarkerExploreWay().also { l3 ->
|
||||
l3.poiType = this.roadwork?.poiType?.toString()
|
||||
l3.generateTime = this.roadwork?.detectTime ?: 0L
|
||||
l3.location = V2XMarkerLocation().also { l4 ->
|
||||
val p = CoordinateUtils.transformWgsToGcj(this.roadwork?.center?.point?.lat ?: 0.0, this.roadwork?.center?.point?.lon ?: 0.0)
|
||||
l4.lon = p[0]
|
||||
l4.lat = p[1]
|
||||
AiRoadMarker.enqueue(Marker(this.roadwork?.center?.point?.lat ?: 0.0, this.roadwork?.center?.point?.lon ?: 0.0, this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0, this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.map { d ->
|
||||
android.util.Pair(d.lon, d.lat)
|
||||
}))
|
||||
l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0
|
||||
}
|
||||
})
|
||||
}
|
||||
this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.also { old ->
|
||||
l1.extras = HashMap<String, List<Pair<Double, Double>>>().also { extra ->
|
||||
extra["polygon"] = old.map { d ->
|
||||
@@ -499,8 +469,38 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
}
|
||||
}
|
||||
}
|
||||
l1.exploreWay = ArrayList<V2XMarkerExploreWay>().also { l2 ->
|
||||
l2.add(V2XMarkerExploreWay().also { l3 ->
|
||||
l3.poiType = this.roadwork?.poiType?.toString()
|
||||
l3.generateTime = this.roadwork?.detectTime ?: 0L
|
||||
l3.location = V2XMarkerLocation().also { l4 ->
|
||||
val p = CoordinateUtils.transformWgsToGcj(this.roadwork?.center?.point?.lat ?: 0.0, this.roadwork?.center?.point?.lon ?: 0.0)
|
||||
l4.lon = p[0]
|
||||
l4.lat = p[1]
|
||||
l4.angle = this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0
|
||||
}
|
||||
|
||||
AiRoadMarker.enqueue(Marker(
|
||||
this.roadwork?.center?.point?.lat ?: 0.0,
|
||||
this.roadwork?.center?.point?.lon ?: 0.0,
|
||||
this.roadwork?.center?.road?.bearing?.toDouble() ?: 0.0,
|
||||
this.roadwork?.polygonList?.takeIf { it.isNotEmpty() }?.map { d -> android.util.Pair(d.lon, d.lat) },
|
||||
null,
|
||||
buildRoadEntity(l3, l1.extras)))
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun buildRoadEntity(e: V2XMarkerExploreWay, extra: Map<String, Any>? = null): V2XRoadEventEntity { // 记录道路事件
|
||||
val v2XRoadEventEntity = V2XRoadEventEntity()
|
||||
v2XRoadEventEntity.location = e.location.toMarkerLocation() // 探路目前只有上报拥堵
|
||||
v2XRoadEventEntity.poiType = EventTypeEnum.AI_ROAD_WORK.poiType
|
||||
v2XRoadEventEntity.noveltyInfo = e.toMarkExploreWay(extra)
|
||||
v2XRoadEventEntity.expireTime = 20000
|
||||
return v2XRoadEventEntity
|
||||
}
|
||||
|
||||
private fun handleWarningTargetEvent(data: V2XWarningTarget) {
|
||||
val v2xMessageEntity = V2XMessageEntity<V2XWarningTarget>()
|
||||
v2xMessageEntity.type = V2XTypeEnum.ALERT_THE_FRONT_WEAKNESS
|
||||
|
||||
@@ -79,4 +79,8 @@ public interface IMoGoV2XMarkerManager extends IProvider {
|
||||
void clearALLPOI();
|
||||
|
||||
|
||||
/**
|
||||
* 强制清除道路事件POI
|
||||
*/
|
||||
void forceClearAlarmPOI();
|
||||
}
|
||||
|
||||
@@ -148,8 +148,9 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
|
||||
v2XRoadEventEntity.setLocation(EntityUtilsKt.toMarkerLocation(markerLocation));
|
||||
// 探路目前只有上报拥堵
|
||||
v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType());
|
||||
String poi = markerExploreWay.getPoiType();
|
||||
|
||||
v2XRoadEventEntity.setPoiType(poi);
|
||||
v2XRoadEventEntity.setNoveltyInfo(EntityUtilsKt.toMarkExploreWay(markerExploreWay,markerCardResult.getExtras()));
|
||||
v2XRoadEventEntity.setExpireTime(20000);
|
||||
mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity);
|
||||
@@ -319,6 +320,13 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void forceClearAlarmPOI() {
|
||||
if (mAlarmInfoMarker != null) {
|
||||
mAlarmInfoMarker.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
|
||||
@@ -14,10 +14,12 @@ import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
|
||||
import com.mogo.eagle.core.function.api.map.listener.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.road.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.overlay.*
|
||||
import com.mogo.module.common.entity.*
|
||||
import com.mogo.module.common.utils.*
|
||||
import io.netty.util.internal.*
|
||||
import java.util.*
|
||||
@@ -170,7 +172,6 @@ object AiRoadMarker {
|
||||
removeLine()
|
||||
}
|
||||
|
||||
|
||||
fun enqueue(marker: Marker) {
|
||||
Logger.d(TAG, "--- enqueue --- 1 ---")
|
||||
if (markers.contains(marker)) {
|
||||
@@ -239,6 +240,7 @@ object AiRoadMarker {
|
||||
return
|
||||
}
|
||||
removeLine()
|
||||
marker.entity?.apply { V2XAiRoadEventMarker.drawMarkers(this) }
|
||||
val evaluator = ArgbEvaluator()
|
||||
val interceptor = DecelerateInterpolator(1.5f)
|
||||
val total = points.size
|
||||
@@ -276,6 +278,7 @@ object AiRoadMarker {
|
||||
private fun unMarker(marker: Marker) {
|
||||
markers -= marker
|
||||
removeLine()
|
||||
V2XAiRoadEventMarker.removeMarkers(null)
|
||||
}
|
||||
|
||||
private fun isOutOfRange(markerLon: Double, markerLat: Double, carLon: Double, carLat: Double, carAngle: Double): Boolean {
|
||||
@@ -292,7 +295,8 @@ object AiRoadMarker {
|
||||
val poi_lon: Double,
|
||||
val poi_angle: Double,
|
||||
val polygon: List<Pair<Double, Double>>?,
|
||||
var farthestPoint: Pair<Double, Double>? = null
|
||||
var farthestPoint: Pair<Double, Double>? = null,
|
||||
var entity: V2XRoadEventEntity? = null
|
||||
) {
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.road
|
||||
|
||||
import android.util.*
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.context
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.v2xMarker
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.R.raw
|
||||
import com.mogo.map.marker.*
|
||||
import com.mogo.map.overlay.*
|
||||
import com.mogo.module.common.entity.*
|
||||
import com.mogo.module.common.utils.*
|
||||
import java.util.*
|
||||
import java.util.concurrent.atomic.*
|
||||
import kotlin.Pair
|
||||
|
||||
object V2XAiRoadEventMarker {
|
||||
|
||||
private val current = AtomicReference<Pair<IMogoPolyline?, List<IMogoMarker>?>>()
|
||||
|
||||
private val v2xLocation = AtomicReference<MogoLocation>()
|
||||
|
||||
private val carLocation = AtomicReference<MogoLocation>()
|
||||
|
||||
private val timer = Timer()
|
||||
|
||||
private val timerTask by lazy { AtomicReference<TimerTask>() }
|
||||
|
||||
private val distance = AtomicInteger(0)
|
||||
|
||||
fun drawMarkers(entity: V2XRoadEventEntity): Pair<IMogoPolyline?, List<IMogoMarker>?>? {
|
||||
removeMarkers(current.get())
|
||||
timerTask.get()?.cancel()
|
||||
val extra = entity.noveltyInfo.extras.get("polygon");
|
||||
if (extra is List<*>) {
|
||||
val l = extra
|
||||
if (l.size > 0) {
|
||||
val polygons: MutableList<androidx.core.util.Pair<Double, Double>> = ArrayList()
|
||||
for (i in l.indices) {
|
||||
val o = l[i]!! as? androidx.core.util.Pair<*, *> ?: continue
|
||||
val p = o
|
||||
val first = p.first
|
||||
val second = p.second
|
||||
if (first == null || second == null) {
|
||||
continue
|
||||
}
|
||||
if (first !is Double || second !is Double) {
|
||||
continue
|
||||
}
|
||||
polygons.add(androidx.core.util.Pair.create(first, second))
|
||||
}
|
||||
if (polygons.size > 0) {
|
||||
val markers = ArrayList<IMogoMarker>(polygons.size)
|
||||
for (i in polygons.indices) {
|
||||
val p = polygons[i]
|
||||
val options = MogoMarkerOptions().data(entity).latitude(p.second).longitude(p.first)
|
||||
options.anchor(0.5f, 0.5f)
|
||||
options.icon3DRes(raw.sanjiaozhui)
|
||||
try {
|
||||
val marker = MogoMarkerManager.getInstance(context()).addMarker("road_pyramid_" + entity.getPoiType(), options)
|
||||
markers += marker
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
}
|
||||
}
|
||||
if (markers.size > 0) {
|
||||
v2xMarker()?.drawableAlarmPOI(context(), entity, null)
|
||||
val l2 = entity.noveltyInfo?.location ?: return null
|
||||
v2xLocation.set(MogoLocation().also { it.longitude = l2.lon; it.latitude = l2.lat; it.bearing = l2.angle.toFloat() })
|
||||
current.set(Pair(null, markers))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return current.get()
|
||||
}
|
||||
|
||||
fun removeMarkers(pair: Pair<IMogoPolyline?, List<IMogoMarker>?>?) {
|
||||
if (pair != null) {
|
||||
realRemove(pair)
|
||||
} else {
|
||||
val prev = current.get()
|
||||
if (prev != null) {
|
||||
realRemove(prev)
|
||||
val v2xMarker = v2xMarker()
|
||||
v2xMarker?.also {
|
||||
it.forceClearAlarmPOI()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun realRemove(pair: Pair<IMogoPolyline?, List<IMogoMarker>?>) {
|
||||
val line = pair.first
|
||||
if (line != null && line.isVisible) {
|
||||
line.remove()
|
||||
}
|
||||
val markers = pair.second
|
||||
if (markers != null && markers.isNotEmpty()) {
|
||||
for (m in markers) {
|
||||
m.remove()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun onLocationChanged(location: MogoLocation) {
|
||||
val markerLocation = v2xLocation.get()
|
||||
carLocation.set(location)
|
||||
if (markerLocation != null) {
|
||||
if (isOutOfRange(markerLocation.longitude, markerLocation.latitude, location.longitude, location.latitude, location.bearing.toDouble())) {
|
||||
v2xLocation.set(null)
|
||||
this.distance.set(0)
|
||||
timer.schedule(object : TimerTask() {
|
||||
override fun run() {
|
||||
val carLocation = this@V2XAiRoadEventMarker.carLocation.get()
|
||||
Log.d("XXXXX", "timer do action ---: marker_lon: ${markerLocation.longitude}, marker_lat: ${markerLocation.latitude}, car_lon:${carLocation.longitude}, car_lat: ${carLocation.latitude}")
|
||||
checkDistanceIsValid(markerLocation.longitude, markerLocation.latitude, carLocation)
|
||||
}
|
||||
}.also { this.timerTask.set(it) }, 1000, 1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
private fun checkDistanceIsValid(x1: Double, y1: Double, location: MogoLocation) {
|
||||
val distance = DrivingDirectionUtils.distance(x1, y1, location.longitude, location.latitude)
|
||||
Log.d("XXXXX", "distance: $distance")
|
||||
if (this.distance.addAndGet(distance.toInt()) >= 100) {
|
||||
Log.d("XXXXX", "remove marker")
|
||||
removeMarkers(null)
|
||||
this.timerTask.get()?.cancel()
|
||||
}
|
||||
}
|
||||
|
||||
private fun isOutOfRange(markerLon: Double, markerLat: Double, carLon: Double, carLat: Double, carAngle: Double): Boolean {
|
||||
return !isFrontOfCar(markerLon, markerLat, carLon, carLat, carAngle)
|
||||
}
|
||||
|
||||
private fun isFrontOfCar(markerLon: Double, markerLat: Double, carLon: Double, carLat: Double, carAngle: Double): Boolean {
|
||||
val degree = DrivingDirectionUtils.getDegreeOfCar2Poi2(carLon, carLat, markerLon, markerLat, carAngle)
|
||||
return degree < 90
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,13 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.scenario.scene.road;
|
||||
|
||||
import android.graphics.Color;
|
||||
|
||||
import androidx.core.util.Pair;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.v2x.R;
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XPolylineManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XStatusManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.view.IV2XMarker;
|
||||
import com.mogo.map.MogoMarkerManager;
|
||||
import com.mogo.map.MogoOverlayManager;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.mogo.module.common.enums.EventTypeEnum;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 道路V2X事件的Marker
|
||||
@@ -28,11 +15,7 @@ import java.util.List;
|
||||
public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
|
||||
|
||||
private final List<IMogoMarker> pyramids = new ArrayList<>();
|
||||
|
||||
private IMogoPolyline polyline;
|
||||
|
||||
private IMogoOverlayManager overlayManager;
|
||||
// private Pair<IMogoPolyline, List<IMogoMarker>> drawInfo;
|
||||
|
||||
@Override
|
||||
public void drawPOI(V2XRoadEventEntity entity) {
|
||||
@@ -42,58 +25,8 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
if (marker != null) {
|
||||
marker.clearAlarmPOI();
|
||||
if (entity != null) {
|
||||
marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null);
|
||||
MarkerExploreWay noveltyInfo = entity.getNoveltyInfo();
|
||||
if (noveltyInfo != null && noveltyInfo.extras != null && noveltyInfo.extras.containsKey("polygon")) {
|
||||
Object extra = noveltyInfo.extras.get("polygon");
|
||||
if (pyramids.size() > 0) {
|
||||
for (IMogoMarker m : pyramids) {
|
||||
m.remove();
|
||||
}
|
||||
pyramids.clear();
|
||||
}
|
||||
if (polyline != null && polyline.isVisible()) {
|
||||
polyline.remove();
|
||||
}
|
||||
if (extra instanceof List) {
|
||||
List l = (List) extra;
|
||||
if (l.size() > 0) {
|
||||
List<Pair<Double, Double>> polygons = new ArrayList<>();
|
||||
for (int i = 0; i < l.size(); i++) {
|
||||
Object o = l.get(i);
|
||||
if (!(o instanceof Pair)) {
|
||||
continue;
|
||||
}
|
||||
Pair p = (Pair) o;
|
||||
Object first = p.first;
|
||||
Object second = p.second;
|
||||
if (first == null || second == null) {
|
||||
continue;
|
||||
}
|
||||
if (!(first instanceof Double) || !(second instanceof Double)) {
|
||||
continue;
|
||||
}
|
||||
polygons.add(Pair.create((Double) first, (Double) second));
|
||||
}
|
||||
|
||||
if (polygons.size() > 0) {
|
||||
for (int i = 0; i < polygons.size(); i++) {
|
||||
Pair<Double, Double> p = polygons.get(i);
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.data(entity)
|
||||
.latitude(p.second)
|
||||
.longitude(p.first);
|
||||
options.anchor(0.5f, 0.5f);
|
||||
options.icon3DRes(R.raw.sanjiaozhui);
|
||||
try {
|
||||
pyramids.add(MogoMarkerManager.getInstance(BridgeApi.INSTANCE.context()).addMarker("road_pyramid_" + entity.getPoiType(), options));
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!Objects.equals(entity.getPoiType(), EventTypeEnum.AI_ROAD_WORK.getPoiType())) {
|
||||
marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,19 +42,6 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
if (polyLineManager != null) {
|
||||
polyLineManager.clearLine();
|
||||
}
|
||||
|
||||
IMoGoV2XStatusManager v2xStatus = BridgeApi.INSTANCE.v2xStatus();
|
||||
if (v2xStatus != null && v2xStatus.isRoadEventPOIShow()) {
|
||||
if (polyline != null) {
|
||||
polyline.remove();
|
||||
}
|
||||
if (pyramids.size() > 0) {
|
||||
for (IMogoMarker marker : pyramids) {
|
||||
marker.remove();
|
||||
}
|
||||
pyramids.clear();
|
||||
}
|
||||
}
|
||||
IMoGoV2XMarkerManager v2xMarker = BridgeApi.INSTANCE.v2xMarker();
|
||||
if (v2xMarker != null) {
|
||||
// 移除事件POI
|
||||
|
||||
Reference in New Issue
Block a user