From 42db74d3a0bd100074443e5b62689eb359580946 Mon Sep 17 00:00:00 2001 From: chenfufeng Date: Wed, 17 Jul 2024 17:35:29 +0800 Subject: [PATCH] =?UTF-8?q?[6.5.0][Fix]=E8=A7=A3=E5=86=B3=E9=81=93?= =?UTF-8?q?=E8=B7=AF=E4=BA=8B=E4=BB=B6=E4=B8=8D=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/function/view/TravelRealityView.kt | 56 ++++++++++++------- 1 file changed, 37 insertions(+), 19 deletions(-) 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 ef11387aa9..840894e5da 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 @@ -198,6 +198,12 @@ class TravelRealityView @JvmOverloads constructor( private val ipPointMap by lazy { HashMap() } + private val eventPointMap by lazy { + HashMap() + } + private val devicePointMap by lazy { + HashMap() + } private var testTime = 0L @@ -459,34 +465,40 @@ class TravelRealityView @JvmOverloads constructor( testTime = System.currentTimeMillis() val eventDrawMap = HashMap() val eventOptionsList = ArrayList() + var distance = 0.0 + var key = "" globalList.forEachIndexed { index, globalPoint -> if (index >= 0 && index < globalList.size - 1) { eventList.forEach { eventBean -> - if (LocationUtils.pointToLine( - globalPoint.lon, - globalPoint.lat, - globalList[index + 1].lon, - globalList[index + 1].lat, - eventBean.lon, - eventBean.lat - ) > 5 - ) { + distance = LocationUtils.pointToLine( + globalPoint.lon, + globalPoint.lat, + globalList[index + 1].lon, + globalList[index + 1].lat, + eventBean.lon, + eventBean.lat + ) + key = "${eventBean.lon},${eventBean.lat}" + if (distance >= 10 || eventPointMap.contains(key)) { + Log.d(TAG, "道路事件:点(${key})到线段${index}-${index+1}的距离为:${distance}米") return@forEach } + eventPointMap[key] = 1 eventBean.orientation = travelNetWorkModel.calculateOrientation( eventBean.lon, eventBean.lat, globalPoint.lon, globalPoint.lat, globalList[index + 1].lon, globalList[index + 1].lat, ) filterEventWithType(eventBean, eventOptionsList, eventDrawMap) - listener?.onDraw(eventDrawMap.values.toList(), true) } } } + listener?.onDraw(eventDrawMap.values.toList(), true) Log.d(TAG, "过滤掉的事件个数为:${eventList.size - eventOptionsList.size}") // 事件不足3个则用路口设备补齐 completeQuantity() // 绘制道路事件 drawMarkers(DRAW_ROAD_EVENT, eventOptionsList) + eventPointMap.clear() } private fun completeQuantity() { @@ -724,22 +736,27 @@ class TravelRealityView @JvmOverloads constructor( if (crossDeviceList.isEmpty()) return val crossOptionsList = ArrayList() val globalList = reqData + var distance = 0.0 + var key = "" val deviceInPaths = ArrayList() globalList?.forEachIndexed { index, globalPoint -> if (index >= 0 && index < globalList.size - 1) { crossDeviceList.forEach { it.deviceInfoList?.forEach loop@{ deviceBean -> - if (LocationUtils.pointToLine( - globalPoint.lon, - globalPoint.lat, - globalList[index + 1].lon, - globalList[index + 1].lat, - deviceBean.lon, - deviceBean.lat - ) > 5 - ) { + distance = LocationUtils.pointToLine( + globalPoint.lon, + globalPoint.lat, + globalList[index + 1].lon, + globalList[index + 1].lat, + deviceBean.lon, + deviceBean.lat + ) + key = "${deviceBean.lon},${deviceBean.lat}" + if (distance >= 10 || devicePointMap.contains(key)) { + Log.d(TAG, "路口设备:点(${key})到线段${index}-${index+1}的距离为:${distance}米") return@loop } + devicePointMap[key] = 1 // 计算事件Marker朝向 deviceBean.orientation = travelNetWorkModel.calculateOrientation( deviceBean.lon, @@ -764,6 +781,7 @@ class TravelRealityView @JvmOverloads constructor( } } } + devicePointMap.clear() if (deviceInPaths.isNotEmpty()) { listener?.onDraw( arrayListOf(EventDrawBean(R.drawable.mogo_quanxi_lukou, "全息路口")),