[6.5.0] feat: 增加公交站点管理类;
This commit is contained in:
@@ -14,6 +14,7 @@ import com.mogo.eagle.function.biz.dispatch.DispatchAutoPilotManager.Companion.d
|
||||
import com.mogo.eagle.function.biz.monitoring.CronTaskManager.Companion.cronTaskManager
|
||||
import com.mogo.eagle.function.biz.notice.NoticeSocketManager.Companion.noticeSocketManager
|
||||
import com.mogo.eagle.function.biz.notice.network.NoticeNetWorkManager
|
||||
import com.mogo.eagle.function.biz.v2x.busstation.BusStationEventManager
|
||||
import com.mogo.eagle.function.biz.v2x.obu.V2xObuEventManager
|
||||
import com.mogo.eagle.function.biz.v2x.overview.OverViewDataManager
|
||||
import com.mogo.eagle.function.biz.v2x.overview.db.OverviewDb
|
||||
@@ -54,6 +55,7 @@ class FuncBizProvider : IMoGoFuncBizProvider {
|
||||
V2NIdentifyDrawer.init()
|
||||
// RedLightWarningManager.INSTANCE.listenTrafficLight()
|
||||
V2XEventAnalyticsManager.init()
|
||||
BusStationEventManager.init()
|
||||
}
|
||||
|
||||
override fun feedBackNoticeTraffic(infoId: String, sn: String, accept: Int) {
|
||||
@@ -126,6 +128,7 @@ class FuncBizProvider : IMoGoFuncBizProvider {
|
||||
dispatchAutoPilotManager.release()
|
||||
cronTaskManager.release()
|
||||
|
||||
BusStationEventManager.unInit()
|
||||
VipCarManager.INSTANCE.destroy()
|
||||
|
||||
if(!(AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package com.mogo.eagle.function.biz.v2x.busstation
|
||||
|
||||
import android.util.Pair
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationWGS84Listener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.map.MogoData
|
||||
import com.mogo.map.entities.BusStation
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import kotlin.math.sin
|
||||
|
||||
/**
|
||||
* 计算通过公交站点 管理类
|
||||
*/
|
||||
object BusStationEventManager : IMoGoChassisLocationWGS84Listener {
|
||||
|
||||
const val TAG = "BusStationEventManager"
|
||||
|
||||
private val mScope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
|
||||
private val isCalculateNearByStation = AtomicBoolean(false)
|
||||
private val farthestLocationList = ArrayList<LonLatPoint>()
|
||||
private val busStationListNearBy = LinkedHashMap<String, BusStation>()
|
||||
|
||||
|
||||
fun init() {
|
||||
CallerChassisLocationWGS84ListenerManager.addListener(TAG, 1, this)
|
||||
}
|
||||
|
||||
fun unInit() {
|
||||
CallerChassisLocationWGS84ListenerManager.removeListener(TAG)
|
||||
mScope?.cancel()
|
||||
}
|
||||
|
||||
override fun onChassisLocationWGS84(gnssInfo: MogoLocation) {
|
||||
if (!isCalculateNearByStation.get()) {
|
||||
isCalculateNearByStation.set(true)
|
||||
calculateNearByStation(gnssInfo, 15, 10)
|
||||
isCalculateNearByStation.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param gnssInfo 当前经纬度
|
||||
* @param segment 段总数
|
||||
* @param metersPreSegment 每段多少米
|
||||
*/
|
||||
private fun calculateNearByStation(
|
||||
gnssInfo: MogoLocation,
|
||||
segmentSum: Int,
|
||||
metersPreSegment: Int
|
||||
) {
|
||||
mScope.launch {
|
||||
farthestLocationList.clear()
|
||||
val heading = gnssInfo.heading
|
||||
//每10米一个点,获取150米范围内的坐标点
|
||||
for (index in 1..segmentSum) {
|
||||
val newPoint = calculateNewPoint(
|
||||
gnssInfo.longitude,
|
||||
gnssInfo.latitude,
|
||||
heading,
|
||||
index * metersPreSegment * 1.0
|
||||
)
|
||||
newPoint?.also {
|
||||
farthestLocationList.add(LonLatPoint(it.first, it.second))
|
||||
}
|
||||
}
|
||||
MogoData.mogoMapData.get()?.also { iMogoData ->
|
||||
val busStationList = iMogoData.getBusStation(farthestLocationList)
|
||||
Logger.d(
|
||||
TAG,
|
||||
"calculateNearByStation --> 查询出附近公交站点 ${busStationList.size} 个"
|
||||
)
|
||||
busStationList.forEach {
|
||||
busStationListNearBy[it.getBusStationId()] = it
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据当前经纬度和方向,计算距离 distance 米处的坐标
|
||||
*/
|
||||
private fun calculateNewPoint(
|
||||
x: Double,
|
||||
y: Double,
|
||||
angle: Double,
|
||||
distance: Double
|
||||
): Pair<Double, Double>? {
|
||||
if (distance == 0.0) {
|
||||
return null
|
||||
}
|
||||
val radian = Math.toRadians(angle)
|
||||
val radianCandle = Math.toRadians(angle)
|
||||
val nX = x + distance * sin(radian) / 100000.0
|
||||
val nY = y + distance * sin(radianCandle) / 100000.0
|
||||
return Pair.create(nX, nY)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,8 +1,10 @@
|
||||
package com.mogo.map
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.map.entities.BusStation
|
||||
import com.mogo.map.entities.Lane
|
||||
import com.mogo.map.entities.RoadInfo
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.data.road.CenterLine
|
||||
|
||||
interface IMogoData {
|
||||
@@ -54,7 +56,13 @@ interface IMogoData {
|
||||
/**
|
||||
* 获取道路宽度
|
||||
*/
|
||||
fun getRoadWidth(lon: Double, lat: Double, angle: Float, isGpsLocation: Boolean, isRTK: Boolean): Float
|
||||
fun getRoadWidth(
|
||||
lon: Double,
|
||||
lat: Double,
|
||||
angle: Float,
|
||||
isGpsLocation: Boolean,
|
||||
isRTK: Boolean
|
||||
): Float
|
||||
|
||||
/**
|
||||
* 获取行车方向
|
||||
@@ -75,17 +83,24 @@ interface IMogoData {
|
||||
/**
|
||||
* 通过cityCode,缓存城市HDMap
|
||||
*/
|
||||
fun cacheHDDataByCity(progress:((cityId: Int, progress: Double) -> Unit), result:((cityId: Int, state: Int) -> Unit))
|
||||
fun cacheHDDataByCity(
|
||||
progress: ((cityId: Int, progress: Double) -> Unit),
|
||||
result: ((cityId: Int, state: Int) -> Unit)
|
||||
)
|
||||
|
||||
/**
|
||||
* 通过经纬度信息,缓存城市HDMap
|
||||
*/
|
||||
fun cacheHDDataByCityByLonLat(location: MogoLocation, progress:((cityId: Int, progress: Double) -> Unit), result:((cityId: Int, state: Int) -> Unit))
|
||||
fun cacheHDDataByCityByLonLat(
|
||||
location: MogoLocation,
|
||||
progress: ((cityId: Int, progress: Double) -> Unit),
|
||||
result: ((cityId: Int, state: Int) -> Unit)
|
||||
)
|
||||
|
||||
/**
|
||||
* 当前城市离线数据是否已缓存
|
||||
*/
|
||||
fun isCityDataCached(cache:((Boolean) -> Unit))
|
||||
fun isCityDataCached(cache: ((Boolean) -> Unit))
|
||||
|
||||
/**
|
||||
* 取消下载 城市HDMap
|
||||
@@ -101,4 +116,9 @@ interface IMogoData {
|
||||
* 根据瓦片Id和道路Id获取车道数据
|
||||
*/
|
||||
fun getLaneInfo(tileId: Long, roadId: Int): List<Lane>
|
||||
|
||||
/**
|
||||
* 获取公交站点集合
|
||||
*/
|
||||
fun getBusStation(routeList: ArrayList<LonLatPoint>): List<BusStation>
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.mogo.map.entities
|
||||
|
||||
data class BusStation(
|
||||
var busStationPoints: List<com.zhidaoauto.map.data.point.LonLatPoint>,
|
||||
var id: Int,
|
||||
var roadId: Int,
|
||||
var type: Int
|
||||
) {
|
||||
override fun toString(): String {
|
||||
return "BusStation(busStationPoints=$busStationPoints, id=$id, roadId=$roadId, type=$type)"
|
||||
}
|
||||
|
||||
fun getBusStationId(): String {
|
||||
return "${id}_${roadId}"
|
||||
}
|
||||
}
|
||||
@@ -5,12 +5,15 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
|
||||
import com.mogo.map.MogoData.Companion.mogoMapData
|
||||
import com.mogo.map.entities.BusStation
|
||||
import com.mogo.map.entities.Lane
|
||||
import com.mogo.map.location.GDLocationClient.Companion.gdLocationClient
|
||||
import com.mogo.map.utils.HDMapUtils.getHDCityCode
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.data.road.CenterLine
|
||||
import com.zhidaoauto.map.data.road.RoadNameInfo
|
||||
import com.zhidaoauto.map.data.road.RoadRectInfos
|
||||
import com.zhidaoauto.map.data.road.RoutePath
|
||||
import com.zhidaoauto.map.data.routeinfo.RoadInfo
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
import com.zhidaoauto.map.sdk.open.abs.IResult
|
||||
@@ -82,7 +85,7 @@ object MapDataWrapper : IMogoData {
|
||||
call: ((CenterLine?) -> Unit)
|
||||
) {
|
||||
try {
|
||||
MapDataApi.getCenterLineRangeInfo(lon, lat, angle, distance,false,6,
|
||||
MapDataApi.getCenterLineRangeInfo(lon, lat, angle, distance, false, 6,
|
||||
object : IResult<CenterLine> {
|
||||
override fun result(code: Int, result: CenterLine?) {
|
||||
call.invoke(result)
|
||||
@@ -206,7 +209,7 @@ object MapDataWrapper : IMogoData {
|
||||
location.longitude, location.latitude,
|
||||
object : OnHdDataDownByCityListener {
|
||||
override fun onMapHDDataCacheProgressByCity(id: Int, p: Double) {
|
||||
progress.invoke(id, p * 100)
|
||||
progress.invoke(id, p * 100)
|
||||
}
|
||||
|
||||
override fun onMapHDDataCacheStateByCity(id: Int, state: Int) {
|
||||
@@ -266,12 +269,38 @@ object MapDataWrapper : IMogoData {
|
||||
})
|
||||
latch.await()
|
||||
Logger.d(TAG, "getRoadInfo --- 2 ---: code -> $tempCode, data -> $tempData")
|
||||
return com.mogo.map.entities.RoadInfo(tempCode, tempData?.tile_id?.toLong()?:0L, tempData?.road_id?.toInt() ?: 0, tempData?.road_name ?: "")
|
||||
return com.mogo.map.entities.RoadInfo(
|
||||
tempCode,
|
||||
tempData?.tile_id?.toLong() ?: 0L,
|
||||
tempData?.road_id?.toInt() ?: 0,
|
||||
tempData?.road_name ?: ""
|
||||
)
|
||||
}
|
||||
|
||||
override fun getLaneInfo(tileId: Long, roadId: Int): List<Lane> {
|
||||
return MapDataApi.getLaneInfo(tileId, roadId)?.map { itx ->
|
||||
Lane(itx.laneId, itx.laneWidth, itx.laneLatLonPoints.map { Pair(it.longitude, it.latitude) })
|
||||
Lane(
|
||||
itx.laneId,
|
||||
itx.laneWidth,
|
||||
itx.laneLatLonPoints.map { Pair(it.longitude, it.latitude) })
|
||||
} ?: emptyList()
|
||||
}
|
||||
|
||||
override fun getBusStation(routeList: ArrayList<LonLatPoint>): MutableList<BusStation> {
|
||||
val latch = CountDownLatch(1)
|
||||
val resultList = mutableListOf<BusStation>()
|
||||
MapDataApi.getBusStation(routeList, object : IResult<RoutePath> {
|
||||
override fun result(code: Int, result: RoutePath?) {
|
||||
result?.steps?.forEach {
|
||||
it?.busStations?.forEach {
|
||||
val busStation = BusStation(it.busStationPoints, it.id, it.roadId, it.type)
|
||||
resultList.add(busStation)
|
||||
}
|
||||
}
|
||||
latch.countDown()
|
||||
}
|
||||
})
|
||||
latch.await()
|
||||
return resultList
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user