From 5419046bb632769a9ce9e689d919f5c12daccb92 Mon Sep 17 00:00:00 2001 From: aibingbing Date: Wed, 17 Jul 2024 16:19:43 +0800 Subject: [PATCH] =?UTF-8?q?[6.5.0][=E9=80=9A=E8=BF=87=E5=85=AC=E4=BA=A4?= =?UTF-8?q?=E7=AB=99]=20fix:=20=E9=AB=98=E7=B2=BE=E5=9C=B0=E5=9B=BEapi=20?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E7=BA=BF=E7=A8=8B=E5=8F=8A=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=B8=8D=E5=9B=9E=E8=B0=83=E9=97=AE=E9=A2=98=E4=BC=98=E5=8C=96?= =?UTF-8?q?=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../busstation/PassBusStationEventManager.kt | 62 +++++++++++++------ .../src/main/java/com/mogo/map/IMogoData.kt | 2 +- .../main/java/com/mogo/map/MapDataWrapper.kt | 8 +-- 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/busstation/PassBusStationEventManager.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/busstation/PassBusStationEventManager.kt index 3505840deb..7650677d9e 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/busstation/PassBusStationEventManager.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/busstation/PassBusStationEventManager.kt @@ -30,6 +30,8 @@ import kotlinx.coroutines.launch import mogo.telematics.pad.MessagePad import java.util.LinkedList import java.util.UUID +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit import java.util.concurrent.atomic.AtomicBoolean import kotlin.random.Random @@ -273,33 +275,53 @@ object PassBusStationEventManager : IMoGoChassisLocationWGS84Listener { } busStationHDMarkerStrategy() } + MogoData.mogoMapData.get()?.also { iMogoData -> - val busStationList = - iMogoData.getBusStation(java.util.ArrayList(farthestLocationList.toMutableList())) - val filteredBusStationList = busStationList.filter { - it.busStationPoints.isNotEmpty() && - DrivingDirectionUtils.getDegreeOfCar2Poi( + val latch = CountDownLatch(1) + iMogoData.getBusStation(java.util.ArrayList(farthestLocationList.toMutableList())) { + try { + val busStationList = it + + val filteredBusStationList = busStationList.filter { + it.busStationPoints.isNotEmpty() && + DrivingDirectionUtils.getDegreeOfCar2Poi( + gnssInfo.longitude, + gnssInfo.latitude, + it.getBusStationPoint().longitude, + it.getBusStationPoint().latitude, + gnssInfo.heading.toInt() + ) < 90 && CoordinateUtils.calculateLineDistance( gnssInfo.longitude, gnssInfo.latitude, it.getBusStationPoint().longitude, it.getBusStationPoint().latitude, - gnssInfo.heading.toInt() - ) < 90 && CoordinateUtils.calculateLineDistance( - gnssInfo.longitude, - gnssInfo.latitude, - it.getBusStationPoint().longitude, - it.getBusStationPoint().latitude, - ) <= (segmentSum * metersPreSegment) + ) <= (segmentSum * metersPreSegment) + } + Logger.d( + TAG, + "calculateNearByStation --> 本次查询出:${busStationList.size}个,本次符合条件:${filteredBusStationList.size}个,当前待提醒:${busStationListNeedNotified.size}个" + ) + synchronized(busStationNearByQueue) { + busStationNearByQueue.clear() + busStationNearByQueue.add(filteredBusStationList) + } + Logger.d(TAG, "getBusStation --- 1 ---") + } catch (e: Exception) { + e.printStackTrace() + } finally { + isCalculateNearByStation.set(false) + latch.countDown() + } } - Logger.d( - TAG, - "calculateNearByStation --> 本次查询出:${busStationList.size}个,本次符合条件:${filteredBusStationList.size}个,当前待提醒:${busStationListNeedNotified.size}个" - ) - synchronized(busStationNearByQueue) { - busStationNearByQueue.clear() - busStationNearByQueue.add(filteredBusStationList) + try { + if (latch.await(3, TimeUnit.SECONDS)) { + Logger.d(TAG, "getBusStation --- 2 ---") + } else { + Logger.d(TAG, "getBusStation --- 3 ---") + } + } catch (e: InterruptedException) { + e.printStackTrace() } - isCalculateNearByStation.set(false) } ?: run { isCalculateNearByStation.set(false) } diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoData.kt b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoData.kt index 0a5de66661..e8fad00b35 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoData.kt +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/IMogoData.kt @@ -121,7 +121,7 @@ interface IMogoData { /** * 获取公交站点集合 */ - fun getBusStation(routeList: ArrayList): List + fun getBusStation(routeList: ArrayList, result:((MutableList) -> Unit)) /** * 获取路口数据 diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MapDataWrapper.kt b/libraries/mogo-map/src/main/java/com/mogo/map/MapDataWrapper.kt index 0c285172c5..14077336b2 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MapDataWrapper.kt +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MapDataWrapper.kt @@ -289,8 +289,8 @@ object MapDataWrapper : IMogoData { } ?: emptyList() } - override fun getBusStation(routeList: ArrayList): MutableList { - val latch = CountDownLatch(1) + @Synchronized + override fun getBusStation(routeList: ArrayList, resultUnit:((MutableList) -> Unit)) { val resultList = mutableListOf() MapDataApi.getBusStation(routeList, object : IResult { override fun result(code: Int, result: RoutePath?) { @@ -300,11 +300,9 @@ object MapDataWrapper : IMogoData { resultList.add(busStation) } } - latch.countDown() + resultUnit.invoke(resultList) } }) - latch.await() - return resultList } override fun getCrossRoad(lon: Double, lat: Double, angle: Double): CrossRoad? {