[3.4.0-map-sdk] loc wgs84 opt , get instead of callback , add func of traffic light cross road

This commit is contained in:
zhongchao
2023-09-21 19:33:37 +08:00
parent 056ec28709
commit 39b7d8907f
13 changed files with 175 additions and 245 deletions

View File

@@ -11,6 +11,7 @@ import com.mogo.eagle.core.data.biz.trafficlight.isInRange
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
@@ -20,7 +21,8 @@ import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightThreadHandl
import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightThreadHandler.Companion.MSG_WHAT_STOP_SEARCH_TRAFFIC_LIGHT
import com.mogo.eagle.function.biz.v2x.trafficlight.network.TrafficLightNetWorkModel
class MogoTrafficLightManager : IMoGoChassisLocationGCJ02Listener {
class MogoTrafficLightManager : IMoGoChassisLocationGCJ02Listener,
CallerMapRoadListenerManager.OnRoadListener {
companion object {
@@ -40,6 +42,8 @@ class MogoTrafficLightManager : IMoGoChassisLocationGCJ02Listener {
@Volatile
private var trafficLightResult: TrafficLightResult? = null
@Volatile
private var mCross: Boolean = false
private var inRange: Boolean = false
@Volatile
private var firstLoopCrossRoad: Boolean = true //开启循环请求路口
@@ -49,6 +53,7 @@ class MogoTrafficLightManager : IMoGoChassisLocationGCJ02Listener {
fun initServer(context: Context) {
mContext = context
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, this)
CallerMapRoadListenerManager.registerRoadListener(TAG, this)
mThreadHandler =
TrafficLightThreadHandler(Looper.getMainLooper(), {
//第一次查询路口时,如果红绿灯显示,则隐藏掉
@@ -118,6 +123,11 @@ class MogoTrafficLightManager : IMoGoChassisLocationGCJ02Listener {
mThreadHandler?.sendEmptyMessageDelayed(MSG_WHAT_LOOP_SEARCH_CROSS_ROAD, 5_000L)
}
override fun onRoadChange(cross: Boolean) {
super.onRoadChange(cross)
mCross = cross
}
private fun checkOutOfRange() {
mLocation?.let { loc ->
roadIDResult?.let {
@@ -128,7 +138,7 @@ class MogoTrafficLightManager : IMoGoChassisLocationGCJ02Listener {
CallerTrafficLightListenerManager.invokeEnterCrossRoad(true)
return
}
if (inRange) {
if (inRange || !mCross) {
// CallerLogger.d(M_V2X + TAG, "离开路口")
CallerTrafficLightListenerManager.invokeEnterCrossRoad(false)
inRange = false

View File

@@ -5,8 +5,6 @@ import com.mogo.commons.utils.MogoAnalyticUtils
import com.mogo.eagle.core.data.app.AppConfigInfo
import com.mogo.eagle.core.data.enums.CommunicationType
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
import com.mogo.eagle.core.function.api.biz.IFuncBizProvider
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.biz.CallerFuncBizListenerManager
@@ -17,7 +15,7 @@ import java.util.concurrent.atomic.AtomicBoolean
/**
* V2X消息播报埋点统计
*/
object V2XEventAnalyticsManager: IMoGoChassisLocationWGS84Listener,IFuncBizProvider{
object V2XEventAnalyticsManager: IFuncBizProvider{
private const val TAG = "V2XEventAnalyticsManager"
private val hasInit by lazy { AtomicBoolean(false) }
@@ -38,10 +36,6 @@ object V2XEventAnalyticsManager: IMoGoChassisLocationWGS84Listener,IFuncBizProvi
private const val EVENT_PARAMS_LATITUDE ="latitude" // 纬度
private const val EVENT_PARAMS_HEADING ="heading" // 航向角
private var longitude: Double?=null //经度
private var latitude: Double?=null //纬度
private var heading: Double?=null //航向角
private var oldTime = System.currentTimeMillis()
fun init(){
@@ -52,13 +46,11 @@ object V2XEventAnalyticsManager: IMoGoChassisLocationWGS84Listener,IFuncBizProvi
private fun registerListener(){
// 添加 ADAS车辆状态&定位 监听
CallerChassisLocationWGS84ListenerManager.addListener(TAG, this)
CallerFuncBizListenerManager.addListener(TAG,this)
}
private fun unRegisterListener(){
// 移除 ADAS车辆状态&定位 监听
CallerChassisLocationWGS84ListenerManager.removeListener(TAG)
CallerFuncBizListenerManager.removeListener(TAG)
}
@@ -87,9 +79,9 @@ object V2XEventAnalyticsManager: IMoGoChassisLocationWGS84Listener,IFuncBizProvi
msgEventParams[EVENT_PARAMS_PLATE_NUMBER] = AppConfigInfo.plateNumber //车牌号
msgEventParams[EVENT_PARAMS_CAR_SN] = MoGoAiCloudClientConfig.getInstance().sn //鹰眼SN
msgEventParams[EVENT_PARAMS_EYE_VERSION] = AppUtils.getAppVersionName() //鹰眼版本
msgEventParams[EVENT_PARAMS_LONGITUDE] = "$longitude" //经度
msgEventParams[EVENT_PARAMS_LATITUDE] = "$latitude" //纬度
msgEventParams[EVENT_PARAMS_HEADING] = "$heading" //航向角
msgEventParams[EVENT_PARAMS_LONGITUDE] = "${CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().longitude}" //经度
msgEventParams[EVENT_PARAMS_LATITUDE] = "${CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().latitude}" //纬度
msgEventParams[EVENT_PARAMS_HEADING] = "${CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().heading}" //航向角
MogoAnalyticUtils.track(EVENT_KEY_RECEIVE_V2X_MSG,msgEventParams)
}
@@ -109,20 +101,12 @@ object V2XEventAnalyticsManager: IMoGoChassisLocationWGS84Listener,IFuncBizProvi
msgEventParams[EVENT_PARAMS_PLATE_NUMBER] = AppConfigInfo.plateNumber //车牌号
msgEventParams[EVENT_PARAMS_CAR_SN] = MoGoAiCloudClientConfig.getInstance().sn //鹰眼SN
msgEventParams[EVENT_PARAMS_EYE_VERSION] = AppUtils.getAppVersionName() //鹰眼版本
msgEventParams[EVENT_PARAMS_LONGITUDE] = "$longitude" //经度
msgEventParams[EVENT_PARAMS_LATITUDE] = "$latitude" //纬度
msgEventParams[EVENT_PARAMS_HEADING] = "$heading" //航向角
msgEventParams[EVENT_PARAMS_LONGITUDE] = "${CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().longitude}" //经度
msgEventParams[EVENT_PARAMS_LATITUDE] = "${CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().latitude}" //纬度
msgEventParams[EVENT_PARAMS_HEADING] = "${CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().heading}" //航向角
MogoAnalyticUtils.track(EVENT_KEY_V2X_MSG_EVENT,msgEventParams)
}
override fun onChassisLocationWGS84(gnssInfo: MogoLocation) {
gnssInfo.let {
longitude = it.longitude
latitude = it.latitude
heading = it.heading
}
}
fun onDestroy(){
if (hasInit.compareAndSet(true, false)){
unRegisterListener()