[MAP] 高精地图Marker绘制逻辑重构
This commit is contained in:
@@ -1,74 +1,53 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Build
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import androidx.annotation.RequiresApi
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager
|
||||
import android.content.*
|
||||
import android.os.*
|
||||
import android.util.*
|
||||
import androidx.annotation.*
|
||||
import androidx.localbroadcastmanager.content.*
|
||||
import com.mogo.eagle.core.data.config.*
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_ALIAS_CODE_CLOUD_V2N
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_CLOUD
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant.Companion.CHAIN_LINK_LOG_CLOUD_V2N
|
||||
import com.mogo.eagle.core.data.enums.*
|
||||
import com.mogo.eagle.core.data.enums.DataSourceType
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.enums.EventTypeHelper
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew.Companion.isRoadEvent
|
||||
import com.mogo.eagle.core.data.enums.WarningDirectionEnum.ALERT_WARNING_TOP
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.map.entity.V2XMessageEntity
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
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.TrafficData
|
||||
import com.mogo.eagle.core.data.v2x.V2XAdvanceWarning
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.map.entity.*
|
||||
import com.mogo.eagle.core.data.msgbox.*
|
||||
import com.mogo.eagle.core.data.traffic.*
|
||||
import com.mogo.eagle.core.data.v2x.*
|
||||
import com.mogo.eagle.core.function.api.autopilot.*
|
||||
import com.mogo.eagle.core.function.api.cloud.*
|
||||
import com.mogo.eagle.core.function.api.hmi.warning.*
|
||||
import com.mogo.eagle.core.function.api.map.angle.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.alarm.V2XAlarmServer
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02
|
||||
import com.mogo.eagle.core.function.call.cloud.*
|
||||
import com.mogo.eagle.core.function.call.hmi.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.function.call.msgbox.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.eagle.function.biz.v2x.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.V2XPoiLoader.Companion.v2xPoiLoader
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.alarm.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst.BROADCAST_SCENE_EXTRA_KEY
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst.BROADCAST_SCENE_HANDLER_ACTION
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.receiver.SceneBroadcastReceiver
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.impl.V2XScenarioManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.toRoadMarker
|
||||
import com.mogo.eagle.core.data.v2x.V2XEvent
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerCardResult
|
||||
import com.mogo.eagle.core.data.v2x.V2XWarningTarget
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoV2XListener
|
||||
import com.mogo.eagle.core.function.api.cloud.IMoGoCloudListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerV2XListenerManager
|
||||
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.V2XPoiLoader.Companion.v2xPoiLoader
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_V2X
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.callback.IV2XCallback
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import com.zhjt.service.chain.TracingConstants
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.android.asCoroutineDispatcher
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.network.callback.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.receiver.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.impl.*
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.*
|
||||
import com.zhjt.service.chain.*
|
||||
import kotlinx.coroutines.*
|
||||
import kotlinx.coroutines.android.*
|
||||
import mogo.telematics.pad.MessagePad.PlanningObject
|
||||
import mogo.v2x.MogoV2X
|
||||
import mogo.v2x.*
|
||||
import java.util.concurrent.*
|
||||
import java.util.concurrent.atomic.*
|
||||
|
||||
object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
IMoGoAutopilotIdentifyListener, IMoGoCloudListener,
|
||||
@@ -80,10 +59,11 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
CoroutineScope(Handler(Looper.getMainLooper()).asCoroutineDispatcher(TAG))
|
||||
}
|
||||
|
||||
private val mV2XRoadEventEntityArrayList = CopyOnWriteArraySet<V2XRoadEventEntity>()
|
||||
|
||||
private val hasInit by lazy { AtomicBoolean(false) }
|
||||
|
||||
fun init(context: Context) {
|
||||
BridgeApi.init(context)
|
||||
if (hasInit.compareAndSet(false, true)) {
|
||||
registerListener()
|
||||
v2xPoiLoader.startLoopPoi()
|
||||
@@ -111,7 +91,6 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
}
|
||||
|
||||
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
|
||||
BridgeApi.location.set(mogoLocation)
|
||||
mogoLocation?.let {
|
||||
v2xPoiLoader.updateCheck(mogoLocation.longitude, mogoLocation.latitude)
|
||||
refreshCarState(mogoLocation)
|
||||
@@ -120,9 +99,7 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
|
||||
private fun refreshCarState(location: MogoLocation) {
|
||||
// 巡航处理
|
||||
val v2XRoadEventEntity = V2XAlarmServer.getDriveFrontAlarmEvent(
|
||||
BridgeApi.v2xMarker()?.v2XRoadEventEntityList, location
|
||||
)
|
||||
val v2XRoadEventEntity = V2XAlarmServer.getDriveFrontAlarmEvent(getV2XRoadEventEntityList(), location)
|
||||
if (v2XRoadEventEntity != null) {
|
||||
val distance = v2XRoadEventEntity.distance
|
||||
val min = if (EventTypeEnumNew.isCloudSocketEvent(v2XRoadEventEntity.poiType)) 0 else 5
|
||||
@@ -144,6 +121,29 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
}
|
||||
}
|
||||
|
||||
private fun getV2XRoadEventEntityList(): CopyOnWriteArrayList<V2XRoadEventEntity> {
|
||||
val roadEventEntities = CopyOnWriteArrayList<V2XRoadEventEntity>() // 当前车辆数据
|
||||
val currentLocation = getChassisLocationGCJ02()
|
||||
for (v2XRoadEventEntity in mV2XRoadEventEntityArrayList) { // 事件位置
|
||||
val location = v2XRoadEventEntity.location
|
||||
if (location != null) {
|
||||
val calculateDistance = CoordinateUtils.calculateLineDistance(location.lat, location.lon, currentLocation.latitude, currentLocation.longitude)
|
||||
v2XRoadEventEntity.distance = calculateDistance.toDouble()
|
||||
}
|
||||
roadEventEntities.add(v2XRoadEventEntity)
|
||||
} // 按照与当前车辆距离排序
|
||||
for (i in roadEventEntities.indices) {
|
||||
for (j in i downTo 1) {
|
||||
if (roadEventEntities[j].distance < roadEventEntities[j - 1].distance) {
|
||||
val v2XRoadEventEntity = roadEventEntities[j - 1]
|
||||
roadEventEntities[j - 1] = roadEventEntities[j]
|
||||
roadEventEntities[j] = v2XRoadEventEntity
|
||||
}
|
||||
}
|
||||
}
|
||||
return roadEventEntities
|
||||
}
|
||||
|
||||
/**
|
||||
* V2XEvent事件回调
|
||||
*/
|
||||
@@ -158,9 +158,6 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
override fun onAck(event: V2XEvent) {
|
||||
Log.d("$M_V2X$TAG", "OK->: $event")
|
||||
when (event) {
|
||||
is V2XEvent.ForwardsWarning -> {
|
||||
handleAdvanceWarningEvent(event)
|
||||
}
|
||||
is V2XEvent.Marker -> {
|
||||
event.data.result?.let {
|
||||
handleRoadMarkerEvent(it)
|
||||
@@ -245,155 +242,35 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IV2XCallback,
|
||||
private fun handleRoadMarkerEvent(data: V2XMarkerCardResult) {
|
||||
try {
|
||||
scope.launch(Dispatchers.Default) {
|
||||
BridgeApi.v2xMarker()?.analysisV2XRoadEvent(data)
|
||||
analysisV2XRoadEvent(data)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
//todo 可优化,与obu解析类似
|
||||
private fun handleAdvanceWarningEvent(event: V2XEvent.ForwardsWarning) {
|
||||
scope.launch {
|
||||
val message = event.data
|
||||
val trafficData = buildTrafficData(message)
|
||||
var changeVisualAngle = false
|
||||
when (message.status) {
|
||||
1 -> {
|
||||
var tempAppId = 0
|
||||
var tempTts = ""
|
||||
var tempContent = ""
|
||||
when (message.typeId) {
|
||||
1001 -> {
|
||||
// 弱势交通碰撞预警
|
||||
EventTypeHelper.getVRU { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
private fun analysisV2XRoadEvent(markerCardResult: V2XMarkerCardResult?) {
|
||||
try { //当没有预警提示的时候重新绘制地图POI点
|
||||
if (markerCardResult != null) { // 清除上次的道路事件, 这里注意,道路事件的触发和这里是异步操作会触发异常
|
||||
mV2XRoadEventEntityArrayList.clear() // 获取探路以及新鲜事儿
|
||||
val exploreWayList = markerCardResult.exploreWay
|
||||
if (exploreWayList != null) {
|
||||
for (markerExploreWay in exploreWayList) {
|
||||
if (isRoadEvent(markerExploreWay.poiType)) {
|
||||
val markerLocation = markerExploreWay.location // 记录道路事件
|
||||
val v2XRoadEventEntity = V2XRoadEventEntity()
|
||||
v2XRoadEventEntity.location = markerLocation // 探路目前只有上报拥堵
|
||||
val poi = markerExploreWay.poiType
|
||||
v2XRoadEventEntity.poiType = poi
|
||||
v2XRoadEventEntity.noveltyInfo = markerExploreWay
|
||||
v2XRoadEventEntity.expireTime = 20000
|
||||
mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity)
|
||||
}
|
||||
1002 -> {
|
||||
// 弱势交通逆行预警
|
||||
EventTypeHelper.getVRURI { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
}
|
||||
1003 -> {
|
||||
// 交叉路口碰撞预警
|
||||
changeVisualAngle = true
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_ICW.poiType.toInt()
|
||||
tempTts = EventTypeEnumNew.TYPE_USECASE_ID_ICW.tts
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_ICW.content
|
||||
}
|
||||
1004 -> {
|
||||
// 交叉路口碰撞预警
|
||||
changeVisualAngle = true
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_BSW.poiType.toInt()
|
||||
tempTts = String.format(
|
||||
EventTypeEnumNew.TYPE_USECASE_ID_BSW.tts,
|
||||
getWarningDirection()
|
||||
)
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_BSW.content
|
||||
}
|
||||
1006 -> {
|
||||
// 逆向超车预警
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.poiType.toInt()
|
||||
tempTts = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.tts
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_DNPW.content
|
||||
}
|
||||
1005 -> {
|
||||
// 闯红灯预警
|
||||
tempAppId = EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.poiType.toInt()
|
||||
tempTts = EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.tts
|
||||
tempContent = EventTypeEnumNew.TYPE_USECASE_ID_IVP_RED.content
|
||||
}
|
||||
2001 -> {
|
||||
// 最优车道100061
|
||||
EventTypeHelper.getOptLine { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
}
|
||||
3001 -> {
|
||||
// 前方道路拥堵预警
|
||||
EventTypeHelper.getTJW { appId, tts, content ->
|
||||
tempAppId = appId
|
||||
tempTts = tts
|
||||
tempContent = content
|
||||
}
|
||||
}
|
||||
}
|
||||
// 不显示弹框,其它保留
|
||||
if (tempContent.isEmpty() || tempTts.isEmpty()) {
|
||||
Log.d("MsgBox-V2XEventManager", "alertContent或ttsContent为空!")
|
||||
}
|
||||
CallerMsgBoxManager.saveMsgBox(
|
||||
MsgBoxBean(
|
||||
MsgBoxType.V2X,
|
||||
V2XMsg(
|
||||
tempAppId.toString(),
|
||||
tempContent,
|
||||
tempTts
|
||||
)
|
||||
)
|
||||
)
|
||||
CallerHmiManager.warningV2X(
|
||||
tempAppId.toString(),
|
||||
tempContent,
|
||||
tempTts,
|
||||
object : IMoGoWarningStatusListener {
|
||||
val change = changeVisualAngle
|
||||
override fun onShow() {
|
||||
if (change) {
|
||||
CallerVisualAngleManager.changeAngle(TooClose)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDismiss() {
|
||||
if (change) {
|
||||
CallerVisualAngleManager.changeAngle(Default())
|
||||
}
|
||||
}
|
||||
}, isFromObu = false
|
||||
)
|
||||
CallerMapUIServiceManager.getMarkerService()?.updateITrafficInfo(trafficData)
|
||||
}
|
||||
2 -> {
|
||||
CallerMapUIServiceManager.getMarkerService()?.updateITrafficInfo(trafficData)
|
||||
}
|
||||
3 -> {
|
||||
trafficData.uuid?.let {
|
||||
CallerMapUIServiceManager.getMarkerService()?.removeCvxRvInfoIndInfo(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getWarningDirection(): String {
|
||||
return "右" //TODO renwj 原来的逻辑,预警方向先写死, 后续做兼容
|
||||
}
|
||||
|
||||
private fun buildTrafficData(message: V2XAdvanceWarning): TrafficData {
|
||||
return TrafficData().apply {
|
||||
type = when (message.objectType) {
|
||||
1 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE
|
||||
2 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE
|
||||
3 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE
|
||||
4 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO
|
||||
6 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_BUS
|
||||
8 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_TRUCK
|
||||
9 -> TrafficTypeEnum.TYPE_TRAFFIC_ID_CAMERA
|
||||
else -> TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI
|
||||
}
|
||||
uuid = message.objectId
|
||||
lat = message.position?.lat ?: 0.0
|
||||
lon = message.position?.lon ?: 0.0
|
||||
heading = message.heading ?: 0.0
|
||||
threatLevel = message.threatLevel ?: -1
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.bridge
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoV2XMarkerManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager
|
||||
import java.lang.ref.WeakReference
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
internal object BridgeApi {
|
||||
|
||||
private val context by lazy {
|
||||
AtomicReference<WeakReference<Context>>(null)
|
||||
}
|
||||
|
||||
val location by lazy {
|
||||
AtomicReference<MogoLocation>()
|
||||
}
|
||||
|
||||
private val v2xMarker by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER).navigation(context()) as? IMoGoV2XMarkerManager
|
||||
}
|
||||
|
||||
private val v2xWarnPolyline by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER).navigation(
|
||||
context()
|
||||
) as? IMoGoWarnPolylineManager
|
||||
}
|
||||
|
||||
private val v2xPersonWarnPolyline by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER).navigation(
|
||||
context()
|
||||
) as? IMoGoPersonWarnPolylineManager
|
||||
}
|
||||
|
||||
private val v2xStopPolyline by lazy {
|
||||
ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STOP_POLYLINE_MANAGER).navigation(
|
||||
context()
|
||||
) as? IMoGoStopPolylineManager
|
||||
}
|
||||
|
||||
fun init(context: Context) {
|
||||
BridgeApi.context.set(WeakReference(context))
|
||||
}
|
||||
|
||||
fun context(): Context = context.get()?.get() ?: Utils.getApp()
|
||||
|
||||
fun v2xMarker() = v2xMarker
|
||||
|
||||
fun v2xWarnPolyline() = v2xWarnPolyline
|
||||
|
||||
fun v2xPersonWarnPolyline() = v2xPersonWarnPolyline
|
||||
|
||||
fun v2xStopPolyline() = v2xStopPolyline
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.consts;
|
||||
|
||||
import androidx.annotation.Keep;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/4/17 7:35 PM
|
||||
* desc : 对外服务模块路径
|
||||
* version: 1.0
|
||||
* 使用方式:
|
||||
* Arouter.getInstance().path("").navigate()
|
||||
*/
|
||||
@Keep
|
||||
public class MoGoV2XServicePaths {
|
||||
|
||||
/**
|
||||
* V2X 道路事件POI点
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_MARKER_MANAGER = "/v2xMarkerManager/api";
|
||||
|
||||
|
||||
/**
|
||||
* V2X 道路事件与车辆的连接线
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_WARN_POLYLINE_MANAGER = "/v2xWarnPolylineManager/api";
|
||||
|
||||
/**
|
||||
* V2X 二轮车和行人连接线
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_PERSON_WARN_POLYLINE_MANAGER = "/v2xPersonWarnPolylineManager/api";
|
||||
|
||||
/**
|
||||
* V2X 停止线连接线
|
||||
*/
|
||||
@Keep
|
||||
public static final String PATH_V2X_STOP_POLYLINE_MANAGER = "/v2xStopPolylineManager/api";
|
||||
}
|
||||
@@ -16,10 +16,5 @@ 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预警日志tag
|
||||
*/
|
||||
public static final String LOG_NAME_WARN = "PersonWarn";
|
||||
|
||||
public static final String V2X_MARKER_OWNER = "v2x_road_marker_owner";
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
/**
|
||||
* 绘制可变宽度和渐变的线,
|
||||
*/
|
||||
public interface IMoGoPersonWarnPolylineManager extends IProvider {
|
||||
/**
|
||||
* 绘制连接线,人物和二轮车
|
||||
*
|
||||
* @param context
|
||||
* @param info
|
||||
*/
|
||||
void drawPersonWarnPolyline(Context context, DrawLineInfo info);
|
||||
|
||||
/**
|
||||
* 移除连接线
|
||||
*/
|
||||
void clearLine();
|
||||
|
||||
IMogoPolyline getMogoPersonWarnPolyline();
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
/**
|
||||
* 绘制可变宽度和渐变的线
|
||||
*/
|
||||
public interface IMoGoStopPolylineManager extends IProvider {
|
||||
/**
|
||||
* 绘制连接线,目标车,与当前车辆间连线
|
||||
*
|
||||
* @param context
|
||||
* @param info
|
||||
*/
|
||||
void drawStopPolyline(Context context, DrawLineInfo info);
|
||||
|
||||
/**
|
||||
* 移除连接线
|
||||
*/
|
||||
void clearLine();
|
||||
|
||||
IMogoPolyline getMogoStopPolyline();
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerCardResult;
|
||||
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/4/17 8:15 PM
|
||||
* desc : V2X 涉及到的地图 POI 点的绘制
|
||||
* version: 1.0
|
||||
*/
|
||||
public interface IMoGoV2XMarkerManager extends IProvider {
|
||||
|
||||
/**
|
||||
* 获取所有的道路事件点,探路事件,返回结果是按照距离当前车辆从近到远排列好的
|
||||
*
|
||||
* @return 按从近到远排列好的道路事件
|
||||
*/
|
||||
CopyOnWriteArrayList<V2XRoadEventEntity> getV2XRoadEventEntityList();
|
||||
|
||||
/**
|
||||
* 从探路数据和新鲜事儿的路况信息中解析出道路事件信息
|
||||
*/
|
||||
void analysisV2XRoadEvent(V2XMarkerCardResult markerCardResult);
|
||||
|
||||
/**
|
||||
* 绘制正在预警的道路事件的POI点
|
||||
* @param context
|
||||
* @param roadEventEntity
|
||||
* @return
|
||||
*/
|
||||
IMogoMarker drawableAlarmPOI(Context context, V2XRoadEventEntity roadEventEntity, IMogoMarkerClickListener clickListener);
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
/**
|
||||
* 绘制可变宽度和渐变的线
|
||||
*/
|
||||
public interface IMoGoWarnPolylineManager extends IProvider {
|
||||
/**
|
||||
* 绘制连接线,目标车,与当前车辆间连线
|
||||
*
|
||||
* @param context
|
||||
* @param info
|
||||
*/
|
||||
void drawWarnPolyline(Context context, DrawLineInfo info);
|
||||
|
||||
/**
|
||||
* 移除连接线
|
||||
*/
|
||||
void clearLine();
|
||||
|
||||
IMogoPolyline getMogoWarnPolyline();
|
||||
}
|
||||
@@ -1,87 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 绘制行人和二轮车连线
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER)
|
||||
public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineManager {
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
|
||||
|
||||
@Override
|
||||
public void drawPersonWarnPolyline(Context context, DrawLineInfo info) {
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
}
|
||||
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions().setGps(true);
|
||||
|
||||
// 渐变色
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
colors.add(0x0DE32F46);
|
||||
colors.add(0xD9E32F46);
|
||||
colors.add(0x0DE32F46);
|
||||
|
||||
// 线条粗细,渐变,渐变色值
|
||||
CallerLogger.INSTANCE.d(M_V2X + V2XConst.LOG_NAME_WARN, "MoGoPersonWarnPolylineManager width = " + info.getWidth());
|
||||
options.width(info.getWidth()).useGradient(true).colorValues(colors);
|
||||
List<MogoLatLng> locations = info.getLocations();
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
options.add(locations.get(i));
|
||||
}
|
||||
// 绘制线的对象
|
||||
IMogoOverlayManager overlay = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlay != null) {
|
||||
mMogoPolyline = overlay.addPolyline(options);
|
||||
mMogoPolyline.setTransparency(0.5f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLine() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 绘制连接线的对象
|
||||
*/
|
||||
@Override
|
||||
public IMogoPolyline getMogoPersonWarnPolyline() {
|
||||
return mMogoPolyline;
|
||||
}
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 当前车辆与道路事件的连接线
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_STOP_POLYLINE_MANAGER)
|
||||
public class MoGoStopPolylineManager implements IMoGoStopPolylineManager {
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
|
||||
@Override
|
||||
public void drawStopPolyline(Context context, DrawLineInfo info) {
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
}
|
||||
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions()
|
||||
.setGps(true);
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
colors.add(0x0DE32F46);
|
||||
colors.add(0xD9E32F46);
|
||||
colors.add(0x0DE32F46);
|
||||
|
||||
CallerLogger.INSTANCE.d(M_V2X + V2XConst.LOG_NAME_WARN, "MoGoStopPolylineManager roadWidth = " + info.getWidth());
|
||||
// 线条粗细,渐变,渐变色值
|
||||
// 当前车辆位置
|
||||
options.width(info.getWidth() == 0.0 ? 60 : info.getWidth()).useGradient(true).colorValues(colors);
|
||||
List<MogoLatLng> locations = info.getLocations();
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
options.add(locations.get(i));
|
||||
}
|
||||
// 绘制线的对象
|
||||
IMogoOverlayManager overlay = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlay != null) {
|
||||
mMogoPolyline = overlay.addPolyline(options);
|
||||
}
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.setTransparency(0.5f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLine() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IMogoPolyline getMogoStopPolyline() {
|
||||
return mMogoPolyline;
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.commons.module.ServiceConst.CARD_TYPE_NOVELTY;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.marker.V2XMarkerAdapter;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.utils.MapUtils;
|
||||
import com.mogo.eagle.core.data.v2x.V2XMarkerCardResult;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/4/17 9:57 PM
|
||||
* desc : V2X 涉及到的地图 POI 点的绘制
|
||||
* version: 1.0
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_MARKER_MANAGER)
|
||||
public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
private static final String TAG = "MoGoV2XMarkerManager";
|
||||
|
||||
// 记录所有的:新鲜事儿的道路事件点、探路事件
|
||||
private final CopyOnWriteArraySet<V2XRoadEventEntity> mV2XRoadEventEntityArrayList = new CopyOnWriteArraySet<>();
|
||||
|
||||
@Override
|
||||
public void init(Context context) {}
|
||||
|
||||
@Override
|
||||
public CopyOnWriteArrayList<V2XRoadEventEntity> getV2XRoadEventEntityList() {
|
||||
CopyOnWriteArrayList<V2XRoadEventEntity> roadEventEntities = new CopyOnWriteArrayList<>();
|
||||
// 当前车辆数据
|
||||
MogoLocation currentLocation = CallerChassisLocationGCJ02ListenerManager.INSTANCE.getChassisLocationGCJ02();
|
||||
if (currentLocation != null) {
|
||||
// 重新计算距离
|
||||
for (V2XRoadEventEntity v2XRoadEventEntity : mV2XRoadEventEntityArrayList) {
|
||||
// 事件位置
|
||||
MarkerLocation location = v2XRoadEventEntity.getLocation();
|
||||
if (location != null) {
|
||||
float calculateDistance = CoordinateUtils.calculateLineDistance(location.getLat(), location.getLon(),
|
||||
currentLocation.getLatitude(), currentLocation.getLongitude());
|
||||
v2XRoadEventEntity.setDistance(calculateDistance);
|
||||
}
|
||||
roadEventEntities.add(v2XRoadEventEntity);
|
||||
}
|
||||
// 按照与当前车辆距离排序
|
||||
for (int i = 0; i < roadEventEntities.size(); i++) {
|
||||
for (int j = i; j > 0; j--) {
|
||||
if (roadEventEntities.get(j).getDistance() < roadEventEntities.get(j - 1).getDistance()) {
|
||||
V2XRoadEventEntity v2XRoadEventEntity = roadEventEntities.get(j - 1);
|
||||
roadEventEntities.set(j - 1, roadEventEntities.get(j));
|
||||
roadEventEntities.set(j, v2XRoadEventEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return roadEventEntities;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void analysisV2XRoadEvent(V2XMarkerCardResult markerCardResult) {
|
||||
try {
|
||||
//当没有预警提示的时候重新绘制地图POI点
|
||||
if (markerCardResult != null) {
|
||||
// 清除上次的道路事件, 这里注意,道路事件的触发和这里是异步操作会触发异常
|
||||
mV2XRoadEventEntityArrayList.clear();
|
||||
// 获取探路以及新鲜事儿
|
||||
List<MarkerExploreWay> exploreWayList = markerCardResult.getExploreWay();
|
||||
if (exploreWayList != null) {
|
||||
for (MarkerExploreWay markerExploreWay : exploreWayList) {
|
||||
if (EventTypeEnumNew.isRoadEvent(markerExploreWay.getPoiType())) {
|
||||
MarkerLocation markerLocation = markerExploreWay.getLocation();
|
||||
// 记录道路事件
|
||||
V2XRoadEventEntity v2XRoadEventEntity = new V2XRoadEventEntity();
|
||||
v2XRoadEventEntity.setLocation(markerLocation);
|
||||
// 探路目前只有上报拥堵
|
||||
String poi = markerExploreWay.getPoiType();
|
||||
v2XRoadEventEntity.setPoiType(poi);
|
||||
v2XRoadEventEntity.setNoveltyInfo(markerExploreWay);
|
||||
v2XRoadEventEntity.setExpireTime(20000);
|
||||
mV2XRoadEventEntityArrayList.add(v2XRoadEventEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMarker drawableAlarmPOI(Context context, V2XRoadEventEntity roadEventEntity, IMogoMarkerClickListener clickListener) {
|
||||
try {
|
||||
// 清除原来的大而全的新鲜事儿
|
||||
if (roadEventEntity.getLocation() != null) {
|
||||
// 道路事件,或者水波纹扩散效果
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.data(roadEventEntity)
|
||||
.latitude(roadEventEntity.getLocation().getLat())
|
||||
.longitude(roadEventEntity.getLocation().getLon());
|
||||
optionsRipple.anchor(0.5f, 0.5f);
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
MarkerExploreWay markerExploreWay = roadEventEntity.getNoveltyInfo();
|
||||
markerShowEntity.setBindObj(markerExploreWay);
|
||||
markerShowEntity.setChecked(false);
|
||||
markerShowEntity.setTextContent(markerExploreWay.getAddr());
|
||||
markerShowEntity.setMarkerLocation(markerExploreWay.getLocation());
|
||||
markerShowEntity.setMarkerType(CARD_TYPE_NOVELTY);
|
||||
optionsRipple.icons(V2XMarkerAdapter.getV2XRoadEventViewGif(context, roadEventEntity));
|
||||
optionsRipple.period(1);
|
||||
IMogoMarker ret = Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).drawMarker(markerShowEntity);
|
||||
// 当前Marker设置为最上面
|
||||
if (ret != null) {
|
||||
ret.setToTop();
|
||||
}
|
||||
// 缩放地图
|
||||
MapUtils.zoomMap(
|
||||
new MogoLatLng(roadEventEntity.getLocation().getLat(),
|
||||
roadEventEntity.getLocation().getLon()
|
||||
), context);
|
||||
|
||||
return ret;
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_V2X + TAG, "Location 必须进行初始化!!!!!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.manager.impl;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.MoGoV2XServicePaths;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 当前车辆与道路事件的连接线
|
||||
*/
|
||||
@Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER)
|
||||
public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
private static final String TAG = "V2XWarningMarker";
|
||||
|
||||
@Override
|
||||
public void drawWarnPolyline(Context context, DrawLineInfo info) {
|
||||
if (info == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
}
|
||||
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions()
|
||||
.setGps(true);
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
|
||||
if (info.isHasStopLines()) {
|
||||
colors.add(0x0D3036FF);
|
||||
colors.add(0xD93036FF);
|
||||
colors.add(0x0D3036FF);
|
||||
} else {
|
||||
colors.add(0x0DE32F46);
|
||||
colors.add(0xD9E32F46);
|
||||
colors.add(0x0DE32F46);
|
||||
}
|
||||
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "MoGoWarnPolylineManager roadWidth = " + info.getWidth());
|
||||
// 线条粗细,渐变,渐变色值
|
||||
options.width(info.getWidth() == 0.0 ? 60 : info.getWidth()).useGradient(true).colorValues(colors);
|
||||
List<MogoLatLng> locations = info.getLocations();
|
||||
for (int i = 0; i < locations.size(); i++) {
|
||||
options.add(locations.get(i));
|
||||
}
|
||||
// 绘制线的对象
|
||||
|
||||
IMogoOverlayManager overlay = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlay != null) {
|
||||
mMogoPolyline = overlay.addPolyline(options);
|
||||
}
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.setTransparency(0.5f);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearLine() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "mMogoPolyline==null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return 绘制连接线的对象
|
||||
*/
|
||||
@Override
|
||||
public IMogoPolyline getMogoWarnPolyline() {
|
||||
return mMogoPolyline;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,135 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.biz.R;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.view.V2XMarkerRoadEventView;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020-01-1015:55
|
||||
* desc : V2X 地图气泡
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XMarkerAdapter {
|
||||
|
||||
/**
|
||||
* 返回道路事件
|
||||
*/
|
||||
public static Bitmap getV2XRoadEventMarkerView(Context context, V2XRoadEventEntity alarmInfo, int imageRes) {
|
||||
return new V2XMarkerRoadEventView(context, alarmInfo).setBackground(imageRes).getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回道路事件gif序列图集合
|
||||
*/
|
||||
public static ArrayList<Bitmap> getV2XRoadEventViewGif(Context context, V2XRoadEventEntity alarmInfo) {
|
||||
ArrayList<Bitmap> bitmapArrayList;
|
||||
if (EventTypeEnumNew.ALERT_TRAFFIC_LIGHT_SUGGEST.getPoiType().equals(alarmInfo.getPoiType())
|
||||
|| EventTypeEnumNew.ALERT_TRAFFIC_LIGHT_WARNING.getPoiType().equals(alarmInfo.getPoiType())
|
||||
|| EventTypeEnumNew.FOURS_BLOCK_UP.getPoiType().equals(alarmInfo.getPoiType())
|
||||
|| EventTypeEnumNew.ALERT_CAR_TROUBLE_WARNING.getPoiType().equals(alarmInfo.getPoiType())) {
|
||||
bitmapArrayList = getV2XRoadEventOrangeMarkerView(context, alarmInfo);
|
||||
} else {
|
||||
bitmapArrayList = getV2XRoadEventRedMarkerView(context, alarmInfo);
|
||||
}
|
||||
return bitmapArrayList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回红色扩散效果的序列
|
||||
*/
|
||||
public static ArrayList<Bitmap> getV2XRoadEventRedMarkerView(Context context, V2XRoadEventEntity alarmInfo) {
|
||||
ArrayList<Bitmap> icons = new ArrayList<>();
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00011));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00012));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00013));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00014));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00015));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00016));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00017));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00018));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00019));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00020));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00021));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00022));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00023));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00024));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00025));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00026));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00027));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00028));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00029));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00030));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00031));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00032));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00033));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00034));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00035));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00036));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00037));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00038));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00039));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00040));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00041));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00042));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00043));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00044));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00045));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00046));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00047));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_red_00048));
|
||||
return icons;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回橘色色扩散效果的序列
|
||||
*/
|
||||
public static ArrayList<Bitmap> getV2XRoadEventOrangeMarkerView(Context context, V2XRoadEventEntity alarmInfo) {
|
||||
ArrayList<Bitmap> icons = new ArrayList<>();
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00011));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00012));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00013));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00014));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00015));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00016));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00017));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00018));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00019));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00020));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00021));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00022));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00023));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00024));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00025));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00026));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00027));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00028));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00029));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00030));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00031));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00032));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00033));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00034));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00035));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00036));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00037));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00038));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00039));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00040));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00041));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00042));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00043));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00044));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00045));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00046));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00047));
|
||||
icons.add(V2XMarkerAdapter.getV2XRoadEventMarkerView(context, alarmInfo, R.drawable.v_to_x_warning_circle_orange_00048));
|
||||
return icons;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,10 +6,11 @@ import android.util.Log
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.marker.IMogoMarker
|
||||
import com.mogo.map.overlay.IMogoPolyline
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.point.*
|
||||
import kotlinx.coroutines.Runnable
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
@@ -17,9 +18,9 @@ import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
|
||||
data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val coordinateType: Int, var markers: ArrayList<IMogoMarker>? = null, var lines: ArrayList<IMogoPolyline>? = null, var onRemoved:((id: String) -> Unit)? = null) {
|
||||
data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val coordinateType: Int, var markers: ArrayList<Point>? = null, var lines: ArrayList<Polyline>? = null, var onRemoved:((id: String) -> Unit)? = null) {
|
||||
|
||||
fun addLine(line: IMogoPolyline) {
|
||||
fun addLine(line: Polyline) {
|
||||
var ll = this.lines
|
||||
if (ll == null) {
|
||||
ll = ArrayList()
|
||||
@@ -28,7 +29,7 @@ data class MarkerWrapper(val id: String, val lon: Double, val lat: Double, val c
|
||||
ll.add(line)
|
||||
}
|
||||
|
||||
fun addMarker(marker: IMogoMarker) {
|
||||
fun addPoint(marker: Point) {
|
||||
var mm = this.markers
|
||||
if (mm == null) {
|
||||
mm = ArrayList()
|
||||
@@ -72,7 +73,6 @@ object MarkerRemoveManager {
|
||||
private val checkTask = object : Runnable {
|
||||
|
||||
override fun run() {
|
||||
|
||||
try {
|
||||
Log.d(TAG, "--- checkTask --- 1 ---")
|
||||
if (lastCarLocation.get() == null) {
|
||||
@@ -113,8 +113,7 @@ object MarkerRemoveManager {
|
||||
marker.markers?.forEach {
|
||||
try {
|
||||
Log.e(TAG, "--- checkTask --- remove marker: $it, id: ${marker.id}")
|
||||
it.setVisible(false)
|
||||
it.destroy()
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removePoint(it.id)
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
removeMarkerError = true
|
||||
@@ -124,9 +123,8 @@ object MarkerRemoveManager {
|
||||
var removeLineError = false
|
||||
marker.lines?.forEach {
|
||||
try {
|
||||
it.isVisible = false
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removeLine(it)
|
||||
Log.e(TAG, "--- checkTask --- remove line : $it, id:${marker.id}")
|
||||
it.destroy()
|
||||
} catch (t: Throwable) {
|
||||
t.printStackTrace()
|
||||
removeLineError = true
|
||||
@@ -172,9 +170,9 @@ object MarkerRemoveManager {
|
||||
t.printStackTrace()
|
||||
} finally {
|
||||
val gcInfo = CallerChassisLocationGCJ02ListenerManager.getChassisLocationGCJ02()
|
||||
lastCarLocation.set((gcInfo?.longitude ?: 0.0) to (gcInfo?.latitude ?: 0.0))
|
||||
lastCarLocation.set(gcInfo.longitude to gcInfo.latitude)
|
||||
val wgsInfo = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
lastGpsLocation.set((wgsInfo?.longitude ?: 0.0) to (wgsInfo?.latitude ?: 0.0))
|
||||
lastGpsLocation.set(wgsInfo.longitude to wgsInfo.latitude)
|
||||
handler.postDelayed(this, 1000)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad
|
||||
import android.animation.ArgbEvaluator
|
||||
import android.graphics.Color
|
||||
import android.os.Handler
|
||||
import android.os.HandlerThread
|
||||
import android.os.Looper
|
||||
import android.util.Log
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
@@ -14,12 +15,13 @@ import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.eagle.function.biz.v2x.V2XBizTrace
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerRemoveManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.road.V2XAiRoadEventMarker
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.overlay.IMogoPolyline
|
||||
import com.mogo.map.overlay.MogoPolylineOptions
|
||||
import com.mogo.map.overlay.core.Level.ROAD_CENTER_LINE
|
||||
import com.mogo.map.overlay.line.*
|
||||
import java.util.*
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
@@ -47,12 +49,16 @@ class AiRoadMarker {
|
||||
|
||||
private val roadMarker by lazy { V2XAiRoadEventMarker() }
|
||||
|
||||
private val line = AtomicReference<IMogoPolyline>()
|
||||
private val line = AtomicReference<Polyline>()
|
||||
|
||||
private val handler by lazy {
|
||||
Handler(Looper.getMainLooper())
|
||||
}
|
||||
|
||||
private val v2nDrawHandler by lazy {
|
||||
HandlerThread("v2n_draw_thread").let { it.start(); Handler(it.looper)}
|
||||
}
|
||||
|
||||
private val checkExpiredTask = Runnable {
|
||||
val poi = this.marker.get()
|
||||
val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
@@ -64,128 +70,118 @@ class AiRoadMarker {
|
||||
}
|
||||
}
|
||||
|
||||
private val options by lazy {
|
||||
MogoPolylineOptions().apply {
|
||||
zIndex(40000f)
|
||||
setGps(true)
|
||||
width(50f)
|
||||
useGradient(true)
|
||||
}
|
||||
private val builder by lazy {
|
||||
Polyline.Options.Builder(V2XConst.V2X_MARKER_OWNER, ROAD_CENTER_LINE).setIsGradient(true).setWidth(50f).setUseGps(true)
|
||||
}
|
||||
|
||||
fun marker(marker: Marker, drawMarker: Boolean, drawRoadLine: Boolean = false) {
|
||||
val location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
this.marker.set(marker)
|
||||
val wrapper = MarkerWrapper(marker.id, marker.poi_lon, marker.poi_lat, 1, null, null)
|
||||
if (drawMarker) {
|
||||
marker.entity?.apply { roadMarker.drawMarkers(this, wrapper) }
|
||||
}
|
||||
if (drawRoadLine) {
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(
|
||||
marker.poi_lon,
|
||||
marker.poi_lat,
|
||||
location.heading.toFloat(),
|
||||
300f
|
||||
)
|
||||
//施工中心点后方的自车行驶方向上300米距离
|
||||
Log.d(TAG, "--- marker --- 3 --- l1:$l1")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- l1:", l1)
|
||||
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(
|
||||
marker.poi_lon,
|
||||
marker.poi_lat,
|
||||
location.heading.toFloat(),
|
||||
-300f
|
||||
)
|
||||
if (l1.points.isEmpty() || l2.points.isEmpty()) {
|
||||
Log.d(TAG, " --- marker --- 3 --- return ----")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- return ----", "")
|
||||
return
|
||||
v2nDrawHandler.post {
|
||||
val location = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84()
|
||||
this.marker.set(marker)
|
||||
val wrapper = MarkerWrapper(marker.id, marker.poi_lon, marker.poi_lat, 1, null, null)
|
||||
if (drawMarker) {
|
||||
marker.entity?.apply { roadMarker.drawMarkers(this, wrapper) }
|
||||
}
|
||||
Log.d(TAG, " --- marker --- 4 --- l2: $l2")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 4 --- l2:", l2)
|
||||
val points = LinkedList<MogoLatLng>()
|
||||
if (l2 != null && l2.points.isNotEmpty()) {
|
||||
points.addAll(l2.points.reversed().map {
|
||||
MogoLatLng(it.second, it.first)
|
||||
})
|
||||
}
|
||||
val centerX = marker.poi_lon
|
||||
val centerY = marker.poi_lat
|
||||
Log.d(TAG, "--- marker --- 5 --- marker: $marker")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 5 --- marker:", marker)
|
||||
val farthestPoint = marker.polygon?.let {
|
||||
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.heading
|
||||
)
|
||||
if (angle < min) {
|
||||
min = angle
|
||||
find = p
|
||||
if (drawRoadLine) {
|
||||
Log.d(TAG, "--- marker --- 1 ---")
|
||||
//施工中心点前方的自车行驶方向上300米距离
|
||||
val l1 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(
|
||||
marker.poi_lon,
|
||||
marker.poi_lat,
|
||||
location.heading.toFloat(),
|
||||
300f
|
||||
)
|
||||
//施工中心点后方的自车行驶方向上300米距离
|
||||
Log.d(TAG, "--- marker --- 3 --- l1:$l1")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- l1:", l1)
|
||||
val l2 = MogoMap.getInstance().mogoMap.getCenterLineRangeInfo(
|
||||
marker.poi_lon,
|
||||
marker.poi_lat,
|
||||
location.heading.toFloat(),
|
||||
-300f
|
||||
)
|
||||
if (l1.points.isEmpty() || l2.points.isEmpty()) {
|
||||
Log.d(TAG, " --- marker --- 3 --- return ----")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 3 --- return ----", "")
|
||||
return@post
|
||||
}
|
||||
Log.d(TAG, " --- marker --- 4 --- l2: $l2")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 4 --- l2:", l2)
|
||||
val points = LinkedList<MogoLatLng>()
|
||||
if (l2 != null && l2.points.isNotEmpty()) {
|
||||
points.addAll(l2.points.reversed().map {
|
||||
MogoLatLng(it.second, it.first)
|
||||
})
|
||||
}
|
||||
val centerX = marker.poi_lon
|
||||
val centerY = marker.poi_lat
|
||||
Log.d(TAG, "--- marker --- 5 --- marker: $marker")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 5 --- marker:", marker)
|
||||
val farthestPoint = marker.polygon?.let {
|
||||
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.heading
|
||||
)
|
||||
if (angle < min) {
|
||||
min = angle
|
||||
find = p
|
||||
}
|
||||
}
|
||||
MogoLatLng(find.second, find.first)
|
||||
} ?: MogoLatLng(centerY, centerX)
|
||||
marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat)
|
||||
Log.d(TAG, "--- marker --- 6 --- marker:$marker")
|
||||
V2XBizTrace.onAck("$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.heading + 180)
|
||||
) < 90L
|
||||
) {
|
||||
points.add(l.let { MogoLatLng(it.second, it.first) })
|
||||
}
|
||||
}
|
||||
}
|
||||
MogoLatLng(find.second, find.first)
|
||||
} ?: MogoLatLng(centerY, centerX)
|
||||
marker.farthestPoint = Pair(farthestPoint.lon, farthestPoint.lat)
|
||||
Log.d(TAG, "--- marker --- 6 --- marker:$marker")
|
||||
V2XBizTrace.onAck("$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.heading + 180)
|
||||
) < 90L
|
||||
) {
|
||||
points.add(l.let { MogoLatLng(it.second, it.first) })
|
||||
}
|
||||
if (points.size <= 1) {
|
||||
return@post
|
||||
}
|
||||
val evaluator = ArgbEvaluator()
|
||||
val interceptor = DecelerateInterpolator(1.5f)
|
||||
val total = points.size
|
||||
val colors = ArrayList<Int>()
|
||||
(0..total).forEach { i ->
|
||||
colors += evaluator.evaluate(
|
||||
interceptor.getInterpolation(i * 1f / total),
|
||||
START_COLOR,
|
||||
END_COLOR
|
||||
) as Int
|
||||
}
|
||||
builder.points(points)
|
||||
builder.colors(colors)
|
||||
builder.setVisible(true)
|
||||
Log.d(TAG, "--- marker --- 7 --- points:${points.size}")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 7 --- points:", "${points.size}")
|
||||
val line = overlayManager?.showOrUpdateLine(builder.build())
|
||||
if (line != null) {
|
||||
this.line.set(line)
|
||||
wrapper.addLine(line)
|
||||
}
|
||||
}
|
||||
if (points.size <= 1) {
|
||||
return
|
||||
}
|
||||
val evaluator = ArgbEvaluator()
|
||||
val interceptor = DecelerateInterpolator(1.5f)
|
||||
val total = points.size
|
||||
val colors = ArrayList<Int>()
|
||||
(0..total).forEach { i ->
|
||||
colors += evaluator.evaluate(
|
||||
interceptor.getInterpolation(i * 1f / total),
|
||||
START_COLOR,
|
||||
END_COLOR
|
||||
) as Int
|
||||
}
|
||||
var line = line.get()
|
||||
options.points(points)
|
||||
options.colorValues(colors)
|
||||
Log.d(TAG, "--- marker --- 7 --- points:${points.size}")
|
||||
V2XBizTrace.onAck("$TAG --- marker --- 7 --- points:", "${points.size}")
|
||||
if (line == null || line.isDestroyed) {
|
||||
val l = overlayManager?.addPolyline(options)
|
||||
this.line.set(l)
|
||||
line = l
|
||||
} else {
|
||||
line.setOption(options)
|
||||
}
|
||||
if (!line.isVisible) {
|
||||
line.isVisible = true
|
||||
}
|
||||
if (line != null) {
|
||||
wrapper.addLine(line)
|
||||
wrapper.onRemoved = { id ->
|
||||
aiMakers.remove(id)
|
||||
}
|
||||
MarkerRemoveManager.addMarker(wrapper)
|
||||
}
|
||||
wrapper.onRemoved = { id ->
|
||||
aiMakers.remove(id)
|
||||
}
|
||||
MarkerRemoveManager.addMarker(wrapper)
|
||||
}
|
||||
|
||||
private fun removeLine() {
|
||||
@@ -196,19 +192,20 @@ class AiRoadMarker {
|
||||
Log.d(TAG,"--- removeRedLine --- 2")
|
||||
V2XBizTrace.onAck("$TAG --- removeRedLine --- 2", "")
|
||||
line.set(null)
|
||||
old.isVisible = false
|
||||
old.remove()
|
||||
old.delegate?.remove()
|
||||
}
|
||||
}
|
||||
|
||||
private fun unMarker(marker: Marker) {
|
||||
Log.d(TAG,"$TAG --- unMarker ---")
|
||||
V2XBizTrace.onAck("$TAG --- unMarker ---", "")
|
||||
this.marker.set(null)
|
||||
removeLine()
|
||||
roadMarker.removeMarkers()
|
||||
handler.removeCallbacks(checkExpiredTask)
|
||||
aiMakers.remove(marker.id)
|
||||
v2nDrawHandler.post {
|
||||
Log.d(TAG,"$TAG --- unMarker ---")
|
||||
V2XBizTrace.onAck("$TAG --- unMarker ---", "")
|
||||
this.marker.set(null)
|
||||
removeLine()
|
||||
roadMarker.removeMarkers()
|
||||
handler.removeCallbacks(checkExpiredTask)
|
||||
aiMakers.remove(marker.id)
|
||||
}
|
||||
}
|
||||
|
||||
fun receive() {
|
||||
|
||||
@@ -5,50 +5,50 @@ import com.mogo.eagle.core.data.enums.EventTypeEnumNew
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi.context
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi.v2xMarker
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper
|
||||
import com.mogo.map.marker.IMogoMarker
|
||||
import com.mogo.map.overlay.IMogoPolyline
|
||||
import com.mogo.map.overlay.MogoPolylineOptions
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.point.*
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
class V2XAiRoadEventMarker {
|
||||
|
||||
private val current = AtomicReference<Pair<IMogoPolyline?, List<IMogoMarker>?>>()
|
||||
|
||||
private val overlayManager by lazy { CallerMapUIServiceManager.getOverlayManager() }
|
||||
private val current = AtomicReference<Pair<Polyline?, List<Point>?>>()
|
||||
|
||||
fun drawMarkers(entity: V2XRoadEventEntity, wrapper: MarkerWrapper) {
|
||||
val polygon = entity.noveltyInfo.polygon
|
||||
v2xMarker()?.drawableAlarmPOI(context(), entity, null)?.also {
|
||||
wrapper.addMarker(it)
|
||||
}
|
||||
CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(
|
||||
Point.Options
|
||||
.Builder(V2XConst.V2X_MARKER_OWNER, Level.MAP_MARKER)
|
||||
.longitude(entity.location.lon)
|
||||
.latitude(entity.location.lat)
|
||||
.icon3DRes(EventTypeEnumNew.getMarker3DRes(entity.poiType))
|
||||
.set3DMode(true)
|
||||
.build())?.also { wrapper.addPoint(it) }
|
||||
if (polygon != null && polygon.isNotEmpty() && entity.poiType != EventTypeEnumNew.TYPE_SOCKET_ROAD_JINGZHI.poiType) {
|
||||
val options = MogoPolylineOptions()
|
||||
val builder = Polyline.Options.Builder(V2XConst.V2X_MARKER_OWNER, Level.MAP_POLYGON)
|
||||
val colors = ArrayList<Int>()
|
||||
colors.add(Color.argb(204, 237, 172, 21))
|
||||
colors.add(Color.argb(0, 255, 255, 255))
|
||||
options.colorValues(colors)
|
||||
builder.colors(colors)
|
||||
val points = ArrayList<MogoLatLng>()
|
||||
|
||||
for (p in polygon) {
|
||||
points.add(MogoLatLng(p.second, p.first))
|
||||
}
|
||||
if (points.size > 2) {
|
||||
points.add(points[0])
|
||||
}
|
||||
options.points(points)
|
||||
options.useGradient(true)
|
||||
options.useFacade(true)
|
||||
options.setGps(true)
|
||||
options.width(5f)
|
||||
options.zIndex(75000f)
|
||||
options.maxIndex(800000f)
|
||||
val line = overlayManager?.addPolyline(options)
|
||||
builder.points(points)
|
||||
builder.setIsGradient(true)
|
||||
builder.useFacade(true)
|
||||
builder.setUseGps(true)
|
||||
builder.setWidth(5f)
|
||||
builder.setMaxIndex(800000f)
|
||||
builder.setVisible(true)
|
||||
val line = CallerMapUIServiceManager.getOverlayManager()?.showOrUpdateLine(builder.build())
|
||||
line?.let {
|
||||
current.set(Pair(line, wrapper.markers))
|
||||
line.isVisible = true
|
||||
wrapper.addLine(line)
|
||||
}
|
||||
}
|
||||
@@ -61,15 +61,15 @@ class V2XAiRoadEventMarker {
|
||||
}
|
||||
}
|
||||
|
||||
private fun realRemove(pair: Pair<IMogoPolyline?, List<IMogoMarker>?>) {
|
||||
private fun realRemove(pair: Pair<Polyline?, List<Point>?>) {
|
||||
val line = pair.first
|
||||
if (line != null && line.isVisible) {
|
||||
line.remove()
|
||||
if (line != null) {
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removeLine(line.id)
|
||||
}
|
||||
val markers = pair.second
|
||||
if (markers != null && markers.isNotEmpty()) {
|
||||
for (m in markers) {
|
||||
m.remove()
|
||||
CallerMapUIServiceManager.getOverlayManager()?.removePoint(m.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,15 +7,17 @@ import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.function.biz.v2x.V2XBizTrace;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoV2XMarkerManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.consts.V2XConst;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerWrapper;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.remove.MarkerRemoveManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.airoad.AiRoadMarker;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.overlay.core.Level;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -30,8 +32,8 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
public void drawPOI(V2XRoadEventEntity entity) {
|
||||
try {
|
||||
// 清除道路事件
|
||||
IMoGoV2XMarkerManager marker = BridgeApi.INSTANCE.v2xMarker();
|
||||
if (marker != null) {
|
||||
IMoGoOverlayManager overlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (overlayManager != null) {
|
||||
if (entity != null) {
|
||||
V2XBizTrace.Companion.onAck("V2XRoadEventMarker -> poiType : ", entity.getPoiType());
|
||||
if (isAiRoadEvent(entity.getPoiType())) {
|
||||
@@ -47,11 +49,16 @@ public class V2XRoadEventMarker implements IV2XMarker<V2XRoadEventEntity> {
|
||||
AiRoadMarker.aiMakers.put(noveltyInfo.getInfoId(), aiMarker);
|
||||
}
|
||||
} else {
|
||||
IMogoMarker iMarker = marker.drawableAlarmPOI(BridgeApi.INSTANCE.context(), entity, null);
|
||||
if (iMarker != null) {
|
||||
Point point = overlayManager.showOrUpdatePoint(
|
||||
new Point.Options.Builder(V2XConst.V2X_MARKER_OWNER, Level.MAP_MARKER)
|
||||
.longitude(entity.getLocation().getLon())
|
||||
.latitude(entity.getLocation().getLat())
|
||||
.set3DMode(true)
|
||||
.icon3DRes(EventTypeEnumNew.getMarker3DRes(entity.getPoiType())).build());
|
||||
if (point != null) {
|
||||
V2XBizTrace.Companion.onAck("V2XRoadEventMarker -> --- add Marker type: ", entity.getPoiType());
|
||||
ArrayList<IMogoMarker> markers = new ArrayList<>();
|
||||
markers.add(iMarker);
|
||||
ArrayList<Point> markers = new ArrayList<>();
|
||||
markers.add(point);
|
||||
String id = entity.getLocation().getLon() + "_" + entity.getLocation().getLat();
|
||||
MarkerRemoveManager.INSTANCE.addMarker(new MarkerWrapper(id, entity.getLocation().getLon(), entity.getLocation().getLat(), 0, markers, null, null));
|
||||
} else {
|
||||
|
||||
@@ -7,9 +7,7 @@ import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.style.ForegroundColorSpan;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
|
||||
import com.mogo.eagle.core.data.enums.WarningDirectionEnum;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
@@ -25,7 +23,6 @@ import com.mogo.eagle.function.biz.v2x.v2n.scenario.impl.AbsV2XScenario;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.core.data.v2x.V2XWarningTarget;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -37,7 +34,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoChassisLocationGCJ02Listener, IMoGoWarningStatusListener {
|
||||
private static final String TAG = "V2XWarningMarker";
|
||||
private static final V2XWarningMarker sV2XWarningMarker = new V2XWarningMarker();
|
||||
// private static final V2XWarningMarker sV2XWarningMarker = new V2XWarningMarker();
|
||||
private V2XWarningTarget mMarkerEntity;
|
||||
|
||||
private WarningDirectionEnum mDirection;
|
||||
@@ -132,7 +129,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMoGoChas
|
||||
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
sV2XWarningMarker.onCarLocationChanged2(gnssInfo);
|
||||
// sV2XWarningMarker.onCarLocationChanged2(gnssInfo);
|
||||
}
|
||||
|
||||
private WarningDirectionEnum getDirection(){
|
||||
|
||||
@@ -1,446 +1,446 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.warning;
|
||||
|
||||
import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
|
||||
import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.module.status.MogoStatusManager;
|
||||
import com.mogo.commons.utils.Trigonometric;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager;
|
||||
import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
import com.mogo.eagle.core.data.v2x.V2XLocation;
|
||||
import com.mogo.eagle.core.data.v2x.V2XWarningTarget;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.marker.IMogoMarkerManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 前方预警marker打点 绘制安全线和预警线 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程,代码保留
|
||||
* @since: 2021/3/30
|
||||
*/
|
||||
public class V2XWarningMarker implements IV2XMarker {
|
||||
private static final String TAG = "V2XWarningMarker";
|
||||
private static final String WARNING_ARROWS = "WARNING_ARROWS";
|
||||
private V2XWarningTarget mCloundWarningInfo;
|
||||
private boolean isSelfLineClear = true;//绘制线是否已被清除
|
||||
private final List fillPoints = new ArrayList();//停止线经纬度合集
|
||||
private boolean isFirstLocation = false;
|
||||
private MogoLatLng carLocation = new MogoLatLng(
|
||||
CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude(),
|
||||
CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude()
|
||||
);
|
||||
|
||||
/*
|
||||
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng middleLocationInStopLine = new MogoLatLng(0, 0);
|
||||
private static long showTime = 6000;
|
||||
private double bearing;
|
||||
private boolean hasStopLines = false;
|
||||
|
||||
@Override
|
||||
public void drawPOI(Object entity) {
|
||||
try {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "===drawPOI");
|
||||
mCloundWarningInfo = (V2XWarningTarget) entity;
|
||||
drawLineWithEntity();
|
||||
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void drawLineWithEntity() {
|
||||
showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() * 1000 : 6000;
|
||||
fillPointOnStopLine();
|
||||
MogoLocation location = BridgeApi.INSTANCE.getLocation().get();
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
bearing = location.getHeading();
|
||||
|
||||
if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null) {
|
||||
hasStopLines = mCloundWarningInfo.getStopLines().size() > 0;
|
||||
}
|
||||
isSelfLineClear = false;
|
||||
isFirstLocation = false;
|
||||
if (fillPoints != null && fillPoints.size() > 0) {
|
||||
//存在停止线的情况 自车与停止线之间绘制蓝色安全线 停止线向前50m绘制红色预警线
|
||||
middleLocationInStopLine = getMiddleLocationInStopLine();
|
||||
//停止线前方画线
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
if (carLocation.lat != 0 && carLocation.lon != 0) {
|
||||
//在自车与停止线直线绘制蓝色预警线
|
||||
//衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
//drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
} else {
|
||||
}
|
||||
//二轮车和行人的渲染和移动
|
||||
IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
if (marker != null) {
|
||||
marker.removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
}
|
||||
|
||||
/* 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
//获取停止线前方50m坐标点
|
||||
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine,
|
||||
50, angleForCarMoveDirection());
|
||||
//停止线向前方50m绘制红色预警线
|
||||
drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine,
|
||||
warningLocation);
|
||||
|
||||
*/
|
||||
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderWarningMoveMarker(mCloundWarningInfo.getLon(), mCloundWarningInfo.getLat(), mCloundWarningInfo.getType(), mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon(), mCloundWarningInfo.getAngle(), mCloundWarningInfo.getShowTime());
|
||||
|
||||
//添加停止线marker
|
||||
//衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
//handleStopLine();
|
||||
}, 0);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "显示时间为++" + showTime + "识别物类型:" +
|
||||
String.valueOf(mCloundWarningInfo.getType()));
|
||||
|
||||
} else { //无停止线
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "无停止线");
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
/* 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "无停止线" + mCloundWarningInfo.toString());
|
||||
//绘制识别物与交汇点连线,并且更新连线数据
|
||||
drawOtherObjectLine(mCloundWarningInfo);
|
||||
//二轮车和行人的渲染和移动
|
||||
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
if (carLocation.lat != 0 && carLocation.lon != 0) {
|
||||
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "数据为空carLocation == null");
|
||||
}
|
||||
*/
|
||||
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderWarningMoveMarker(mCloundWarningInfo.getLon()
|
||||
, mCloundWarningInfo.getLat()
|
||||
, mCloundWarningInfo.getType()
|
||||
, mCloundWarningInfo.getCollisionLat()
|
||||
, mCloundWarningInfo.getCollisionLon()
|
||||
, mCloundWarningInfo.getAngle()
|
||||
, mCloundWarningInfo.getShowTime());
|
||||
}, 0);
|
||||
|
||||
}
|
||||
clearAllLine();
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* */
|
||||
public double angleForCarMoveDirection() {
|
||||
MogoLatLng startLatLng = new MogoLatLng(carLocation.lat, carLocation.lon);
|
||||
MogoLatLng endLatLng = new MogoLatLng(middleLocationInStopLine.lat, middleLocationInStopLine.lon);
|
||||
double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==" + String.valueOf(angle));
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
/*绘制停止线前方50m的红色预警线
|
||||
* startLatLng: 划线起点=停止线上的坐标点
|
||||
* mogoLatLng: 停止线前方50m坐标点
|
||||
* */
|
||||
private void drawRedWarningLineFrontOfStopLine(V2XWarningTarget info, MogoLatLng
|
||||
startLatLng, MogoLatLng mogoLatLng) {
|
||||
if (info != null) {
|
||||
double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, mogoLatLng.lon, mogoLatLng.lat);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==drawRedWarningLineFrontOfStopLine:" + String.valueOf(angle));
|
||||
IMoGoStopPolylineManager stopPolyLineMnager = BridgeApi.INSTANCE.v2xStopPolyline();
|
||||
if (stopPolyLineMnager != null) {
|
||||
IMogoPolyline polyLine = stopPolyLineMnager.getMogoStopPolyline();
|
||||
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng.lon, startLatLng.lat, 25, angle);
|
||||
if (polyLine != null) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "drawStopLine polyLine != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
|
||||
polyLine.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatLng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.getHeading());
|
||||
CallerLogger.INSTANCE.d(TAG, "drawStopLine width = " + info.getRoadwidth());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
stopPolyLineMnager.drawStopPolyline(BridgeApi.INSTANCE.context(), lineInfo);
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线前方50m区域的三个坐标点是:" + startLatLng.lon + "," + startLatLng.lat +
|
||||
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
|
||||
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
|
||||
}
|
||||
} else {
|
||||
clearAllLine();
|
||||
}
|
||||
}
|
||||
|
||||
public void clearAllLine() {
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "清除所有预警线的时间是:" + String.valueOf(showTime));
|
||||
//清除识别物到碰撞点预警线
|
||||
IMoGoPersonWarnPolylineManager personStopPolyLineManager = BridgeApi.INSTANCE.v2xPersonWarnPolyline();
|
||||
if (personStopPolyLineManager != null) {
|
||||
personStopPolyLineManager.clearLine();
|
||||
}
|
||||
//清除车前方第一条预警线
|
||||
IMoGoWarnPolylineManager warnPolyLineManager = BridgeApi.INSTANCE.v2xWarnPolyline();
|
||||
if (warnPolyLineManager != null) {
|
||||
warnPolyLineManager.clearLine();
|
||||
}
|
||||
//清除停止线
|
||||
IMoGoStopPolylineManager stopPolyLineManager = BridgeApi.INSTANCE.v2xStopPolyline();
|
||||
if (stopPolyLineManager != null) {
|
||||
stopPolyLineManager.clearLine();
|
||||
}
|
||||
|
||||
IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
if (marker != null) {
|
||||
//清除小箭头
|
||||
marker.removeMarkers(WARNING_ARROWS);
|
||||
//清除停止线
|
||||
marker.removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
}
|
||||
|
||||
isSelfLineClear = true;
|
||||
}, showTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* 补点后的停止线经纬度合集
|
||||
*/
|
||||
public void fillPointOnStopLine() {
|
||||
try {
|
||||
fillPoints.clear();
|
||||
List stopLines = mCloundWarningInfo.getStopLines();
|
||||
if (stopLines != null && stopLines.size() > 1) {
|
||||
V2XLocation x = mCloundWarningInfo.getStopLines().get(0);
|
||||
V2XLocation y = mCloundWarningInfo.getStopLines().get(1);
|
||||
//两点间的距离
|
||||
float distance = CoordinateUtils.calculateLineDistance(x.getLon(), x.getLat(), y.getLon(), y.getLat());
|
||||
float average = distance / 3;
|
||||
//两点间的角度
|
||||
double angle = Trigonometric.getAngle(x.getLon(), x.getLat(), y.getLon(), y.getLat());
|
||||
//根据距离和角度获取下个点的经纬度
|
||||
fillPoints.add(x);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(x.getLon(), x.getLat(), average * i, angle);
|
||||
fillPoints.add(newLocation);
|
||||
}
|
||||
fillPoints.add(y);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线数据不存在");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CallerLogger.INSTANCE.e(M_V2X + TAG, "exception : " + e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 停止线绘制
|
||||
* */
|
||||
private void handleStopLine() {
|
||||
try {
|
||||
if (mCloundWarningInfo != null) {
|
||||
IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
if (marker != null) {
|
||||
marker.removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
}
|
||||
for (int i = 0; i < fillPoints.size(); i++) {
|
||||
V2XWarningTarget entity = new V2XWarningTarget();
|
||||
MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
|
||||
entity.setLat(latLng.lat);
|
||||
entity.setLon(latLng.lon);
|
||||
entity.setHeading(mCloundWarningInfo.getHeading());
|
||||
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderStopLineMarker(entity.getLon(), entity.getLat());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng.lon, latlng.lat, mCloundWarningInfo.getStopLineDistance(),
|
||||
mCloundWarningInfo.getAngle());
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/*
|
||||
* 自车前方的点,落点在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
* */
|
||||
private MogoLatLng getMiddleLocationInStopLine() {
|
||||
if (carLocation.lat == 0 || carLocation.lon == 0) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "获取不到车的位置");
|
||||
}
|
||||
MogoLatLng newLocation = new MogoLatLng(0, 0);
|
||||
if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null && mCloundWarningInfo.getStopLines().size() > 1) {
|
||||
V2XLocation x = mCloundWarningInfo.getStopLines().get(0);
|
||||
V2XLocation y = mCloundWarningInfo.getStopLines().get(1);
|
||||
float distance = CoordinateUtils.calculateLineDistance(x.getLon(), x.getLat(), y.getLat(), y.getLat());
|
||||
double angle = Trigonometric.getAngle(x.getLat(), x.getLat(), y.getLon(), y.getLat());
|
||||
newLocation = Trigonometric.getNewLocation(x.getLon(), x.getLat(), distance * 0.5, angle);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线返回坐标点数量不正确" + mCloundWarningInfo.getStopLines().size());
|
||||
}
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
/**
|
||||
* 存在停止线时自车与停止线之间为蓝色预警
|
||||
* 不存在停止线,自车与预碰撞点之间为红色预警
|
||||
* lon 自车经度
|
||||
* lat 自车纬度
|
||||
*/
|
||||
public void drawSelfCarLine(double lon, double lat, float bearing) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "drawSelfCarLine");
|
||||
if (!isSelfLineClear) {
|
||||
if (mCloundWarningInfo != null) {
|
||||
IMoGoWarnPolylineManager warnPolyLineManager = BridgeApi.INSTANCE.v2xWarnPolyline();
|
||||
if (warnPolyLineManager == null) {
|
||||
return;
|
||||
}
|
||||
IMogoPolyline mogoPolyline = warnPolyLineManager.getMogoWarnPolyline();
|
||||
MogoLatLng startLatlng = new MogoLatLng(0, 0);
|
||||
MogoLatLng endLatlng = new MogoLatLng(0, 0);
|
||||
MogoLatLng addMiddleLoc = new MogoLatLng(0, 0);
|
||||
|
||||
if (!isFirstLocation) {
|
||||
carLocation = getMogoLat(new MogoLatLng(lat, lon));
|
||||
isFirstLocation = true;
|
||||
}
|
||||
//绘制线的终点(在停止线上或者预碰撞点上)
|
||||
endLatlng = new MogoLatLng(hasStopLines ?
|
||||
middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(), hasStopLines ?
|
||||
middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
|
||||
|
||||
startLatlng = new MogoLatLng(lat, lon);
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
//扩展点为了渐变色添加
|
||||
addMiddleLoc = Trigonometric.getNewLocation(startLatlng.getLon(), startLatlng.getLat(), distance / 2,
|
||||
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==扩展点为了渐变色添加:" +
|
||||
String.valueOf(Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat)));
|
||||
if (mogoPolyline != null) {
|
||||
mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
mogoPolyline.setTransparency(0.5f);
|
||||
} else {
|
||||
DrawLineInfo info = new DrawLineInfo(); // 对象
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatlng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
info.setLocations(locations);
|
||||
info.setHeading(bearing);
|
||||
info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
|
||||
if (mCloundWarningInfo.getStopLines() != null) {
|
||||
info.setHasStopLines(mCloundWarningInfo.getStopLines().size() > 0);
|
||||
}
|
||||
warnPolyLineManager.drawWarnPolyline(BridgeApi.INSTANCE.context(), info);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "自车前方第一条线" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
|
||||
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
|
||||
} else {
|
||||
clearAllLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 侧方目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
|
||||
*/
|
||||
private void drawOtherObjectLine(V2XWarningTarget info) {
|
||||
if (info != null) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "info != null");
|
||||
IMoGoPersonWarnPolylineManager personWarnPolylineManager = BridgeApi.INSTANCE.v2xPersonWarnPolyline();
|
||||
if (personWarnPolylineManager == null) {
|
||||
return;
|
||||
}
|
||||
IMogoPolyline polyLine = personWarnPolylineManager.getMogoPersonWarnPolyline();
|
||||
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());//识别物坐标
|
||||
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());//预碰撞点坐标
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);//识别物到碰撞点之间的距离
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng.getLon(), startLatlng.getLat(), distance / 2,
|
||||
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));//补点
|
||||
if (polyLine != null) {
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "目标物与碰撞点连线 != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
polyLine.setTransparency(0.5f);
|
||||
} else {
|
||||
//识别物到预碰撞点之间的箭头
|
||||
addArrows(startLatlng, endLatlng);
|
||||
DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
List locations = new ArrayList();
|
||||
locations.add(startLatlng);
|
||||
locations.add(addMiddleLoc);
|
||||
locations.add(endLatlng);
|
||||
lineInfo.setLocations(locations);
|
||||
lineInfo.setHeading(info.getHeading());
|
||||
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
personWarnPolylineManager.drawPersonWarnPolyline(BridgeApi.INSTANCE.context(), lineInfo);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
}
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_V2X + TAG, "info == null");
|
||||
clearAllLine();
|
||||
}
|
||||
}
|
||||
|
||||
//侧面目标物与碰撞点之间添加多个小箭头
|
||||
private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
|
||||
float distance = CoordinateUtils.calculateLineDistance(
|
||||
startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
double rotate = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "添加小箭头--目标物与预碰撞点之间的距离是" + String.valueOf(distance));
|
||||
if (distance > 5) {
|
||||
int count = (int) (distance / 5);
|
||||
for (int i = 0; i < count; i++) {
|
||||
MogoLatLng newLo = Trigonometric.getNewLocation(
|
||||
startLatLng.getLon(), startLatLng.getLat(), 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat));
|
||||
Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue());
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "小箭头位置" + newLo);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//线随车动
|
||||
public void onCarLocationChanged2(MogoLocation latLng) {
|
||||
carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
if (MogoStatusManager.getInstance().isVrMode() && !isSelfLineClear) {
|
||||
if (mCloundWarningInfo != null) {
|
||||
V2XLocation v2XLocation = new V2XLocation();
|
||||
v2XLocation.setLat(latLng.getLatitude());
|
||||
v2XLocation.setLon(latLng.getLongitude());
|
||||
mCloundWarningInfo.setCarLocation(v2XLocation);
|
||||
}
|
||||
//衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
//drawSelfCarLine(latLng.getLongitude(), latLng.getLatitude(), latLng.getBearing());
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_V2X + TAG, "车辆行驶轨迹" + latLng.getLongitude() + "," + latLng.getLatitude());
|
||||
}
|
||||
}
|
||||
//package com.mogo.eagle.function.biz.v2x.v2n.scenario.scene.warning;
|
||||
//
|
||||
//import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_STOP_LINE_DATA;
|
||||
//import static com.mogo.eagle.core.data.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
|
||||
//import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
//
|
||||
//import com.mogo.commons.AbsMogoApplication;
|
||||
//import com.mogo.commons.module.status.MogoStatusManager;
|
||||
//import com.mogo.commons.utils.Trigonometric;
|
||||
//import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
//import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
//import com.mogo.eagle.core.data.v2x.DrawLineInfo;
|
||||
//import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager;
|
||||
//import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
//import com.mogo.eagle.function.biz.v2x.v2n.bridge.BridgeApi;
|
||||
//import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoPersonWarnPolylineManager;
|
||||
//import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoStopPolylineManager;
|
||||
//import com.mogo.eagle.function.biz.v2x.v2n.manager.IMoGoWarnPolylineManager;
|
||||
//import com.mogo.eagle.function.biz.v2x.v2n.scenario.view.IV2XMarker;
|
||||
//import com.mogo.eagle.core.data.v2x.V2XLocation;
|
||||
//import com.mogo.eagle.core.data.v2x.V2XWarningTarget;
|
||||
//import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
//import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
|
||||
//import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
//import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
//import com.mogo.map.marker.IMogoMarkerManager;
|
||||
//import com.mogo.map.overlay.IMogoPolyline;
|
||||
//
|
||||
//import java.util.ArrayList;
|
||||
//import java.util.Arrays;
|
||||
//import java.util.List;
|
||||
//import java.util.Objects;
|
||||
//
|
||||
///**
|
||||
// * @author liujing
|
||||
// * @description 前方预警marker打点 绘制安全线和预警线 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程,代码保留
|
||||
// * @since: 2021/3/30
|
||||
// */
|
||||
//public class V2XWarningMarker implements IV2XMarker {
|
||||
// private static final String TAG = "V2XWarningMarker";
|
||||
// private static final String WARNING_ARROWS = "WARNING_ARROWS";
|
||||
// private V2XWarningTarget mCloundWarningInfo;
|
||||
// private boolean isSelfLineClear = true;//绘制线是否已被清除
|
||||
// private final List fillPoints = new ArrayList();//停止线经纬度合集
|
||||
// private boolean isFirstLocation = false;
|
||||
// private MogoLatLng carLocation = new MogoLatLng(
|
||||
// CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude(),
|
||||
// CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude()
|
||||
// );
|
||||
//
|
||||
// /*
|
||||
// * 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
// * */
|
||||
// private MogoLatLng middleLocationInStopLine = new MogoLatLng(0, 0);
|
||||
// private static long showTime = 6000;
|
||||
// private double bearing;
|
||||
// private boolean hasStopLines = false;
|
||||
//
|
||||
// @Override
|
||||
// public void drawPOI(Object entity) {
|
||||
// try {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "===drawPOI");
|
||||
// mCloundWarningInfo = (V2XWarningTarget) entity;
|
||||
// drawLineWithEntity();
|
||||
//
|
||||
// } catch (Exception e) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, e.toString());
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// public void drawLineWithEntity() {
|
||||
// showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() * 1000 : 6000;
|
||||
// fillPointOnStopLine();
|
||||
// MogoLocation location = BridgeApi.INSTANCE.getLocation().get();
|
||||
// if (location == null) {
|
||||
// return;
|
||||
// }
|
||||
// bearing = location.getHeading();
|
||||
//
|
||||
// if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null) {
|
||||
// hasStopLines = mCloundWarningInfo.getStopLines().size() > 0;
|
||||
// }
|
||||
// isSelfLineClear = false;
|
||||
// isFirstLocation = false;
|
||||
// if (fillPoints.size() > 0) {
|
||||
// //存在停止线的情况 自车与停止线之间绘制蓝色安全线 停止线向前50m绘制红色预警线
|
||||
// middleLocationInStopLine = getMiddleLocationInStopLine();
|
||||
// //停止线前方画线
|
||||
// WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
// if (carLocation.lat != 0 && carLocation.lon != 0) {
|
||||
// //在自车与停止线直线绘制蓝色预警线
|
||||
// //衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
// //drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
// } else {
|
||||
// }
|
||||
// //二轮车和行人的渲染和移动
|
||||
// IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
// if (marker != null) {
|
||||
// marker.removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
// }
|
||||
//
|
||||
// /* 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
// //获取停止线前方50m坐标点
|
||||
// MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine,
|
||||
// 50, angleForCarMoveDirection());
|
||||
// //停止线向前方50m绘制红色预警线
|
||||
// drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine,
|
||||
// warningLocation);
|
||||
//
|
||||
// */
|
||||
// Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderWarningMoveMarker(mCloundWarningInfo.getLon(), mCloundWarningInfo.getLat(), mCloundWarningInfo.getType(), mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon(), mCloundWarningInfo.getAngle(), mCloundWarningInfo.getShowTime());
|
||||
//
|
||||
// //添加停止线marker
|
||||
// //衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
// //handleStopLine();
|
||||
// }, 0);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "显示时间为++" + showTime + "识别物类型:" +
|
||||
// String.valueOf(mCloundWarningInfo.getType()));
|
||||
//
|
||||
// } else { //无停止线
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "无停止线");
|
||||
// WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
// /* 衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "无停止线" + mCloundWarningInfo.toString());
|
||||
// //绘制识别物与交汇点连线,并且更新连线数据
|
||||
// drawOtherObjectLine(mCloundWarningInfo);
|
||||
// //二轮车和行人的渲染和移动
|
||||
// V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
// if (carLocation.lat != 0 && carLocation.lon != 0) {
|
||||
// drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
||||
// } else {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "数据为空carLocation == null");
|
||||
// }
|
||||
// */
|
||||
// Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderWarningMoveMarker(mCloundWarningInfo.getLon()
|
||||
// , mCloundWarningInfo.getLat()
|
||||
// , mCloundWarningInfo.getType()
|
||||
// , mCloundWarningInfo.getCollisionLat()
|
||||
// , mCloundWarningInfo.getCollisionLon()
|
||||
// , mCloundWarningInfo.getAngle()
|
||||
// , mCloundWarningInfo.getShowTime());
|
||||
// }, 0);
|
||||
//
|
||||
// }
|
||||
// clearAllLine();
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// *
|
||||
// * */
|
||||
// public double angleForCarMoveDirection() {
|
||||
// MogoLatLng startLatLng = new MogoLatLng(carLocation.lat, carLocation.lon);
|
||||
// MogoLatLng endLatLng = new MogoLatLng(middleLocationInStopLine.lat, middleLocationInStopLine.lon);
|
||||
// double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==" + String.valueOf(angle));
|
||||
// return angle;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /*绘制停止线前方50m的红色预警线
|
||||
// * startLatLng: 划线起点=停止线上的坐标点
|
||||
// * mogoLatLng: 停止线前方50m坐标点
|
||||
// * */
|
||||
// private void drawRedWarningLineFrontOfStopLine(V2XWarningTarget info, MogoLatLng
|
||||
// startLatLng, MogoLatLng mogoLatLng) {
|
||||
// if (info != null) {
|
||||
// double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, mogoLatLng.lon, mogoLatLng.lat);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==drawRedWarningLineFrontOfStopLine:" + String.valueOf(angle));
|
||||
// IMoGoStopPolylineManager stopPolyLineMnager = BridgeApi.INSTANCE.v2xStopPolyline();
|
||||
// if (stopPolyLineMnager != null) {
|
||||
// IMogoPolyline polyLine = stopPolyLineMnager.getMogoStopPolyline();
|
||||
// MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
|
||||
// MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng.lon, startLatLng.lat, 25, angle);
|
||||
// if (polyLine != null) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "drawStopLine polyLine != null");
|
||||
// polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
|
||||
// polyLine.setTransparency(0.5f);
|
||||
// } else {
|
||||
// DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
// List locations = new ArrayList();
|
||||
// locations.add(startLatLng);
|
||||
// locations.add(addMiddleLoc);
|
||||
// locations.add(endLatlng);
|
||||
// lineInfo.setLocations(locations);
|
||||
// lineInfo.setHeading(info.getHeading());
|
||||
// CallerLogger.INSTANCE.d(TAG, "drawStopLine width = " + info.getRoadwidth());
|
||||
// lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
// stopPolyLineMnager.drawStopPolyline(BridgeApi.INSTANCE.context(), lineInfo);
|
||||
// }
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线前方50m区域的三个坐标点是:" + startLatLng.lon + "," + startLatLng.lat +
|
||||
// "中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
|
||||
// + "终点" + endLatlng.lon + "," + endLatlng.lat);
|
||||
// }
|
||||
// } else {
|
||||
// clearAllLine();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void clearAllLine() {
|
||||
// UiThreadHandler.postDelayed(() -> {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "清除所有预警线的时间是:" + String.valueOf(showTime));
|
||||
// //清除识别物到碰撞点预警线
|
||||
// IMoGoPersonWarnPolylineManager personStopPolyLineManager = BridgeApi.INSTANCE.v2xPersonWarnPolyline();
|
||||
// if (personStopPolyLineManager != null) {
|
||||
// personStopPolyLineManager.clearLine();
|
||||
// }
|
||||
// //清除车前方第一条预警线
|
||||
// IMoGoWarnPolylineManager warnPolyLineManager = BridgeApi.INSTANCE.v2xWarnPolyline();
|
||||
// if (warnPolyLineManager != null) {
|
||||
// warnPolyLineManager.clearLine();
|
||||
// }
|
||||
// //清除停止线
|
||||
// IMoGoStopPolylineManager stopPolyLineManager = BridgeApi.INSTANCE.v2xStopPolyline();
|
||||
// if (stopPolyLineManager != null) {
|
||||
// stopPolyLineManager.clearLine();
|
||||
// }
|
||||
//
|
||||
// IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
// if (marker != null) {
|
||||
// //清除小箭头
|
||||
// marker.removeMarkers(WARNING_ARROWS);
|
||||
// //清除停止线
|
||||
// marker.removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
// }
|
||||
//
|
||||
// isSelfLineClear = true;
|
||||
// }, showTime);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 补点后的停止线经纬度合集
|
||||
// */
|
||||
// public void fillPointOnStopLine() {
|
||||
// try {
|
||||
// fillPoints.clear();
|
||||
// List stopLines = mCloundWarningInfo.getStopLines();
|
||||
// if (stopLines != null && stopLines.size() > 1) {
|
||||
// V2XLocation x = mCloundWarningInfo.getStopLines().get(0);
|
||||
// V2XLocation y = mCloundWarningInfo.getStopLines().get(1);
|
||||
// //两点间的距离
|
||||
// float distance = CoordinateUtils.calculateLineDistance(x.getLon(), x.getLat(), y.getLon(), y.getLat());
|
||||
// float average = distance / 3;
|
||||
// //两点间的角度
|
||||
// double angle = Trigonometric.getAngle(x.getLon(), x.getLat(), y.getLon(), y.getLat());
|
||||
// //根据距离和角度获取下个点的经纬度
|
||||
// fillPoints.add(x);
|
||||
// for (int i = 1; i < 3; i++) {
|
||||
// MogoLatLng newLocation = Trigonometric.getNewLocation(x.getLon(), x.getLat(), average * i, angle);
|
||||
// fillPoints.add(newLocation);
|
||||
// }
|
||||
// fillPoints.add(y);
|
||||
// } else {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线数据不存在");
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// CallerLogger.INSTANCE.e(M_V2X + TAG, "exception : " + e);
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// * 停止线绘制
|
||||
// * */
|
||||
// private void handleStopLine() {
|
||||
// try {
|
||||
// if (mCloundWarningInfo != null) {
|
||||
// IMogoMarkerManager marker = CallerMapUIServiceManager.INSTANCE.getMarkerManager(AbsMogoApplication.getApp());
|
||||
// if (marker != null) {
|
||||
// marker.removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA);
|
||||
// }
|
||||
// for (int i = 0; i < fillPoints.size(); i++) {
|
||||
// V2XWarningTarget entity = new V2XWarningTarget();
|
||||
// MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
|
||||
// entity.setLat(latLng.lat);
|
||||
// entity.setLon(latLng.lon);
|
||||
// entity.setHeading(mCloundWarningInfo.getHeading());
|
||||
// Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).renderStopLineMarker(entity.getLon(), entity.getLat());
|
||||
// }
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
||||
// MogoLatLng newLocation = Trigonometric.getNewLocation(latlng.lon, latlng.lat, mCloundWarningInfo.getStopLineDistance(),
|
||||
// mCloundWarningInfo.getAngle());
|
||||
// return newLocation;
|
||||
// }
|
||||
//
|
||||
// /*
|
||||
// * 自车前方的点,落点在停止线上--通过自车位置与距离停止线之间的距离计算
|
||||
// * */
|
||||
// private MogoLatLng getMiddleLocationInStopLine() {
|
||||
// if (carLocation.lat == 0 || carLocation.lon == 0) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "获取不到车的位置");
|
||||
// }
|
||||
// MogoLatLng newLocation = new MogoLatLng(0, 0);
|
||||
// if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null && mCloundWarningInfo.getStopLines().size() > 1) {
|
||||
// V2XLocation x = mCloundWarningInfo.getStopLines().get(0);
|
||||
// V2XLocation y = mCloundWarningInfo.getStopLines().get(1);
|
||||
// float distance = CoordinateUtils.calculateLineDistance(x.getLon(), x.getLat(), y.getLat(), y.getLat());
|
||||
// double angle = Trigonometric.getAngle(x.getLat(), x.getLat(), y.getLon(), y.getLat());
|
||||
// newLocation = Trigonometric.getNewLocation(x.getLon(), x.getLat(), distance * 0.5, angle);
|
||||
// } else {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线返回坐标点数量不正确" + mCloundWarningInfo.getStopLines().size());
|
||||
// }
|
||||
// return newLocation;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 存在停止线时自车与停止线之间为蓝色预警
|
||||
// * 不存在停止线,自车与预碰撞点之间为红色预警
|
||||
// * lon 自车经度
|
||||
// * lat 自车纬度
|
||||
// */
|
||||
// public void drawSelfCarLine(double lon, double lat, float bearing) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "drawSelfCarLine");
|
||||
// if (!isSelfLineClear) {
|
||||
// if (mCloundWarningInfo != null) {
|
||||
// IMoGoWarnPolylineManager warnPolyLineManager = BridgeApi.INSTANCE.v2xWarnPolyline();
|
||||
// if (warnPolyLineManager == null) {
|
||||
// return;
|
||||
// }
|
||||
// IMogoPolyline mogoPolyline = warnPolyLineManager.getMogoWarnPolyline();
|
||||
// MogoLatLng startLatlng = new MogoLatLng(0, 0);
|
||||
// MogoLatLng endLatlng = new MogoLatLng(0, 0);
|
||||
// MogoLatLng addMiddleLoc = new MogoLatLng(0, 0);
|
||||
//
|
||||
// if (!isFirstLocation) {
|
||||
// carLocation = getMogoLat(new MogoLatLng(lat, lon));
|
||||
// isFirstLocation = true;
|
||||
// }
|
||||
// //绘制线的终点(在停止线上或者预碰撞点上)
|
||||
// endLatlng = new MogoLatLng(hasStopLines ?
|
||||
// middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(), hasStopLines ?
|
||||
// middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
|
||||
//
|
||||
// startLatlng = new MogoLatLng(lat, lon);
|
||||
// float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
// //扩展点为了渐变色添加
|
||||
// addMiddleLoc = Trigonometric.getNewLocation(startLatlng.getLon(), startLatlng.getLat(), distance / 2,
|
||||
// Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==扩展点为了渐变色添加:" +
|
||||
// String.valueOf(Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat)));
|
||||
// if (mogoPolyline != null) {
|
||||
// mogoPolyline.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
// mogoPolyline.setTransparency(0.5f);
|
||||
// } else {
|
||||
// DrawLineInfo info = new DrawLineInfo(); // 对象
|
||||
// List locations = new ArrayList();
|
||||
// locations.add(startLatlng);
|
||||
// locations.add(addMiddleLoc);
|
||||
// locations.add(endLatlng);
|
||||
// info.setLocations(locations);
|
||||
// info.setHeading(bearing);
|
||||
// info.setWidth(mCloundWarningInfo.getRoadwidth() * 14 + 5);
|
||||
// if (mCloundWarningInfo.getStopLines() != null) {
|
||||
// info.setHasStopLines(mCloundWarningInfo.getStopLines().size() > 0);
|
||||
// }
|
||||
// warnPolyLineManager.drawWarnPolyline(BridgeApi.INSTANCE.context(), info);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "自车前方第一条线" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
// }
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
|
||||
// "中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
|
||||
// } else {
|
||||
// clearAllLine();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 侧方目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
|
||||
// */
|
||||
// private void drawOtherObjectLine(V2XWarningTarget info) {
|
||||
// if (info != null) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "info != null");
|
||||
// IMoGoPersonWarnPolylineManager personWarnPolylineManager = BridgeApi.INSTANCE.v2xPersonWarnPolyline();
|
||||
// if (personWarnPolylineManager == null) {
|
||||
// return;
|
||||
// }
|
||||
// IMogoPolyline polyLine = personWarnPolylineManager.getMogoPersonWarnPolyline();
|
||||
// MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());//识别物坐标
|
||||
// MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());//预碰撞点坐标
|
||||
// float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);//识别物到碰撞点之间的距离
|
||||
// MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng.getLon(), startLatlng.getLat(), distance / 2,
|
||||
// Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));//补点
|
||||
// if (polyLine != null) {
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "目标物与碰撞点连线 != null");
|
||||
// polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
// polyLine.setTransparency(0.5f);
|
||||
// } else {
|
||||
// //识别物到预碰撞点之间的箭头
|
||||
// addArrows(startLatlng, endLatlng);
|
||||
// DrawLineInfo lineInfo = new DrawLineInfo();
|
||||
// List locations = new ArrayList();
|
||||
// locations.add(startLatlng);
|
||||
// locations.add(addMiddleLoc);
|
||||
// locations.add(endLatlng);
|
||||
// lineInfo.setLocations(locations);
|
||||
// lineInfo.setHeading(info.getHeading());
|
||||
// lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
||||
// personWarnPolylineManager.drawPersonWarnPolyline(BridgeApi.INSTANCE.context(), lineInfo);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng);
|
||||
// }
|
||||
// } else {
|
||||
// CallerLogger.INSTANCE.e(M_V2X + TAG, "info == null");
|
||||
// clearAllLine();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// //侧面目标物与碰撞点之间添加多个小箭头
|
||||
// private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
|
||||
// float distance = CoordinateUtils.calculateLineDistance(
|
||||
// startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
// double rotate = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "添加小箭头--目标物与预碰撞点之间的距离是" + String.valueOf(distance));
|
||||
// if (distance > 5) {
|
||||
// int count = (int) (distance / 5);
|
||||
// for (int i = 0; i < count; i++) {
|
||||
// MogoLatLng newLo = Trigonometric.getNewLocation(
|
||||
// startLatLng.getLon(), startLatLng.getLat(), 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat));
|
||||
// Objects.requireNonNull(CallerMapUIServiceManager.INSTANCE.getMarkerService()).drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue());
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "小箭头位置" + newLo);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// //线随车动
|
||||
// public void onCarLocationChanged2(MogoLocation latLng) {
|
||||
// carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
|
||||
// if (MogoStatusManager.getInstance().isVrMode() && !isSelfLineClear) {
|
||||
// if (mCloundWarningInfo != null) {
|
||||
// V2XLocation v2XLocation = new V2XLocation();
|
||||
// v2XLocation.setLat(latLng.getLatitude());
|
||||
// v2XLocation.setLon(latLng.getLongitude());
|
||||
// mCloundWarningInfo.setCarLocation(v2XLocation);
|
||||
// }
|
||||
// //衡阳交付-取消划线需求,只渲染识别物红色模型移动过程
|
||||
// //drawSelfCarLine(latLng.getLongitude(), latLng.getLatitude(), latLng.getBearing());
|
||||
// }
|
||||
// CallerLogger.INSTANCE.d(M_V2X + TAG, "车辆行驶轨迹" + latLng.getLongitude() + "," + latLng.getLatitude());
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.mogo.eagle.function.biz.v2x.v2n.utils
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.utilcode.util.WindowUtils
|
||||
|
||||
class MapUtils {
|
||||
|
||||
companion object {
|
||||
|
||||
@JvmStatic
|
||||
fun zoomMap(latLng: MogoLatLng?, context: Context) {
|
||||
try {
|
||||
if (latLng == null) {
|
||||
return
|
||||
}
|
||||
val mBoundRect = Rect()
|
||||
mBoundRect.bottom = WindowUtils.dip2px(context, 100f)
|
||||
mBoundRect.top = WindowUtils.dip2px(context, 370f)
|
||||
mBoundRect.left = WindowUtils.dip2px(context, 575f)
|
||||
mBoundRect.right = WindowUtils.dip2px(context, 100f)
|
||||
// 当前车辆位置
|
||||
val carLocation = MogoLatLng(
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().latitude,
|
||||
CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84().longitude
|
||||
)
|
||||
// 调整自适应的地图镜头
|
||||
CallerMapUIServiceManager.getMapUIController()
|
||||
?.showBounds("MapUtils", carLocation, listOf(latLng), mBoundRect, true)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user