Merge branch 'dev_arch_opt_3.0' into dev_robobus-m1-p-app-module_1.0.0_230112_1.0.0

This commit is contained in:
yangyakun
2023-02-06 18:50:17 +08:00
65 changed files with 1667 additions and 1872 deletions

View File

@@ -57,6 +57,9 @@ dependencies {
kapt rootProject.ext.dependencies.aroutercompiler
implementation rootProject.ext.dependencies.rxandroid
implementation rootProject.ext.dependencies.androidxroomruntime
kapt rootProject.ext.dependencies.androidxroomcompiler
implementation rootProject.ext.dependencies.androidxroomktx
implementation project(':foudations:mogo-commons')
implementation project(':core:mogo-core-data')

View File

@@ -2,6 +2,7 @@ package com.mogo.eagle.function.biz
import android.content.Context
import com.alibaba.android.arouter.facade.annotation.Route
import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.eagle.core.data.camera.CameraEntity
import com.mogo.eagle.core.data.constants.MogoServicePaths
import com.mogo.eagle.core.function.api.biz.IMoGoFuncBizProvider
@@ -10,6 +11,8 @@ import com.mogo.eagle.function.biz.dispatch.DispatchAutoPilotManager.Companion.d
import com.mogo.eagle.function.biz.monitoring.CronTaskManager.Companion.cronTaskManager
import com.mogo.eagle.function.biz.notice.NoticeSocketManager.Companion.noticeSocketManager
import com.mogo.eagle.function.biz.notice.network.NoticeNetWorkManager
import com.mogo.eagle.function.biz.v2x.overview.OverViewDataManager
import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb
import com.mogo.eagle.function.biz.v2x.speedlimit.SpeedLimitDispatcher
import com.mogo.eagle.function.biz.v2x.trafficlight.core.MogoTrafficLightManager
import com.mogo.eagle.function.biz.v2x.trafficlight.core.TrafficLightDispatcher
@@ -68,6 +71,18 @@ class FuncBizProvider : IMoGoFuncBizProvider {
cronTaskManager.clear()
}
override fun fetchInfStructures() {
OverViewDataManager.fetchInfStructures()
}
override fun getAllV2XEvents() {
OverViewDataManager.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().sn)
}
override fun initOverViewDb(context: Context) {
OverviewDb.getDb(context)
}
override fun onDestroy() {
noticeSocketManager.release()
dispatchAutoPilotManager.release()

View File

@@ -1,21 +1,23 @@
package com.mogo.eagle.core.function.overview
package com.mogo.eagle.function.biz.v2x.overview
import androidx.lifecycle.*
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.constants.HostConst
import com.mogo.eagle.core.data.map.Infrastructure
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.overview.db.OverviewDb
import com.mogo.eagle.core.function.overview.remote.OverViewServiceApi
import com.mogo.eagle.core.function.overview.remote.V2XEvent
import com.mogo.eagle.core.function.call.biz.CallerFuncBizListenerManager
import com.mogo.eagle.core.network.MoGoRetrofitFactory
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb
import com.mogo.eagle.function.biz.v2x.overview.remote.OverViewServiceApi
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import java.util.concurrent.TimeUnit
object OverViewDataManager {
@@ -26,37 +28,8 @@ object OverViewDataManager {
OverviewDb.getDb(AbsMogoApplication.getApp()).overviewDao()
}
private val _infStructures = MutableLiveData<List<Infrastructure>>()
private val _V2XEvents = MutableLiveData<List<V2XEvent>>()
private var disposable: Disposable? = null
val infStructures
get() = _infStructures
private val _infStructuresMap = _infStructures
.switchMap { infStructures ->
liveData {
val map = HashMap<String, ArrayList<Infrastructure>>()
infStructures.forEach {
val geoHash = it.geoHash
if (geoHash == null) {
return@forEach
} else {
if (!map.containsKey(geoHash)) {
val list = ArrayList<Infrastructure>()
list.add(it)
map[geoHash] = list
} else {
map[geoHash]?.add(it)
}
}
}
emit(map)
}
}
val infStructuresMap
get() = _infStructuresMap
fun fetchInfStructures() {
ProcessLifecycleOwner.get().lifecycleScope.launch {
val data = try {
@@ -67,8 +40,27 @@ object OverViewDataManager {
e.printStackTrace()
null
}
data?.let {
_infStructures.value = it
data?.let { infStructures ->
withContext(Dispatchers.Default) {
val map = HashMap<String, ArrayList<Infrastructure>>()
infStructures.forEach {
val geoHash = it.geoHash
if (geoHash == null) {
return@forEach
} else {
if (!map.containsKey(geoHash)) {
val list = ArrayList<Infrastructure>()
list.add(it)
map[geoHash] = list
} else {
map[geoHash]?.add(it)
}
}
}
withContext(Dispatchers.Main) {
CallerFuncBizListenerManager.invokeInfStructures(map)
}
}
}
}
}
@@ -113,13 +105,11 @@ object OverViewDataManager {
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
it?.apply {
_V2XEvents.value = this
CallerFuncBizListenerManager.invokeV2XEvents(this)
}
}
}
fun getV2XEventLiveData() = _V2XEvents
fun stopQueryV2XEvents() {
disposable?.dispose()
}

View File

@@ -1,4 +1,4 @@
package com.mogo.eagle.core.function.overview.db
package com.mogo.eagle.function.biz.v2x.overview.db
import androidx.room.Dao
import androidx.room.Query

View File

@@ -1,4 +1,4 @@
package com.mogo.eagle.core.function.overview.db
package com.mogo.eagle.function.biz.v2x.overview.db
import android.content.Context
import androidx.room.Database

View File

@@ -1,4 +1,4 @@
package com.mogo.eagle.core.function.overview.remote
package com.mogo.eagle.function.biz.v2x.overview.remote
import io.reactivex.Observable
import retrofit2.http.GET

View File

@@ -0,0 +1,20 @@
package com.mogo.eagle.function.biz.v2x.overview.remote
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import com.mogo.eagle.core.data.BaseData
import com.mogo.eagle.core.data.v2x.V2XEvent
@Keep
data class V2XEventResult (
@SerializedName("result")
var result: Result?
): BaseData()
@Keep
data class Result(
@SerializedName("eventList")
var v2XEventList: List<V2XEvent>?
)

View File

@@ -105,6 +105,7 @@ class MoGoAutopilotControlProvider :
.setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION)
.setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext))
.setClient(false)
.setIdentityMode(FunctionBuildConfig.appIdentityMode)
// .setSubscribeInterfaceOptions(subscribeInterfaceOptions)//
.build()
@@ -195,6 +196,7 @@ class MoGoAutopilotControlProvider :
val options = AdasOptions
.Builder()
.setClient(true)
.setIdentityMode(FunctionBuildConfig.appIdentityMode)
.build()
AdasManager.getInstance()
.create(options, MoGoAdasMsgConnectStatusListenerImpl())
@@ -222,6 +224,7 @@ class MoGoAutopilotControlProvider :
.setIpcConnectionMode(AdasOptions.IPC_CONNECTION_MODE.FIXATION)
.setIpcFixationIP(AdasManager.getInstance().getIPCFixationIPList(mContext))
.setClient(false)// 乘客端直连工控机改为false
.setIdentityMode(FunctionBuildConfig.appIdentityMode)
.build()
AdasManager.getInstance().create(options, MoGoAdasMsgConnectStatusListenerImpl())
//////////////////////////////////注意先后顺序AdasManager.getInstance().create后才可以设置监听/////////////////////////////////////////////

View File

@@ -59,7 +59,6 @@ import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.support.obu.ObuScene
import com.zhidao.support.adas.high.AdasManager
import com.zhidao.support.adas.high.OnAdasListener
import com.zhidao.support.adas.high.bean.AutopilotAbility
import com.zhidao.support.adas.high.bean.AutopilotStatistics
import com.zhidao.support.adas.high.common.ProtocolStatus
import com.zhjt.service.chain.ChainLog
@@ -608,8 +607,8 @@ class MoGoAdasListenerImpl : OnAdasListener {
* 是否可以启动自动驾驶
* 使用方法查看app_ipc_monitoring/uiMainActivity/onAutopilotAbility
*/
override fun onAutopilotAbility(ability: AutopilotAbility?) {
invokeAutopilotAbility(ability)
override fun onAutopilotAbility(isAutopilotAbility: Boolean, unableAutopilotReason: String?) {
invokeAutopilotAbility(isAutopilotAbility, unableAutopilotReason)
}
/**

View File

@@ -538,8 +538,6 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
}
}
private var isRedLight = false
private var isGreenLight = false
private var isShowGreenWave = false
private var isShowRunRedLight = false
@@ -662,11 +660,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
}
// 红灯
2, 3 -> { //todo 小鹏
if (!isRedLight) {
isRedLight = true
}
isGreenLight = false
2, 3 -> {
CallerTrafficLightListenerManager.showTrafficLight(
TrafficLightEnum.RED,
DataSourceType.TELEMATIC
@@ -676,11 +670,7 @@ class MogoObuDcCombineManager private constructor() : IMoGoObuDcCombineListener
}
// 绿灯
4, 5, 6 -> { //todo 小鹏
if (!isGreenLight) {
isGreenLight = true
}
isRedLight = false
4, 5, 6 -> {
CallerTrafficLightListenerManager.showTrafficLight(
TrafficLightEnum.GREEN,
DataSourceType.TELEMATIC

View File

@@ -635,382 +635,322 @@ class MogoPrivateObuNewManager private constructor() {
}
}
}
}
/**
* 获取消息的方位 车辆相关
*/
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
// CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification")
return when (targetClassification) {
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
/**
* 获取消息的方位 车辆相关
*/
private fun getMessageDirection(targetClassification: Int): WarningDirectionEnum {
// CallerLogger.d("$M_OBU${TAG_MOGO_NEW_OBU}", "预警红边:预警方向->$targetClassification")
return when (targetClassification) {
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_IN_LANE,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_TOP //正前方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_IN_LANE -> WarningDirectionEnum.ALERT_WARNING_BOTTOM //正后方
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_RIGHT -> WarningDirectionEnum.ALERT_WARNING_RIGHT //正右方
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方
MogoObuConstants.VEH_TARGET_POSITION.INTERSECTION_LEFT -> WarningDirectionEnum.ALERT_WARNING_LEFT //正左方
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_LEFT,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_LEFT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAR_LEFT
-> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_LEFT,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_LEFT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAR_LEFT
-> WarningDirectionEnum.ALERT_WARNING_TOP_LEFT //左前方
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_RIGHT,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAT_RIGHT
-> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方
MogoObuConstants.VEH_TARGET_POSITION.AHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.AHEAD_FAR_RIGHT,
MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.ONCOMING_FAT_RIGHT
-> WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT //右前方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_LEFT,
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_LEFT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_LEFT,
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT //左后方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_RIGHT,
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方
MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_RIGHT, MogoObuConstants.VEH_TARGET_POSITION.BEHEAD_FAR_RIGHT,
-> WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT //右后方
MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知
else -> WarningDirectionEnum.ALERT_WARNING_ALL
}
}
/**
* 构造对应展示数据和场景 根据obu的场景add change delete确定是否展示
*
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截
*
* @see com.mogo.module.common.enums.EventTypeEnum
*/
private fun handleSdkObu(
appId: String,
direction: WarningDirectionEnum,
status: Int,
level: Int,
info: MogoObuRvWarningData
) {
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的
var alertContent: String = ""
var ttsContent: String = ""
var changeVisualAngle = false
when (appId) {
//交叉路口碰撞预警
MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType)
}
//交叉路口碰撞预警
MogoObuConstants.V2X_WARNING_TYPE.ICW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType)
}
//左转辅助预警
MogoObuConstants.V2X_WARNING_TYPE.LTA.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType)
}
//盲区预警
MogoObuConstants.V2X_WARNING_TYPE.BSW.toString() -> {
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType)
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType)
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) { //左后
changeVisualAngle = true
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) { //右后
changeVisualAngle = true
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
}
}
// 变道预警,注意左后车辆/注意右后车辆
MogoObuConstants.V2X_WARNING_TYPE.LCW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType)
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) {
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) {
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
}
}
//逆向超车预警
MogoObuConstants.V2X_WARNING_TYPE.DNPW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType)
}
//紧急制动预警
MogoObuConstants.V2X_WARNING_TYPE.EBW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType)
}
//异常车辆提醒
MogoObuConstants.V2X_WARNING_TYPE.AVW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType)
alertContent = String.format(alertContent, direction.desc)
ttsContent = String.format(ttsContent, direction.desc)
}
//车辆失控预警
MogoObuConstants.V2X_WARNING_TYPE.CLW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType)
alertContent = String.format(alertContent, direction.desc)
ttsContent = String.format(ttsContent, direction.desc)
}
//车辆失控预警
MogoObuConstants.V2X_WARNING_TYPE.EVW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType)
}
// 这里处理固定的提示信息,包括了<紧急车辆提醒>
else -> { //TODO
// ttsContent = EventTypeEnumNew.getWarningTts(appId.toString())
// alertContent = EventTypeEnumNew.getWarningContent(appId.toString())
MogoObuConstants.VEH_TARGET_POSITION.UNCLASSIFIED -> WarningDirectionEnum.ALERT_WARNING_NON //未知
else -> WarningDirectionEnum.ALERT_WARNING_ALL
}
}
when (status) {
// 添加,更新 add的时候可能级别是2
MogoObuConstants.STATUS.ADD,
MogoObuConstants.STATUS.UPDATE -> {
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"new handleSdkObu appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
)
if (level == 2 || level == 3) {
//不显示弹框,其它保留
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
appId,
alertContent,
ttsContent
)
).apply {
sourceType = DataSourceType.OBU
}
)
CallerHmiManager.warningV2X(
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
object : IMoGoWarningStatusListener {
override fun onShow() {
super.onShow()
if (changeVisualAngle) {
CallerVisualAngleManager.changeVisualAngle(TooClose)
}
}
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
if (changeVisualAngle) {
CallerVisualAngleManager.changeVisualAngle(Default())
}
}
}
)
//显示警告红边
CallerHmiManager.showWarning(direction)
/**
* 构造对应展示数据和场景 根据obu的场景add change delete确定是否展示
*
* @param appId 使用WarningTypeEnum获取icon、提示内容、tts内容 TODO 添加事件频繁播报拦截
*
* @see com.mogo.module.common.enums.EventTypeEnum
*/
private fun handleSdkObu(
appId: String,
direction: WarningDirectionEnum,
status: Int,
level: Int,
info: MogoObuRvWarningData
) {
// 这里排除需要特殊定制的语音及文案外,其余的都可以使用 EventTypeEnumNew 提供的
var alertContent: String = ""
var ttsContent: String = ""
var changeVisualAngle = false
when (appId) {
//交叉路口碰撞预警
MogoObuConstants.V2X_WARNING_TYPE.FCW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_FCW.poiType)
}
//更新周边车辆进行预警颜色变换,车辆实时移动和变色 UUID不需要匹配了
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
CallerMapUIServiceManager.getMarkerService()
?.updateITrafficThreatLevelInfo(it)
//交叉路口碰撞预警
MogoObuConstants.V2X_WARNING_TYPE.ICW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType)
}
//左转辅助预警
MogoObuConstants.V2X_WARNING_TYPE.LTA.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LTA.poiType)
}
//盲区预警
MogoObuConstants.V2X_WARNING_TYPE.BSW.toString() -> {
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType)
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType)
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) { //左后
changeVisualAngle = true
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) { //右后
changeVisualAngle = true
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
}
}
// 变道预警,注意左后车辆/注意右后车辆
MogoObuConstants.V2X_WARNING_TYPE.LCW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_LCW.poiType)
if (
direction == WarningDirectionEnum.ALERT_WARNING_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_LEFT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_LEFT
) {
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
} else if (
direction == WarningDirectionEnum.ALERT_WARNING_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_TOP_RIGHT ||
direction == WarningDirectionEnum.ALERT_WARNING_BOTTOM_RIGHT
) {
ttsContent = String.format(ttsContent, "")
alertContent = String.format(alertContent, "")
}
}
//逆向超车预警
MogoObuConstants.V2X_WARNING_TYPE.DNPW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType)
}
//紧急制动预警
MogoObuConstants.V2X_WARNING_TYPE.EBW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EBW.poiType)
}
//异常车辆提醒
MogoObuConstants.V2X_WARNING_TYPE.AVW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_AVW.poiType)
alertContent = String.format(alertContent, direction.desc)
ttsContent = String.format(ttsContent, direction.desc)
}
//车辆失控预警
MogoObuConstants.V2X_WARNING_TYPE.CLW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_CLW.poiType)
alertContent = String.format(alertContent, direction.desc)
ttsContent = String.format(ttsContent, direction.desc)
}
//车辆失控预警
MogoObuConstants.V2X_WARNING_TYPE.EVW.toString() -> {
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_EVW.poiType)
}
// 这里处理固定的提示信息,包括了<紧急车辆提醒>
else -> { //TODO
// ttsContent = EventTypeEnumNew.getWarningTts(appId.toString())
// alertContent = EventTypeEnumNew.getWarningContent(appId.toString())
}
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
// CallerHmiManager.disableWarningV2X((appId + direction.direction))
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
it.threatLevel = 0x01
CallerMapUIServiceManager.getMarkerService()
?.updateITrafficThreatLevelInfo(it)
}
}
}
}
/**
* 处理红绿灯
*/
private fun handlerTrafficLight(appId: Int, status: Int, lights: List<SpatLight>) {
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights ---appId = $appId"
)
when (status) {
// 添加
MogoObuConstants.STATUS.ADD,
MogoObuConstants.STATUS.UPDATE
-> {
if (lights != null && lights.isNotEmpty()) {
changeTrafficLightStatus(appId, lights)
}
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 移除顶部弹窗
CallerTrafficLightListenerManager.disableTrafficLight()
isShowGreenWave = false
isShowRunRedLight = false
isYellowLight = false
// lightCountDownRed = 1
// lightCountDownGreen = 1
// lightCountDownYellow = 1
}
}
}
private var isRedLight = false
private var isGreenLight = false
private var isYellowLight = false
private var isShowGreenWave = false
private var isShowRunRedLight = false
// private var lightCountDownRed : Int = 1
// private var lightCountDownGreen : Int = 1
// private var lightCountDownYellow : Int = 1
/**
* 修改红绿灯
*/
@Synchronized
private fun changeTrafficLightStatus(
appId: Int,
lights: List<SpatLight>
) {
var ttsContent = ""
var alertContent = ""
//这里需要根据真实数据确定 index 取值方式
val currentLight = lights[0]
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"changeTrafficLightStatus currentLight = $currentLight ----currentLight.light = ${currentLight.light} ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId --countDown = ${currentLight.countDown.toInt()}"
)
// 闯红灯预警,绿波通行和闯红灯是互斥的
when (appId) {
0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE 无效
}
1 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次
if (!isShowRunRedLight) {
isShowRunRedLight = true
when (status) {
// 添加,更新 add的时候可能级别是2
MogoObuConstants.STATUS.ADD,
MogoObuConstants.STATUS.UPDATE -> {
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"changeTrafficLightStatus 闯红灯 --------> "
"new handleSdkObu appId2 = $appId --- level = $level ---ttsContent = $ttsContent --- alertContent = $alertContent --- direction = $direction"
)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
alertContent,
ttsContent
)
).apply {
sourceType = DataSourceType.OBU
}
)
CallerHmiManager.warningV2X(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
alertContent,
ttsContent// 只有第一次才tts防止更新的时候不断的提醒
)
}
}
2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次 100m的时候
if (!isShowGreenWave) {
isShowGreenWave = true
var minSpeedTemp = Math.round(currentLight.suggestMinSpeed * 3.6)
var maxSpeedTemp = Math.round(currentLight.suggestMaxSpeed * 3.6)
if (minSpeedTemp == maxSpeedTemp) {
minSpeedTemp -= 5
}
val adviceSpeed = "$minSpeedTemp - $maxSpeedTemp"
val adviceSpeedTts = "$minSpeedTemp$maxSpeedTemp"
// val adviceSpeed =
// "${Math.round(currentLight.suggestMinSpeed*3.6)} - ${Math.round(currentLight.suggestMaxSpeed*3.6)}"
// val adviceSpeedTts =
// "${Math.round(currentLight.suggestMinSpeed*3.6)} 到 ${Math.round(currentLight.suggestMaxSpeed*3.6)}"
ttsContent =
String.format(
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
adviceSpeedTts
)
alertContent =
String.format(
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
adviceSpeed
)
val maxSpeed = currentLight.suggestMaxSpeed
if (maxSpeed > 0) {
if (level == 2 || level == 3) {
//不显示弹框,其它保留
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
appId,
alertContent,
ttsContent
)
).apply {
sourceType = DataSourceType.OBU
}
)
CallerHmiManager.warningV2X(
appId,
alertContent,
ttsContent,// 只有第一次才tts防止更新的时候不断的提醒
object : IMoGoWarningStatusListener {
override fun onShow() {
super.onShow()
if (changeVisualAngle) {
CallerVisualAngleManager.changeVisualAngle(TooClose)
}
}
override fun onDismiss() {
// 关闭警告红边
CallerHmiManager.dismissWarning(WarningDirectionEnum.ALERT_WARNING_ALL)
if (changeVisualAngle) {
CallerVisualAngleManager.changeVisualAngle(Default())
}
}
}
)
//显示警告红边
CallerHmiManager.showWarning(direction)
}
//更新周边车辆进行预警颜色变换,车辆实时移动和变色 UUID不需要匹配了
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
CallerMapUIServiceManager.getMarkerService()
?.updateITrafficThreatLevelInfo(it)
}
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 关闭警告红边
CallerHmiManager.showWarning(WarningDirectionEnum.ALERT_WARNING_NON)
// 移除顶部弹窗
// CallerHmiManager.disableWarningV2X((appId + direction.direction))
//更新周边车辆进行预警颜色变换,车辆实时移动和变色
TrafficDataConvertUtilsNew.cvxV2vThreatIndInfo2TrafficData(info)?.let {
it.threatLevel = 0x01
CallerMapUIServiceManager.getMarkerService()
?.updateITrafficThreatLevelInfo(it)
}
}
}
}
/**
* 处理红绿灯
*/
private fun handlerTrafficLight(appId: Int, status: Int, lights: List<SpatLight>) {
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"handlerTrafficLight --- status = $status ---lights.size = ${lights.size} ---lights = $lights ---appId = $appId"
)
when (status) {
// 添加
MogoObuConstants.STATUS.ADD,
MogoObuConstants.STATUS.UPDATE
-> {
if (lights != null && lights.isNotEmpty()) {
changeTrafficLightStatus(appId, lights)
}
}
// 删除
MogoObuConstants.STATUS.DELETE -> {
// 移除顶部弹窗
CallerTrafficLightListenerManager.disableTrafficLight()
isShowGreenWave = false
isShowRunRedLight = false
}
}
}
private var isYellowLight = false
private var isShowGreenWave = false
private var isShowRunRedLight = false
/**
* 修改红绿灯
*/
@Synchronized
private fun changeTrafficLightStatus(
appId: Int,
lights: List<SpatLight>
) {
var ttsContent = ""
var alertContent = ""
//这里需要根据真实数据确定 index 取值方式
val currentLight = lights[0]
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"changeTrafficLightStatus currentLight = $currentLight ----currentLight.light = ${currentLight.light} ---currentLight.phase = ${currentLight.phaseId} ---appId = $appId --countDown = ${currentLight.countDown.toInt()}"
)
// 闯红灯预警,绿波通行和闯红灯是互斥的
when (appId) {
0 -> {//不可用 V2I_RLVW_VIOLATION_TYPE_UNAVAILABLE 无效
}
1 -> {//闯红灯 V2I_RLVW_VIOLATION_TYPE_RUNNING_RED_LIGHT 一个红灯周期只显示一次
if (!isShowRunRedLight) {
isShowRunRedLight = true
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"changeTrafficLightStatus 闯红灯 --------> "
)
ttsContent =
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
alertContent =
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType)
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
alertContent,
ttsContent
)
@@ -1020,51 +960,80 @@ private fun changeTrafficLightStatus(
)
CallerHmiManager.warningV2X(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType,
alertContent,
ttsContent// 只有第一次才tts防止更新的时候不断的提醒
)
}
}
2 -> { //绿波通行引导 V2I_RLVW_VIOLATION_TYPE_NO_VIOLATION 一个绿灯周期只显示一次 100m的时候
if (!isShowGreenWave) {
isShowGreenWave = true
var minSpeedTemp = Math.round(currentLight.suggestMinSpeed * 3.6)
var maxSpeedTemp = Math.round(currentLight.suggestMaxSpeed * 3.6)
if (minSpeedTemp == maxSpeedTemp) {
minSpeedTemp -= 5
}
val adviceSpeed = "$minSpeedTemp - $maxSpeedTemp"
val adviceSpeedTts = "$minSpeedTemp$maxSpeedTemp"
ttsContent =
String.format(
EventTypeEnumNew.getWarningTts(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
adviceSpeedTts
)
alertContent =
String.format(
EventTypeEnumNew.getWarningContent(EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType),
adviceSpeed
)
val maxSpeed = currentLight.suggestMaxSpeed
if (maxSpeed > 0) {
CallerMsgBoxManager.saveMsgBox(
MsgBoxBean(
MsgBoxType.V2X,
V2XMsg(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
alertContent,
ttsContent
)
).apply {
sourceType = DataSourceType.OBU
}
)
CallerHmiManager.warningV2X(
EventTypeEnumNew.TYPE_USECASE_ID_IVP_GREEN.poiType,
alertContent,
ttsContent// 只有第一次才tts防止更新的时候不断的提醒
)
}
}
}
}
when (currentLight.light) {
// 灯光不可用
0 -> {
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.BLACK)
}
// 红灯
2, 3 -> {
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.RED)
}
// 绿灯
4, 5, 6 -> {
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.GREEN)
}
// 黄灯
7, 8 -> {
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.YELLOW)
}
}
}
when (currentLight.light) {
// 灯光不可用
0 -> {
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.BLACK)
}
// 红灯
2, 3 -> {
if (!isRedLight) { //todo 小鹏
isRedLight = true
}
isGreenLight = false
isYellowLight = false
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.RED)
val red = currentLight.countDown.toInt()
}
// 绿灯
4, 5, 6 -> { //todo 小鹏
if (!isGreenLight) {
isGreenLight = true
}
isRedLight = false
isYellowLight = false
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.GREEN)
val green = currentLight.countDown.toInt()
}
// 黄灯
7, 8 -> {
if (!isYellowLight) {
isYellowLight = true
}
isRedLight = false
isGreenLight = false
CallerTrafficLightListenerManager.invokeObuTrafficLightStatus(TrafficLightEnum.YELLOW)
val yellow = currentLight.countDown.toInt()
}
}
}

View File

@@ -343,34 +343,34 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
}
override fun showSmallFragment() {
// 加载全览模式图层
val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
.navigation() as BaseFragment
activity?.supportFragmentManager?.beginTransaction()
?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply {
if (!fragmentOverview.isAdded) {
add(
R.id.module_main_id_smp_fragment,
fragmentOverview,
fragmentOverview.tagName
)
} else {
show(fragmentOverview)
}.commitAllowingStateLoss()
}
CallerDevaToolsManager.hideStatusBar()
// // 加载全览模式图层
// val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
// .navigation() as BaseFragment
// activity?.supportFragmentManager?.beginTransaction()
// ?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply {
// if (!fragmentOverview.isAdded) {
// add(
// R.id.module_main_id_smp_fragment,
// fragmentOverview,
// fragmentOverview.tagName
// )
// } else {
// show(fragmentOverview)
// }.commitAllowingStateLoss()
// }
// CallerDevaToolsManager.hideStatusBar()
}
override fun hideSmallFragment() {
val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
.navigation() as BaseFragment
activity?.supportFragmentManager?.beginTransaction()
?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply {
if (fragmentOverview.isVisible) {
hide(fragmentOverview)
}
}
?.commitAllowingStateLoss()
// val fragmentOverview = ARouter.getInstance().build(MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
// .navigation() as BaseFragment
// activity?.supportFragmentManager?.beginTransaction()
// ?.setCustomAnimations(R.anim.slide_in, R.anim.fade_out)?.apply {
// if (fragmentOverview.isVisible) {
// hide(fragmentOverview)
// }
// }
// ?.commitAllowingStateLoss()
}
}

View File

@@ -22,12 +22,12 @@ import com.mogo.eagle.core.data.constants.MoGoConfig;
import com.mogo.eagle.core.data.constants.MogoServicePaths;
import com.mogo.eagle.core.function.api.chat.biz.ChatConsts;
import com.mogo.eagle.core.function.api.devatools.IMogoDevaToolsUpgradeListener;
import com.mogo.eagle.core.function.call.biz.CallerFuncBizManager;
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager;
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsUpgradeListenerManager;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager;
import com.mogo.eagle.core.function.msgbox.db.MsgBoxDb;
import com.mogo.eagle.core.function.overview.db.OverviewDb;
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
import com.mogo.eagle.core.utilcode.mogo.AppLaunchTimeUtils;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
@@ -194,7 +194,7 @@ public abstract class MainMoGoApplication extends AbsMogoApplication {
}
private void initOverviewDb() {
OverviewDb.Companion.getDb(this);
CallerFuncBizManager.getBizProvider().initOverViewDb(this);
}
/**

View File

@@ -11,7 +11,6 @@ import com.mogo.eagle.core.data.map.CenterLine
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener
import com.mogo.eagle.core.function.business.MapPointCloudSubscriber
@@ -20,20 +19,11 @@ import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber
import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
import com.mogo.eagle.core.function.call.map.CallerHDMapManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
import com.mogo.eagle.core.function.overview.InfStructureManager
import com.mogo.eagle.core.function.overview.InfStructureManager.savePlanningData
import com.mogo.eagle.core.function.overview.obtainViewModel
import com.mogo.eagle.core.function.overview.vm.OverViewModel
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.Utils
import com.mogo.map.IMogoMap
import com.mogo.map.MogoMapView
import com.mogo.map.uicontroller.IMogoMapUIController

View File

@@ -1,51 +0,0 @@
package com.mogo.eagle.core.function.overview
import com.mogo.eagle.core.data.map.Infrastructure
import mogo.telematics.pad.MessagePad
/**
* 本地数据库查询出来的红绿灯、摄像头等数据
*/
object InfStructureManager {
// 每个GeoHash网格对应的新基建Bean
private val _infMap by lazy {
HashMap<String, ArrayList<Infrastructure>>()
}
// 全局路径规划中所有点的GeoHash网格对应的新基建数据集合
private val _pathMap by lazy {
HashMap<String, ArrayList<Infrastructure>>()
}
private val _planningList by lazy {
ArrayList<MessagePad.Location>()
}
fun saveData(map: HashMap<String, java.util.ArrayList<Infrastructure>>) {
if (_infMap.isNotEmpty()) {
_infMap.clear()
}
_infMap.putAll(map)
}
fun getData(): Map<String, ArrayList<Infrastructure>> = _infMap
fun savePathData(map: HashMap<String, java.util.ArrayList<Infrastructure>>) {
if (_pathMap.isNotEmpty()) {
_pathMap.clear()
}
_pathMap.putAll(map)
}
fun getPathData(): Map<String, ArrayList<Infrastructure>> = _pathMap
fun savePlanningData(planningList: List<MessagePad.Location>) {
if (_planningList.isNotEmpty()) {
_planningList.clear()
}
_planningList.addAll(planningList)
}
fun getPlanningData() = _planningList
}

View File

@@ -1,13 +0,0 @@
package com.mogo.eagle.core.function.overview
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProviders
import com.mogo.commons.AbsMogoApplication
fun <T : ViewModel> AppCompatActivity.obtainViewModel(viewModelClass: Class<T>) =
ViewModelProviders.of(this, ViewModelFactory.getInstance(application)).get(viewModelClass)
fun <T : ViewModel> Fragment.obtainViewModel(viewModelClass: Class<T>) =
ViewModelProviders.of(this, ViewModelFactory.getInstance(AbsMogoApplication.getApp())).get(viewModelClass)

View File

@@ -1,41 +0,0 @@
package com.mogo.eagle.core.function.overview
import android.annotation.SuppressLint
import android.app.Application
import androidx.annotation.VisibleForTesting
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelProvider
import com.mogo.eagle.core.function.overview.db.OverviewDao
import com.mogo.eagle.core.function.overview.db.OverviewDb
import com.mogo.eagle.core.function.overview.vm.OverViewModel
class ViewModelFactory private constructor(
private val overviewDao: OverviewDao
) : ViewModelProvider.NewInstanceFactory() {
override fun <T : ViewModel> create(modelClass: Class<T>) =
with(modelClass) {
when {
isAssignableFrom(OverViewModel::class.java) ->
OverViewModel(overviewDao)
else ->
throw IllegalArgumentException("Unknown ViewModel class: ${modelClass.name}")
}
} as T
companion object {
@SuppressLint("StaticFieldLeak")
@Volatile private var INSTANCE: ViewModelFactory? = null
fun getInstance(application: Application) =
INSTANCE ?: synchronized(ViewModelFactory::class.java) {
INSTANCE ?: ViewModelFactory(
OverviewDb.getDb(application).overviewDao())
.also { INSTANCE = it }
}
@VisibleForTesting fun destroyInstance() {
INSTANCE = null
}
}
}

View File

@@ -1,73 +0,0 @@
package com.mogo.eagle.core.function.overview.remote
import androidx.annotation.Keep
import com.google.gson.annotations.SerializedName
import com.mogo.eagle.core.data.BaseData
@Keep
data class V2XEventResult (
@SerializedName("result")
var result: Result?
): BaseData()
@Keep
data class Result(
@SerializedName("eventList")
var v2XEventList: List<V2XEvent>?
)
@Keep
data class V2XEvent(
@SerializedName("receiveTime")
var receiveTime: Long,
@SerializedName("detectTime")
var detectTime: Long,
@SerializedName("id")
var id: String?,
@SerializedName("center")
var center: Center?,
@SerializedName("centerRoad")
var centerRoad: CenterRoad?,
@SerializedName("radius")
var radius: Double,
@SerializedName("poiType")
var poiType: String?,
@SerializedName("coordinateType")
var coordinateType:Int? = null
)
@Keep
data class Center(
@SerializedName("lat")
var lat: Double,
@SerializedName("lon")
var lon: Double
)
@Keep
data class CenterRoad(
@SerializedName("bearing")
var bearing: Double,
@SerializedName("laneNo")
var laneNo: Long,
@SerializedName("roadId")
var roadId: String?,
@SerializedName("roadName")
var roadName: String?,
@SerializedName("tileId")
var tileId: Long
)

View File

@@ -20,17 +20,16 @@ import com.mogo.cloud.passport.MoGoAiCloudClientConfig
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.Infrastructure
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.data.v2x.V2XEvent
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
import com.mogo.eagle.core.function.api.v2x.IFuncBizProvider
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.getGlobalPath
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
import com.mogo.eagle.core.function.call.biz.CallerFuncBizListenerManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showVideoDialog
import com.mogo.eagle.core.function.map.R
import com.mogo.eagle.core.function.overview.InfStructureManager
import com.mogo.eagle.core.function.overview.InfStructureManager.getData
import com.mogo.eagle.core.function.overview.OverViewDataManager
import com.mogo.eagle.core.function.overview.remote.V2XEvent
import com.mogo.eagle.core.function.smp.MakerWithCount
import com.mogo.eagle.core.function.smp.MarkerDrawerManager
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.callback
@@ -40,7 +39,6 @@ import com.mogo.eagle.core.function.smp.MarkerDrawerManager.planningPoints
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.startLoopCalCarLocation
import com.mogo.eagle.core.function.smp.MarkerDrawerManager.updateRoutePoints
import com.mogo.eagle.core.function.smp.V2XMarkerView
import com.mogo.eagle.core.utilcode.kotlin.lifecycleOwner
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils.isTaxi
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
@@ -69,6 +67,8 @@ class OverMapView @JvmOverloads constructor(
private val pathMap: MutableMap<String?, ArrayList<Infrastructure>?> = HashMap()
private val posInfMap: MutableMap<LatLng?, ArrayList<Infrastructure>?> = HashMap()
private var geoHashInfMap: HashMap<String, java.util.ArrayList<Infrastructure>>? = null
// =============绘制轨迹线相关=============
private var mCarMarker: Marker? = null
private var mCompassMarker: Marker? = null
@@ -189,18 +189,17 @@ class OverMapView @JvmOverloads constructor(
override fun onAttachedToWindow() {
super.onAttachedToWindow()
OverViewDataManager.infStructuresMap.observe(lifecycleOwner) { list ->
InfStructureManager.saveData(list)
}
// 查询本地数据库中的摄像头数据
OverViewDataManager.fetchInfStructures()
CallerFuncBizListenerManager.addListener(TAG, object : IFuncBizProvider {
override fun onInfStructures(map: HashMap<String, ArrayList<Infrastructure>>?) {
geoHashInfMap = map
}
override fun onV2XEvents(v2xEvents: List<V2XEvent>?) {
showV2XEventMarkers(v2xEvents)
}
})
// 主动查一次全局路径规划的数据
getGlobalPath()
// 定时查询V2X事件
OverViewDataManager.getV2XEventLiveData().observe(lifecycleOwner) {
showV2XEventMarkers(it)
}
OverViewDataManager.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().sn)
}
private fun setUpMap() {
@@ -297,32 +296,45 @@ class OverMapView @JvmOverloads constructor(
}
}
startLoopCalCarLocation()
UiThreadHandler.post { drawInfrastructureMarkers(locationList) }
UiThreadHandler.post {
if (geoHashInfMap.isNullOrEmpty()) {
UiThreadHandler.postDelayed({
drawInfrastructureMarkers(locationList)
}, 1000)
} else {
drawInfrastructureMarkers(locationList)
}
}
}
/**
* 显示V2X事件的Marker
*/
fun showV2XEventMarkers(v2XEvents: List<V2XEvent>?) {
private fun showV2XEventMarkers(v2XEvents: List<V2XEvent>?) {
if (v2XEvents == null || v2XEvents.isEmpty()) return
clearV2XMarkers()
val markerOptionsList = ArrayList<MarkerOptions>()
for ((_, _, _, center, _, _, poiType, coordinateType) in v2XEvents) {
for (v2xEvent in v2XEvents) {
val center = v2xEvent.center
if (center != null) {
center.lon
val markerOption = MarkerOptions()
var latLng: LatLng = if (coordinateType == null || coordinateType == 0) {
LatLng(center.lat, center.lon)
} else {
// wgs84坐标系需转成高德坐标系
coordinateConverterWgsToGcj(mContext!!, center.lat, center.lon)
}
var latLng: LatLng =
if (v2xEvent.coordinateType == null || v2xEvent.coordinateType == 0) {
LatLng(center.lat, center.lon)
} else {
// wgs84坐标系需转成高德坐标系
coordinateConverterWgsToGcj(
mContext!!,
center.lat,
center.lon
)
}
markerOption.position(latLng)
markerOption.anchor(0.13f, 1f)
markerOption.icon(
BitmapDescriptorFactory.fromBitmap(
getV2XBitmap(
poiType
v2xEvent.poiType
)
)
)
@@ -364,7 +376,6 @@ class OverMapView @JvmOverloads constructor(
// 注册定位监听
CallerChassisLocationGCJ20ListenerManager.removeListener(TAG)
CallerPlanningRottingListenerManager.removeListener(TAG)
OverViewDataManager.stopQueryV2XEvents()
}
override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {
@@ -386,7 +397,8 @@ class OverMapView @JvmOverloads constructor(
* @param locationList
*/
private fun drawInfrastructureMarkers(locationList: List<MessagePad.Location>?) {
if (locationList == null) return
val infMap = geoHashInfMap
if (locationList == null || infMap.isNullOrEmpty()) return
if (pathMap.isNotEmpty()) {
pathMap.clear()
}
@@ -399,7 +411,7 @@ class OverMapView @JvmOverloads constructor(
// 网格内的轨迹点只取一次s
if (!pathMap.containsKey(geoHash)) {
// 从缓存的新基建数据中去取对应geoHash的新基建数据集合
infList = getData()[geoHash]
infList = infMap[geoHash]
if (infList != null) {
pathMap[geoHash] = infList
}

View File

@@ -1,141 +0,0 @@
package com.mogo.eagle.core.function.overview.vm
import androidx.lifecycle.*
import com.mogo.commons.constants.HostConst
import com.mogo.eagle.core.data.map.Infrastructure
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager.getAutoPilotStatusInfo
import com.mogo.eagle.core.function.overview.db.OverviewDao
import com.mogo.eagle.core.function.overview.remote.OverViewServiceApi
import com.mogo.eagle.core.function.overview.remote.V2XEvent
import com.mogo.eagle.core.network.MoGoRetrofitFactory
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.Disposable
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.launch
import java.util.concurrent.TimeUnit
class OverViewModel(
private val overviewDao: OverviewDao
) : ViewModel() {
private val _infStructures = MutableLiveData<List<Infrastructure>>()
private val _V2XEvents = MutableLiveData<List<V2XEvent>>()
private var disposable: Disposable? = null
companion object {
const val TAG = "OverViewModel"
}
val infStructures
get() = _infStructures
private val _infStructuresMap = _infStructures
.switchMap { infStructures ->
liveData {
val map = HashMap<String, ArrayList<Infrastructure>>()
infStructures.forEach {
val geoHash = it.geoHash
if (geoHash == null) {
return@forEach
} else {
if (!map.containsKey(geoHash)) {
val list = ArrayList<Infrastructure>()
list.add(it)
map[geoHash] = list
} else {
map[geoHash]?.add(it)
}
}
}
emit(map)
}
}
val infStructuresMap
get() = _infStructuresMap
fun fetchInfStructures() {
viewModelScope.launch {
val data = try {
// 只查找摄像头
overviewDao.listInfStructures(0)
// overviewDao.listAllInfStructures()
} catch (e: Exception) {
e.printStackTrace()
null
}
data?.let {
_infStructures.value = it
}
}
}
fun updateGeoHash(id: Int, geoHash: String) {
viewModelScope.launch {
try {
overviewDao.updateGeoHash(id, geoHash)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
fun getAllV2XEventsByLineId(sn: String) {
if (disposable != null && !disposable!!.isDisposed) {
disposable!!.dispose()
}
// 1分钟查询一次
disposable = Observable.interval(2000, 60000, TimeUnit.MILLISECONDS)
.flatMap {
val lineId = getLineId()
if (lineId > 0) {
MoGoRetrofitFactory.getInstance(HostConst.getHost())
.create(OverViewServiceApi::class.java)
.queryAllV2XEventsByLineId(lineId.toString(), sn)
.map {
if (it.code == 200 || it.code == 0) {
CallerLogger.d(SceneConstant.M_MAP + TAG, "请求成功size为${it.result?.v2XEventList?.size}")
return@map it.result?.v2XEventList
} else {
CallerLogger.d(SceneConstant.M_MAP + TAG, "请求失败code为${it.code}")
return@map ArrayList()
}
}
} else {
Observable.just(ArrayList())
}
}
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe {
it?.apply {
_V2XEvents.value = this
}
}
}
fun getV2XEventLiveData() = _V2XEvents
fun stopQueryV2XEvents() {
disposable?.dispose()
}
private fun getLineId(): Long {
var lineId: Long = -1
val parameter = getAutoPilotStatusInfo()
.autopilotControlParameters
if (parameter != null) {
if (parameter.autoPilotLine != null) {
lineId = parameter.autoPilotLine!!.lineId
CallerLogger.d(SceneConstant.M_MAP + TAG, "lineId为:$lineId")
} else {
CallerLogger.d(SceneConstant.M_MAP + TAG, "parameter.autoPilotLine为null")
}
} else {
CallerLogger.d(SceneConstant.M_MAP + TAG, "parameter为null")
}
return lineId
}
}

View File

@@ -1,550 +0,0 @@
package com.mogo.eagle.core.function.smp;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.os.Bundle;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.Nullable;
import com.amap.api.maps.AMap;
import com.amap.api.maps.CameraUpdate;
import com.amap.api.maps.CameraUpdateFactory;
import com.amap.api.maps.TextureMapView;
import com.amap.api.maps.UiSettings;
import com.amap.api.maps.model.BitmapDescriptor;
import com.amap.api.maps.model.BitmapDescriptorFactory;
import com.amap.api.maps.model.CameraPosition;
import com.amap.api.maps.model.CustomMapStyleOptions;
import com.amap.api.maps.model.LatLng;
import com.amap.api.maps.model.LatLngBounds;
import com.amap.api.maps.model.Marker;
import com.amap.api.maps.model.MarkerOptions;
import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.map.Infrastructure;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.function.map.R;
import com.mogo.eagle.core.function.overview.InfStructureManager;
import com.mogo.eagle.core.function.overview.remote.Center;
import com.mogo.eagle.core.function.overview.remote.V2XEvent;
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import ch.hsr.geohash.GeoHash;
import kotlin.Pair;
import me.jessyan.autosize.utils.AutoSizeUtils;
import mogo.telematics.pad.MessagePad;
/**
* 小地图的方向View
* 监听自动驾驶路径结束,结束高德地图导航
*
* @author donghongyu
* @date 12/14/20 4:40 PM
*/
public class AMapCustomView
extends RelativeLayout
implements IMoGoChassisLocationGCJ02Listener {
public static final String TAG = "AMapCustomView";
private TextureMapView mAMapView;
private AMap mAMap;
private int zoomLevel = 15;
private CameraUpdate mCameraUpdate;
private Context mContext;
private float mTilt = 60f;
private TextView overLayerView;
private boolean calculate = false;
// 全局路径规划中的GeoHash网格
private Map<String, ArrayList<Infrastructure>> pathMap = new HashMap();
private Map<LatLng, ArrayList<Infrastructure>> posInfMap = new HashMap();
// =============绘制轨迹线相关=============
private Marker mCarMarker;
private Marker mCompassMarker;
private Marker mStartMarker;
private Marker mEndMarker;
private Polyline mBottomPolyline;
private Polyline mCoveredPolyline;
// 计算索引并设置对应的Bitmap
BitmapDescriptor arrivedBitmap;
BitmapDescriptor unArrivedBitmap;
// 绘制轨迹线的集合
private List<BitmapDescriptor> textureList = new ArrayList<>();
private List<Integer> texIndexList = new ArrayList<>();
private MogoLocation mLocation;
private boolean isFirstLocation = true;
CustomMapStyleOptions mCustomMapStyleOptions;
ArrayList<Marker> currMarkerList;
public AMapCustomView(Context context) {
this(context, null);
}
public AMapCustomView(Context context, @Nullable AttributeSet attrs) {
this(context, attrs, 0);
}
public AMapCustomView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
try {
initView(context);
} catch (Exception e) {
e.printStackTrace();
}
}
private void initView(Context context) {
mContext = context;
View smpView = LayoutInflater.from(context).inflate(R.layout.module_overview_map_view, this);
mAMapView = smpView.findViewById(R.id.aMapView);
overLayerView = findViewById(R.id.overLayer);
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
overLayerView.setBackground(getResources().getDrawable(R.drawable.amap_reset));
arrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_arrived);
unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.taxi_map_arrow_un_arrive);
} else {
overLayerView.setBackground(getResources().getDrawable(R.drawable.amap_reset_bus));
arrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.arrow_arrived_img);
unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_smooth_route);
}
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener);
initAMapView(context);
// 注册定位监听
CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this);
//设置全览模式
overLayerView.setOnClickListener(v -> {
displayCustomOverView();
});
}
private void initAMapView(Context context) {
Log.d(TAG, "initAMapView");
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel);
mAMap = mAMapView.getMap();
mCustomMapStyleOptions = new CustomMapStyleOptions();
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
mCustomMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style.data"));
mCustomMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra.data"));
} else {
mCustomMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style_bus.data"));
mCustomMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra_bus.data"));
}
mAMap.setOnMapLoadedListener(() -> {
Log.d(TAG, "---onMapLoaded---");
if (mCustomMapStyleOptions != null) {
// 加载自定义样式
mCustomMapStyleOptions.setEnable(true);
// 设置自定义样式
mAMap.setCustomMapStyle(mCustomMapStyleOptions);
}
// 实时路况图层关闭必须添加在loaded结束之后,其他位置不生效
mAMap.setTrafficEnabled(false);
});
setUpMap();
customOptions();
}
private void setUpMap() {
// 地图文字标注
mAMap.showMapText(true);
//设置希望展示的地图缩放级别
mAMap.moveCamera(mCameraUpdate);
//设置地图的样式
UiSettings uiSettings = mAMap.getUiSettings();
//地图缩放级别的交换按钮
uiSettings.setZoomControlsEnabled(false);
//所有手势
uiSettings.setAllGesturesEnabled(true);
//隐藏指南针
uiSettings.setCompassEnabled(false);
//设置倾斜手势是否可用。
uiSettings.setTiltGesturesEnabled(true);
//隐藏默认的定位按钮
uiSettings.setMyLocationButtonEnabled(false);
//设置Logo下边界距离屏幕底部的边距,设置为负值即可
uiSettings.setLogoBottomMargin(-150);
Log.d(TAG, "before onMapLoaded");
}
/**
* 自定义导航View和路况状态
*/
private void customOptions() {
if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon))
.anchor(0.5f, 0.5f));
mCompassMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.amap_custom_corner))
.anchor(0.5f, 0.5f));
} else {
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon))
.anchor(0.5f, 0.5f));
mCompassMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_corner))
.anchor(0.5f, 0.5f));
}
mStartMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start)));
mEndMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end)));
}
private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() {
/**
* 根据全路径获取起始点和经停点进行导航路线绘制
* 自动驾驶启动后获得数据,获取全路径的具体时间要进行路测
* 室内某个bag包自动驾驶启动8s后返回
*/
@Override
public void onAutopilotRotting(@org.jetbrains.annotations.Nullable MessagePad.GlobalPathResp globalPathResp) {
Log.d(TAG, "onAutopilotRotting");
if (globalPathResp != null) {
handlePlanningData(globalPathResp.getWayPointsList());
}
}
};
public void handlePlanningData(List<MessagePad.Location> locationList) {
if (locationList == null || locationList.size() == 0) return;
List list = locationList;
// 转成高德坐标系并存储
MarkerDrawerManager.INSTANCE.updateRoutePoints(list, mContext);
List<LatLng> planningPointList = MarkerDrawerManager.INSTANCE.getPlanningPoints();
UiThreadHandler.post(() -> {
displayCustomOverView();
drawStartAndEndMarker(planningPointList);
});
MarkerDrawerManager.INSTANCE.setCallback((points, locIndex) -> {
// 每1s刷新一下轨迹线
UiThreadHandler.post(() -> {
if (points.size() > 0) {
drawPolyline(points, locIndex);
}
});
});
MarkerDrawerManager.INSTANCE.startLoopCalCarLocation();
UiThreadHandler.post(() -> {
drawInfrastructureMarkers(locationList);
});
}
public void showV2XEventMarkers(List<V2XEvent> v2XEvents) {
if (v2XEvents == null || v2XEvents.size() <= 0) return;
clearV2XMarkers();
ArrayList<MarkerOptions> markerOptionsList = new ArrayList<>();
for (V2XEvent event : v2XEvents) {
Center center = event.getCenter();
if (center != null) {
center.getLon();
MarkerOptions markerOption = new MarkerOptions();
LatLng latLng;
if (event.getCoordinateType() == null || event.getCoordinateType() == 0) {
latLng = new LatLng(center.getLat(), center.getLon());
} else {
// wgs84坐标系需转成高德坐标系
latLng = MarkerDrawerManager.INSTANCE.coordinateConverterWgsToGcj(mContext, center.getLat(), center.getLon());
}
markerOption.position(latLng);
markerOption.anchor(0.13f, 1f);
markerOption.icon(BitmapDescriptorFactory.fromBitmap(getV2XBitmap(event.getPoiType())));
markerOptionsList.add(markerOption);
}
}
if (markerOptionsList.size() > 0) {
drawV2XMarkers(markerOptionsList);
}
}
public void drawV2XMarkers(ArrayList<MarkerOptions> markerOptionsList) {
currMarkerList = mAMap.addMarkers(markerOptionsList, false);
}
private Bitmap getV2XBitmap(String poiType) {
V2XMarkerView marker = new V2XMarkerView(getContext(), null, 0, poiType);
marker.measure(View.MeasureSpec.makeMeasureSpec(AutoSizeUtils.dp2px(mContext, 229), View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(AutoSizeUtils.dp2px(mContext, 96), View.MeasureSpec.EXACTLY));
marker.layout(0, 0, marker.getMeasuredWidth(), marker.getMeasuredHeight());
Bitmap bitmap = Bitmap.createBitmap(marker.getWidth(), marker.getHeight(), Bitmap.Config.ARGB_8888);
marker.draw(new Canvas(bitmap));
return bitmap;
}
public void clearV2XMarkers() {
if (currMarkerList != null) {
for (Marker marker : currMarkerList) {
marker.destroy();
}
currMarkerList = null;
}
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerChassisLocationGCJ20ListenerManager.INSTANCE.removeListener(TAG);
CallerPlanningRottingListenerManager.INSTANCE.removeListener(TAG);
}
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return false;
}
public void onCreateView(Bundle savedInstanceState) {
if (mAMapView != null) {
mAMapView.onCreate(savedInstanceState);
}
}
public void onResume() {
if (mAMapView != null) {
mAMapView.onResume();
}
}
public void onPause() {
if (mAMapView != null) {
mAMapView.onPause();
}
}
public void onDestroy() {
if (mAMapView != null) {
mAMapView.onDestroy();
}
if (mAMapView != null) {
mAMapView.onDestroy();
}
}
public void clearCustomPolyline() {
if (mBottomPolyline != null) {
mBottomPolyline.remove();
}
if (mCoveredPolyline != null) {
mCoveredPolyline.remove();
}
}
/**
* 绘制新基建Markers(比如:摄像头)
*
* @param locationList
*/
private void drawInfrastructureMarkers(List<MessagePad.Location> locationList) {
if (locationList == null) return;
if (!pathMap.isEmpty()) {
pathMap.clear();
}
String geoHash;
ArrayList<Infrastructure> infList;
for (int i = 0; i < locationList.size(); i++) {
LatLng latLng = MarkerDrawerManager.INSTANCE.coordinateConverterWgsToGcj(mContext, locationList.get(i));
geoHash = GeoHash.withCharacterPrecision(latLng.latitude, latLng.longitude, 7).toBase32();
// 网格内的轨迹点只取一次s
if (!pathMap.containsKey(geoHash)) {
// 从缓存的新基建数据中去取对应geoHash的新基建数据集合
infList = InfStructureManager.INSTANCE.getData().get(geoHash);
if (infList != null) {
pathMap.put(geoHash, infList);
}
}
}
drawInfMarkers(pathMap);
}
//todo 扶风 需重构此处,封装至 全览
public void drawInfMarkers(Map<String, ArrayList<Infrastructure>> infStruMap) {
// 绘制新基建数据
if (!posInfMap.isEmpty()) {
posInfMap.clear();
}
ArrayList<MarkerOptions> markerOptionsList = new ArrayList();
for (ArrayList<Infrastructure> structureList : infStruMap.values()) {
// 每个GeoHash内根据坐标系象限分散开摄像头icon显示
MarkerOptions markerOption = new MarkerOptions();
LatLng latLng = new LatLng(Double.valueOf(structureList.get(0).getLat()),
Double.valueOf(structureList.get(0).getLon()));
markerOption.position(latLng);
Bitmap bitmap = getBitmap(structureList.size());
markerOption.icon(BitmapDescriptorFactory.fromBitmap(
bitmap
));
markerOption.zIndex(2f);
posInfMap.put(latLng, structureList);
markerOptionsList.add(markerOption);
}
mAMap.addMarkers(markerOptionsList, false);
mAMap.setOnMarkerClickListener(marker -> {
List<Infrastructure> infList = posInfMap.get(marker.getPosition());
// 如果是摄像头
if (infList != null) {
CallerHmiManager.INSTANCE.showVideoDialog(infList);
return true;
}
return false;
});
}
private Bitmap getBitmap(int count) {
MakerWithCount marker = new MakerWithCount(getContext());
marker.setCount(count);
marker.measure(View.MeasureSpec.makeMeasureSpec(116, View.MeasureSpec.EXACTLY),
View.MeasureSpec.makeMeasureSpec(116, View.MeasureSpec.EXACTLY));
marker.layout(0, 0, marker.getMeasuredWidth(), marker.getMeasuredHeight());
Bitmap bitmap = Bitmap.createBitmap(marker.getWidth(), marker.getHeight(), Bitmap.Config.ARGB_8888);
marker.draw(new Canvas(bitmap));
return bitmap;
}
/**
* 进入自定义全览模式
*/
private void displayCustomOverView() {
ArrayList<LatLng> linePointsLatLng = MarkerDrawerManager.INSTANCE.getPlanningPoints();
if (linePointsLatLng.size() > 1) {
//圈定地图显示范围
//存放经纬度
LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
for (int i = 0; i < linePointsLatLng.size(); i++) {
boundsBuilder.include(linePointsLatLng.get(i));
}
LatLng currentLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
boundsBuilder.include(currentLatLng);
CameraPosition cameraPosition = new CameraPosition.Builder().tilt(mTilt).build();
//第二个参数为四周留空宽度
mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100));
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
} else {
//设置希望展示的地图缩放级别
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(mCarMarker.getPosition()).tilt(0).zoom(zoomLevel).build();
mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
}
}
/**
* 绘制自车
*
* @param location
*/
private void drawCarMarker(MogoLocation location) {
if (location == null) return;
if (mCarMarker != null) {
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
mCarMarker.setRotateAngle((float) (360 - location.getHeading()));
mCarMarker.setPosition(currentLatLng);
mCarMarker.setToTop();
if (mCompassMarker != null) {
mCompassMarker.setRotateAngle((float) (360 - location.getHeading()));
mCompassMarker.setPosition(currentLatLng);
}
}
}
/**
* 绘制起始点、终点
*/
private void drawStartAndEndMarker(List<LatLng> coordinates) {
if (mStartMarker != null) {
mStartMarker.setVisible(false);
}
if (mEndMarker != null) {
mEndMarker.setVisible(false);
}
if (coordinates.size() > 2) {
// 设置开始结束Marker位置
LatLng startLatLng = coordinates.get(0);
LatLng endLatLng = coordinates.get(coordinates.size() - 1);
mStartMarker.setPosition(startLatLng);
mEndMarker.setPosition(endLatLng);
mStartMarker.setVisible(true);
mEndMarker.setVisible(true);
}
}
/**
* 绘制轨迹线
*
* @param coordinates
* @param locIndex
*/
private void drawPolyline(List<LatLng> coordinates, int locIndex) {
if (textureList.size() > 0) {
textureList.clear();
}
if (texIndexList.size() > 0) {
texIndexList.clear();
}
for (int i = 0; i < coordinates.size(); i++) {
if (i <= locIndex) {
// 已走过的置灰
textureList.add(arrivedBitmap);
} else {
// 未走过的纹理
textureList.add(unArrivedBitmap);
}
texIndexList.add(i);
}
if (mAMap != null && coordinates.size() > 2) {
//设置线段纹理
PolylineOptions polylineOptions = new PolylineOptions();
polylineOptions.addAll(coordinates);
polylineOptions.width(14); //线段宽度
polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound);
polylineOptions.setCustomTextureList(textureList);
polylineOptions.setCustomTextureIndex(texIndexList);
// 绘制线
mBottomPolyline = mCoveredPolyline;
mCoveredPolyline = mAMap.addPolyline(polylineOptions);
if (mBottomPolyline != null) {
mBottomPolyline.remove();
}
}
}
@Override
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
mLocation = gnssInfo;
MarkerDrawerManager.INSTANCE.setLonLat(new Pair(gnssInfo.getLongitude(), gnssInfo.getLatitude()));
drawCarMarker(gnssInfo);
if (isFirstLocation) {
displayCustomOverView();
isFirstLocation = false;
}
}
}

View File

@@ -1,163 +0,0 @@
package com.mogo.eagle.core.function.smp;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import androidx.annotation.Nullable;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
import com.mogo.commons.mvp.BaseFragment;
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
import com.mogo.eagle.core.data.constants.MoGoFragmentPaths;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.function.api.map.smp.IMogoSmallMapProvider;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.map.R;
import com.mogo.eagle.core.function.overview.InfStructureManager;
import com.mogo.eagle.core.function.overview.ViewModelExtKt;
import com.mogo.eagle.core.function.overview.vm.OverViewModel;
import java.util.List;
/**
* @author donghongyu
* @date 2021/5/19 10:50 上午
* 全览模式Fragment
*/
@Route(path = MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW)
public class OverviewMapFragment extends BaseFragment
implements IMogoSmallMapProvider {
private final String TAG = "OverviewMapFragment";
protected AMapCustomView mAMapCustomView;
private OverViewModel mViewModel;
@Override
public void onAttach(Context context) {
super.onAttach(context);
}
@Override
protected int getLayoutId() {
return R.layout.module_overview_map_fragment;
}
@Override
public String getTagName() {
return TAG;
}
@Override
protected void initViews() {
}
@Override
protected void initViews(Bundle savedInstanceState) {
super.initViews(savedInstanceState);
mAMapCustomView = mRootView.findViewById(R.id.smallMapDirectionView);
mAMapCustomView.onCreateView(savedInstanceState);
}
@Override
public void showPanel() {
if (mAMapCustomView != null) {
mAMapCustomView.setVisibility(View.VISIBLE);
}
}
@Override
public void hidePanel() {
if (mAMapCustomView != null) {
mAMapCustomView.setVisibility(View.GONE);
}
}
@Override
public void startQueryV2XEvents() {
if (isAdded()) {
if (mViewModel != null) {
mViewModel.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().getSn());
}
}
}
@Override
public void clearV2XMarkers() {
if (isAdded()) {
if (mAMapCustomView != null) {
mAMapCustomView.clearV2XMarkers();
}
if (mViewModel != null) {
mViewModel.stopQueryV2XEvents();
}
}
}
@Override
public void drawablePolyline(List<MogoLatLng> coordinates) {
}
@Override
public void clearPolyline() {
}
@Override
public void onResume() {
super.onResume();
if (mAMapCustomView != null) {
mAMapCustomView.onResume();
}
mAMapCustomView.handlePlanningData(InfStructureManager.INSTANCE.getPlanningData());
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// 主动查一次全局路径规划的数据
CallerAutoPilotControlManager.INSTANCE.getGlobalPath();
queryV2XEvents();
}
private void queryV2XEvents() {
mViewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class);
mViewModel.getV2XEventLiveData().observe(this.getViewLifecycleOwner(), v2XEvents -> {
mAMapCustomView.showV2XEventMarkers(v2XEvents);
});
mViewModel.getAllV2XEventsByLineId(MoGoAiCloudClientConfig.getInstance().getSn());
}
/**
* @return Taxi的下发的轨迹id
*/
private long getLineId() {
long lineId = -1;
AutopilotControlParameters parameter = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo()
.getAutopilotControlParameters();
if (parameter != null) {
if (parameter.autoPilotLine != null) {
lineId = parameter.autoPilotLine.getLineId();
}
}
return lineId;
}
@Override
public void onPause() {
super.onPause();
if (mAMapCustomView != null) {
mAMapCustomView.onPause();
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (mAMapCustomView != null) {
mAMapCustomView.onDestroy();
}
}
}

View File

@@ -0,0 +1,350 @@
package com.mogo.eagle.core.function.smp.view
import android.content.Context
import android.graphics.Color
import android.os.Bundle
import android.util.AttributeSet
import android.view.LayoutInflater
import android.widget.RelativeLayout
import androidx.annotation.UiThread
import com.amap.api.maps.*
import com.amap.api.maps.model.*
import com.mogo.cloud.commons.utils.CoordinateUtils
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.map.MogoLatLng
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.getGlobalPath
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
import com.mogo.eagle.core.function.map.R
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import mogo.telematics.pad.MessagePad
import java.util.*
import kotlin.math.floor
class SmallMapView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : RelativeLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
IMoGoPlanningRottingListener,
IMoGoAutopilotStatusListener {
private var mAMapNaviView: TextureMapView? = null
private var mAMap: AMap? = null
private var mCarMarker: Marker? = null
private var mStartMarker: Marker? = null
private var mEndMarker: Marker? = null
private val zoomLevel = 15
private val mCoordinatesLatLng: MutableList<LatLng> = ArrayList()
private var mPolyline: Polyline? = null
private var mCameraUpdate: CameraUpdate? = null
private var mContext: Context? = null
private var mLocation: MogoLocation? = null
private var autoPilotStatus = 0
companion object {
const val TAG = "SmallMapView"
}
init {
try {
initView(context)
} catch (e: Exception) {
e.printStackTrace()
}
}
// =================必须通知高德地图生命周期的变化=================
fun onCreateView(savedInstanceState: Bundle?) {
if (mAMapNaviView != null) {
mAMapNaviView!!.onCreate(savedInstanceState)
}
}
fun onResume() {
if (mAMapNaviView != null) {
mAMapNaviView!!.onResume()
}
}
fun onPause() {
if (mAMapNaviView != null) {
mAMapNaviView!!.onPause()
}
}
fun onDestroy() {
if (mAMapNaviView != null) {
mAMapNaviView!!.onDestroy()
}
}
// =================必须通知高德地图生命周期的变化=================
fun convert(coordinates: List<MogoLatLng>) {
mCoordinatesLatLng.clear()
val latLngs = coordinateConverterFrom84ForList(mContext, coordinates)
mCoordinatesLatLng.addAll(latLngs)
}
@UiThread
fun drawablePolyline() {
clearPolyline()
if (mAMap != null) {
if (mCoordinatesLatLng.size > 2) {
// 设置开始结束Marker位置
mStartMarker!!.position = mCoordinatesLatLng[0]
mEndMarker!!.position = mCoordinatesLatLng[mCoordinatesLatLng.size - 1]
mStartMarker!!.setToTop()
mStartMarker!!.isVisible = true
mEndMarker!!.isVisible = true
mEndMarker!!.setToTop()
//存放所有点的经纬度
val boundsBuilder = LatLngBounds.Builder()
for (i in mCoordinatesLatLng.indices) {
//把所有点都include进去LatLng类型
boundsBuilder.include(mCoordinatesLatLng[i])
}
//第二个参数为四周留空宽度
mAMap!!.animateCamera(
CameraUpdateFactory.newLatLngBounds(
boundsBuilder.build(),
30
)
)
// 绘制线
mPolyline = mAMap!!.addPolyline(
PolylineOptions()
.addAll(mCoordinatesLatLng)
.color(Color.argb(255, 31, 127, 255))
.width(12f)
)
}
}
}
@UiThread
fun clearPolyline() {
if (mPolyline != null) {
mPolyline!!.remove()
}
if (mStartMarker != null) {
mStartMarker!!.isVisible = false
}
if (mEndMarker != null) {
mEndMarker!!.isVisible = false
}
}
private fun initView(context: Context) {
mContext = context
val smpView = LayoutInflater.from(context).inflate(R.layout.module_small_map_view, this)
mAMapNaviView = smpView.findViewById(R.id.aMapNaviView)
initAMapView()
// 注册定位监听
CallerChassisLocationGCJ20ListenerManager.addListener(TAG, this)
CallerPlanningRottingListenerManager.addListener(TAG, this)
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
startTask()
}
private fun initAMapView() {
mCameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel.toFloat())
mAMap = mAMapNaviView!!.map
// 关闭地图文字标注
mAMap?.showMapText(false)
// 设置导航地图模式aMap是地图控制器对象。
mAMap?.mapType = AMap.MAP_TYPE_NIGHT
// 关闭显示实时路况图层aMap是地图控制器对象。
mAMap?.isTrafficEnabled = false
// 设置 锚点 图标
mCarMarker = if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
mAMap?.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon))
.anchor(0.5f, 0.5f)
)
} else {
mAMap?.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon))
.anchor(0.5f, 0.5f)
)
}
mStartMarker = mAMap?.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start))
)
mEndMarker = mAMap?.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end))
)
// 加载自定义样式
val customMapStyleOptions = CustomMapStyleOptions()
.setEnable(true)
.setStyleData(MapAssetStyleUtils.getAssetsStyle(context, "over_view_style.data"))
.setStyleExtraData(
MapAssetStyleUtils.getAssetsExtraStyle(
context,
"over_view_style_extra.data"
)
)
// 设置自定义样式
mAMap?.setCustomMapStyle(customMapStyleOptions)
//设置希望展示的地图缩放级别
mAMap?.moveCamera(mCameraUpdate)
// 设置地图的样式
val uiSettings = mAMap?.uiSettings
uiSettings?.isZoomControlsEnabled = false // 地图缩放级别的交换按钮
uiSettings?.setAllGesturesEnabled(false) // 所有手势
uiSettings?.isMyLocationButtonEnabled = false // 显示默认的定位按钮
uiSettings?.setLogoBottomMargin(-150) //设置Logo下边界距离屏幕底部的边距,设置为负值即可
mAMap?.setOnMapLoadedListener(AMap.OnMapLoadedListener {
CallerLogger.d(
SceneConstant.M_MAP + TAG,
"smp---onMapLoaded"
)
// 加载自定义样式
val customMapStyleOptions1 = CustomMapStyleOptions()
.setEnable(true)
.setStyleData(MapAssetStyleUtils.getAssetsStyle(context, "over_view_style.data"))
.setStyleExtraData(
MapAssetStyleUtils.getAssetsExtraStyle(
context,
"over_view_style_extra.data"
)
)
// 设置自定义样式
mAMap?.setCustomMapStyle(customMapStyleOptions1)
mAMapNaviView!!.map.setPointToCenter(
mAMapNaviView!!.width / 2,
mAMapNaviView!!.height / 2
)
})
}
private fun startTask() {
val mTimer = Timer()
mTimer.schedule(UpdateLocationTask(), 1000, 200)
}
private inner class UpdateLocationTask : TimerTask() {
override fun run() {
if (mLocation != null) {
if (mCarMarker == null) {
mCarMarker = mAMap!!.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo))
.anchor(0.5f, 0.5f)
)
}
if (mCarMarker == null) {
return
}
val currentLatLng = LatLng(mLocation!!.latitude, mLocation!!.longitude)
val bearing = floor(mLocation!!.heading).toFloat()
//更新车辆位置
mCarMarker!!.position = currentLatLng
if (mCoordinatesLatLng.size > 1) {
// 结束位置
val endLatLng = mCoordinatesLatLng[mCoordinatesLatLng.size - 1]
val calculateDistance = CoordinateUtils.calculateLineDistance(
endLatLng.latitude, endLatLng.longitude,
currentLatLng.latitude, currentLatLng.longitude
)
CallerLogger.d(
SceneConstant.M_MAP + TAG,
"calculateDistance=$calculateDistance"
)
if (calculateDistance <= 5) {
clearPolyline()
mCoordinatesLatLng.clear()
}
}
val cameraPosition: CameraPosition =
CameraPosition.Builder().target(mCarMarker!!.position).tilt(0f).bearing(bearing)
.zoom(zoomLevel.toFloat()).build()
mAMap?.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
}
}
}
private fun coordinateConverterFrom84(mContext: Context?, mogoLatLng: MogoLatLng): LatLng {
val mCoordinateConverter = CoordinateConverter(mContext)
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS)
mCoordinateConverter.coord(LatLng(mogoLatLng.lat, mogoLatLng.lon))
return mCoordinateConverter.convert()
}
private fun coordinateConverterFrom84ForList(
mContext: Context?,
mogoLatLngList: List<MogoLatLng>
): List<LatLng> {
val list: MutableList<LatLng> = ArrayList()
for (m in mogoLatLngList) {
val mogoLatLng = coordinateConverterFrom84(mContext, m)
list.add(mogoLatLng)
}
return list
}
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
if (mogoLocation == null) {
return
}
mLocation = mogoLocation
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {
val tempStatus = autoPilotStatusInfo.pilotmode
if (tempStatus != 1) {
UiThreadHandler.post {
clearPolyline()
}
} else if (tempStatus == 1 && autoPilotStatus == 0) {
getGlobalPath()
}
autoPilotStatus = tempStatus
}
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
if (globalPathResp == null || globalPathResp.wayPointsList.size == 0) {
return
}
val latLngList: MutableList<MogoLatLng> = ArrayList()
for (routeModel in globalPathResp.wayPointsList) {
latLngList.add(MogoLatLng(routeModel.latitude, routeModel.longitude))
}
if (latLngList.size > 0) {
UiThreadHandler.post {
convert(latLngList)
drawablePolyline()
}
} else {
UiThreadHandler.post {
clearPolyline()
}
}
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
// 注册定位监听
CallerChassisLocationGCJ20ListenerManager.removeListener(TAG)
CallerPlanningRottingListenerManager.removeListener(TAG)
CallerAutoPilotStatusListenerManager.removeListener(TAG)
}
}

View File

@@ -1,14 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mogo.eagle.core.function.smp.AMapCustomView
android:id="@+id/smallMapDirectionView"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -94,7 +94,7 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback,
V2XManager.init(V2XConfig.Builder().also {
it.aiCloudConfig(MoGoAiCloudClientConfig.getInstance())
it.context(context)
it.loggable(true)
it.loggable(false)
it.distanceForTriggerRefresh(200f) //行驶超过200包含刷新道路周边信息短链请求
it.durationForTriggerRefresh(
60,

View File

@@ -16,17 +16,6 @@ public class V2XConst {
public static final String BROADCAST_SCENE_HANDLER_ACTION = "com.v2x.scene_handler_broadcast";
public static final String BROADCAST_SCENE_EXTRA_KEY = "V2XMessageEntity";
/**
* V2X 测试控制面板广播Action
*/
public static final String BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType";
public static final String BROADCAST_SCENE_ACTION = "com.v2x.scene_local_broadcast";
public static final String V2X_ROAD_PRODUCE = "v2x_road_produce";
public static final String LAUNCHER_ICON_CLICK = "Launcher_Icon_Click";
/**
* V2X预警日志tag

View File

@@ -57,10 +57,6 @@ public class V2XScenarioManager implements IV2XScenarioManager {
ThreadUtils.runOnUiThread(() -> {
// 提取之前存储的场景
if (v2XMessageEntity != null) {
// 广播给应用内部其它模块
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(Utils.getApp()).sendBroadcast(intent);
// 如果没有拿到之前的,根据类型分发
switch (v2XMessageEntity.getType()) {
case V2XMessageEntity.V2XTypeEnum.ALERT_ROAD_WARNING:

View File

@@ -38,8 +38,6 @@ class AiRoadMarker {
private val marker by lazy { AtomicReference<Marker>() }
private val carLocation by lazy { AtomicReference<Triple<Double, Double, Double>>() }
private val overlayManager by lazy {
CallerMapUIServiceManager.getOverlayManager(
AbsMogoApplication.getApp()

View File

@@ -0,0 +1,14 @@
package com.mogo.eagle.core.function.v2x.events.test
class TestConsts {
companion object {
/**
* V2X 测试控制面板广播Action
*/
@JvmField
val BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY = "sceneType"
}
}

View File

@@ -29,7 +29,7 @@ public class TestV2XReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
try {
this.mContext = context;
int sceneType = intent.getIntExtra(V2XConst.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
int sceneType = intent.getIntExtra(TestConsts.BROADCAST_TEST_PANEL_CONTROL_TYPE_EXTRA_KEY, 0);
// 分发场景
dispatchSceneTest(sceneType);