[dev_arch_opt_3.0]

[Change]
[
1、删除地图中废弃的定位回掉方法
2、修改小地图监听位置更改的方式,设置为10HZ,更新地图解决跳变问题
]

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2023-02-07 18:45:58 +08:00
parent 7ae724c3f0
commit daf51c78ce
15 changed files with 261 additions and 296 deletions

View File

@@ -6,16 +6,20 @@ import com.amap.api.location.AMapLocationClientOption
import com.amap.api.location.AMapLocationListener
import com.mogo.commons.AbsMogoApplication
import com.mogo.commons.constants.SharedPrefsConstants
import com.mogo.eagle.core.data.config.FunctionBuildConfig
import com.mogo.eagle.core.data.enums.DataSourceType
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssListener
import com.mogo.eagle.core.function.api.obu.IMoGoObuLocationWGS84Listener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuLocationWGS84ListenerManager
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.CoordinateTransform
import com.mogo.eagle.core.utilcode.util.TimeUtils
import com.mogo.eagle.core.utilcode.util.Utils
import com.mogo.support.obu.model.MogoObuHvBasicsData
import mogo.telematics.pad.MessagePad
/**
@@ -25,6 +29,7 @@ import mogo.telematics.pad.MessagePad
*/
object MoGoLocationDispatcher :
IMoGoChassisGnssListener,
IMoGoObuLocationWGS84Listener,
AMapLocationListener {
private val TAG = "MoGoLocationManager"
@@ -37,6 +42,11 @@ object MoGoLocationDispatcher :
*/
private var lastGnssLocation: MogoLocation = MogoLocation()
/**
* 最后一次OBU GNSS 返回更新的位置
*/
private var lastOBULocation: MogoLocation = MogoLocation()
/**
* 最后一次高德定位返回的位置信息
*/
@@ -69,6 +79,7 @@ object MoGoLocationDispatcher :
// 初始化监听订阅工控机位置信息
CallerChassisGnssListenerManager.addListener(TAG, this)
CallerObuLocationWGS84ListenerManager.addListener(TAG, this)
}
override fun onChassisGnss(gnssInfo: MessagePad.GnssInfo) {
@@ -95,17 +106,18 @@ object MoGoLocationDispatcher :
lastGnssLocation.errorCode = it.errorCode
lastGnssLocation.errorInfo = it.errorInfo
}
// WGS84坐标系高精度位置信息
CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84(
lastGnssLocation,
DataSourceType.TELEMATIC
)
// GCJ02高德坐标系位置信息
CallerChassisLocationGCJ20ListenerManager.invokeChassisLocationGCJ02(
lastGnssLocation,
DataSourceType.TELEMATIC
)
if (1 == FunctionBuildConfig.gpsProvider) {
// WGS84坐标系高精度位置信息
CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84(
lastGnssLocation,
DataSourceType.TELEMATIC
)
// GCJ02高德坐标系位置信息
CallerChassisLocationGCJ20ListenerManager.invokeChassisLocationGCJ02(
lastGnssLocation,
DataSourceType.TELEMATIC
)
}
}
/**
@@ -115,7 +127,7 @@ object MoGoLocationDispatcher :
override fun onLocationChanged(aMapLocation: AMapLocation) {
mapLocation = aMapLocation
// 更新GNSS 信息
lastGaoDeLocation.lastReceiveTime = TimeUtils.getNowMills()
// 将高德中的一些用于业务的数据进行融合例如CityCode、address等
mapLocation?.let {
@@ -150,27 +162,100 @@ object MoGoLocationDispatcher :
lastGaoDeLocation.errorInfo = it.errorInfo
}
// 计算最后一次工控机同步的定位是否超时,如果超时则切换为高德地图定位,暂定超过10秒需要切换
if (TimeUtils.getNowMills() - lastGnssLocation.lastReceiveTime > 10000) {
// WGS84坐标系高精度位置信息
CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84(
lastGaoDeLocation,
DataSourceType.MAP
)
// GCJ02高德坐标系位置信息
CallerChassisLocationGCJ20ListenerManager.invokeChassisLocationGCJ02(
lastGaoDeLocation,
DataSourceType.MAP
)
// 计算最后一次工控机同步的定位是否超时,如果超时则切换为高德地图定位,暂定超过30秒需要切换
if (1 == FunctionBuildConfig.gpsProvider) {
if (TimeUtils.getNowMills() - lastGnssLocation.lastReceiveTime > 30000) {
syncGaoDeLocation()
}
} else if (2 == FunctionBuildConfig.gpsProvider) {
if (TimeUtils.getNowMills() - lastOBULocation.lastReceiveTime > 30000) {
syncGaoDeLocation()
}
}
// 本地SP缓存城市Code
val cityCode = aMapLocation.cityCode
if (cityCode != null && cityCode.isNotEmpty()) {
mCityCode = aMapLocation.cityCode
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, cityCode)
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
.putString(
SharedPrefsConstants.LOCATION_LATITUDE,
aMapLocation.latitude.toString()
)
SharedPrefsMgr.getInstance(AbsMogoApplication.getApp())
.putString(
SharedPrefsConstants.LOCATION_LONGITUDE,
aMapLocation.longitude.toString()
)
}
}
/**
* 对外同步高德回掉的定位数据
*/
private fun syncGaoDeLocation() {
// WGS84坐标系高精度位置信息
CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84(
lastGaoDeLocation,
DataSourceType.MAP
)
// GCJ02高德坐标系位置信息
CallerChassisLocationGCJ20ListenerManager.invokeChassisLocationGCJ02(
lastGaoDeLocation,
DataSourceType.MAP
)
}
/**
* OBU定位回调监听
*/
override fun onObuLocationWGS84(data: MogoObuHvBasicsData) {
// 更新GNSS 信息
lastOBULocation.longitude = data.vehBasicsMsg.longitude
lastOBULocation.latitude = data.vehBasicsMsg.latitude
lastOBULocation.heading = data.vehBasicsMsg.heading
lastOBULocation.gnssSpeed = data.vehBasicsMsg.speed.toFloat()
lastOBULocation.altitude = data.vehBasicsMsg.elevation
lastOBULocation.satelliteTime = data.vehBasicsMsg.secMark
lastOBULocation.lastReceiveTime = TimeUtils.getNowMills()
// 将高德中的一些用于业务的数据进行融合例如CityCode、address等
mapLocation?.let {
lastOBULocation.cityName = it.city
lastOBULocation.cityCode = it.cityCode
lastOBULocation.provider = it.provider
lastOBULocation.address = it.address
lastOBULocation.district = it.district
lastOBULocation.province = it.province
lastOBULocation.adCode = it.adCode
lastOBULocation.locationDetail = it.locationDetail
lastOBULocation.poiName = it.poiName
lastOBULocation.aoiName = it.aoiName
lastOBULocation.street = it.street
lastOBULocation.streetNum = it.streetNum
lastOBULocation.description = it.description
lastOBULocation.buildingId = it.buildingId
lastOBULocation.floor = it.floor
lastOBULocation.errorCode = it.errorCode
lastOBULocation.errorInfo = it.errorInfo
}
if (2 == FunctionBuildConfig.gpsProvider) {
// WGS84坐标系高精度位置信息
CallerChassisLocationWGS84ListenerManager.invokeChassisLocationWGS84(
lastOBULocation,
DataSourceType.OBU
)
// GCJ02高德坐标系位置信息
CallerChassisLocationGCJ20ListenerManager.invokeChassisLocationGCJ02(
lastOBULocation,
DataSourceType.OBU
)
}
}
}

View File

@@ -16,6 +16,7 @@ import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Defa
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.TooClose
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
import com.mogo.eagle.core.function.call.obu.CallerObuConnectListenerManager
import com.mogo.eagle.core.function.call.obu.CallerObuLocationWGS84ListenerManager
import com.mogo.eagle.core.function.call.v2x.CallerLimitingVelocityListenerManager
import com.mogo.eagle.core.function.call.v2x.CallerTrafficLightListenerManager
import com.mogo.eagle.core.function.datacenter.obu.utils.TrafficDataConvertUtilsNew
@@ -31,7 +32,6 @@ import com.mogo.support.obu.model.*
import com.mogo.support.obu.model.advance.SpatLight
import com.mogo.support.obu.option.MogoObuCom
import com.mogo.support.obu.option.MogoObuOptions
import org.json.JSONObject
import kotlin.math.roundToInt
/**
@@ -107,45 +107,22 @@ class MogoPrivateObuNewManager private constructor() {
/**
* HV车辆基础信息 CvxHvCarIndInfo CvxHvInfoIndInfo
*/
override fun onMogoObuHvBasics(p0: MogoObuHvBasicsData?) {
if (p0 != null && p0.vehBasicsMsg != null) {
override fun onMogoObuHvBasics(mogoObuHvBasicsData: MogoObuHvBasicsData?) {
if (mogoObuHvBasicsData != null && mogoObuHvBasicsData.vehBasicsMsg != null) {
CallerLogger.d(
"$M_OBU${MogoObuConst.TAG_MOGO_NEW_OBU}",
"onMogoObuHvBasics lon = ${p0.vehBasicsMsg.longitude} --- lat = ${p0.vehBasicsMsg.latitude} ---speed = ${p0.vehBasicsMsg.speed} ---heading = ${p0.vehBasicsMsg.heading} --acceleration = ${p0.vehBasicsMsg.accFourAxes.accLat} --yawRate = ${p0.vehBasicsMsg.accFourAxes.accYaw}"
"onMogoObuHvBasics lon = ${mogoObuHvBasicsData.vehBasicsMsg.longitude} --- lat = ${mogoObuHvBasicsData.vehBasicsMsg.latitude} ---speed = ${mogoObuHvBasicsData.vehBasicsMsg.speed} ---heading = ${mogoObuHvBasicsData.vehBasicsMsg.heading} --acceleration = ${mogoObuHvBasicsData.vehBasicsMsg.accFourAxes.accLat} --yawRate = ${mogoObuHvBasicsData.vehBasicsMsg.accFourAxes.accYaw}"
)
val data = JSONObject()
try {
data.putOpt("lon", p0.vehBasicsMsg.longitude)
data.putOpt("lat", p0.vehBasicsMsg.latitude)
data.putOpt("speed", p0.vehBasicsMsg.speed)
data.putOpt("heading", p0.vehBasicsMsg.heading)
data.putOpt("acceleration", p0.vehBasicsMsg.accFourAxes.accLat)
data.putOpt("yawRate", p0.vehBasicsMsg.accFourAxes.accYaw)
try {
data.putOpt("systemTime", System.currentTimeMillis())
} catch (e: Exception) {
e.printStackTrace()
}
try {
data.putOpt("satelliteTime", System.currentTimeMillis())
} catch (e: Exception) {
e.printStackTrace()
}
// 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统1-工控机2-OBU
if (2 == FunctionBuildConfig.gpsProvider) {
// 同步给MAP地图
CallerMapUIServiceManager.getMapUIController()?.syncLocation2Map(data)
// 同步更新经纬度和系统时间至 AutoPilotStatusListener
CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(
System.currentTimeMillis() / 1000.0,
p0.vehBasicsMsg.longitude,
p0.vehBasicsMsg.latitude
)
}
} catch (e: Exception) {
e.printStackTrace()
// 使用与渠道配置一样的gps提供者提供的数据,app/productFlavors/fPadLenovo.gradle GPS_PROVIDER 0-Android系统1-工控机2-OBU
if (2 == FunctionBuildConfig.gpsProvider) {
// 同步给MAP地图
CallerObuLocationWGS84ListenerManager.invokeObuLocationWGS84(mogoObuHvBasicsData)
// 同步更新经纬度和系统时间至 AutoPilotStatusListener
CallerAutoPilotStatusListenerManager.updateAutoPilotLatLon(
System.currentTimeMillis() / 1000.0,
mogoObuHvBasicsData.vehBasicsMsg.longitude,
mogoObuHvBasicsData.vehBasicsMsg.latitude
)
}
}
}
@@ -621,7 +598,7 @@ class MogoPrivateObuNewManager private constructor() {
}
}
}
}
/**
* 获取消息的方位 车辆相关
@@ -894,7 +871,6 @@ private var isShowGreenWave = false
private var isShowRunRedLight = false
/**
* 修改红绿灯
*/
@@ -1004,22 +980,38 @@ private fun changeTrafficLightStatus(
when (currentLight.light) {
// 灯光不可用
0 -> {
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(TrafficLightEnum.BLACK,-1,DataSourceType.OBU)
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.BLACK,
-1,
DataSourceType.OBU
)
}
// 红灯
2, 3 -> {
val red = currentLight.countDown.toInt()
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(TrafficLightEnum.RED,red,DataSourceType.OBU)
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.RED,
red,
DataSourceType.OBU
)
}
// 绿灯
4, 5, 6 -> {
val green = currentLight.countDown.toInt()
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(TrafficLightEnum.GREEN,green,DataSourceType.OBU)
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.GREEN,
green,
DataSourceType.OBU
)
}
// 黄灯
7, 8 -> {
val yellow = currentLight.countDown.toInt()
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(TrafficLightEnum.YELLOW,yellow,DataSourceType.OBU)
CallerTrafficLightListenerManager.invokeTrafficLightPlusSource(
TrafficLightEnum.YELLOW,
yellow,
DataSourceType.OBU
)
}
}
}