[6.5.0][通过公交站] fix: 高精地图api 调用线程及可能不回调问题优化;
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user