[dev_arch_opt_3.0][fix]修正因位置回调重构造成的v2x事件不显示问题
This commit is contained in:
@@ -10,23 +10,24 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.*
|
||||
import com.mogo.eagle.core.function.api.map.collect.IMoGoMapDataCollectProvider
|
||||
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
|
||||
import com.zhidaoauto.map.operational.open.GatherApi
|
||||
import com.zhidaoauto.map.operational.open.GatherParams
|
||||
import com.zhidaoauto.map.operational.open.abs.OnTaskListener
|
||||
import mogo.telematics.pad.MessagePad.GnssInfo
|
||||
import record_cache.RecordPanelOuterClass
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
@Route(path = MogoServicePaths.PATH_MAP_DATA_COLLECT_PROVIDER)
|
||||
class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener, IMoGoMapLocationListener, IMoGoTokenCallback,
|
||||
class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener, IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback,
|
||||
IMoGoAutopilotRecordListener {
|
||||
|
||||
companion object {
|
||||
@@ -52,7 +53,7 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
|
||||
|
||||
override fun init(context: Context?) {
|
||||
|
||||
CallerMapLocationListenerManager.addListener(TAG, this, false)
|
||||
CallerChassisLocationGCJ20ListenerManager.addListener(TAG, this)
|
||||
CallerAutopilotRecordListenerManager.addListener(TAG, this)
|
||||
|
||||
executor.set(context?.let {
|
||||
@@ -74,7 +75,7 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
|
||||
|
||||
override fun onDestroy() {
|
||||
CallerLogger.d("$M_MAP$TAG", "--------- onDestroy --------")
|
||||
CallerMapLocationListenerManager.removeListener(TAG, false)
|
||||
CallerChassisLocationGCJ20ListenerManager.removeListener(TAG)
|
||||
CallerAutopilotRecordListenerManager.removeListener(TAG)
|
||||
executor.get()?.setOnTaskListener(null)
|
||||
listeners.clear()
|
||||
@@ -170,18 +171,17 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) {
|
||||
location ?: return
|
||||
override fun onChassisLocationGCJ02(gnssInfo: GnssInfo?) {
|
||||
val location = CallerMapLocationListenerManager.getCurrentLocation() ?: return
|
||||
executor.get()?.updateLocation(
|
||||
location.longitude,
|
||||
location.latitude,
|
||||
location.longitude,
|
||||
location.latitude,
|
||||
location.altitude,
|
||||
location.bearing,
|
||||
location.speed,
|
||||
isGps)
|
||||
false)
|
||||
}
|
||||
|
||||
|
||||
private fun isInValidStatus(): Boolean {
|
||||
if (map.isEmpty()) {
|
||||
return true
|
||||
|
||||
@@ -24,10 +24,10 @@ import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
import com.mogo.eagle.core.data.msgbox.V2XMsg
|
||||
import com.mogo.eagle.core.data.traffic.*
|
||||
import com.mogo.eagle.core.function.api.autopilot.*
|
||||
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.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
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.map.CallerVisualAngleManager.Scene.Default
|
||||
@@ -72,12 +72,13 @@ import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.android.*
|
||||
import mogo.telematics.pad.MessagePad.GnssInfo
|
||||
import tv.danmaku.ijk.media.player.*
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.atomic.*
|
||||
|
||||
|
||||
object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallback {
|
||||
object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback, IV2XCallback {
|
||||
|
||||
private const val TAG = "V2XEventManager"
|
||||
|
||||
@@ -87,8 +88,6 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
|
||||
private val hasInit by lazy { AtomicBoolean(false) }
|
||||
|
||||
// 记录历史行驶轨迹,用于车行驶方向计算,只保留两个数据
|
||||
private val historyPath = arrayOfNulls<MogoLocation>(2)
|
||||
|
||||
var v2xEventDisposable: Disposable? = null
|
||||
|
||||
@@ -120,7 +119,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
|
||||
private fun registerListener() {
|
||||
V2XManager.addCallback(this)
|
||||
CallerMapLocationListenerManager.addListener(TAG, this, false)
|
||||
CallerChassisLocationGCJ20ListenerManager.addListener(TAG, this)
|
||||
mogoMarkersHandler.registerMarkerClickListener(CARD_TYPE_ROAD_CONDITION,
|
||||
object : IMogoMarkerClickListener {
|
||||
override fun onMarkerClicked(marker: IMogoMarker?): Boolean {
|
||||
@@ -132,7 +131,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
|
||||
private fun unRegisterListener() {
|
||||
V2XManager.removeCallback(this)
|
||||
CallerMapLocationListenerManager.removeListener(TAG, false)
|
||||
CallerChassisLocationGCJ20ListenerManager.removeListener(TAG)
|
||||
|
||||
mogoMarkersHandler.unregisterMarkerClickListener(CARD_TYPE_ROAD_CONDITION)
|
||||
}
|
||||
@@ -206,8 +205,8 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
V2XScenarioManager.getInstance().handlerMessage(entity)
|
||||
}
|
||||
|
||||
override fun onLocationChanged(location: MogoLocation?, from: Int, isGps: Boolean) {
|
||||
location ?: return
|
||||
override fun onChassisLocationGCJ02(gnssInfo: GnssInfo?) {
|
||||
val location = CallerMapLocationListenerManager.getCurrentLocation() ?: return
|
||||
BridgeApi.location.set(location)
|
||||
if (V2XManager.hasInit()) {
|
||||
V2XManager.onLocationChanged(
|
||||
@@ -218,7 +217,6 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
|
||||
V2XOptimalRouteObserver.getInstance().update(location)
|
||||
refreshCarState(location)
|
||||
}
|
||||
|
||||
private fun refreshCarState(location: MogoLocation) {
|
||||
V2XStatusManager.getInstance().location = location
|
||||
val v2xPolyline = BridgeApi.v2xPolyline()?.mogoPolyline
|
||||
|
||||
@@ -4,12 +4,12 @@ import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.util.Log
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.map.marker.IMogoMarker
|
||||
import com.mogo.map.overlay.IMogoPolyline
|
||||
import kotlinx.coroutines.Runnable
|
||||
import mogo.telematics.pad.MessagePad.GnssInfo
|
||||
import java.util.LinkedList
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
@@ -64,9 +64,9 @@ object MarkerManager {
|
||||
|
||||
private val elapsedDistances by lazy { ConcurrentHashMap<MarkerWrapper, Double>() }
|
||||
|
||||
private val lastCarLocation by lazy { AtomicReference<MogoLocation>() }
|
||||
private val lastCarLocation by lazy { AtomicReference<Pair<Double, Double>>() }
|
||||
|
||||
private val lastGpsLocation by lazy { AtomicReference<MogoLocation>() }
|
||||
private val lastGpsLocation by lazy { AtomicReference<Pair<Double, Double>>() }
|
||||
|
||||
private val checkTask = object : Runnable {
|
||||
|
||||
@@ -83,21 +83,22 @@ object MarkerManager {
|
||||
}
|
||||
Log.d(TAG, "--- checkTask --- 3 ---")
|
||||
val toRemove = toRemoveMakers.iterator()
|
||||
val carLoc = AtomicReference<MogoLocation>()
|
||||
val carLoc = AtomicReference<GnssInfo>()
|
||||
while (toRemove.hasNext()) {
|
||||
val marker = toRemove.next()
|
||||
if (carLoc.get() == null) {
|
||||
carLoc.set(if (marker.coordinateType == 0) {
|
||||
//高德坐标
|
||||
CallerMapLocationListenerManager.getCurrentLocation()
|
||||
CallerChassisLocationGCJ20ListenerManager.getChassisLocationGCJ02()
|
||||
} else {
|
||||
CallerMapLocationListenerManager.getCurrentGpsLocation()
|
||||
//高精坐标
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
})
|
||||
}
|
||||
val currentLocation = carLoc.get()
|
||||
val lastLocation = if (marker.coordinateType == 0) lastCarLocation.get() else lastGpsLocation.get()
|
||||
if (currentLocation != null && lastLocation != null) {
|
||||
val delta = CoordinateUtils.calculateLineDistance(currentLocation.longitude, currentLocation.latitude, lastLocation.longitude, lastLocation.latitude)
|
||||
val delta = CoordinateUtils.calculateLineDistance(currentLocation.longitude, currentLocation.latitude, lastLocation.first, lastLocation.second)
|
||||
Log.d(TAG, "--- checkTask --- 4 ---:delta:$delta, id:${marker.id}")
|
||||
var elapsed = elapsedDistances[marker]
|
||||
if (elapsed == null) {
|
||||
@@ -148,14 +149,15 @@ object MarkerManager {
|
||||
if (carLoc.get() == null) {
|
||||
carLoc.set(if (marker.coordinateType == 0) {
|
||||
//高德坐标
|
||||
CallerMapLocationListenerManager.getCurrentLocation()
|
||||
CallerChassisLocationGCJ20ListenerManager.getChassisLocationGCJ02()
|
||||
} else {
|
||||
CallerMapLocationListenerManager.getCurrentGpsLocation()
|
||||
//高精坐标
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
})
|
||||
}
|
||||
val location = carLoc.get()
|
||||
if (location != null) {
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(location.longitude, location.latitude, marker.lon, marker.lat, location.bearing.toDouble())
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(location.longitude, location.latitude, marker.lon, marker.lat, location.heading)
|
||||
if (angle >= 90) {
|
||||
iterator.remove()
|
||||
synchronized(toRemoveMakers) {
|
||||
@@ -167,8 +169,10 @@ object MarkerManager {
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
} finally {
|
||||
lastCarLocation.set(CallerMapLocationListenerManager.getCurrentLocation())
|
||||
lastGpsLocation.set(CallerMapLocationListenerManager.getCurrentGpsLocation())
|
||||
val gcInfo = CallerChassisLocationGCJ20ListenerManager.getChassisLocationGCJ02()
|
||||
lastCarLocation.set((gcInfo?.longitude ?: 0.0) to (gcInfo?.latitude ?: 0.0))
|
||||
val wgsInfo = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
lastGpsLocation.set((wgsInfo?.longitude ?: 0.0) to (wgsInfo?.latitude ?: 0.0))
|
||||
handler.postDelayed(this, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.mogo.cloud.commons.utils.*
|
||||
import com.mogo.commons.AbsMogoApplication
|
||||
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.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.road.V2XAiRoadEventMarker
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
@@ -61,7 +62,7 @@ class AiRoadMarker {
|
||||
|
||||
private val checkExpiredTask = Runnable {
|
||||
val poi = this.marker.get()
|
||||
val car = CallerMapLocationListenerManager.getCurrentGpsLocation()
|
||||
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
if (poi != null && car != null) {
|
||||
val distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, poi.poi_lon, poi.poi_lat)
|
||||
if (distance < 500) {
|
||||
@@ -80,7 +81,7 @@ class AiRoadMarker {
|
||||
}
|
||||
|
||||
fun marker(marker: Marker, drawMarker: Boolean, drawRoadLine: Boolean = false) {
|
||||
val location = CallerMapLocationListenerManager.getCurrentGpsLocation() ?: return
|
||||
val location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() ?: return
|
||||
this.marker.set(marker)
|
||||
val wrapper = MarkerWrapper(marker.id, marker.poi_lon, marker.poi_lat, 1, null, null)
|
||||
if (drawMarker) {
|
||||
@@ -88,10 +89,10 @@ class AiRoadMarker {
|
||||
}
|
||||
if (drawRoadLine) {
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.bearing, 300f)
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.heading.toFloat(), 300f)
|
||||
//施工中心点后方的自车行驶方向上300米距离
|
||||
Logger.d(TAG, "--- marker --- 3 --- l1: $l1")
|
||||
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.bearing, -300f)
|
||||
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(marker.poi_lon, marker.poi_lat, location.heading.toFloat(), -300f)
|
||||
if (l1.points.isEmpty() || l2.points.isEmpty()) {
|
||||
Logger.d(TAG, "--- marker --- 3 --- return ----")
|
||||
return
|
||||
@@ -110,7 +111,7 @@ class AiRoadMarker {
|
||||
var find: Pair<Double, Double> = Pair(centerX, centerY)
|
||||
var min = Long.MAX_VALUE
|
||||
for (p in it) {
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(centerX, centerY, p.first, p.second, location.bearing.toDouble())
|
||||
val angle = DrivingDirectionUtils.getDegreeOfCar2Poi2(centerX, centerY, p.first, p.second, location.heading)
|
||||
if (angle < min) {
|
||||
min = angle
|
||||
find = p
|
||||
@@ -122,7 +123,7 @@ class AiRoadMarker {
|
||||
Logger.d(TAG, "--- marker --- 6 --- marker: $marker")
|
||||
if (l1 != null && l1.points.isNotEmpty()) {
|
||||
for (l in l1.points) {
|
||||
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(farthestPoint.lon, farthestPoint.lat, l.first, l.second, (location.bearing + 180).toDouble()) < 90L) {
|
||||
if (DrivingDirectionUtils.getDegreeOfCar2Poi2(farthestPoint.lon, farthestPoint.lat, l.first, l.second, (location.heading + 180)) < 90L) {
|
||||
points.add(l.let { MogoLatLng(it.second, it.first) })
|
||||
}
|
||||
}
|
||||
@@ -180,7 +181,7 @@ class AiRoadMarker {
|
||||
fun receive() {
|
||||
Logger.d(TAG, "receive --- 1 ---")
|
||||
val poi = this.marker.get()
|
||||
val car = CallerMapLocationListenerManager.getCurrentGpsLocation()
|
||||
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
if (poi != null && car != null) {
|
||||
val distance = CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, poi.poi_lon, poi.poi_lat)
|
||||
Logger.d(TAG, "receive --- 2 ---:car:[${car.longitude}, ${car.latitude}] -> poi:[${poi.poi_lon}, ${poi.poi_lat}] --> distance:$distance")
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.mogo.eagle.core.data.msgbox.MsgBoxBean;
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType;
|
||||
import com.mogo.eagle.core.data.msgbox.V2XMsg;
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
|
||||
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.CallerVisualAngleManager;
|
||||
@@ -31,6 +32,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
|
||||
/**
|
||||
@@ -123,9 +125,8 @@ public class V2XRoadEventScenario extends AbsV2XScenario<V2XRoadEventEntity> imp
|
||||
EventTypeEnumNew. TYPE_SOCKET_ROAD_JINGZHI.getPoiType().equals(poiType) ||
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_CONGESTION.getPoiType().equals(poiType) ||
|
||||
EventTypeEnumNew.TYPE_SOCKET_ROAD_SHIGU.getPoiType().equals(poiType)) {
|
||||
MogoLocation carLocation = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
|
||||
MarkerExploreWay noveltyInfo = content.getNoveltyInfo();
|
||||
if (carLocation != null && noveltyInfo != null) {
|
||||
if (noveltyInfo != null) {
|
||||
MarkerLocation eventLocation = noveltyInfo.getLocation();
|
||||
if (eventLocation != null) {
|
||||
double distance = content.getDistance();
|
||||
|
||||
Reference in New Issue
Block a user