Merge branch 'refs/heads/dev_robotaxi-d_240912_6.7.0' into dev_robotaxi-d_240912_6.7.2_local
# Conflicts: # core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/roadcross/RoadCrossCameraManager.kt # core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/RoadCrossRoamView.kt
This commit is contained in:
@@ -7,13 +7,15 @@ import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.os.Message
|
||||
import com.mogo.commons.debug.DebugConfig
|
||||
import com.mogo.commons.voice.AIAssist
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.data.road.CameraDeviceInfo
|
||||
import com.mogo.eagle.core.data.road.RoadCrossCamera
|
||||
import com.mogo.eagle.core.function.api.map.listener.IGaoDeMapLocationListener
|
||||
import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener
|
||||
import com.mogo.eagle.core.function.business.roadcross.net.NDERoadCameraNetWorkModel.Companion.ndeRoadCameraNetWorkModel
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerGaoDeMapLocationListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.map.R
|
||||
@@ -24,17 +26,19 @@ import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.map.overlay.core.Level
|
||||
import com.mogo.map.overlay.point.Point
|
||||
import com.mogo.skin.utils.SkinResources
|
||||
import com.zhidaoauto.map.data.road.RoadCross
|
||||
import com.zhidaoauto.map.data.road.StopLine
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
@SuppressLint("NewApi")
|
||||
class RoadCrossCameraManager : IMoGoMapRoadListener, IGaoDeMapLocationListener {
|
||||
companion object {
|
||||
|
||||
private const val TAG = "RoadCrossCameraManager"
|
||||
private const val REQUEST_CAMERA_MSG = 0
|
||||
private const val REMOVE_MARKER_MSG = 1
|
||||
private const val REQUEST_CAMERA_DELAY_TIME = 50000L
|
||||
private const val REMOVE_MARKER_DELAY_TIME = 10000L
|
||||
|
||||
val instance: RoadCrossCameraManager by lazy(mode = LazyThreadSafetyMode.SYNCHRONIZED) {
|
||||
@@ -48,25 +52,71 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
private var isCameraRequest = false
|
||||
|
||||
@Volatile
|
||||
private var roadCrossCameraList: List<CameraDeviceInfo>? = null
|
||||
private var roadCrossCameraList: List<RoadCrossCamera>? = null
|
||||
|
||||
private val overlayManager = CallerMapUIServiceManager.getOverlayManager()
|
||||
|
||||
private val handler = object :Handler(Looper.getMainLooper()){
|
||||
private val handler = object : Handler(Looper.getMainLooper()) {
|
||||
override fun handleMessage(msg: Message) {
|
||||
super.handleMessage(msg)
|
||||
CallerLogger.d("$M_MAP$TAG", "remove marker")
|
||||
overlayManager?.removeAllPointsInOwner(TAG)
|
||||
when (msg.what) {
|
||||
REQUEST_CAMERA_MSG -> {
|
||||
getAllRoadCross()
|
||||
}
|
||||
|
||||
REMOVE_MARKER_MSG -> {
|
||||
CallerLogger.d("$M_MAP$TAG", "remove marker")
|
||||
overlayManager?.removeAllPointsInOwner(TAG)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun init(context: Context?) {
|
||||
mContext = context
|
||||
CallerMapRoadListenerManager.addListener(TAG, this)
|
||||
CallerGaoDeMapLocationListenerManager.addListener(TAG, this)
|
||||
getAllRoadCross()
|
||||
}
|
||||
|
||||
private fun getAllRoadCross() {
|
||||
val cityCode = CallerMapUIServiceManager.getCityCode()
|
||||
if (cityCode.isNullOrEmpty() || (cityCode.isNotEmpty() && cityCode == "010")) {
|
||||
handler.removeMessages(REQUEST_CAMERA_MSG)
|
||||
handler.sendEmptyMessageDelayed(REQUEST_CAMERA_MSG, REQUEST_CAMERA_DELAY_TIME + 100000)
|
||||
return
|
||||
}
|
||||
ndeRoadCameraNetWorkModel.getRoadCrossInfo(
|
||||
onSuccess = { it ->
|
||||
if (it.isNotEmpty()) {
|
||||
roadCrossCameraList = it
|
||||
val map = mutableMapOf<String, RoadCrossCamera>()
|
||||
it.forEach { road ->
|
||||
road.crossingId?.let { id ->
|
||||
map[id] = road
|
||||
}
|
||||
}
|
||||
roadCrossTrace("getAllRoadCross", map)
|
||||
} else {
|
||||
traceError("roadCrossInfo request size is zero")
|
||||
}
|
||||
},
|
||||
onError = {
|
||||
handler.removeMessages(REQUEST_CAMERA_MSG)
|
||||
handler.sendEmptyMessageDelayed(REQUEST_CAMERA_MSG, REQUEST_CAMERA_DELAY_TIME)
|
||||
traceError("roadCrossInfo request errorMsg: $it")
|
||||
})
|
||||
}
|
||||
|
||||
override fun onCityCodeChanged(cityCode: String) {
|
||||
super.onCityCodeChanged(cityCode)
|
||||
if (cityCode != "010") {
|
||||
getAllRoadCross()
|
||||
}
|
||||
}
|
||||
|
||||
private var distance: Double by Delegates.observable(0.0) { _, _, newV ->
|
||||
if(!AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)){
|
||||
if (!AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) {
|
||||
return@observable
|
||||
}
|
||||
if (!isCameraRequest && newV < 100) {
|
||||
@@ -76,38 +126,26 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
"$M_MAP$TAG",
|
||||
"触发接口调用 dis: $distance , roadCrossEnd: ${roadCrossEnd ?: "null"} "
|
||||
)
|
||||
if(roadCrossEnd == null){
|
||||
if (roadCrossEnd == null) {
|
||||
roadCrossTrace(
|
||||
TAG, mapOf("errorMsg" to "触发接口调用,roadCrossEnd获取为null",)
|
||||
TAG, mapOf("errorMsg" to "触发接口调用,roadCrossEnd获取为null")
|
||||
)
|
||||
}
|
||||
|
||||
if(AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)){
|
||||
AIAssist.getInstance(mContext).speakTTSVoice("${SkinResources.getInstance().getString(
|
||||
com.mogo.eagle.core.data.R.string.operation_platform_name)}检测到前方${distance.toInt()}米您将通过路口,已为您切换展示路口全息影像")
|
||||
}
|
||||
if (roadCrossEnd != null) {
|
||||
ndeRoadCameraNetWorkModel.getRoadCrossInfo(roadCrossEnd,
|
||||
onSuccess = {
|
||||
if (it.crossingId == null) {
|
||||
traceError("roadUniqueId is null")
|
||||
return@getRoadCrossInfo
|
||||
}
|
||||
if (it.deviceInfoList.isEmpty()) {
|
||||
traceError("deviceInfoList isEmpty")
|
||||
return@getRoadCrossInfo
|
||||
}
|
||||
roadCrossCameraList = it.deviceInfoList
|
||||
// 地图上打marker(注意marker方向),marker点击获取对应ip
|
||||
ThreadUtils.runOnUiThread {
|
||||
if (roadCrossCameraList != null) {
|
||||
roadCrossCameraList?.forEach {
|
||||
if (!it.roadUniqueId.isNullOrEmpty() && it.roadUniqueId == roadCrossEnd) {
|
||||
it.deviceInfoList.forEach { deviceInfo ->
|
||||
addCameraDeviceMarker(deviceInfo)
|
||||
}
|
||||
} else {
|
||||
requestSingleCross(roadCrossEnd)
|
||||
}
|
||||
},
|
||||
onError = {
|
||||
traceError("roadCrossInfo request errorMsg: $it")
|
||||
})
|
||||
}
|
||||
} else {
|
||||
requestSingleCross(roadCrossEnd)
|
||||
}
|
||||
} else {
|
||||
traceError("roadCross is null")
|
||||
}
|
||||
@@ -116,6 +154,30 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun requestSingleCross(roadCrossEnd: String) {
|
||||
ndeRoadCameraNetWorkModel.getRoadCrossInfo(roadCrossEnd,
|
||||
onSuccess = { result ->
|
||||
val it = result[0]
|
||||
if (it.crossingId == null) {
|
||||
traceError("roadUniqueId is null")
|
||||
return@getRoadCrossInfo
|
||||
}
|
||||
if (it.deviceInfoList.isEmpty()) {
|
||||
traceError("deviceInfoList isEmpty")
|
||||
return@getRoadCrossInfo
|
||||
}
|
||||
// 地图上打marker(注意marker方向),marker点击获取对应ip
|
||||
ThreadUtils.runOnUiThread {
|
||||
it.deviceInfoList.forEach { deviceInfo ->
|
||||
addCameraDeviceMarker(deviceInfo)
|
||||
}
|
||||
}
|
||||
},
|
||||
onError = {
|
||||
traceError("roadCrossInfo request errorMsg: $it")
|
||||
})
|
||||
}
|
||||
|
||||
private fun addCameraDeviceMarker(cameraDeviceInfo: CameraDeviceInfo) {
|
||||
mContext?.let {
|
||||
val builder =
|
||||
@@ -146,6 +208,46 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
}
|
||||
}
|
||||
|
||||
fun hasCrossCamera(): Boolean {
|
||||
if(CallerMapUIServiceManager.getCityCode() == "010"){
|
||||
roadCrossTrace(
|
||||
TAG, mapOf("errorMsg" to "cityCode限制 - 北京无路口设备")
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
val roadCrossEnd = CallerMapRoadListenerManager.getCrossEndInfo()
|
||||
if(roadCrossEnd == null){
|
||||
roadCrossTrace(
|
||||
TAG, mapOf("errorMsg" to "hasCrossCamera - 未获取到地图crossEnd数据")
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
if (roadCrossCameraList == null) {
|
||||
roadCrossTrace(
|
||||
TAG, mapOf("errorMsg" to "hasCrossCamera - 未获取到全市路口设备信息")
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
roadCrossCameraList?.forEach {
|
||||
val result = (!it.roadUniqueId.isNullOrEmpty()
|
||||
&& it.roadUniqueId == roadCrossEnd)
|
||||
if(result){
|
||||
roadCrossTrace(
|
||||
TAG, mapOf("errorMsg" to "hasCrossCamera - 遍历匹配路口数据命中 - $roadCrossEnd")
|
||||
)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
roadCrossTrace(
|
||||
TAG, mapOf("errorMsg" to "hasCrossCamera - 均不匹配上述条件")
|
||||
)
|
||||
return false
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
private fun batchRequestCrossLive(cameraDeviceInfo: List<CameraDeviceInfo>) {
|
||||
val list = mutableListOf<String>()
|
||||
@@ -168,7 +270,7 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
override fun onRoadChange(cross: Boolean, roadCross: RoadCross?) {
|
||||
super.onRoadChange(cross, roadCross)
|
||||
// 出路口
|
||||
if(!isCameraRequest){
|
||||
if (!isCameraRequest) {
|
||||
CallerLogger.d("$M_MAP$TAG", "未触发路口获取marker")
|
||||
return
|
||||
}
|
||||
@@ -177,7 +279,7 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
ndeRoadCameraNetWorkModel.cancelRequest("roadCross")
|
||||
// 清除marker
|
||||
CallerLogger.d("$M_MAP$TAG", "remove marker handler")
|
||||
handler.sendEmptyMessageDelayed(REQUEST_CAMERA_MSG, REMOVE_MARKER_DELAY_TIME)
|
||||
handler.sendEmptyMessageDelayed(REMOVE_MARKER_MSG, REMOVE_MARKER_DELAY_TIME)
|
||||
// 释放控制
|
||||
isCameraRequest = false
|
||||
CallerLogger.d("$M_MAP$TAG", "经过路口,释放控制")
|
||||
@@ -202,7 +304,7 @@ class RoadCrossCameraManager : IMoGoMapRoadListener {
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_STATUS,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_MAP,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_MAP_ROAD_CROSS_ERROR,
|
||||
paramIndexes = [0]
|
||||
paramIndexes = [0, 1]
|
||||
)
|
||||
private fun roadCrossTrace(tag: String, paramMap: Any) {
|
||||
CallerLogger.d("$M_MAP$tag", "$paramMap")
|
||||
|
||||
@@ -27,8 +27,8 @@ class NDERoadCameraNetWorkModel private constructor() {
|
||||
}
|
||||
|
||||
fun getRoadCrossInfo(
|
||||
crossID: String,
|
||||
onSuccess: ((RoadCrossCamera) -> Unit),
|
||||
crossID: String? = null,
|
||||
onSuccess: ((List<RoadCrossCamera>) -> Unit),
|
||||
onError: ((String) -> Unit)
|
||||
) {
|
||||
request<BaseResponse<List<RoadCrossCamera>>>("roadCross") {
|
||||
@@ -39,7 +39,7 @@ class NDERoadCameraNetWorkModel private constructor() {
|
||||
getNetWorkApi().roadCameraRequest(
|
||||
pair.first,
|
||||
pair.second,
|
||||
crossID,
|
||||
crossID?:"",
|
||||
loc.longitude,
|
||||
loc.latitude,
|
||||
CallerMapUIServiceManager.getCityCode() ?: ""
|
||||
@@ -48,7 +48,7 @@ class NDERoadCameraNetWorkModel private constructor() {
|
||||
}
|
||||
onSuccess {
|
||||
if (it.result.isNotEmpty()) {
|
||||
onSuccess.invoke(it.result[0])
|
||||
onSuccess.invoke(it.result)
|
||||
} else {
|
||||
onError.invoke("getRoadCrossInfo empty camera info")
|
||||
}
|
||||
|
||||
@@ -121,6 +121,9 @@ class MapRoamView(context: Context?, attrs: AttributeSet?) : MogoMapView(context
|
||||
}
|
||||
|
||||
override fun onAiIdentifyData(obj: SocketDownData.SocketDownDataProto?) {
|
||||
if(obj == null){
|
||||
trace(TAG, mapOf("onAiIdentifyData" to "空数据"))
|
||||
}
|
||||
obj?.let {
|
||||
obj.data?.let {
|
||||
if (it.allListList == null || it.allListList.size == 0) {
|
||||
|
||||
@@ -19,7 +19,9 @@ import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener
|
||||
import com.mogo.eagle.core.function.api.hmi.view.IViewControlListener.Companion.V2X_EVENT_TAG
|
||||
import com.mogo.eagle.core.function.api.map.road.IMoGoMapRoadListener
|
||||
import com.mogo.eagle.core.function.business.roadcross.RoadCrossCameraManager.Companion.instance
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerServicesEventManager
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiViewControlListenerManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapIdentifyManager
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager
|
||||
@@ -56,10 +58,14 @@ class RoadCrossRoamView @JvmOverloads constructor(
|
||||
private const val MSG_HIDE_VIEW_TIME = 10_000L
|
||||
}
|
||||
|
||||
@Volatile
|
||||
private var isShow = false
|
||||
|
||||
private var showState by Delegates.observable(false) { _, oldV, newV ->
|
||||
if (oldV != newV) {
|
||||
updateView(newV)
|
||||
if (!newV) {
|
||||
isShow = false
|
||||
}
|
||||
updateView(newV)
|
||||
}
|
||||
|
||||
private var animator: ObjectAnimator? = null
|
||||
@@ -184,16 +190,28 @@ class RoadCrossRoamView @JvmOverloads constructor(
|
||||
|
||||
override fun onStopLineInfo(info: StopLine) {
|
||||
super.onStopLineInfo(info)
|
||||
val cross = CallerMapRoadListenerManager.getCrossEndInfo()
|
||||
if (info.distance == 0.0 || info.distance > 200) {
|
||||
CallerLogger.d("$M_MAP$TAG", "showState return , distance is ${info.distance}")
|
||||
if (cross != null && cross != "0") {
|
||||
CallerLogger.d("$M_MAP$TAG", "未触发,路口ID:$cross , 距离超出:${info.distance}")
|
||||
}
|
||||
return
|
||||
}
|
||||
showState = info.distance in 110.0..200.0
|
||||
CallerLogger.d("$M_MAP$TAG", "命中 before:$showState")
|
||||
showState = info.distance in 100.0..200.0
|
||||
CallerLogger.d("$M_MAP$TAG", "命中 after:$showState,路口ID:$cross , dis:${info.distance}")
|
||||
}
|
||||
|
||||
private fun attachView() {
|
||||
if (isShow) {
|
||||
return
|
||||
}
|
||||
if (this.visibility == View.VISIBLE) {
|
||||
return
|
||||
}
|
||||
// 没有路线不做提示
|
||||
if (CallerAutoPilotStatusListenerManager.getLineId() == 0L) {
|
||||
CallerLogger.d("$M_MAP$TAG", "没有路线不做提示")
|
||||
return
|
||||
}
|
||||
// 处于漫游模式下不做处理
|
||||
@@ -209,13 +227,29 @@ class RoadCrossRoamView @JvmOverloads constructor(
|
||||
CallerLogger.d("$M_MAP$TAG", "attachView return , mainPageVisible is false")
|
||||
return
|
||||
}
|
||||
// 没有路侧设备,不做处理
|
||||
CallerLogger.d("$M_MAP$TAG", "命中,attachView")
|
||||
val cross = CallerMapRoadListenerManager.getCrossEndInfo()
|
||||
if (cross.isNullOrEmpty()) {
|
||||
CallerLogger.d("$M_MAP$TAG", "未触发,路口ID:$cross")
|
||||
return
|
||||
}
|
||||
if (!instance.hasCrossCamera()) {
|
||||
CallerLogger.d("$M_MAP$TAG", "没有路侧设备,不做处理")
|
||||
return
|
||||
}
|
||||
isShow = true
|
||||
//播放语音
|
||||
val dis = CallerMapRoadListenerManager.getStopLineDistance()?.toInt() ?: 0
|
||||
if (AppIdentityModeUtils.isDriver(FunctionBuildConfig.appIdentityMode)) {
|
||||
AIAssist.getInstance(context)
|
||||
.speakTTSVoice("前方${dis}米将通过路口,${SkinResources.getInstance().getString(R.string.operation_platform_name)}为您提供路口全息影像,助力出行")
|
||||
var disStr = "前方即将通过路口,蘑菇为您提供路口全息影像,助力出行"
|
||||
if (dis >= 80) {
|
||||
disStr = "前方${dis}米将通过路口,${SkinResources.getInstance().getString(R.string.operation_platform_name)}为您提供路口全息影像,助力出行"
|
||||
}
|
||||
AIAssist.getInstance(context).speakTTSVoice(disStr)
|
||||
}
|
||||
CallerHmiViewControlListenerManager.invokeV2XEvent(View.VISIBLE, TAG)
|
||||
CallerServicesEventManager.updateServicesNum(CallerServicesEventManager.ServiceType.ROAD)
|
||||
bringToFront()
|
||||
this.visibility = View.VISIBLE
|
||||
ivZhiRoadRoamView.visibility = View.VISIBLE
|
||||
|
||||
@@ -33,9 +33,11 @@ import com.amap.api.maps.model.PolylineOptions
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.data.och.OchInfo
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.api.datacenter.IDataCenterBizListener
|
||||
import com.mogo.eagle.core.function.business.travelreality.CrossDeviceBean
|
||||
import com.mogo.eagle.core.function.business.travelreality.DeviceInfoBean
|
||||
import com.mogo.eagle.core.function.business.travelreality.EventBean
|
||||
@@ -48,6 +50,7 @@ import com.mogo.eagle.core.function.business.travelreality.view.VideoMarkerEntit
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
import com.mogo.eagle.core.function.call.datacenter.CallerDataCenterBizListener
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
|
||||
import com.mogo.eagle.core.function.map.R
|
||||
import com.mogo.eagle.core.function.smp.view.SmallMapView
|
||||
@@ -74,7 +77,8 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoChassisLocationGCJ02Listener,
|
||||
IMoGoPlanningRottingListener, IMoGoAutopilotStatusListener {
|
||||
IMoGoPlanningRottingListener, IMoGoAutopilotStatusListener,
|
||||
IDataCenterBizListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "TravelRealityView"
|
||||
@@ -227,6 +231,9 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
*/
|
||||
@Volatile
|
||||
private var isSmallMap: Boolean = true
|
||||
|
||||
@Volatile
|
||||
private var isPlayingAnim = false
|
||||
private var iconRes = R.drawable.small_map_car
|
||||
|
||||
@Volatile
|
||||
@@ -236,6 +243,8 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
private var mPolyline: Polyline? = null
|
||||
private var mSmallStartMarker: Marker? = null
|
||||
private var mSmallEndMarker: Marker? = null
|
||||
private var mStartLatLng: LatLng? = null
|
||||
private var mEndLatLng: LatLng? = null
|
||||
|
||||
init {
|
||||
try {
|
||||
@@ -321,6 +330,10 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
this.isSmallMap = isSmallMap
|
||||
}
|
||||
|
||||
fun setIsPlaying(isPlaying: Boolean) {
|
||||
isPlayingAnim = isPlaying
|
||||
}
|
||||
|
||||
fun swapSettings() {
|
||||
if (isSmallMap) {
|
||||
Message.obtain().apply {
|
||||
@@ -329,6 +342,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
// 显示小地图样式
|
||||
changeMapSettings(true)
|
||||
resumeStartEndMarker()
|
||||
globalPathResp?.let {
|
||||
if (it.wayPointsList.size > 0) {
|
||||
drawRotting()
|
||||
@@ -339,6 +353,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
hideSmallCarMarker()
|
||||
// 显示行程总览地图样式
|
||||
changeMapSettings(false)
|
||||
resumeStartEndMarker()
|
||||
// 绘制自车
|
||||
mLocation?.let { drawCarMarker(it) }
|
||||
val globalPath = reqData
|
||||
@@ -595,6 +610,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
// 注册定位监听
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener("${TAG}${this.hashCode()}", this)
|
||||
CallerAutoPilotStatusListenerManager.addListener("${TAG}${this.hashCode()}", this)
|
||||
CallerDataCenterBizListener.addListener("${TAG}${this.hashCode()}", this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
@@ -606,6 +622,7 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener("${TAG}${this.hashCode()}")
|
||||
CallerPlanningRottingListenerManager.removeListener("${TAG}${this.hashCode()}")
|
||||
CallerAutoPilotStatusListenerManager.removeListener("${TAG}${this.hashCode()}")
|
||||
CallerDataCenterBizListener.removeListener("${TAG}${this.hashCode()}")
|
||||
nonFrequentHandler?.looper?.quitSafely()
|
||||
nonFrequentHandler = null
|
||||
travelNetWorkModel.cancelAllRequest()
|
||||
@@ -684,38 +701,6 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
globalData[0].lon
|
||||
)
|
||||
CallerLogger.w("$M_MAP$TAG", "起终点距离为:$distance")
|
||||
// if (distance < 2000) {
|
||||
// roadRange = maxRoadRange
|
||||
// roadWidth = minRoadWidth
|
||||
// globalWidth = minGlobalWidth
|
||||
// } else {
|
||||
// roadRange = minRoadRange
|
||||
// roadWidth = maxRoadWidth
|
||||
// globalWidth = maxGlobalWidth
|
||||
// }
|
||||
val optionList = ArrayList<MarkerOptions>()
|
||||
optionList.add(
|
||||
MarkerOptions().apply {
|
||||
icon(BitmapDescriptorFactory.fromResource(startPointDrawable))
|
||||
position(
|
||||
coordinateConverterWgsToGcj(
|
||||
globalData[0].lat,
|
||||
globalData[0].lon
|
||||
)
|
||||
)
|
||||
}
|
||||
)
|
||||
val endOption = MarkerOptions()
|
||||
endOption.icon(BitmapDescriptorFactory.fromResource(endPointDrawable))
|
||||
endOption.position(
|
||||
coordinateConverterWgsToGcj(
|
||||
globalData[globalData.size - 1].lat,
|
||||
globalData[globalData.size - 1].lon
|
||||
)
|
||||
)
|
||||
optionList.add(endOption)
|
||||
// 绘制起终点
|
||||
drawStartEndMarker(optionList)
|
||||
// 绘制全局轨迹
|
||||
drawPolyline(DRAW_POLY_LINE, globalOptions)
|
||||
}
|
||||
@@ -1523,14 +1508,6 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
clearPolyline()
|
||||
if (mAMap != null) {
|
||||
if (mCoordinatesLatLng.size >= 2) {
|
||||
// 设置开始结束Marker位置
|
||||
mSmallStartMarker!!.position = mCoordinatesLatLng[0]
|
||||
mSmallEndMarker!!.position = mCoordinatesLatLng[mCoordinatesLatLng.size - 1]
|
||||
mSmallStartMarker!!.setToTop()
|
||||
mSmallStartMarker!!.isVisible = true
|
||||
mSmallEndMarker!!.isVisible = true
|
||||
mSmallEndMarker!!.setToTop()
|
||||
|
||||
//存放所有点的经纬度
|
||||
val boundsBuilder = LatLngBounds.Builder()
|
||||
for (i in mCoordinatesLatLng.indices) {
|
||||
@@ -1571,6 +1548,15 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideStartEndMarker() {
|
||||
if (mSmallStartMarker != null) {
|
||||
mSmallStartMarker!!.isVisible = false
|
||||
}
|
||||
if (mSmallEndMarker != null) {
|
||||
mSmallEndMarker!!.isVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun hideSmallCarMarker() {
|
||||
mSmallCarMarker?.isVisible = false
|
||||
}
|
||||
@@ -1702,6 +1688,72 @@ class TravelRealityView @JvmOverloads constructor(
|
||||
return latLngList
|
||||
}
|
||||
|
||||
override fun invokeOchInfo(ochInfo: OchInfo) {
|
||||
super.invokeOchInfo(ochInfo)
|
||||
Log.d(TAG, "invokeOchInfo:$ochInfo")
|
||||
if (ochInfo.type == 0) {
|
||||
val locList = ochInfo.latLonList
|
||||
if (locList.isEmpty() || locList.size < 2) {
|
||||
mStartLatLng = null
|
||||
mEndLatLng = null
|
||||
UiThreadHandler.post {
|
||||
hideStartEndMarker()
|
||||
}
|
||||
} else {
|
||||
// 设置开始结束Marker位置
|
||||
mStartLatLng = coordinateConverterWgsToGcj(
|
||||
locList[0].latitude,
|
||||
locList[0].longitude
|
||||
)
|
||||
mEndLatLng = coordinateConverterWgsToGcj(
|
||||
locList[1].latitude,
|
||||
locList[1].longitude
|
||||
)
|
||||
}
|
||||
if (!isPlayingAnim) {
|
||||
drawStartAndEnd()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun resumeStartEndMarker() {
|
||||
if (mStartLatLng != null && mEndLatLng != null) {
|
||||
drawStartAndEnd()
|
||||
} else {
|
||||
if (isSmallMap) {
|
||||
UiThreadHandler.post {
|
||||
hideStartEndMarker()
|
||||
}
|
||||
} else {
|
||||
drawStartEndMarker(emptyList())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun drawStartAndEnd() {
|
||||
if (isSmallMap) {
|
||||
UiThreadHandler.post {
|
||||
mSmallStartMarker!!.position = mStartLatLng
|
||||
mSmallEndMarker!!.position = mEndLatLng
|
||||
mSmallStartMarker!!.setToTop()
|
||||
mSmallStartMarker!!.isVisible = true
|
||||
mSmallEndMarker!!.isVisible = true
|
||||
mSmallEndMarker!!.setToTop()
|
||||
}
|
||||
} else {
|
||||
val options = ArrayList<MarkerOptions>()
|
||||
options.add(MarkerOptions().also { option ->
|
||||
option.icon(BitmapDescriptorFactory.fromResource(startPointDrawable))
|
||||
option.position(mStartLatLng)
|
||||
})
|
||||
options.add(MarkerOptions().also { option ->
|
||||
option.icon(BitmapDescriptorFactory.fromResource(endPointDrawable))
|
||||
option.position(mEndLatLng)
|
||||
})
|
||||
drawStartEndMarker(options)
|
||||
}
|
||||
}
|
||||
|
||||
interface OnDrawListener {
|
||||
// isEvent为true表示是事件,反之则表示全息路口
|
||||
fun onDraw(eventList: List<EventDrawBean>, isEvent: Boolean)
|
||||
|
||||
Reference in New Issue
Block a user