[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
)
}
}
}

View File

@@ -2,12 +2,12 @@ package com.zhjt.mogo_core_function_devatools.env
import android.content.Context.MODE_PRIVATE
import android.os.Process
import com.mogo.commons.constants.*
import com.mogo.commons.debug.*
import com.mogo.commons.constants.SharedPrefsConstants
import com.mogo.commons.debug.DebugConfig
import com.mogo.eagle.core.data.EnvConfig
import com.mogo.eagle.core.function.call.map.*
import com.mogo.eagle.core.utilcode.mogo.storage.*
import com.mogo.eagle.core.utilcode.util.*
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.Utils
object EnvChangeManager {
@@ -34,7 +34,7 @@ object EnvChangeManager {
fun getCityName(): String {
val cache = getConfig()
return if (cache == null) {
when(CallerMapLocationListenerManager.getCurrentLocation()?.cityCode ?: SharedPrefsMgr.getInstance(Utils.getApp()).getString(SharedPrefsConstants.LOCATION_CITY_CODE) ?: "010") {
when(CallerChassisLocationGCJ20ListenerManager.getChassisLocationGCJ02()?.cityCode ?: SharedPrefsMgr.getInstance(Utils.getApp()).getString(SharedPrefsConstants.LOCATION_CITY_CODE) ?: "010") {
"010" -> "北京"
"0734" -> "衡阳"
else -> "未知"

View File

@@ -14,7 +14,6 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Liste
import com.mogo.eagle.core.function.api.map.collect.IMoGoMapDataCollectProvider
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
import com.zhidaoauto.map.operational.open.GatherApi
@@ -26,7 +25,8 @@ import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.atomic.AtomicReference
@Route(path = MogoServicePaths.PATH_MAP_DATA_COLLECT_PROVIDER)
class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener, IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback,
class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback,
IMoGoAutopilotRecordListener {
companion object {
@@ -57,11 +57,14 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
executor.set(context?.let {
GatherApi.also { itx ->
itx.init(it,
GatherParams.init()
.setDebugMode(false)
.setCoordinateType(GatherParams.COORDINATETYPE_GCJ02))
} })
itx.init(
it,
GatherParams.init()
.setDebugMode(false)
.setCoordinateType(GatherParams.COORDINATETYPE_GCJ02)
)
}
})
executor.get()?.setOnTaskListener(this)
val carSn = MoGoAiCloudClientConfig.getInstance().sn
if (!TextUtils.isEmpty(carSn)) {
@@ -69,7 +72,7 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
}
MoGoAiCloudClient.getInstance().addTokenCallbacks(this)
CallerLogger.d("$M_MAP$TAG", "--------- init --------")
CallerLogger.d("$M_MAP$TAG", "executor: ${ executor.get()?.hashCode() ?: 0 }")
CallerLogger.d("$M_MAP$TAG", "executor: ${executor.get()?.hashCode() ?: 0}")
}
override fun onDestroy() {
@@ -90,7 +93,13 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
recordPanel.stat == 102 || //工控机达到最大采集时长
recordPanel.stat == 103) //工控机磁盘满了
) {
finish(recordPanel.id, recordPanel.stat, "", recordPanel.filename ?: "", recordPanel.note ?: "")
finish(
recordPanel.id,
recordPanel.stat,
"",
recordPanel.filename ?: "",
recordPanel.note ?: ""
)
}
}
@@ -131,7 +140,7 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
}
CallerLogger.d("$M_MAP$TAG", "-- finish: 结束任务[$id]")
executor.get()?.finishTask(id, state, gpsPath, videoPath, reason)
} catch (e : Throwable) {
} catch (e: Throwable) {
e.printStackTrace()
CallerLogger.e("$M_MAP$TAG", "-- finish:\n$e")
} finally {
@@ -171,14 +180,16 @@ class MoGoMapDataCollectProvider : IMoGoMapDataCollectProvider, OnTaskListener,
}
override fun onChassisLocationGCJ02(gnssInfo: MogoLocation?) {
val location = CallerMapLocationListenerManager.getCurrentLocation() ?: return
executor.get()?.updateLocation(
location.longitude,
location.latitude,
location.altitude,
location.heading.toFloat(),
location.gnssSpeed,
false)
if (gnssInfo != null) {
executor.get()?.updateLocation(
gnssInfo.longitude,
gnssInfo.latitude,
gnssInfo.altitude,
gnssInfo.heading.toFloat(),
gnssInfo.gnssSpeed,
false
)
}
}
private fun isInValidStatus(): Boolean {

View File

@@ -29,7 +29,6 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import mogo.telematics.pad.MessagePad
import java.util.*
import kotlin.math.floor
class SmallMapView @JvmOverloads constructor(
@@ -156,10 +155,9 @@ class SmallMapView @JvmOverloads constructor(
initAMapView()
// 注册定位监听
CallerChassisLocationGCJ20ListenerManager.addListener(TAG, this)
CallerChassisLocationGCJ20ListenerManager.addListener(TAG, 10,this)
CallerPlanningRottingListenerManager.addListener(TAG, this)
CallerAutoPilotStatusListenerManager.addListener(TAG, this)
startTask()
}
private fun initAMapView() {
@@ -237,52 +235,6 @@ class SmallMapView @JvmOverloads constructor(
})
}
private fun startTask() {
val mTimer = Timer()
mTimer.schedule(UpdateLocationTask(), 1000, 200)
}
private inner class UpdateLocationTask : TimerTask() {
override fun run() {
if (mLocation != null) {
if (mCarMarker == null) {
mCarMarker = mAMap!!.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo))
.anchor(0.5f, 0.5f)
)
}
if (mCarMarker == null) {
return
}
val currentLatLng = LatLng(mLocation!!.latitude, mLocation!!.longitude)
val bearing = floor(mLocation!!.heading).toFloat()
//更新车辆位置
mCarMarker!!.position = currentLatLng
if (mCoordinatesLatLng.size > 1) {
// 结束位置
val endLatLng = mCoordinatesLatLng[mCoordinatesLatLng.size - 1]
val calculateDistance = CoordinateUtils.calculateLineDistance(
endLatLng.latitude, endLatLng.longitude,
currentLatLng.latitude, currentLatLng.longitude
)
CallerLogger.d(
SceneConstant.M_MAP + TAG,
"calculateDistance=$calculateDistance"
)
if (calculateDistance <= 5) {
clearPolyline()
mCoordinatesLatLng.clear()
}
}
val cameraPosition: CameraPosition =
CameraPosition.Builder().target(mCarMarker!!.position).tilt(0f).bearing(bearing)
.zoom(zoomLevel.toFloat()).build()
mAMap?.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
}
}
}
private fun coordinateConverterFrom84(mContext: Context?, mogoLatLng: MogoLatLng): LatLng {
val mCoordinateConverter = CoordinateConverter(mContext)
mCoordinateConverter.from(CoordinateConverter.CoordType.GPS)
@@ -307,6 +259,49 @@ class SmallMapView @JvmOverloads constructor(
return
}
mLocation = mogoLocation
if (mCarMarker == null) {
mCarMarker =
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
mAMap?.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon))
.anchor(0.5f, 0.5f)
)
} else {
mAMap?.addMarker(
MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon))
.anchor(0.5f, 0.5f)
)
}
}
if (mCarMarker == null) {
return
}
val currentLatLng = LatLng(mLocation!!.latitude, mLocation!!.longitude)
val bearing = floor(mLocation!!.heading).toFloat()
//更新车辆位置
mCarMarker!!.position = currentLatLng
if (mCoordinatesLatLng.size > 1) {
// 结束位置
val endLatLng = mCoordinatesLatLng[mCoordinatesLatLng.size - 1]
val calculateDistance = CoordinateUtils.calculateLineDistance(
endLatLng.latitude, endLatLng.longitude,
currentLatLng.latitude, currentLatLng.longitude
)
CallerLogger.d(
SceneConstant.M_MAP + TAG,
"calculateDistance=$calculateDistance"
)
if (calculateDistance <= 5) {
clearPolyline()
mCoordinatesLatLng.clear()
}
}
val cameraPosition: CameraPosition =
CameraPosition.Builder().target(mCarMarker!!.position).tilt(0f).bearing(bearing)
.zoom(zoomLevel.toFloat()).build()
mAMap?.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition))
}
override fun onAutopilotStatusResponse(autoPilotStatusInfo: AutopilotStatusInfo) {

View File

@@ -34,7 +34,6 @@ import com.mogo.eagle.core.function.call.analytics.AnalyticsManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
import com.mogo.eagle.core.function.call.cloud.CallerCloudListenerManager
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
@@ -146,7 +145,7 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
return HttpDnsSimpleLocation(envConfig.cityCode, envConfig.lat, envConfig.lon)
}
var mogoLocation: MogoLocation? = null
val locationClient = CallerMapLocationListenerManager.getCurrentLocation()
val locationClient = CallerChassisLocationGCJ20ListenerManager.getChassisLocationGCJ02()
if (locationClient != null) {
mogoLocation = locationClient
}
@@ -305,7 +304,7 @@ class HttpDnsStartUp : AndroidStartup<Boolean>() {
private fun startSocketService() {
CallerLogger.d(SceneConstant.M_MAIN + TAG, "startSocketService")
val location = CallerMapLocationListenerManager.getCurrentLocation()
val location = CallerChassisLocationGCJ20ListenerManager.getChassisLocationGCJ02()
// 关闭长链服务
MogoAiCloudSocketManager.getInstance(context).destroy()
MogoAiCloudSocketManager.getInstance(context)

View File

@@ -31,7 +31,6 @@ import com.mogo.eagle.core.function.api.hmi.warning.IMoGoWarningStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager.Scene.Default
@@ -124,16 +123,17 @@ object V2XEventManager : IMoGoChassisLocationGCJ02Listener, IMoGoTokenCallback,
mogoMarkersHandler.unregisterMarkerClickListener(CARD_TYPE_ROAD_CONDITION)
}
override fun onChassisLocationGCJ02(gnssInfo: MogoLocation?) {
val location = CallerMapLocationListenerManager.getCurrentLocation() ?: return
BridgeApi.location.set(location)
if (V2XManager.hasInit()) {
V2XManager.onLocationChanged(
longitude = location.longitude,
latitude = location.latitude
)
override fun onChassisLocationGCJ02(mogoLocation: MogoLocation?) {
BridgeApi.location.set(mogoLocation)
mogoLocation?.let {
if (V2XManager.hasInit()) {
V2XManager.onLocationChanged(
longitude = it.longitude,
latitude = mogoLocation.latitude
)
}
refreshCarState(mogoLocation)
}
refreshCarState(location)
}
private fun refreshCarState(location: MogoLocation) {

View File

@@ -2,7 +2,9 @@ package com.mogo.eagle.core.function.v2x.events.manager.impl;
import static com.mogo.commons.module.ServiceConst.CARD_TYPE_NOVELTY;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
import android.content.Context;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.eagle.core.data.enums.EventTypeEnumNew;
@@ -12,7 +14,7 @@ import com.mogo.eagle.core.data.map.entity.MarkerExploreWay;
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
import com.mogo.eagle.core.data.map.entity.MarkerShowEntity;
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
import com.mogo.eagle.core.function.v2x.events.consts.MoGoV2XServicePaths;
import com.mogo.eagle.core.function.v2x.events.manager.IMoGoV2XMarkerManager;
@@ -26,6 +28,7 @@ import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.MogoMarkerOptions;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CopyOnWriteArrayList;
@@ -52,7 +55,7 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
public CopyOnWriteArrayList<V2XRoadEventEntity> getV2XRoadEventEntityList() {
CopyOnWriteArrayList<V2XRoadEventEntity> roadEventEntities = new CopyOnWriteArrayList<>();
// 当前车辆数据
MogoLocation currentLocation = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
MogoLocation currentLocation = CallerChassisLocationGCJ20ListenerManager.INSTANCE.getChassisLocationGCJ02();
if (currentLocation != null) {
// 重新计算距离
for (V2XRoadEventEntity v2XRoadEventEntity : mV2XRoadEventEntityArrayList) {

View File

@@ -205,6 +205,19 @@ public class MogoLocation implements Cloneable {
}
}
public double getYawRate() {
if (gnssInfo != null) {
return gnssInfo.getYawRate();
}
return 0;
}
public void setYawRate(double yawRate) {
if (gnssInfo != null) {
gnssInfo = gnssInfo.toBuilder().setYawRate(yawRate).build();
}
}
public String getAddress() {
return address;
}

View File

@@ -22,6 +22,9 @@ object CallerChassisLocationGCJ20ListenerManager : CallerBase<IMoGoChassisLocati
/**
* 添加监听并指定回掉频率
* @param tag
* @param callBackHz // 设置数据回调频率单位HZ1HZ的周期是1秒50HZ的周期是1/50=0.02秒10HZ的周期是1/10=0.1秒。
* @param listener
*/
fun addListener(
tag: String,
@@ -41,7 +44,7 @@ object CallerChassisLocationGCJ20ListenerManager : CallerBase<IMoGoChassisLocati
* @param gnssInfo
*/
@Synchronized
fun invokeChassisLocationGCJ02(gnssInfo: MogoLocation?,sourceType: DataSourceType) {
fun invokeChassisLocationGCJ02(gnssInfo: MogoLocation?, sourceType: DataSourceType) {
gnssInfo?.let {
// 转换 WGS84-->GCJ02 坐标
val gcj20Location =

View File

@@ -1,27 +0,0 @@
package com.mogo.eagle.core.function.call.map
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.function.call.base.CallerBase
/**
* 高德地图 位置改变 监听管理
* @author dongghongyu
* @date 2021/9/30 5:48 下午
*/
object CallerMapLocationListenerManager : CallerBase<Any>() {
// 记录地图最后一次位置
@Volatile
private var mLocation: MogoLocation? = null
/**
* 获取当前经纬度
*/
fun getCurrentLocation(): MogoLocation? {
return mLocation
}
fun setCurrentLocation(location: MogoLocation) {
mLocation = location
}
}

View File

@@ -11,8 +11,6 @@ import com.mogo.eagle.core.data.map.CenterLine;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import org.json.JSONObject;
import java.util.List;
/**
@@ -175,7 +173,6 @@ public interface IMogoMapUIController {
void setCarCursorOption(@Nullable CarCursorOption option);
/**
*
* @param type :车尾灯类型 time: 闪烁时间 最小500ms 小于500ms 默认为500ms
*/
void setCarLightsType(int type, int time);
@@ -258,17 +255,6 @@ public interface IMogoMapUIController {
}
//todo 改造,此处调用到数据中心同步,删除此处更新。后续更新调用, {@link CallerMapUIServiceManager#getSingletonLocationClient}
/**
* 使用自动驾驶车的定位数据
*
* @param data
*/
default void syncLocation2Map(JSONObject data) {
}
/**
* 获取车速资源缓存 id
*
@@ -303,9 +289,10 @@ public interface IMogoMapUIController {
/**
* 获取当前道路方向
*
* @return angle
*/
Double getRoadAngle(Double lon,Double lat,float angle);
Double getRoadAngle(Double lon, Double lat, float angle);
/**
* 设置锁屏模式

View File

@@ -24,7 +24,6 @@ import android.view.View;
import androidx.annotation.NonNull;
import com.mogo.commons.constants.SharedPrefsConstants;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
import com.mogo.eagle.core.data.enums.TrafficTypeEnum;
@@ -32,13 +31,12 @@ import com.mogo.eagle.core.data.map.CenterLine;
import com.mogo.eagle.core.data.map.MapRoadInfo;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager;
import com.mogo.eagle.core.function.call.map.CallerMapDevaListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapStyleListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.listener.MogoMapListenerHandler;
@@ -67,9 +65,7 @@ import com.zhidaoauto.map.sdk.open.camera.CameraUpdateFactory;
import com.zhidaoauto.map.sdk.open.camera.LatLngBounds;
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
import com.zhidaoauto.map.sdk.open.location.LocationClient;
import com.zhidaoauto.map.sdk.open.location.LocationListener;
import com.zhidaoauto.map.sdk.open.location.MyLocationStyle;
import com.zhidaoauto.map.sdk.open.location.RTKAutopilotLocationBean;
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptorFactory;
import com.zhidaoauto.map.sdk.open.marker.Marker;
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener;
@@ -83,14 +79,12 @@ import com.zhjt.service.chain.TracingConstants;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class AMapViewWrapper implements IMogoMapView,
IMogoMapUIController,
LocationListener,
OnMapLoadedListener,
MapStatusListener,
OnCameraChangeListener,
@@ -180,10 +174,6 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnMapLoadedListener(this);
mMapView.setOnMapTouchListener(this);
mMapView.setOnMapClickListener(this);
LocationClient client = mMapView.getLocationClient();
if (client != null) {
client.registerListener(this);
}
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ZOOM);
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ROTATE);
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_3D);
@@ -208,7 +198,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void onStopLineInfo(@androidx.annotation.Nullable StopLine stopLine) {
MogoLocation carLoc = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
MogoLocation carLoc = CallerChassisLocationGCJ20ListenerManager.INSTANCE.getChassisLocationGCJ02();
if (stopLine != null && stopLine.road_id != null && !stopLine.road_id.isEmpty() && stopLine.points != null && stopLine.points.size() > 0) {
ArrayList<LonLatPoint> points = stopLine.points;
if (carLoc != null) {
@@ -316,7 +306,6 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnMapLoadedListener(null);
mMapView.setOnMapTouchListener(null);
mMapView.setOnMapClickListener(null);
mMapView.getLocationClient().unRegisterListener(this);
mMapView.setOnCameraChangeListener(null);
MapAutoApi.INSTANCE.unregisterLogListener(this);
CallerLogger.INSTANCE.d(M_MAP + TAG, "map onDestroy");
@@ -694,37 +683,6 @@ public class AMapViewWrapper implements IMogoMapView,
CallerMapDevaListenerManager.INSTANCE.invokeUploadLogFile(filePath);
}
@Override
public void onLocationChanged(@NotNull com.zhidaoauto.map.sdk.open.location.MogoLocation location) {
CallerMapLocationListenerManager.INSTANCE.setCurrentLocation(ObjectUtils.fromLocation(location));
// 将有效经纬度暂存本地提供给下一次的Http-DNS使用防止首次请求位置获取不到
if (location.getLat() > 0 && location.getLon() > 0) {
if (location.getCityCode() != null && !location.getCityCode().isEmpty()) {
SharedPrefsMgr.getInstance(mMapView.getContext())
.putString(SharedPrefsConstants.LOCATION_CITY_CODE, location.getCityCode());
}
SharedPrefsMgr.getInstance(mMapView.getContext())
.putString(SharedPrefsConstants.LOCATION_LATITUDE, String.valueOf(location.getLat()));
SharedPrefsMgr.getInstance(mMapView.getContext())
.putString(SharedPrefsConstants.LOCATION_LONGITUDE, String.valueOf(location.getLon()));
}
if (checkAMapView() && mMapLoaded) {
// 地图初始化完成后每隔5s自动判断当前地图的模式
if (mIsFirstLocated) {
if (!mIsDelayed) {
mIsDelayed = true;
UiThreadHandler.postDelayed(() -> {
//CallerLogger.INSTANCE.d(M_MAP+TAG, "倒计时结束");
mIsFirstLocated = false;
}, 5_000L);
}
} else {
mIsFirstLocated = true;
mIsDelayed = false;
}
}
}
@Override
public void onMapClick(@Nullable LonLatPoint lonLatPoint) {
@@ -889,42 +847,6 @@ public class AMapViewWrapper implements IMogoMapView,
}
}
@Override
public void syncLocation2Map(JSONObject data) {
if (!checkAMapView()) {
return;
}
if (data == null) {
CallerLogger.INSTANCE.d(M_MAP + TAG, "停止使用rtk定位数据");
return;
}
double lon = data.optDouble("lon", -1);
double lat = data.optDouble("lat", -1);
double alt = data.optDouble("alt", -1);
double heading = data.optDouble("heading", -1);
double acceleration = data.optDouble("acceleration", -1);
double yawRate = data.optDouble("yawRate", -1);
double speed = data.optDouble("speed", -1);
long systemTime = data.optLong("systemTime");
long satelliteTime = data.optLong("satelliteTime");
if (lon == -1) {
return;
}
RTKAutopilotLocationBean bean = new RTKAutopilotLocationBean();
bean.setYaw_rate(yawRate);
bean.setHeading(heading);
bean.setAcceleration(acceleration);
bean.setAlt(alt);
bean.setSystemTime(systemTime);
bean.setSatelliteTime(satelliteTime);
bean.setLon(lon);
bean.setGnss_speed(((float) speed));
bean.setLat(lat);
// 使用外部定位数据修改自车位置
mMapView.getLocationClient().updateRTKAutoPilotLocation(bean);
CallerMapDataCollectorManager.INSTANCE.setIsInit();
}
@Override
public void stepInVrMode(boolean isDayMode) {

View File

@@ -14,8 +14,6 @@ import com.mogo.map.uicontroller.MapCameraPosition;
import com.mogo.map.uicontroller.MapControlResult;
import com.mogo.map.uicontroller.VisualAngleMode;
import org.json.JSONObject;
import java.util.List;
/**
@@ -322,14 +320,6 @@ public class MogoMapUIController implements IMogoMapUIController {
}
}
@Override
public void syncLocation2Map(JSONObject data) {
initDelegate();
if (mDelegate != null) {
mDelegate.syncLocation2Map(data);
}
}
@Override
public void destroy() {
mDelegate = null;

View File

@@ -9,8 +9,6 @@ import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.zhidaoauto.map.sdk.open.MapAutoApi;
import org.json.JSONObject;
import java.util.List;
/**
@@ -283,12 +281,6 @@ public class AMapUIController implements IMogoMapUIController {
}
}
@Override
public void syncLocation2Map(JSONObject data) {
if (mClient != null) {
mClient.syncLocation2Map(data);
}
}
@Override
public void stepInVrMode(boolean isDayMode) {