[8.0.0][opt]调整预测的数据和绘制逻辑
This commit is contained in:
@@ -4,6 +4,7 @@ import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.yycp.api.proto.SocketDownData
|
||||
import prediction2025.Prediction2025
|
||||
|
||||
interface Identify {
|
||||
|
||||
@@ -19,6 +20,14 @@ interface Identify {
|
||||
|
||||
}
|
||||
|
||||
fun renderPredictionResult(predictionObjectList: List<Prediction2025.mPredictionObjectApp>?) {
|
||||
|
||||
}
|
||||
|
||||
fun renderPredictionResult(predictionObjectList: List<Prediction2025.mPredictionObjectApp>?, mapInstance:String) {
|
||||
|
||||
}
|
||||
|
||||
fun renderPlanningWarningObj(planningObjects: List<MessagePad.PlanningObject>?) {
|
||||
|
||||
}
|
||||
@@ -34,4 +43,8 @@ interface Identify {
|
||||
fun clearAiMarker(mapInstance:String) {
|
||||
|
||||
}
|
||||
|
||||
fun clearPredictionMarker(mapInstance:String) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.mogo.eagle.core.function.business.identify
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Message
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener
|
||||
@@ -14,6 +15,7 @@ import com.zhjt.service.chain.ChainLog
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.yycp.api.proto.SocketDownData
|
||||
import prediction2025.Prediction2025
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConfigListener {
|
||||
@@ -31,21 +33,25 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
|
||||
// 预测
|
||||
object PreDriverIdentify {
|
||||
internal val preDataDrawer = IdentifyNewDataDrawer()
|
||||
internal val preDataDrawer2 = IdentifyNewDataDrawer()
|
||||
internal val preDataDrawer3 = IdentifyNewDataDrawer()
|
||||
internal val preDataDrawer = IdentifyPredictionDataDrawer()
|
||||
// internal val preDataDrawer2 = IdentifyPredictionDataDrawer()
|
||||
// internal val preDataDrawer3 = IdentifyPredictionDataDrawer()
|
||||
internal val preDataDrawer2 = IdentifyOriginDataDrawer()
|
||||
internal val preDataDrawer3 = IdentifyOriginDataDrawer()
|
||||
}
|
||||
|
||||
// 决策
|
||||
object DesDriverIdentify {
|
||||
internal val desDataDrawer = IdentifyNewDataDrawer()
|
||||
internal val desDataDrawer = IdentifyOriginDataDrawer()
|
||||
}
|
||||
|
||||
private var identify: Identify = DriverIdentify.originDataDrawer
|
||||
private var aiCloudIdentify: Identify? = null
|
||||
// 预测
|
||||
private var preIdentify: Identify = PreDriverIdentify.preDataDrawer
|
||||
private var preIdentify2: Identify = PreDriverIdentify.preDataDrawer2
|
||||
private var preIdentify3: Identify = PreDriverIdentify.preDataDrawer3
|
||||
// 决策
|
||||
private var desIdentify: Identify = DesDriverIdentify.desDataDrawer
|
||||
|
||||
private var startTime: Long = 0L
|
||||
@@ -71,6 +77,8 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
private const val MSG_DATA_OBU_WARNING_REMOVE = 4
|
||||
private const val MSG_DATA_CLEAR = 5
|
||||
private const val MSG_DATA_AI_CLEAR = 6
|
||||
private const val MSG_DATA_PRE_TRACK = 7
|
||||
private const val MSG_DATA_PRE_CLEAR = 8
|
||||
|
||||
// 维护一个线程定时轮询数据进行地图绘制
|
||||
private val mDrawerHandler: Handler =
|
||||
@@ -89,14 +97,14 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
lostFrame(internal.toString())
|
||||
identify.clearOldMarker()
|
||||
}
|
||||
if (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - preStartTime) >= 1000) {
|
||||
if (FunctionBuildConfig.isDrawPreIdentifyData && TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - preStartTime) >= 1000) {
|
||||
preIdentify.clearOldMarker()
|
||||
}
|
||||
if (FunctionBuildConfig.isDrawDecIdentifyData && TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - desStartTime) >= 1000) {
|
||||
desIdentify.clearOldMarker()
|
||||
preIdentify2.clearOldMarker()
|
||||
preIdentify3.clearOldMarker()
|
||||
}
|
||||
if (TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - desStartTime) >= 1000) {
|
||||
desIdentify.clearOldMarker()
|
||||
}
|
||||
sendEmptyMessageDelayed(MSG_CHECK, 1000L)
|
||||
}
|
||||
|
||||
@@ -106,13 +114,15 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
identify.renderAdasRecognizedResult(objectList)
|
||||
startTime = System.nanoTime()
|
||||
|
||||
preIdentify.renderAdasRegResult(objectList, MogoMap.SMALL_PRED_MAP)
|
||||
preIdentify2.renderAdasRegResult(objectList, MogoMap.SMALL_PRED_MAP2)
|
||||
preIdentify3.renderAdasRegResult(objectList, MogoMap.SMALL_PRED_MAP3)
|
||||
preStartTime = System.nanoTime()
|
||||
|
||||
desIdentify.renderAdasRegResult(objectList, MogoMap.SMALL_DES_MAP)
|
||||
desStartTime = System.nanoTime()
|
||||
if (FunctionBuildConfig.isDrawDecIdentifyData) {
|
||||
desIdentify.renderAdasRegResult(objectList, MogoMap.SMALL_DES_MAP)
|
||||
desStartTime = System.nanoTime()
|
||||
}
|
||||
if (FunctionBuildConfig.isDrawPreIdentifyData) {
|
||||
preIdentify2.renderAdasRegResult(objectList, MogoMap.SMALL_PRED_MAP2)
|
||||
preIdentify3.renderAdasRegResult(objectList, MogoMap.SMALL_PRED_MAP3)
|
||||
preStartTime = System.nanoTime()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,6 +135,15 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
}
|
||||
}
|
||||
|
||||
MSG_DATA_PRE_TRACK -> {
|
||||
if (msg.obj is List<*>) {
|
||||
val objectList = msg.obj as List<Prediction2025.mPredictionObjectApp>
|
||||
preIdentify.renderPredictionResult(objectList, MogoMap.SMALL_PRED_MAP)
|
||||
// preIdentify2.renderPredictionResult(objectList, MogoMap.SMALL_PRED_MAP2)
|
||||
// preIdentify3.renderPredictionResult(objectList, MogoMap.SMALL_PRED_MAP3)
|
||||
}
|
||||
}
|
||||
|
||||
MSG_DATA_WARNING -> {
|
||||
if (msg.obj is List<*>) {
|
||||
identify.renderPlanningWarningObj(msg.obj as List<MessagePad.PlanningObject>?)
|
||||
@@ -150,6 +169,12 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
MSG_DATA_AI_CLEAR -> {
|
||||
aiCloudIdentify!!.clearAiMarker(msg.data.getString("mapInstance")!!)
|
||||
}
|
||||
|
||||
MSG_DATA_PRE_CLEAR -> {
|
||||
preIdentify.clearPredictionMarker(MogoMap.SMALL_PRED_MAP)
|
||||
preIdentify2.clearPredictionMarker(MogoMap.SMALL_PRED_MAP2)
|
||||
preIdentify3.clearPredictionMarker(MogoMap.SMALL_PRED_MAP3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,6 +186,13 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
mDrawerHandler.sendMessage(message)
|
||||
}
|
||||
|
||||
override fun renderPredictionResult(predictionObjectList: List<Prediction2025.mPredictionObjectApp>?) {
|
||||
val message = Message.obtain()
|
||||
message.what = MSG_DATA_PRE_TRACK
|
||||
message.obj = predictionObjectList
|
||||
mDrawerHandler.sendMessage(message)
|
||||
}
|
||||
|
||||
override fun renderAiCloudResult(
|
||||
resultList: List<SocketDownData.CloudRoadDataProto>,
|
||||
mapInstance: String
|
||||
@@ -192,6 +224,12 @@ object IdentifyFactory : Identify, IMoGoObuStatusListener, IMoGoAutopilotCarConf
|
||||
mDrawerHandler.sendMessage(message)
|
||||
}
|
||||
|
||||
override fun clearPredictionMarker(mapInstance: String) {
|
||||
val message = Message.obtain()
|
||||
message.what = MSG_DATA_PRE_CLEAR
|
||||
mDrawerHandler.sendMessage(message)
|
||||
}
|
||||
|
||||
override fun updateTrackerWarningInfo(trafficData: TrafficData) {
|
||||
super.updateTrackerWarningInfo(trafficData)
|
||||
val message = Message.obtain()
|
||||
|
||||
@@ -87,6 +87,45 @@ class IdentifyOriginDataDrawer : Identify {
|
||||
}
|
||||
}
|
||||
|
||||
override fun renderAdasRegResult(resultList: List<TrackedObject>?, mapInstance: String) {
|
||||
if (resultList.isNullOrEmpty()) {
|
||||
clearOldMarker()
|
||||
return
|
||||
}
|
||||
if (!MogoStatusManager.getInstance().isVrMode) {
|
||||
clearOldMarker()
|
||||
return
|
||||
}
|
||||
|
||||
//清除缓存
|
||||
for (data in resultList) {
|
||||
if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains(data.uuid.toString())) {
|
||||
if (TrackerSourceFilterHelper.filterData(data)) {
|
||||
continue
|
||||
}
|
||||
trafficDataUuidList.remove(data.uuid.toString())
|
||||
}
|
||||
}
|
||||
|
||||
//清除缓存,删除marker
|
||||
val it: MutableIterator<*> = trafficDataUuidList.iterator()
|
||||
while (it.hasNext()) {
|
||||
val key = it.next() as String
|
||||
it.remove()
|
||||
mMarkersCaches.remove(key)
|
||||
MogoIdentifyManager.getInstance()
|
||||
.removeMarker(key, mapInstance)
|
||||
TrackerSourceFilterHelper.removeBottomMarker(key)
|
||||
}
|
||||
|
||||
val filterList = filterTrafficData(resultList)
|
||||
if (filterList.size > 0) {
|
||||
// 绘制新数据
|
||||
MogoIdentifyManager.getInstance()
|
||||
.updateBatchMarkerPosition(filterList, mapInstance)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据过滤器
|
||||
*
|
||||
|
||||
@@ -5,19 +5,18 @@ import androidx.collection.ArraySet
|
||||
import com.mogo.commons.module.status.MogoStatusManager
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.map.identify.MogoIdentifyManager
|
||||
import mogo.telematics.pad.MessagePad.PlanningObject
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import prediction2025.Prediction2025
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
/**
|
||||
* 域控制器识别信息绘制
|
||||
* 域控制器预测数据绘制
|
||||
*/
|
||||
class IdentifyNewDataDrawer : Identify {
|
||||
class IdentifyPredictionDataDrawer : Identify {
|
||||
|
||||
/**
|
||||
* 上一帧数据的缓存
|
||||
*/
|
||||
private val mMarkersCaches = ConcurrentHashMap<String, TrackedObject>()
|
||||
private val mMarkersCaches = ConcurrentHashMap<String, Prediction2025.mPredictionObjectApp>()
|
||||
|
||||
/**
|
||||
* 记录每次实际绘制的交通元素UUID
|
||||
@@ -29,25 +28,17 @@ class IdentifyNewDataDrawer : Identify {
|
||||
* 过滤后的数据集合
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
private val mFilterTrafficData = HashMap<String, TrackedObject>()
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
override fun renderPlanningWarningObj(planningObjects: List<PlanningObject>?) {
|
||||
WarningHelper.renderPlanningOriginWarningObj(planningObjects, mMarkersCaches)
|
||||
}
|
||||
private val mFilterTrafficData = HashMap<String, Prediction2025.mPredictionObjectApp>()
|
||||
|
||||
override fun renderOBUWarningObj(exist: Boolean, obuTrafficData: TrafficData) {
|
||||
WarningHelper.renderOBUWarningObj(exist, obuTrafficData)
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染 adas 识别的数据
|
||||
*
|
||||
* @param resultList adas感知融合数据
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
override fun renderAdasRegResult(resultList: List<TrackedObject>?, mapInstance:String) {
|
||||
if (resultList == null || resultList.isEmpty()) {
|
||||
override fun renderPredictionResult(
|
||||
predictionObjectList: List<Prediction2025.mPredictionObjectApp>?,
|
||||
mapInstance: String
|
||||
) {
|
||||
if (predictionObjectList.isNullOrEmpty()) {
|
||||
clearOldMarker()
|
||||
return
|
||||
}
|
||||
@@ -55,14 +46,10 @@ class IdentifyNewDataDrawer : Identify {
|
||||
clearOldMarker()
|
||||
return
|
||||
}
|
||||
|
||||
//清除缓存
|
||||
for (data in resultList) {
|
||||
if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains(data.uuid.toString())) {
|
||||
if (TrackerSourceFilterHelper.filterData(data)) {
|
||||
continue
|
||||
}
|
||||
trafficDataUuidList.remove(data.uuid.toString())
|
||||
for (data in predictionObjectList) {
|
||||
if (trafficDataUuidList.size > 0 && trafficDataUuidList.contains("" + data.mNid)) {
|
||||
trafficDataUuidList.remove("" + data.mNid)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,15 +60,14 @@ class IdentifyNewDataDrawer : Identify {
|
||||
it.remove()
|
||||
mMarkersCaches.remove(key)
|
||||
MogoIdentifyManager.getInstance()
|
||||
.removeMarker(key, mapInstance)
|
||||
TrackerSourceFilterHelper.removeBottomMarker(key)
|
||||
.removeMarker(key.hashCode().toString(), mapInstance)
|
||||
}
|
||||
|
||||
val filterList = filterTrafficData(resultList)
|
||||
val filterList = filterTrafficData(predictionObjectList)
|
||||
if (filterList.size > 0) {
|
||||
// 绘制新数据
|
||||
MogoIdentifyManager.getInstance()
|
||||
.updateBatchMarkerPosition(filterList, mapInstance)
|
||||
.updatePreMarkerPosition(filterList, mapInstance)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,32 +77,28 @@ class IdentifyNewDataDrawer : Identify {
|
||||
* @return 过滤后的数据集合
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
private fun filterTrafficData(trafficData: List<TrackedObject>): HashMap<String, TrackedObject> {
|
||||
private fun filterTrafficData(trafficData: List<Prediction2025.mPredictionObjectApp>): HashMap<String, Prediction2025.mPredictionObjectApp> {
|
||||
mFilterTrafficData.clear()
|
||||
trafficDataUuidList.clear()
|
||||
for (data in trafficData) {
|
||||
// 过滤掉未知感知数据
|
||||
if (TrackerSourceFilterHelper.filterData(data)) {
|
||||
continue
|
||||
}
|
||||
var temp: TrackedObject = data
|
||||
val uuid = data.uuid.toString()
|
||||
val cacheData = mMarkersCaches[uuid]
|
||||
if (cacheData != null) {
|
||||
val color = TrackerSourceFilterHelper.getDefaultColor(data)
|
||||
temp = data.toBuilder().setColor(color).build()
|
||||
}
|
||||
mFilterTrafficData[uuid] = temp
|
||||
mMarkersCaches[uuid] = temp
|
||||
val uuid = "" + data.mNid
|
||||
mMarkersCaches[uuid] = data
|
||||
trafficDataUuidList.add(uuid)
|
||||
// TrackerSourceFilterHelper.filterZombieMarker(data)
|
||||
mFilterTrafficData[uuid] = data
|
||||
}
|
||||
return mFilterTrafficData
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除旧的 marker 数据
|
||||
*/
|
||||
@SuppressLint("NewApi")
|
||||
override fun clearPredictionMarker(mapInstance:String) {
|
||||
trafficDataUuidList.clear()
|
||||
mMarkersCaches.forEach { (uuid, _) ->
|
||||
mMarkersCaches.remove(uuid)
|
||||
MogoIdentifyManager.getInstance()
|
||||
.removeMarker(uuid.hashCode().toString(), mapInstance)
|
||||
}
|
||||
mFilterTrafficData.clear()
|
||||
}
|
||||
|
||||
override fun clearOldMarker() {
|
||||
for (uuid in trafficDataUuidList) {
|
||||
MogoIdentifyManager.getInstance()
|
||||
@@ -127,5 +109,4 @@ class IdentifyNewDataDrawer : Identify {
|
||||
mMarkersCaches.clear()
|
||||
WarningHelper.clear()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +1,23 @@
|
||||
package com.mogo.eagle.core.function.business.identify
|
||||
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.traffic.TrafficData
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotIdentifyListener
|
||||
import com.mogo.eagle.core.function.api.base.IMoGoSubscriber
|
||||
import com.mogo.eagle.core.function.api.datacenter.obu.IMoGoObuStatusListener
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.PredictionOverlayDrawer
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.PredictionOverlayDrawer2
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotIdentifyListenerManager
|
||||
import com.mogo.eagle.core.function.call.obu.CallerObuWarningListenerManager
|
||||
import com.mogo.eagle.core.function.utils.LocationUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.identify.MogoIdentifyManager
|
||||
import mogo.telematics.pad.MessagePad
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.yycp.api.proto.SocketDownData
|
||||
import prediction2025.Prediction2025
|
||||
|
||||
/**
|
||||
* 订阅感知数据的订阅者
|
||||
@@ -59,6 +65,47 @@ class MapIdentifySubscriber private constructor() : IMoGoSubscriber,
|
||||
}
|
||||
}
|
||||
|
||||
private var carPoiList1: List<geometry.Geometry.Point>? = null
|
||||
private var carPoiList2: List<geometry.Geometry.Point>? = null
|
||||
private var location1: MogoLocation? = null
|
||||
private var location2: MogoLocation? = null
|
||||
override fun onPredictionObstacleTrajectory(predictionObjects: Prediction2025.mPredictionObjects) {
|
||||
if (FunctionBuildConfig.isDrawPreIdentifyData) {
|
||||
try {
|
||||
ThreadUtils.getSinglePool().execute {
|
||||
// 渲染它车
|
||||
IdentifyFactory.renderPredictionResult(predictionObjects.objsAppList)
|
||||
// 渲染自车
|
||||
predictionObjects.objsAppList.forEach { preObj ->
|
||||
if (preObj.mNid == 800000L) {
|
||||
// 自车有2条轨迹,一条概率大、一条概率小
|
||||
if (preObj.predictionTrajectoryList == null || preObj.predictionTrajectoryList.size < 2) return@forEach
|
||||
carPoiList1 = preObj.predictionTrajectoryList[0].trajectoryPointsList
|
||||
carPoiList2 = preObj.predictionTrajectoryList[1].trajectoryPointsList
|
||||
val largeType: Int
|
||||
location1 = LocationUtils.generateLocation(carPoiList1!![0].x, carPoiList1!![0].y, carPoiList1!![1].x, carPoiList1!![1].y)
|
||||
location2 = LocationUtils.generateLocation(carPoiList2!![0].x, carPoiList2!![0].y, carPoiList2!![1].x, carPoiList2!![1].y)
|
||||
if (location1 == null || location2 == null) return@forEach
|
||||
if (preObj.predictionTrajectoryList[0].predictionProbability >= preObj.predictionTrajectoryList[1].predictionProbability) {
|
||||
MogoIdentifyManager.getInstance().updateGps(location1!!, MogoMap.SMALL_PRED_MAP)
|
||||
largeType = 2
|
||||
} else {
|
||||
MogoIdentifyManager.getInstance().updateGps(location2!!, MogoMap.SMALL_PRED_MAP)
|
||||
largeType = 3
|
||||
}
|
||||
PredictionOverlayDrawer.getInstance().drawPredictionList(carPoiList1, location1!!.heading, false, 2, largeType)
|
||||
PredictionOverlayDrawer2.getInstance().drawPredictionList(carPoiList2, location2!!.heading, false, 3, largeType)
|
||||
MogoIdentifyManager.getInstance().updateGps(location1!!, MogoMap.SMALL_PRED_MAP2)
|
||||
MogoIdentifyManager.getInstance().updateGps(location2!!, MogoMap.SMALL_PRED_MAP3)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun renderAiCloudResult(cloudData: List<SocketDownData.CloudRoadDataProto>, mapInstance:String = MogoMap.DEFAULT) {
|
||||
try {
|
||||
ThreadUtils.getSinglePool().execute {
|
||||
|
||||
@@ -131,12 +131,16 @@ public class MogoRouteOverlayManager implements
|
||||
// Log.d(TAG, "-- onChassisLocationGCJ02 -- 1 ---" + ":auto-mode:" + autoPilotState + ", isArriveAtStation: " + isArriveAtStation);
|
||||
if (isArriveAtStation && autoPilotState != 2) {
|
||||
RouteOverlayDrawer.getInstance().clearMogoRouteOverlay();
|
||||
PredictionOverlayDrawer.getInstance().clearPreRouteOverlay();
|
||||
PredictionOverlayDrawer2.getInstance().clearPreRouteOverlay();
|
||||
return;
|
||||
}
|
||||
// Log.d(TAG, "-- onChassisLocationGCJ02 -- 2 ---" + "auto-mode:" + autoPilotState + ", isDemoMode:" + FunctionBuildConfig.isDemoMode + ", force:" + FunctionBuildConfig.isForceDrawAutopilotTrajectoryByDebugSettingView);
|
||||
boolean force = hasGreenWave.get() || FunctionBuildConfig.isForceDrawAutopilotTrajectoryByDebugSettingView || FunctionBuildConfig.isDemoMode && FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData;
|
||||
if (!force && autoPilotState != 2) {
|
||||
RouteOverlayDrawer.getInstance().clearMogoRouteOverlay();
|
||||
PredictionOverlayDrawer.getInstance().clearPreRouteOverlay();
|
||||
PredictionOverlayDrawer2.getInstance().clearPreRouteOverlay();
|
||||
return;
|
||||
}
|
||||
// Log.d(TAG, "-- onChassisLocationGCJ02 -- 3 ---");
|
||||
|
||||
@@ -0,0 +1,369 @@
|
||||
package com.mogo.eagle.core.function.business.routeoverlay;
|
||||
|
||||
import static com.mogo.map.MogoMap.DEFAULT;
|
||||
import static com.mogo.map.MogoMap.SMALL_DES_MAP;
|
||||
import static com.mogo.map.MogoMap.SMALL_PRED_MAP;
|
||||
import static com.mogo.map.MogoMap.SMALL_PRED_MAP2;
|
||||
import static com.mogo.map.MogoMap.SMALL_PRED_MAP3;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.util.Pools;
|
||||
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
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.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.MogoMap;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.overlay.core.Level;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import com.zhidaoauto.map.sdk.open.common.tools.MapTools;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import kotlin.Pair;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
public class PredictionOverlayDrawer {
|
||||
|
||||
private static final String TAG = "PredictionOverlayDrawer";
|
||||
|
||||
// 连接线参数
|
||||
private Handler mRenderHandler;
|
||||
private final IMoGoOverlayManager mogoOverlayManager;
|
||||
private static volatile PredictionOverlayDrawer sInstance;
|
||||
private static final byte[] obj = new byte[0];
|
||||
private static final int COLOR_LIGHT = Color.parseColor("#BAEBF5");
|
||||
|
||||
private final List<Integer> greenWaveColors = new ArrayList<>();
|
||||
|
||||
private PredictionOverlayDrawer() {
|
||||
// 渐变色
|
||||
mogoOverlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (mogoOverlayManager != null) {
|
||||
// 线条粗细,渐变,渐变色值
|
||||
HandlerThread renderTask = new HandlerThread("prediction_render") {
|
||||
@Override
|
||||
protected void onLooperPrepared() {
|
||||
super.onLooperPrepared();
|
||||
mRenderHandler = new Handler(getLooper());
|
||||
}
|
||||
};
|
||||
renderTask.start();
|
||||
ArrayList<Pair<Integer, Integer>> temps = new ArrayList<>();
|
||||
temps.add(new Pair<>(0, 51));
|
||||
temps.add(new Pair<>(10, 102));
|
||||
temps.add(new Pair<>(30, 51));
|
||||
temps.add(new Pair<>(100, 0));
|
||||
List<Integer> alphas = MapTools.INSTANCE.getColorAlpha(temps);
|
||||
if (alphas != null && !alphas.isEmpty()) {
|
||||
for (int i : alphas) {
|
||||
greenWaveColors.add(Color.argb(i, 48, 163, 255));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static PredictionOverlayDrawer getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (obj) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new PredictionOverlayDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void clearPreRouteOverlay() {
|
||||
if (mogoOverlayManager != null) {
|
||||
if (mPreRenderTask != null) {
|
||||
mRenderHandler.removeCallbacks(mPreRenderTask);
|
||||
}
|
||||
mogoOverlayManager.hideAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
private class RenderTask implements Runnable {
|
||||
private volatile List<MogoLatLng> predictionList;
|
||||
|
||||
private final Pools.Pool<MogoLatLng> pools;
|
||||
private final LinkedList<MogoLatLng> points;
|
||||
|
||||
private double bearing;
|
||||
private boolean hasGreenWave;
|
||||
private int preViewType;
|
||||
private int largeType;
|
||||
|
||||
private Polyline.Options mPolylineOptions;
|
||||
//用于taxi乘客屏渐变颜色集合
|
||||
private List<Integer> colors = null;
|
||||
|
||||
public RenderTask() {
|
||||
this.pools = new Pools.SimplePool<>(500);
|
||||
this.points = new LinkedList<>();
|
||||
mPolylineOptions = new Polyline.Options.Builder("prediction_overlay" + preViewType, Level.GUIDE_ROUTE_LINE)
|
||||
.setUseGps(true)
|
||||
.setWidth(20)
|
||||
.setIsGradient(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void setPreData(List<MogoLatLng> data, double bearing, boolean hasGreenWave, int preType, int largeType) {
|
||||
predictionList = data;
|
||||
this.bearing = bearing;
|
||||
this.hasGreenWave = hasGreenWave;
|
||||
preViewType = preType;
|
||||
this.largeType = largeType;
|
||||
}
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
@Override
|
||||
public void run() {
|
||||
IMoGoOverlayManager overlayManager = mogoOverlayManager;
|
||||
if (overlayManager == null) {
|
||||
return;
|
||||
}
|
||||
LinkedList<MogoLatLng> pps = this.points;
|
||||
boolean isExcept = false;
|
||||
int total;
|
||||
|
||||
try {
|
||||
pps.clear();
|
||||
List<MogoLatLng> routes = this.predictionList;
|
||||
if (routes == null || (total = routes.size()) < 2) {
|
||||
isExcept = true;
|
||||
return;
|
||||
}
|
||||
boolean isColorfulStrategy = !hasGreenWave && !AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) || !AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode);
|
||||
if (isColorfulStrategy) {
|
||||
RouteStrategy.INSTANCE.start();
|
||||
} else {
|
||||
if (colors == null || colors.isEmpty()) {
|
||||
ArrayList<Pair<Integer, Integer>> temps = new ArrayList<>();
|
||||
temps.add(new Pair<>(0, 51));
|
||||
temps.add(new Pair<>(10, 102));
|
||||
temps.add(new Pair<>(30, 51));
|
||||
temps.add(new Pair<>(100, 0));
|
||||
List<Integer> alphas = MapTools.INSTANCE.getColorAlpha(temps);
|
||||
if (alphas != null && !alphas.isEmpty()) {
|
||||
colors = new CopyOnWriteArrayList<>();
|
||||
for (int i : alphas) {
|
||||
colors.add(Color.argb(i, 48, 163, 255));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < total; i++) {
|
||||
MogoLatLng route = null;
|
||||
try {
|
||||
route = routes.get(i);
|
||||
if (route == null) {
|
||||
continue;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
Log.d("Route", "render-error:" + t.getMessage());
|
||||
}
|
||||
if (route == null) {
|
||||
//数组越界了,结束循环
|
||||
break;
|
||||
}
|
||||
MogoLatLng acquire = pools.acquire();
|
||||
double latitude = route.getLat();
|
||||
double longitude = route.getLon();
|
||||
if (acquire == null) {
|
||||
acquire = new MogoLatLng(latitude, longitude);
|
||||
} else {
|
||||
acquire.lon = longitude;
|
||||
acquire.lat = latitude;
|
||||
}
|
||||
acquire.acc = 0.0;// 加速度
|
||||
acquire.speed = 0.0;// 速度
|
||||
pps.add(acquire);
|
||||
if (isColorfulStrategy) {
|
||||
RouteStrategy.INSTANCE.check(0.0, 0.0, predictionList.size());
|
||||
}
|
||||
}
|
||||
double lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
|
||||
double lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
|
||||
if (!points.isEmpty()) {
|
||||
MogoLatLng top = null;
|
||||
while (!points.isEmpty()) {
|
||||
MogoLatLng first = points.peek();
|
||||
if (first == null) {
|
||||
continue;
|
||||
}
|
||||
if (first == top) {
|
||||
break;
|
||||
}
|
||||
lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
|
||||
lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
|
||||
long angle = isPointOnCarFront(lon, lat, bearing, first.lon, first.lat);
|
||||
if (angle >= 90) {
|
||||
if (isColorfulStrategy) {
|
||||
RouteStrategy.INSTANCE.remove(first.acc);
|
||||
}
|
||||
pools.release(first);
|
||||
points.poll();
|
||||
}
|
||||
top = first;
|
||||
}
|
||||
if (points.isEmpty()) {
|
||||
isExcept = true;
|
||||
return;
|
||||
}
|
||||
MogoLatLng self = pools.acquire();
|
||||
if (self == null) {
|
||||
self = new MogoLatLng(lat, lon);
|
||||
} else {
|
||||
self.lat = lat;
|
||||
self.lon = lon;
|
||||
}
|
||||
points.addFirst(self);
|
||||
|
||||
Polyline.Options.Builder builder;
|
||||
if (mPolylineOptions == null) {
|
||||
builder = new Polyline.Options.Builder("router_overlay", Level.GUIDE_ROUTE_LINE)
|
||||
.setUseGps(true)
|
||||
.setWidth(20)
|
||||
.setIsGradient(true);
|
||||
} else {
|
||||
builder = mPolylineOptions.builder();
|
||||
}
|
||||
|
||||
if (isColorfulStrategy) {
|
||||
RouteStrategy.INSTANCE.end();
|
||||
Strategy strategy = RouteStrategy.INSTANCE.getStrategy();
|
||||
List<Integer> colors = strategy.getColors();
|
||||
boolean isLightOn = strategy instanceof ColorfulStrategy && ((ColorfulStrategy) strategy).isLightOn();
|
||||
builder.colors(colors);
|
||||
builder.setLightOn(isLightOn);
|
||||
builder.setLightColor(COLOR_LIGHT);
|
||||
builder.setLightSpeed(0.3f);
|
||||
} else {
|
||||
if (!hasGreenWave) {
|
||||
if (colors != null && !colors.isEmpty()) {
|
||||
builder.colors(colors);
|
||||
builder.setIsGradient(true);
|
||||
builder.setLightOn(true);
|
||||
builder.isShowArrow(false);
|
||||
builder.setLightColor(COLOR_LIGHT);
|
||||
builder.setLightSpeed(0.3f);
|
||||
}
|
||||
} else {
|
||||
builder.colors(greenWaveColors)
|
||||
.setIsGradient(true)
|
||||
.setLightOn(false)
|
||||
.isShowArrow(true);
|
||||
}
|
||||
}
|
||||
builder.points(points);
|
||||
builder.setVisible(true);
|
||||
Polyline.Options options = builder.build();
|
||||
if (mPolylineOptions == null) {
|
||||
mPolylineOptions = options;
|
||||
}
|
||||
if (FunctionBuildConfig.isDrawDecIdentifyData) {
|
||||
if (preViewType == 2) {
|
||||
overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP2);
|
||||
} else if (preViewType == 3) {
|
||||
overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP3);
|
||||
}
|
||||
if (preViewType == largeType) {
|
||||
overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isExcept = true;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
} finally {
|
||||
if (isExcept) {
|
||||
setVisible(false);
|
||||
}
|
||||
if (!points.isEmpty()) {
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
MogoLatLng latLng = points.get(i);
|
||||
if (latLng == null) {
|
||||
continue;
|
||||
}
|
||||
pools.release(latLng);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long isPointOnCarFront(double car_lon, double car_lat, double car_head, double lon, double lat) {
|
||||
return DrivingDirectionUtils.getDegreeOfCar2Poi2(car_lon, car_lat, lon, lat, car_head);
|
||||
}
|
||||
}
|
||||
|
||||
private volatile RenderTask mPreRenderTask;
|
||||
private volatile RenderTask mPreRenderTask2;
|
||||
|
||||
public void drawPredictionList(List<geometry.Geometry.Point> dataList, double bearing, boolean hasGreenWave, int preType, int largeType) {
|
||||
IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(DEFAULT);
|
||||
double[] arr = null;
|
||||
if (mogoOverlayManager != null && iMogoMap != null) {
|
||||
if (mPreRenderTask == null) {
|
||||
mPreRenderTask = new RenderTask();
|
||||
}
|
||||
List<MogoLatLng> latLngList = new ArrayList<>();
|
||||
for (geometry.Geometry.Point point : dataList) {
|
||||
arr = iMogoMap.switchData(point.getX(), point.getY(), false);
|
||||
if (arr == null || arr.length < 2) continue;
|
||||
latLngList.add(new MogoLatLng(arr[1], arr[0]));
|
||||
}
|
||||
if (latLngList.isEmpty()) return;
|
||||
mPreRenderTask.setPreData(latLngList, bearing, hasGreenWave, preType, largeType);
|
||||
if (mRenderHandler != null) {
|
||||
mRenderHandler.removeCallbacks(mPreRenderTask);
|
||||
mRenderHandler.post(mPreRenderTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drawPredictionList2(List<geometry.Geometry.Point> dataList, double bearing, boolean hasGreenWave, int preType, int largeType) {
|
||||
IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(DEFAULT);
|
||||
double[] arr = null;
|
||||
if (mogoOverlayManager != null) {
|
||||
if (mPreRenderTask2 == null) {
|
||||
mPreRenderTask2 = new RenderTask();
|
||||
}
|
||||
List<MogoLatLng> latLngList = new ArrayList<>();
|
||||
for (geometry.Geometry.Point point : dataList) {
|
||||
arr = iMogoMap.switchData(point.getX(), point.getY(), false);
|
||||
if (arr == null || arr.length < 2) continue;
|
||||
latLngList.add(new MogoLatLng(arr[0], arr[1]));
|
||||
}
|
||||
if (latLngList.isEmpty()) return;
|
||||
mPreRenderTask2.setPreData(latLngList, bearing, hasGreenWave, preType, largeType);
|
||||
if (mRenderHandler != null) {
|
||||
mRenderHandler.removeCallbacks(mPreRenderTask2);
|
||||
mRenderHandler.post(mPreRenderTask2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisible(boolean isVisible) {
|
||||
if (mogoOverlayManager != null) {
|
||||
if (isVisible) {
|
||||
mogoOverlayManager.showAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
|
||||
} else {
|
||||
mogoOverlayManager.hideAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,344 @@
|
||||
package com.mogo.eagle.core.function.business.routeoverlay;
|
||||
|
||||
import static com.mogo.map.MogoMap.DEFAULT;
|
||||
import static com.mogo.map.MogoMap.SMALL_PRED_MAP;
|
||||
import static com.mogo.map.MogoMap.SMALL_PRED_MAP2;
|
||||
import static com.mogo.map.MogoMap.SMALL_PRED_MAP3;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.core.util.Pools;
|
||||
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
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.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.MogoMap;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
import com.mogo.map.overlay.core.Level;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import com.zhidaoauto.map.sdk.open.common.tools.MapTools;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import kotlin.Pair;
|
||||
|
||||
public class PredictionOverlayDrawer2 {
|
||||
|
||||
private static final String TAG = "PredictionOverlayDrawer2";
|
||||
|
||||
// 连接线参数
|
||||
private Handler mRenderHandler;
|
||||
private final IMoGoOverlayManager mogoOverlayManager;
|
||||
private static volatile PredictionOverlayDrawer2 sInstance;
|
||||
private static final byte[] obj = new byte[0];
|
||||
private static final int COLOR_LIGHT = Color.parseColor("#BAEBF5");
|
||||
|
||||
private final List<Integer> greenWaveColors = new ArrayList<>();
|
||||
|
||||
private PredictionOverlayDrawer2() {
|
||||
// 渐变色
|
||||
mogoOverlayManager = CallerMapUIServiceManager.INSTANCE.getOverlayManager();
|
||||
if (mogoOverlayManager != null) {
|
||||
// 线条粗细,渐变,渐变色值
|
||||
HandlerThread renderTask = new HandlerThread("prediction_render") {
|
||||
@Override
|
||||
protected void onLooperPrepared() {
|
||||
super.onLooperPrepared();
|
||||
mRenderHandler = new Handler(getLooper());
|
||||
}
|
||||
};
|
||||
renderTask.start();
|
||||
ArrayList<Pair<Integer, Integer>> temps = new ArrayList<>();
|
||||
temps.add(new Pair<>(0, 51));
|
||||
temps.add(new Pair<>(10, 102));
|
||||
temps.add(new Pair<>(30, 51));
|
||||
temps.add(new Pair<>(100, 0));
|
||||
List<Integer> alphas = MapTools.INSTANCE.getColorAlpha(temps);
|
||||
if (alphas != null && !alphas.isEmpty()) {
|
||||
for (int i : alphas) {
|
||||
greenWaveColors.add(Color.argb(i, 48, 163, 255));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static PredictionOverlayDrawer2 getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (obj) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new PredictionOverlayDrawer2();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void clearPreRouteOverlay() {
|
||||
if (mogoOverlayManager != null) {
|
||||
if (mPreRenderTask != null) {
|
||||
mRenderHandler.removeCallbacks(mPreRenderTask);
|
||||
}
|
||||
mogoOverlayManager.hideAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
private class RenderTask implements Runnable {
|
||||
private volatile List<MogoLatLng> predictionList;
|
||||
|
||||
private final Pools.Pool<MogoLatLng> pools;
|
||||
private final LinkedList<MogoLatLng> points;
|
||||
|
||||
private double bearing;
|
||||
private boolean hasGreenWave;
|
||||
private int preViewType;
|
||||
private int largeType;
|
||||
|
||||
private Polyline.Options mPolylineOptions;
|
||||
//用于taxi乘客屏渐变颜色集合
|
||||
private List<Integer> colors = null;
|
||||
|
||||
public RenderTask() {
|
||||
this.pools = new Pools.SimplePool<>(500);
|
||||
this.points = new LinkedList<>();
|
||||
mPolylineOptions = new Polyline.Options.Builder("prediction_overlay" + preViewType, Level.GUIDE_ROUTE_LINE)
|
||||
.setUseGps(true)
|
||||
.setWidth(20)
|
||||
.setIsGradient(true)
|
||||
.build();
|
||||
}
|
||||
|
||||
public void setPreData(List<MogoLatLng> data, double bearing, boolean hasGreenWave, int preType, int largeType) {
|
||||
predictionList = data;
|
||||
this.bearing = bearing;
|
||||
this.hasGreenWave = hasGreenWave;
|
||||
preViewType = preType;
|
||||
this.largeType = largeType;
|
||||
}
|
||||
|
||||
@SuppressLint("LongLogTag")
|
||||
@Override
|
||||
public void run() {
|
||||
IMoGoOverlayManager overlayManager = mogoOverlayManager;
|
||||
if (overlayManager == null) {
|
||||
return;
|
||||
}
|
||||
LinkedList<MogoLatLng> pps = this.points;
|
||||
boolean isExcept = false;
|
||||
int total;
|
||||
|
||||
try {
|
||||
pps.clear();
|
||||
List<MogoLatLng> routes = this.predictionList;
|
||||
if (routes == null || (total = routes.size()) < 2) {
|
||||
isExcept = true;
|
||||
return;
|
||||
}
|
||||
boolean isColorfulStrategy = !hasGreenWave && !AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) || !AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode);
|
||||
if (isColorfulStrategy) {
|
||||
RouteStrategy.INSTANCE.start();
|
||||
} else {
|
||||
if (colors == null || colors.isEmpty()) {
|
||||
ArrayList<Pair<Integer, Integer>> temps = new ArrayList<>();
|
||||
temps.add(new Pair<>(0, 51));
|
||||
temps.add(new Pair<>(10, 102));
|
||||
temps.add(new Pair<>(30, 51));
|
||||
temps.add(new Pair<>(100, 0));
|
||||
List<Integer> alphas = MapTools.INSTANCE.getColorAlpha(temps);
|
||||
if (alphas != null && !alphas.isEmpty()) {
|
||||
colors = new CopyOnWriteArrayList<>();
|
||||
for (int i : alphas) {
|
||||
colors.add(Color.argb(i, 48, 163, 255));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < total; i++) {
|
||||
MogoLatLng route = null;
|
||||
try {
|
||||
route = routes.get(i);
|
||||
if (route == null) {
|
||||
continue;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
Log.d("Route", "render-error:" + t.getMessage());
|
||||
}
|
||||
if (route == null) {
|
||||
//数组越界了,结束循环
|
||||
break;
|
||||
}
|
||||
MogoLatLng acquire = pools.acquire();
|
||||
double latitude = route.getLat();
|
||||
double longitude = route.getLon();
|
||||
if (acquire == null) {
|
||||
acquire = new MogoLatLng(latitude, longitude);
|
||||
} else {
|
||||
acquire.lon = longitude;
|
||||
acquire.lat = latitude;
|
||||
}
|
||||
acquire.acc = 0.0;// 加速度
|
||||
acquire.speed = 0.0;// 速度
|
||||
pps.add(acquire);
|
||||
if (isColorfulStrategy) {
|
||||
RouteStrategy.INSTANCE.check(0.0, 0.0, predictionList.size());
|
||||
}
|
||||
}
|
||||
double lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
|
||||
double lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
|
||||
if (!points.isEmpty()) {
|
||||
MogoLatLng top = null;
|
||||
while (!points.isEmpty()) {
|
||||
MogoLatLng first = points.peek();
|
||||
if (first == null) {
|
||||
continue;
|
||||
}
|
||||
if (first == top) {
|
||||
break;
|
||||
}
|
||||
lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
|
||||
lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
|
||||
long angle = isPointOnCarFront(lon, lat, bearing, first.lon, first.lat);
|
||||
if (angle >= 90) {
|
||||
if (isColorfulStrategy) {
|
||||
RouteStrategy.INSTANCE.remove(first.acc);
|
||||
}
|
||||
pools.release(first);
|
||||
points.poll();
|
||||
}
|
||||
top = first;
|
||||
}
|
||||
if (points.isEmpty()) {
|
||||
isExcept = true;
|
||||
return;
|
||||
}
|
||||
MogoLatLng self = pools.acquire();
|
||||
if (self == null) {
|
||||
self = new MogoLatLng(lat, lon);
|
||||
} else {
|
||||
self.lat = lat;
|
||||
self.lon = lon;
|
||||
}
|
||||
points.addFirst(self);
|
||||
|
||||
Polyline.Options.Builder builder;
|
||||
if (mPolylineOptions == null) {
|
||||
builder = new Polyline.Options.Builder("router_overlay", Level.GUIDE_ROUTE_LINE)
|
||||
.setUseGps(true)
|
||||
.setWidth(20)
|
||||
.setIsGradient(true);
|
||||
} else {
|
||||
builder = mPolylineOptions.builder();
|
||||
}
|
||||
|
||||
if (isColorfulStrategy) {
|
||||
RouteStrategy.INSTANCE.end();
|
||||
Strategy strategy = RouteStrategy.INSTANCE.getStrategy();
|
||||
List<Integer> colors = strategy.getColors();
|
||||
boolean isLightOn = strategy instanceof ColorfulStrategy && ((ColorfulStrategy) strategy).isLightOn();
|
||||
builder.colors(colors);
|
||||
builder.setLightOn(isLightOn);
|
||||
builder.setLightColor(COLOR_LIGHT);
|
||||
builder.setLightSpeed(0.3f);
|
||||
} else {
|
||||
if (!hasGreenWave) {
|
||||
if (colors != null && !colors.isEmpty()) {
|
||||
builder.colors(colors);
|
||||
builder.setIsGradient(true);
|
||||
builder.setLightOn(true);
|
||||
builder.isShowArrow(false);
|
||||
builder.setLightColor(COLOR_LIGHT);
|
||||
builder.setLightSpeed(0.3f);
|
||||
}
|
||||
} else {
|
||||
builder.colors(greenWaveColors)
|
||||
.setIsGradient(true)
|
||||
.setLightOn(false)
|
||||
.isShowArrow(true);
|
||||
}
|
||||
}
|
||||
builder.points(points);
|
||||
builder.setVisible(true);
|
||||
Polyline.Options options = builder.build();
|
||||
if (mPolylineOptions == null) {
|
||||
mPolylineOptions = options;
|
||||
}
|
||||
if (FunctionBuildConfig.isDrawDecIdentifyData) {
|
||||
if (preViewType == 2) {
|
||||
overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP2);
|
||||
} else if (preViewType == 3) {
|
||||
overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP3);
|
||||
}
|
||||
if (preViewType == largeType) {
|
||||
overlayManager.showOrUpdateLine(options, SMALL_PRED_MAP);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
isExcept = true;
|
||||
}
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
} finally {
|
||||
if (isExcept) {
|
||||
setVisible(false);
|
||||
}
|
||||
if (!points.isEmpty()) {
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
MogoLatLng latLng = points.get(i);
|
||||
if (latLng == null) {
|
||||
continue;
|
||||
}
|
||||
pools.release(latLng);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long isPointOnCarFront(double car_lon, double car_lat, double car_head, double lon, double lat) {
|
||||
return DrivingDirectionUtils.getDegreeOfCar2Poi2(car_lon, car_lat, lon, lat, car_head);
|
||||
}
|
||||
}
|
||||
|
||||
private volatile RenderTask mPreRenderTask;
|
||||
|
||||
public void drawPredictionList(List<geometry.Geometry.Point> dataList, double bearing, boolean hasGreenWave, int preType, int largeType) {
|
||||
IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(DEFAULT);
|
||||
double[] arr = null;
|
||||
if (mogoOverlayManager != null && iMogoMap != null) {
|
||||
if (mPreRenderTask == null) {
|
||||
mPreRenderTask = new RenderTask();
|
||||
}
|
||||
List<MogoLatLng> latLngList = new ArrayList<>();
|
||||
for (geometry.Geometry.Point point : dataList) {
|
||||
arr = iMogoMap.switchData(point.getX(), point.getY(), false);
|
||||
if (arr == null || arr.length < 2) continue;
|
||||
latLngList.add(new MogoLatLng(arr[1], arr[0]));
|
||||
}
|
||||
if (latLngList.isEmpty()) return;
|
||||
mPreRenderTask.setPreData(latLngList, bearing, hasGreenWave, preType, largeType);
|
||||
if (mRenderHandler != null) {
|
||||
mRenderHandler.removeCallbacks(mPreRenderTask);
|
||||
mRenderHandler.post(mPreRenderTask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisible(boolean isVisible) {
|
||||
if (mogoOverlayManager != null) {
|
||||
if (isVisible) {
|
||||
mogoOverlayManager.showAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
|
||||
} else {
|
||||
mogoOverlayManager.hideAllLinesInLevel(Level.GUIDE_ROUTE_LINE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,7 +267,9 @@ public class RouteOverlayDrawer {
|
||||
mPolylineOptions = options;
|
||||
}
|
||||
overlayManager.showOrUpdateLine(options,DEFAULT);
|
||||
overlayManager.showOrUpdateLine(options,SMALL_DES_MAP);
|
||||
if (FunctionBuildConfig.isDrawDecIdentifyData) {
|
||||
overlayManager.showOrUpdateLine(options,SMALL_DES_MAP);
|
||||
}
|
||||
} else {
|
||||
isExcept = true;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.mogo.eagle.core.function.utils
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.MogoMap.Companion.mapInstance
|
||||
|
||||
object LocationUtils {
|
||||
/**
|
||||
* 必须先根据定位计算度带,即调用switchData(gnssInfo.longitude, gnssInfo.latitude, true)
|
||||
*/
|
||||
fun generateLocation(x: Double, y: Double, heading: Double): MogoLocation? {
|
||||
val mogoMap = mapInstance.getMogoMap(MogoMap.DEFAULT)
|
||||
if (mogoMap != null) {
|
||||
val lonLat = mogoMap.switchData(x, y, false)
|
||||
if (lonLat == null || lonLat.size < 2) return null
|
||||
val location = MogoLocation()
|
||||
location.longitude = lonLat[0]
|
||||
location.latitude = lonLat[1]
|
||||
location.heading = heading
|
||||
return location
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同上,必须先根据定位计算度带
|
||||
*/
|
||||
fun generateLocation(x: Double, y: Double, preX: Double, preY: Double): MogoLocation? {
|
||||
val mogoMap = mapInstance.getMogoMap(MogoMap.DEFAULT)
|
||||
if (mogoMap != null) {
|
||||
val lonLat = mogoMap.switchData(x, y, false)
|
||||
val preLonLat = mogoMap.switchData(preX, preY, false)
|
||||
if (lonLat == null || lonLat.size < 2 || preLonLat == null || preLonLat.size < 2) return null
|
||||
val location = MogoLocation()
|
||||
location.longitude = lonLat[0]
|
||||
location.latitude = lonLat[1]
|
||||
location.heading = DrivingDirectionUtils.getLineAngle(lonLat[0], lonLat[1], preLonLat[0], preLonLat[1])
|
||||
return location
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,6 @@ class PredictionMap2View(context: Context, attrs: AttributeSet) : MogoMapView(co
|
||||
|
||||
override fun onChassisLocationWGS84(gnssInfo: MogoLocation) {
|
||||
// 跟新地图控件
|
||||
setExtraGPSData(gnssInfo)
|
||||
// setExtraGPSData(gnssInfo)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ class PredictionMap3View(context: Context, attrs: AttributeSet) : MogoMapView(co
|
||||
|
||||
override fun onChassisLocationWGS84(gnssInfo: MogoLocation) {
|
||||
// 跟新地图控件
|
||||
setExtraGPSData(gnssInfo)
|
||||
// setExtraGPSData(gnssInfo)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,12 +11,13 @@ import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
|
||||
import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.view.PredictionMap2View.Companion
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
|
||||
import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.MogoMap.Companion.SMALL_PRED_MAP
|
||||
import com.mogo.map.MogoMap.Companion.mapInstance
|
||||
import com.mogo.map.MogoMapView
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapLoadedListener
|
||||
import com.zhidaoauto.map.sdk.open.view.HDTypes
|
||||
@@ -42,6 +43,9 @@ class PredictionMapView(context: Context, attrs: AttributeSet) : MogoMapView(con
|
||||
// typedArray.recycle()
|
||||
// }
|
||||
|
||||
@Volatile
|
||||
private var lastTime: Long = 0L
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
initMapView()
|
||||
@@ -118,7 +122,11 @@ class PredictionMapView(context: Context, attrs: AttributeSet) : MogoMapView(con
|
||||
|
||||
override fun onChassisLocationWGS84(gnssInfo: MogoLocation) {
|
||||
// 跟新地图控件
|
||||
setExtraGPSData(gnssInfo)
|
||||
// setExtraGPSData(gnssInfo)
|
||||
if (System.currentTimeMillis() - lastTime >= 5000) {
|
||||
// 预测给的UTM坐标数据没有带上度带信息,根据定位计算度带
|
||||
mapInstance.getMogoMap(MogoMap.DEFAULT)?.switchData(gnssInfo.longitude, gnssInfo.latitude, true)
|
||||
lastTime = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -231,6 +231,20 @@ object FunctionBuildConfig {
|
||||
@JvmField
|
||||
var isDrawPointCloudData = false
|
||||
|
||||
/**
|
||||
* 地图是否绘制预测数据的Marker
|
||||
*/
|
||||
@Volatile
|
||||
@JvmField
|
||||
var isDrawPreIdentifyData = false
|
||||
|
||||
/**
|
||||
* 地图是否绘制决策数据的Marker
|
||||
*/
|
||||
@Volatile
|
||||
@JvmField
|
||||
var isDrawDecIdentifyData = false
|
||||
|
||||
/**
|
||||
* 自车是否展示光圈(6.2.6版本改为默认展示)
|
||||
* true - 展示
|
||||
|
||||
@@ -15,34 +15,6 @@ import prediction2025.Prediction2025
|
||||
*/
|
||||
object CallerAutopilotIdentifyListenerManager : CallerBase<IMoGoAutopilotIdentifyListener>() {
|
||||
|
||||
private val typeMap: Map<Adas.TrackedObjectType, Adas.TrackedObjectClassID> = mapOf(
|
||||
Adas.TrackedObjectType.TYPE_PEDESTRIAN to Adas.TrackedObjectClassID.Person,
|
||||
Adas.TrackedObjectType.TYPE_MOTOR to Adas.TrackedObjectClassID.MotorCycle,
|
||||
Adas.TrackedObjectType.TYPE_BICYCLE to Adas.TrackedObjectClassID.Bicycle,
|
||||
Adas.TrackedObjectType.TYPE_CAR to Adas.TrackedObjectClassID.Car,
|
||||
Adas.TrackedObjectType.TYPE_TRUCK to Adas.TrackedObjectClassID.Truck,
|
||||
Adas.TrackedObjectType.TYPE_BUS to Adas.TrackedObjectClassID.Bus,
|
||||
Adas.TrackedObjectType.TYPE_WARNINGTRIANGLE to Adas.TrackedObjectClassID.WarningTriangle,
|
||||
Adas.TrackedObjectType.TYPE_ROADWORK_OCCUPY_0501 to Adas.TrackedObjectClassID.RoadWork_occupy_0501,
|
||||
Adas.TrackedObjectType.TYPE_ROADWORK_BREAK_0502 to Adas.TrackedObjectClassID.RoadWork_break_0502,
|
||||
Adas.TrackedObjectType.TYPE_ROAD_CONGESTION to Adas.TrackedObjectClassID.ROAD_CONGESTION
|
||||
)
|
||||
|
||||
/**
|
||||
* 域控障碍物类型转换成鹰眼使用的类型
|
||||
*
|
||||
* @param classType 域控障碍物类型(目前只有Prediction2025.mPredictionObjects.objs_app.classtype 是域控的障碍物类型)
|
||||
* @return 障碍物类型 与 message_pad中的TrackedObjects 的 objs.type 类型一致
|
||||
*/
|
||||
fun trackedObjectTypeTransform(classType: Int): Int {
|
||||
var type = Adas.TrackedObjectType.forNumber(classType)
|
||||
if (type == null) {
|
||||
type = Adas.TrackedObjectType.TYPE_UNKNOWN
|
||||
}
|
||||
val classId = typeMap[type] ?: Adas.TrackedObjectClassID.Unknown
|
||||
return classId.number
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别交通元素数据发生更新 回调
|
||||
*/
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.mogo.map.overlay.proxy.point.IMapPointOverlay
|
||||
import com.mogo.map.overlay.proxy.line.IMapPolylineOverlay
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.yycp.api.proto.SocketDownData
|
||||
import prediction2025.Prediction2025
|
||||
import java.util.HashMap
|
||||
|
||||
/**
|
||||
@@ -51,6 +52,8 @@ interface IMogoMap {
|
||||
*/
|
||||
fun updateBatchAiMarkerPosition(optionsArrayList: HashMap<String, SocketDownData.CloudRoadDataProto>?)
|
||||
|
||||
fun updatePreMarkerPosition(optionsArrayList: HashMap<String, Prediction2025.mPredictionObjectApp>?)
|
||||
|
||||
/**
|
||||
* 添加感知使用到的3d模型
|
||||
*
|
||||
@@ -65,4 +68,6 @@ interface IMogoMap {
|
||||
* @param uuidString
|
||||
*/
|
||||
fun removeMarker(uuidString: String?)
|
||||
|
||||
fun switchData(x: Double, y: Double, isWgs84: Boolean): DoubleArray?
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.mogo.map.identity
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.map.MogoMap
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.yycp.api.proto.SocketDownData
|
||||
import prediction2025.Prediction2025
|
||||
import java.util.HashMap
|
||||
|
||||
/**
|
||||
@@ -29,4 +31,15 @@ interface IMogoIdentifyManager {
|
||||
* @param optionsArrayList 锚点集合
|
||||
*/
|
||||
fun updateBatchAiMarkerPosition(optionsArrayList: HashMap<String, SocketDownData.CloudRoadDataProto>, mapInstance:String = MogoMap.DEFAULT)
|
||||
|
||||
/**
|
||||
* 批量更新预测数据对应的锚点位置
|
||||
*
|
||||
* @param optionsArrayList 锚点集合
|
||||
*/
|
||||
fun updatePreMarkerPosition(optionsArrayList: HashMap<String, Prediction2025.mPredictionObjectApp>, mapInstance:String)
|
||||
|
||||
fun updateGps(gnssInfo: MogoLocation, mapInstance: String)
|
||||
|
||||
fun updateUTM(carX: Double, carY: Double, preX: Double, preY: Double, mapInstance: String)
|
||||
}
|
||||
@@ -219,6 +219,7 @@ data class Polyline(val id: String, val owner: String, val level: Level, val opt
|
||||
}
|
||||
|
||||
private fun str2Int(tag: String): Int {
|
||||
if (tag.isEmpty()) return 0
|
||||
var sum = 0
|
||||
for (c in tag) {
|
||||
sum += c.code
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.zhidaoauto.map.sdk.open.view.MapAutoView
|
||||
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper
|
||||
import mogo.telematics.pad.MessagePad.TrackedObject
|
||||
import mogo.yycp.api.proto.SocketDownData
|
||||
import prediction2025.Prediction2025
|
||||
import java.util.function.BiConsumer
|
||||
|
||||
/**
|
||||
@@ -176,6 +177,40 @@ class AMapWrapper(map: MapAutoViewHelper?, mapView: MapAutoView, controller: IMo
|
||||
}
|
||||
}
|
||||
|
||||
var preMarkerOptions = BatchMarkerOptions()
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
override fun updatePreMarkerPosition(optionsArrayList: java.util.HashMap<String, Prediction2025.mPredictionObjectApp>?) {
|
||||
if (!checkAMap()) {
|
||||
return
|
||||
}
|
||||
if (optionsArrayList == null || optionsArrayList.size == 0) {
|
||||
return
|
||||
}
|
||||
val markerOptionsArrayList = ArrayList<MarkerSimpleData>()
|
||||
optionsArrayList.forEach(BiConsumer { s: String?, preObject: Prediction2025.mPredictionObjectApp? ->
|
||||
val markerOptions = ObjectUtils.fromPreData(preObject)
|
||||
if (markerOptions != null) {
|
||||
markerOptionsArrayList.add(markerOptions)
|
||||
}
|
||||
})
|
||||
if (markerOptionsArrayList.size == 0) {
|
||||
return
|
||||
}
|
||||
// val time = markerOptionsArrayList[0].time
|
||||
// 最后一个参数,是否管理锚点的删除
|
||||
preMarkerOptions.list = markerOptionsArrayList
|
||||
preMarkerOptions.delayStrategy = false
|
||||
preMarkerOptions.ruleAngle = 8.0f
|
||||
preMarkerOptions.controlIcon = 1
|
||||
// // marker做动画时需用到(要么一直不传,要么一直都传)
|
||||
// preMarkerOptions.satelliteTime = time
|
||||
preMarkerOptions.deleteRule = 0
|
||||
if (mMapView.getMarkerController() != null) {
|
||||
mMapView.getMarkerController()!!.updateBatchMarkerPositon(preMarkerOptions)
|
||||
}
|
||||
}
|
||||
|
||||
override fun addPreVehicleModel(type: Int, modelRes: Int): String? {
|
||||
try {
|
||||
if (mMapView.getMarkerController() != null) {
|
||||
@@ -205,4 +240,8 @@ class AMapWrapper(map: MapAutoViewHelper?, mapView: MapAutoView, controller: IMo
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun switchData(x: Double, y: Double, isWgs84: Boolean): DoubleArray? {
|
||||
return mAMap?.switchData(x, y, isWgs84)
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,18 @@
|
||||
package com.mogo.map.identify;
|
||||
|
||||
import static com.mogo.map.MogoMap.DEFAULT;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.MogoMap;
|
||||
import com.mogo.map.identity.IMogoIdentifyManager;
|
||||
import java.util.HashMap;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
import prediction2025.Prediction2025;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -69,4 +76,40 @@ public class MogoIdentifyManager implements IMogoIdentifyManager {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatePreMarkerPosition(@NonNull HashMap<String, Prediction2025.mPredictionObjectApp> optionsArrayList, @NonNull String mapInstance) {
|
||||
try {
|
||||
IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(mapInstance);
|
||||
if(iMogoMap != null){
|
||||
iMogoMap.updatePreMarkerPosition(optionsArrayList);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateGps(MogoLocation gnssInfo, @NonNull String mapInstance) {
|
||||
IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(mapInstance);
|
||||
if(iMogoMap != null){
|
||||
iMogoMap.getUiController().setExtraGPSData(gnssInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUTM(double carX, double carY, double preX, double preY, @NonNull String mapInstance) {
|
||||
IMogoMap iMogoMap = MogoMap.Companion.getMapInstance().getMogoMap(DEFAULT);// 同一个地图实例保存根据定位计算度带后的值
|
||||
IMogoMap mogoMap2 = MogoMap.Companion.getMapInstance().getMogoMap(mapInstance);
|
||||
if(iMogoMap != null && mogoMap2 != null){
|
||||
double[] arr = iMogoMap.switchData(carX, carY, false);
|
||||
double[] preArr = iMogoMap.switchData(preX, preY, false);
|
||||
if (arr != null && arr.length == 2 && preArr != null && preArr.length == 2) {
|
||||
double angle = DrivingDirectionUtils.getLineAngle(arr[0], arr[1], preArr[0], preArr[1]);
|
||||
MogoLocation location = new MogoLocation();
|
||||
location.setHeading(angle);
|
||||
location.setLongitude(arr[0]);
|
||||
location.setLatitude(arr[1]);
|
||||
mogoMap2.getUiController().setExtraGPSData(location);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.view.View;
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.map.uicontroller.MapCameraPosition;
|
||||
@@ -19,12 +20,15 @@ import com.zhidaoauto.map.sdk.open.renders.marker.MarkerOptions;
|
||||
import com.zhidaoauto.map.sdk.open.renders.marker.MarkerSimpleData;
|
||||
import com.zhidaoauto.map.sdk.open.renders.poyline.PolylineOptions;
|
||||
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
|
||||
import com.zhjt.mogo.adas.data.Adas;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo.yycp.api.proto.SocketDownData;
|
||||
import prediction2025.Prediction2025;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -34,6 +38,19 @@ import mogo.yycp.api.proto.SocketDownData;
|
||||
*/
|
||||
public class ObjectUtils {
|
||||
|
||||
private static Map<Adas.TrackedObjectType, Adas.TrackedObjectClassID> sTypeMap = Map.of(
|
||||
Adas.TrackedObjectType.TYPE_PEDESTRIAN, Adas.TrackedObjectClassID.Person,
|
||||
Adas.TrackedObjectType.TYPE_MOTOR, Adas.TrackedObjectClassID.MotorCycle,
|
||||
Adas.TrackedObjectType.TYPE_BICYCLE, Adas.TrackedObjectClassID.Bicycle,
|
||||
Adas.TrackedObjectType.TYPE_CAR, Adas.TrackedObjectClassID.Car,
|
||||
Adas.TrackedObjectType.TYPE_TRUCK, Adas.TrackedObjectClassID.Truck,
|
||||
Adas.TrackedObjectType.TYPE_BUS, Adas.TrackedObjectClassID.Bus,
|
||||
Adas.TrackedObjectType.TYPE_WARNINGTRIANGLE, Adas.TrackedObjectClassID.WarningTriangle,
|
||||
Adas.TrackedObjectType.TYPE_ROADWORK_OCCUPY_0501, Adas.TrackedObjectClassID.RoadWork_occupy_0501,
|
||||
Adas.TrackedObjectType.TYPE_ROADWORK_BREAK_0502, Adas.TrackedObjectClassID.RoadWork_break_0502,
|
||||
Adas.TrackedObjectType.TYPE_ROAD_CONGESTION, Adas.TrackedObjectClassID.ROAD_CONGESTION
|
||||
);
|
||||
|
||||
public static MarkerOptions fromMogo(Point.Options opt, MapAutoView mapAutoView) {
|
||||
|
||||
if (opt == null) {
|
||||
@@ -174,6 +191,55 @@ public class ObjectUtils {
|
||||
return markerOptions;
|
||||
}
|
||||
|
||||
public static MarkerSimpleData fromPreData(Prediction2025.mPredictionObjectApp preData) {
|
||||
if (preData == null || preData.getMNid() == 800000) {// 过滤掉自车
|
||||
return null;
|
||||
}
|
||||
MarkerSimpleData markerOptions = null;
|
||||
try {
|
||||
markerOptions = new MarkerSimpleData();
|
||||
markerOptions.setId(preData.getMNid());
|
||||
markerOptions.setMarkerType(trackedObjectTypeTransform(preData.getClasstype()));
|
||||
markerOptions.setRotateAngle(getPredictionHeading(preData));
|
||||
// 自车2条轨迹,它车1条轨迹;每条轨迹的第一个点为位置,其它点为预测轨迹点
|
||||
markerOptions.setLat(preData.getPredictionTrajectoryList().get(0).getTrajectoryPointsList().get(0).getX());
|
||||
markerOptions.setLon(preData.getPredictionTrajectoryList().get(0).getTrajectoryPointsList().get(0).getY());
|
||||
// marker做动画时需用到(要么一直不传,要么一直都传)
|
||||
// markerOptions.setTime(Double.valueOf(preData.getSatelliteTime() * 1000).longValue());
|
||||
markerOptions.setColor("#90ABCAFF");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return markerOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* 域控障碍物类型转换成鹰眼使用的类型
|
||||
*
|
||||
* @param classType 域控障碍物类型(目前只有Prediction2025.mPredictionObjects.objs_app.classtype 是域控的障碍物类型)
|
||||
* @return 障碍物类型 与 message_pad中的TrackedObjects 的 objs.type 类型一致
|
||||
*/
|
||||
private static int trackedObjectTypeTransform(int classType) {
|
||||
Adas.TrackedObjectType type = Adas.TrackedObjectType.forNumber(classType);
|
||||
if (type == null) {
|
||||
type = Adas.TrackedObjectType.TYPE_UNKNOWN;
|
||||
}
|
||||
Adas.TrackedObjectClassID classID = sTypeMap.get(type);
|
||||
if (classID == null) {
|
||||
classID = Adas.TrackedObjectClassID.Unknown;
|
||||
}
|
||||
return classID.getNumber();
|
||||
}
|
||||
|
||||
private static float getPredictionHeading(Prediction2025.mPredictionObjectApp preData) {
|
||||
List<geometry.Geometry.Point> pointList = preData.getPredictionTrajectoryList().get(0).getTrajectoryPointsList();
|
||||
if (pointList.size() >= 2) {
|
||||
return (float) DrivingDirectionUtils.getLineAngle(pointList.get(0).getX(), pointList.get(0).getY(), pointList.get(1).getX(), pointList.get(1).getY());
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static BitmapDescriptor getBitmapDescriptorFromMogo(Bitmap icon, View view) {
|
||||
if (icon != null) {
|
||||
return BitmapDescriptorFactory.INSTANCE.fromBitmap(icon);
|
||||
|
||||
Reference in New Issue
Block a user