[dev_arch_opt_3.0][fix]修正因位置回调重构造成的v2x事件不显示问题

This commit is contained in:
renwj
2023-01-30 19:11:06 +08:00
parent 0b84b3855e
commit 2baf4aa785
9 changed files with 66 additions and 219 deletions

View File

@@ -29,8 +29,10 @@ import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_C
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_CLOUD
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CONNECT_STATUS
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.*
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener
import com.mogo.eagle.core.function.call.analytics.AnalyticsManager
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
@@ -45,6 +47,7 @@ import com.rousetime.android_startup.AndroidStartup
import com.zhjt.mogo_core_function_devatools.env.EnvChangeManager
import com.zhjt.service.chain.ChainLog
import com.zhjt.service.chain.TracingConstants.Endpoint.Companion.PAD
import mogo.telematics.pad.MessagePad.GnssInfo
class HttpDnsStartUp : AndroidStartup<Boolean>() {
@@ -70,8 +73,7 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
override fun dependenciesByName(): List<String> {
return listOf(
"com.mogo.launcher.stageone.APMStartup",
"com.mogo.launcher.stageone.ThreadOptStartup"
"com.mogo.launcher.stageone.APMStartup"
)
}
@@ -292,17 +294,16 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
context?.let {
MogoLocationInfoServices.getInstance().init(it)
MogoLocationInfoServices.getInstance().start()
CallerMapLocationListenerManager.addListener(
CallerChassisLocationGCJ20ListenerManager.addListener(
TAG,
object : IMoGoMapLocationListener {
override fun onLocationChanged(
location: MogoLocation?, from: Int, isGps: Boolean) {
location?.let { loc ->
object : IMoGoChassisLocationGCJ02Listener {
override fun onChassisLocationGCJ02(gnssInfo: GnssInfo?) {
CallerMapLocationListenerManager.getCurrentLocation()?.let { loc ->
MogoLocationInfoServices.getInstance().provideLocation(loc)
}
}
},
false
)
}
}

View File

@@ -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

View File

@@ -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

View File

@@ -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)
}
}

View File

@@ -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")

View File

@@ -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();

View File

@@ -13,21 +13,9 @@ import java.util.concurrent.ConcurrentHashMap
object CallerMapLocationListenerManager : CallerBase<Any>() {
// 记录地图最后一次位置
@Volatile
private var mLocation: MogoLocation? = null
/**
* 记录最后一次高精坐标的位置
*/
private var mGpsLocation: MogoLocation? = null
// 存储所有注册了监听的对象invokeXXXX进行遍历回调将信息同步
private val mMapStyleChangeListeners: ConcurrentHashMap<String, IMoGoMapLocationListener> =
ConcurrentHashMap()
// 高精坐标回调
private val mGpsChangedListeners: ConcurrentHashMap<String, IMoGoMapLocationListener> = ConcurrentHashMap()
/**
* 获取当前经纬度
*/
@@ -35,103 +23,7 @@ object CallerMapLocationListenerManager : CallerBase<Any>() {
return mLocation
}
/**
* 获取当前高精坐标
*/
fun getCurrentGpsLocation(): MogoLocation? {
return mGpsLocation
}
/**
* 添加 地图样式改变 监听
* @param tag 标记,用来注销监听使用
* @param listener 监听回调
*/
fun addListener(tag: String, listener: IMoGoMapLocationListener, isGps: Boolean) {
if (!isGps) {
if (mMapStyleChangeListeners.containsKey(tag)) {
return
}
mMapStyleChangeListeners[tag] = listener
listener.onLocationChanged(mLocation, 0, isGps)
} else {
if (mGpsChangedListeners.containsKey(tag)) {
return
}
mGpsChangedListeners[tag] = listener
listener.onLocationChanged(mGpsLocation, 0, isGps)
}
}
/**
* 删除 地图样式改变 监听
* @param tag 标记,用来注销监听使用
*/
fun removeListener(tag: String, isGps: Boolean) {
if (!isGps) {
if (!mMapStyleChangeListeners.containsKey(tag)) {
return
}
mMapStyleChangeListeners.remove(tag)
} else {
if (!mGpsChangedListeners.containsKey(tag)) {
return
}
mGpsChangedListeners.remove(tag)
}
}
/**
* 删除 地图样式改变 监听
* @param listener 要删除的监听对象
*/
fun removeListener(listener: IMoGoMapLocationListener, isGps: Boolean) {
if (!isGps) {
if (!mMapStyleChangeListeners.containsValue(listener)) {
return
}
mMapStyleChangeListeners.forEach {
if (it.value == listener) {
mMapStyleChangeListeners.remove(it.key)
}
}
} else {
if (!mGpsChangedListeners.containsValue(listener)) {
return
}
mGpsChangedListeners.forEach {
if (it.value == listener) {
mGpsChangedListeners.remove(it.key)
}
}
}
}
/**
* 触发 地图样式改变 监听
*/
fun invokeMapLocationChangeListener() {
invokeMapLocationChangeListener(mLocation, 0, false)
}
/**
* 触发 地图样式改变 监听
* @param location 选中状态
*/
fun invokeMapLocationChangeListener(location: MogoLocation?, from: Int, isGps: Boolean) {
if (!isGps) {
mLocation = location
mMapStyleChangeListeners.forEach {
val listener = it.value
listener.onLocationChanged(location, from, isGps)
}
} else {
mGpsLocation = location
mGpsChangedListeners.forEach {
it.value.onLocationChanged(location, from, isGps)
}
}
fun setCurrentLocation(location: MogoLocation) {
mLocation = location
}
}

View File

@@ -12,6 +12,7 @@ import androidx.lifecycle.LifecycleOwner
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.*
import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
import com.mogo.eagle.core.function.call.autopilot.*
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.OnRoadListener
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.*
import com.mogo.eagle.core.utilcode.kotlin.lifeCycleOwner
@@ -23,6 +24,7 @@ import com.zhidaoauto.map.sdk.open.tools.MapTools
import kotlinx.coroutines.*
import kotlinx.coroutines.android.asCoroutineDispatcher
import kotlinx.coroutines.internal.synchronized
import mogo.telematics.pad.MessagePad.GnssInfo
import java.util.*
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeUnit.SECONDS
@@ -63,7 +65,7 @@ object CallerVisualAngleManager {
val displayThreshold: Long //最大展示时长 > 0; 表示最长展示多长时间, -1 表示,一直展示,直到触发默认视角, 0: 默认视角专用值,
}
private val triggerLocation = AtomicReference<MogoLocation>()
private val triggerLocation = AtomicReference<GnssInfo>()
private val distanceOfCarToStopLine = AtomicReference(0.0)
@@ -76,7 +78,7 @@ object CallerVisualAngleManager {
override fun onRoadIdInfo(roadId: String) {
this.roadId.set(roadId)
Log.d(TAG, "-- onRoadIdInfo --: prev: ${this.triggerRoadId.get()} -> curr: $roadId")
val loc = CallerMapLocationListenerManager.getCurrentLocation()
val loc = CallerChassisLocationGCJ20ListenerManager.getChassisLocationGCJ02()
var triggerClose = false
val distance = distanceOfCarToStopLine.get() + 5
if (hasCrossRoad && distance > 0) {
@@ -109,7 +111,7 @@ object CallerVisualAngleManager {
hasCrossRoad = true
triggerRoadId.set(this.roadId.get())
distanceOfCarToStopLine.set(info.distanceOfCarToStopLine)
triggerLocation.set(CallerMapLocationListenerManager.getCurrentLocation())
triggerLocation.set(CallerChassisLocationGCJ20ListenerManager.getChassisLocationGCJ02())
changeVisualAngle(CrossRoad(true))
}
}

View File

@@ -121,10 +121,6 @@ public class AMapViewWrapper implements IMogoMapView,
private boolean mIsFirstLocated = true;
private boolean mIsDelayed = false;
// GPS 位置回调
private final LocationListener mGpsLocationListener =
location -> CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(ObjectUtils.fromLocation(location), 0, true);
public AMapViewWrapper(MapAutoView mMapView) {
CallerLogger.INSTANCE.i(M_MAP + TAG, "autoop--AMapViewWrapper: init");
this.mMapView = mMapView;
@@ -189,7 +185,6 @@ public class AMapViewWrapper implements IMogoMapView,
LocationClient client = mMapView.getLocationClient();
if (client != null) {
client.registerListener(this);
client.registerGpsListener(mGpsLocationListener);
}
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ZOOM);
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ROTATE);
@@ -704,45 +699,12 @@ public class AMapViewWrapper implements IMogoMapView,
CallerMapDevaListenerManager.INSTANCE.invokeUploadLogFile(filePath);
}
// TODO 这里需要数据中心代理
// private static class LocationTask implements Runnable {
//
// private MogoLocation location;
//
// public void setMoGoLocation(MogoLocation location) {
// this.location = location;
// }
//
// @Override
// public void run() {
// if (location != null) {
// CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(location, 1, false);
// location = null;
// }
// }
// }
// private volatile LocationTask mLocationTask;
// private final Handler mainHandler = new Handler(Looper.getMainLooper());
@Override
public void onLocationChanged(@NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location) {
// MogoLocation currentLocation = ObjectUtils.fromLocation(location);
// if (Looper.myLooper() == Looper.getMainLooper()) {
// CallerMapLocationListenerManager.INSTANCE.invokeMapLocationChangeListener(currentLocation, 1, false);
// } else {
// if (mLocationTask == null) {
// mLocationTask = new LocationTask();
// }
// mLocationTask.setMoGoLocation(currentLocation);
// mainHandler.removeCallbacks(mLocationTask);
// mainHandler.post(mLocationTask);
// }
CallerMapLocationListenerManager.INSTANCE.setCurrentLocation(ObjectUtils.fromLocation(location));
// 将有效经纬度暂存本地提供给下一次的Http-DNS使用防止首次请求位置获取不到
if (location.getLat() > 0 && location.getLon() > 0) {
if (location.getCityCode() != null && !location.getCityCode().isEmpty()) {
if (location.getCityCode() != null && !location.getCityCode().isEmpty()) {
SharedPrefsMgr.getInstance(mMapView.getContext())
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, location.getCityCode());
}
@@ -752,20 +714,6 @@ public class AMapViewWrapper implements IMogoMapView,
.putString(SharedPrefsConstants.LOCATION_LONGITUDE, String.valueOf(location.getLon()));
}
// // 同步给各个模块
// Location sysLocation = new Location(location.getProvider());
// sysLocation.setAltitude(location.getAltitude());
// sysLocation.setLatitude(location.getLat());
// sysLocation.setLongitude(location.getLon());
// sysLocation.setProvider(location.getProvider());
// sysLocation.setAccuracy(location.getAcceleration());
// sysLocation.setTime(location.duration);
// sysLocation.setBearing((float) location.getHeading());
// sysLocation.setSpeed(location.getSpeed());
// if (MogoCarLocationChangedListenerRegister.getInstance().getListener() != null) {
// MogoCarLocationChangedListenerRegister.getInstance().getListener().onCarLocationChanged2(sysLocation);
// }
if (checkAMapView() && mMapLoaded) {
// 地图初始化完成后每隔5s自动判断当前地图的模式
if (mIsFirstLocated) {