From 19423b92081be04bd0ffe2361e6e74b3c47468d3 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Fri, 12 Jul 2024 16:57:19 +0800 Subject: [PATCH] =?UTF-8?q?[6.5.0][Feat]=E6=96=B0=E5=A2=9E=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E6=98=BE=E7=A4=BA=E7=9A=84=E5=9B=9E=E8=B0=83=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../business/travelreality/EventBean.kt | 1 + .../business/travelreality/EventDrawBean.kt | 3 ++ .../core/function/view/TravelRealityView.kt | 44 ++++++++++++++----- 3 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventDrawBean.kt diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventBean.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventBean.kt index 4fd1cc15f3..2f231f98d4 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventBean.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventBean.kt @@ -15,6 +15,7 @@ data class EventBean( */ var orientation: Int = 0 var title: String? = "" + var resId: Int = 0 } data class GeoCoord(var lon: Double, var lat: Double) \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventDrawBean.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventDrawBean.kt new file mode 100644 index 0000000000..bc7efdaba6 --- /dev/null +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/EventDrawBean.kt @@ -0,0 +1,3 @@ +package com.mogo.eagle.core.function.business.travelreality + +data class EventDrawBean(var resId: Int, var title: String) diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt index dd7078d60c..c42d62e339 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt @@ -34,6 +34,7 @@ import com.mogo.eagle.core.function.business.roadcross.net.NDERoadCameraNetWorkM import com.mogo.eagle.core.function.business.travelreality.CrossDeviceBean import com.mogo.eagle.core.function.business.travelreality.DeviceInfoBean import com.mogo.eagle.core.function.business.travelreality.EventBean +import com.mogo.eagle.core.function.business.travelreality.EventDrawBean import com.mogo.eagle.core.function.business.travelreality.EventReqEntity import com.mogo.eagle.core.function.business.travelreality.Point import com.mogo.eagle.core.function.business.travelreality.TravelRealityModel.Companion.travelNetWorkModel @@ -201,6 +202,8 @@ class TravelRealityView @JvmOverloads constructor( private var testTime = 0L + private var listener: OnDrawListener? = null + init { try { val typedArray = context.obtainStyledAttributes(attrs, R.styleable.TravelRealityView) @@ -253,6 +256,10 @@ class TravelRealityView @JvmOverloads constructor( } // =================必须通知高德地图生命周期的变化================= + fun setOnDrawListener(listener: OnDrawListener) { + this.listener = listener + } + private fun initView(context: Context) { mContext = context val mapView = @@ -440,7 +447,7 @@ class TravelRealityView @JvmOverloads constructor( val globalList = reqData if (eventList.isEmpty() || globalList.isNullOrEmpty()) return testTime = System.currentTimeMillis() - + val eventDrawMap = HashMap() val eventOptionsList = ArrayList() globalList.forEachIndexed { index, globalPoint -> if (index >= 0 && index < globalList.size - 1) { @@ -458,7 +465,8 @@ class TravelRealityView @JvmOverloads constructor( } eventBean.orientation = travelNetWorkModel.calculateOrientation(eventBean.lon, eventBean.lat, globalPoint.lon, globalPoint.lat, globalList[index + 1].lon, globalList[index + 1].lat,) - filterEventWithType(eventBean, eventOptionsList) + filterEventWithType(eventBean, eventOptionsList, eventDrawMap) + listener?.onDraw(eventDrawMap.values.toList(), true) } } } @@ -500,7 +508,8 @@ class TravelRealityView @JvmOverloads constructor( private fun filterEventWithType( eventBean: EventBean, - eventOptionsList: ArrayList + eventOptionsList: ArrayList, + eventDrawMap: HashMap ) { roadEventList.clear() when (eventBean.poiType) { @@ -511,8 +520,12 @@ class TravelRealityView @JvmOverloads constructor( zIndex(0.8f) icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_shigu_nor)) }) + eventBean.resId = R.drawable.mogo_shigu_nor eventBean.title = "交通事故" roadEventList.add(eventBean) + if (!eventDrawMap.containsKey("800003")) { + eventDrawMap["800003"] = EventDrawBean(R.drawable.mogo_shigu_nor, "交通事故") + } } "800002" -> {// 施工 @@ -522,8 +535,12 @@ class TravelRealityView @JvmOverloads constructor( zIndex(0.8f) icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_shigong_image)) }) + eventBean.resId = R.drawable.mogo_shigong_image eventBean.title = "道路施工" roadEventList.add(eventBean) + if (!eventDrawMap.containsKey("800002")) { + eventDrawMap["800002"] = EventDrawBean(R.drawable.mogo_shigong_image, "道路施工") + } } "800006" -> {// 拥堵 @@ -542,19 +559,16 @@ class TravelRealityView @JvmOverloads constructor( zIndex(0.8f) icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_jingzhi_nor)) }) + eventBean.resId = R.drawable.mogo_jingzhi_nor eventBean.title = "静止事件" roadEventList.add(eventBean) + if (!eventDrawMap.containsKey("800004")) { + eventDrawMap["800004"] = EventDrawBean(R.drawable.mogo_jingzhi_nor, "静止事件") + } } else -> { - eventOptionsList.add(MarkerOptions().apply { - position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) - anchor(0.5f, 0.5f) - zIndex(0.8f) - icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_jingzhi_nor)) - }) - eventBean.title = "未知事件" - roadEventList.add(eventBean) + Log.d(TAG, "请求到未知事件!") } } } @@ -694,6 +708,9 @@ class TravelRealityView @JvmOverloads constructor( } } } + if (deviceInPaths.isNotEmpty()) { + listener?.onDraw(arrayListOf(EventDrawBean(R.drawable.mogo_quanxi_lukou, "全息路口")), false) + } deviceInPathList = arrayListOf(CrossDeviceBean("", 0.0, "", 0.0, deviceInPaths)) // 绘制路口设备 drawMarkers(DRAW_CROSS_DEVICE, crossOptionsList) @@ -1016,6 +1033,11 @@ class TravelRealityView @JvmOverloads constructor( } } } + + interface OnDrawListener { + // isEvent为true表示是事件,反之则表示全息路口 + fun onDraw(eventList: List, isEvent: Boolean) + } private inner class NonFrequentHandler(looper: Looper) : Handler(looper) { @Suppress("UNCHECKED_CAST")