[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)
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ interface IMogoData {
|
||||
/**
|
||||
* 获取公交站点集合
|
||||
*/
|
||||
fun getBusStation(routeList: ArrayList<LonLatPoint>): List<BusStation>
|
||||
fun getBusStation(routeList: ArrayList<LonLatPoint>, result:((MutableList<BusStation>) -> Unit))
|
||||
|
||||
/**
|
||||
* 获取路口数据
|
||||
|
||||
@@ -289,8 +289,8 @@ object MapDataWrapper : IMogoData {
|
||||
} ?: emptyList()
|
||||
}
|
||||
|
||||
override fun getBusStation(routeList: ArrayList<LonLatPoint>): MutableList<BusStation> {
|
||||
val latch = CountDownLatch(1)
|
||||
@Synchronized
|
||||
override fun getBusStation(routeList: ArrayList<LonLatPoint>, resultUnit:((MutableList<BusStation>) -> Unit)) {
|
||||
val resultList = mutableListOf<BusStation>()
|
||||
MapDataApi.getBusStation(routeList, object : IResult<RoutePath> {
|
||||
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? {
|
||||
|
||||
Reference in New Issue
Block a user