「Change」

修复「OCH 小地图」车辆角度晃动问题

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2022-04-02 15:17:14 +08:00
parent 8a5c3f0ea2
commit 126905b257

View File

@@ -336,7 +336,7 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
}
private fun refreshCarState(location: MogoLocation) {
fixCarAngle(location)
V2XStatusManager.getInstance().location = location
// 只有车速大于 5 的时候进行计算
if (location.speed < 5) return
val v2xPolyline = BridgeApi.v2xPolyline()?.mogoPolyline
@@ -422,32 +422,6 @@ object V2XEventManager : IMoGoMapLocationListener, IMoGoTokenCallback, IV2XCallb
}
}
private fun fixCarAngle(location: MogoLocation) { // 记录位置轨迹
// 记录位置轨迹
if (historyPath[0] != null) {
historyPath[1] = historyPath[0]
}
historyPath[0] = location
if (historyPath[1] != null && historyPath[0] != null) {
val carAngle: Double = DrivingDirectionUtils.getCarAngle(
historyPath[1]!!.latitude,
historyPath[1]!!.longitude,
historyPath[0]!!.latitude,
historyPath[0]!!.longitude
).toDouble()
//CallerLogger.d("$M_V2X$TAG",
// "\n车辆经纬度" + Arrays.toString(historyPath) +
// "\n车辆角度" + carAngle);
// 这里是真实的车辆角度
location.bearing = carAngle.toFloat()
} else { //CallerLogger.e("$M_V2X$TAG",
// "\n首次获取经纬度默认车头朝北" + Arrays.toString(historyPath));
location.bearing = 0.0f
}
V2XStatusManager.getInstance().location = location
}
override fun onTokenGot(token: String?, sn: String?) {
if (V2XManager.hasInit()) {