diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt index 01fe5f583b..f9a38cd5e1 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/pnc/V2NIdentifyDrawer.kt @@ -81,7 +81,7 @@ internal object V2NIdentifyDrawer: IEventDismissListener { Log.d("V2NIdentifyDrawer", "---callback -- drawShiGu --- 1 ---") } val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() - val filtered = events.filterIsInstance().filter { itx -> + var filtered = events.filterIsInstance().filter { itx -> DrivingDirectionUtils.getDegreeOfCar2Poi( car.longitude, car.latitude, @@ -104,8 +104,17 @@ internal object V2NIdentifyDrawer: IEventDismissListener { } else { Log.d("V2NIdentifyDrawer", "---callback -- drawShiGu --- 2 ---") } + val data = filtered + filtered = filtered.filter { itx -> + val trackedSourceList = itx.trackedSourceList + trackedSourceList.isNotEmpty() && trackedSourceList.find { it.source != 1 } != null + } + if (filtered.isEmpty()) { + V2XBizTrace.onAck(data, mapOf("shiGong-shiGu-filter-2" to "数据来源不对"), true) + return@Callback true + } filtered.forEach { itx -> - val id = itx.uuid.toString() + val id = itx.v2XUuid.ifEmpty { itx.uuid.toString() } V2XBizTrace.onAck(itx, "filtered -> ${itx.type}") Log.d("V2NIdentifyDrawer", "---callback --- id: $id ---") AiRoadMarker.aiMakers.getOrPut(id) { @@ -197,110 +206,6 @@ internal object V2NIdentifyDrawer: IEventDismissListener { } } else if (msg.what == MSG_WHAT_DRAW_YONGDU) { Log.d("V2NIdentifyDrawer", "---callback -- drawYongDu --- 1 ---") -/* val events = msg.obj as? List<*> - if (events == null || events.isEmpty()) { - Log.d("V2NIdentifyDrawer", "---callback -- drawYongDu --- 1 filter is empty ---") - V2XBizTrace.onAck(TAG, mapOf("yongDu" to ""), true) - return@Callback true - } - val car = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() - val filtered = events.filterIsInstance().filter { itx -> - val eventLon = - itx.eventPos?.offsetLL?.positionLatLon?.lon?.let { it * 1.0 / 10_000_000 } - ?: 0.0 - val eventLat = - itx.eventPos?.offsetLL?.positionLatLon?.lat?.let { it * 1.0 / 10_000_000 } - ?: 0.0 - DrivingDirectionUtils.getDegreeOfCar2Poi( - car.longitude, - car.latitude, - eventLon, - eventLat, - car.heading.toInt() - ) < 90 && CoordinateUtils.calculateLineDistance(car.longitude, car.latitude, eventLon, eventLat) <= 300 - } - if (filtered.isEmpty()) { - Log.d("V2NIdentifyDrawer", "---callback -- drawYongDu --- 2 filter is empty ---") - V2XBizTrace.onAck(TAG, mapOf("yongDu-filter" to ""), true) - return@Callback true - } - Log.d("V2NIdentifyDrawer", "---callback -- drawYongDu --- 2 ---") - filtered.forEach { itx -> - val id = itx.rteId.toString() - val lon = itx.eventPos?.offsetLL?.positionLatLon?.lon?.let { it * 1.0 / 10_000_000 } - ?: 0.0 - val lat = itx.eventPos?.offsetLL?.positionLatLon?.lat?.let { it * 1.0 / 10_000_000 } - ?: 0.0 - Log.d("V2NIdentifyDrawer", "---callback -- id: $id---") - AiRoadMarker.aiMakers.getOrPut(id) { - AiRoadMarker().apply { - val poiType = getPoiType(itx.eventType).poiType - marker(Marker(id, poiType, lon, lat, car.heading, null, null, - V2XRoadEventEntity().also { e -> - e.poiType = poiType - e.location = MarkerLocation().also { l -> - val p = CoordinateTransform.WGS84ToGCJ02(lon, lat) - l.lon = p[0] - l.lat = p[1] - l.angle = car.heading - } - e.noveltyInfo = MarkerExploreWay().also { - it.poiType = poiType - it.location = e.location - it.polygon = emptyList() - } - }), true, isDrawRoadLine(poiType) - ) - - val distance = CoordinateUtils.calculateLineDistance( - lon, - lat, - car.longitude, - car.latitude - ) - val alertContent = getAlertContent(poiType, distance.toDouble()) - val ttsContent = getTtsContent(poiType, distance.toDouble()) - V2XBizTrace.onAck(TAG, "绘制poi事件:$poiType") - saveMsgBox( - MsgBoxBean( - V2X, - V2XMsg( - poiType, - alertContent, - ttsContent, - CommunicationType.V2N.name - ) - ) - ) - CallerHmiManager.warningV2X( - poiType, - alertContent, - ttsContent, - object : IMoGoWarningStatusListener { - override fun onShow() { - super.onShow() - runCatching { CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), State.START) } - CallerVisualAngleManager.changeScene(RoadEvent(2, SECONDS)) - } - - override fun onDismiss() { - super.onDismiss() - runCatching { CallerHmiManager.notifyXiaoZhiStatusChanged(V2N(EventTypeEnumNew.getEnumType(poiType)), State.STOP) } - CallerVisualAngleManager.changeScene(Default()) - } - }, - ALERT_WARNING_TOP, - 10000, - false - ) - //消息埋点 - V2XEventAnalyticsManager.triggerV2XEvent( - poiType, alertContent, ttsContent, - DataSourceType.AICLOUD, CommunicationType.V2N - ) - } - }.receive() - }*/ } else if (msg.what == MSG_WHAT_DRAW_OTHER_RETROGRADE_VEHICLE) { val event = msg.obj as? MessagePad.Event if (event == null) { diff --git a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt index 1d0f038c63..d27373bc91 100644 --- a/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt +++ b/core/function-impl/mogo-core-function-biz/src/main/java/com/mogo/eagle/function/biz/v2x/v2n/scenario/scene/airoad/AiRoadMarker.kt @@ -115,7 +115,7 @@ class AiRoadMarker { .longitude(marker.poi_lon) .latitude(marker.poi_lat) if (marker.poiType == EventTypeEnumNew.TYPE_SOCKET_ROAD_PEOPLE_CROSS.poiType) { - builder.anchorColor("#FFE1BA9A") + builder.anchorColor("#D6E1BA9A") } CallerMapUIServiceManager.getOverlayManager()?.showOrUpdatePoint(builder.build())?.let { p -> if (!markerIds.contains(markerId)) { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityModel.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityModel.kt index dbe4727c42..cc4b539ae4 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityModel.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/business/travelreality/TravelRealityModel.kt @@ -12,11 +12,15 @@ import com.bumptech.glide.request.transition.Transition import com.mogo.commons.constants.HostConst import com.mogo.eagle.core.data.BaseResponse import com.mogo.eagle.core.data.Response +import com.mogo.eagle.core.data.road.RoadCameraLive +import com.mogo.eagle.core.function.business.roadcross.net.BATCH_LIVE +import com.mogo.eagle.core.function.business.roadcross.net.INDERoadCameraApiService import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager import com.mogo.eagle.core.network.MoGoRetrofitFactory import com.mogo.eagle.core.network.apiCall import com.mogo.eagle.core.network.apiResponseCall +import com.mogo.eagle.core.network.cancel import com.mogo.eagle.core.network.request import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils import com.mogo.eagle.core.utilcode.util.LocationUtils @@ -26,6 +30,15 @@ import java.util.Locale class TravelRealityModel private constructor() { + @Volatile + private var eventKey = "" + @Volatile + private var deviceKey = "" + @Volatile + private var trackKey = "" + @Volatile + private var liveKey = "" + companion object { val travelNetWorkModel by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { TravelRealityModel() @@ -42,7 +55,8 @@ class TravelRealityModel private constructor() { */ fun getEventsWithTrajRequest(reqData: EventReqEntity, onSuccess: ((List) -> Unit), onError: ((String) -> Unit)){ - request?>>{ + eventKey = "getEvents_${System.currentTimeMillis()}" + request?>>(eventKey) { loader { apiResponseCall{ val time = System.currentTimeMillis().toString() @@ -63,7 +77,8 @@ class TravelRealityModel private constructor() { * 查询路口设备 */ fun getCrossDevice(onSuccess: ((List) -> Unit), onError: ((String) -> Unit)) { - request?>>{ + deviceKey = "getDevice_${System.currentTimeMillis()}" + request?>>(deviceKey) { loader { apiCall{ val time = System.currentTimeMillis().toString() @@ -82,6 +97,21 @@ class TravelRealityModel private constructor() { } } + fun cancelAllRequest() { + if (eventKey.isNotEmpty()) { + cancel(eventKey) + } + if (deviceKey.isNotEmpty()) { + cancel(deviceKey) + } + if (trackKey.isNotEmpty()) { + cancel(trackKey) + } + if (liveKey.isNotEmpty()) { + cancel(liveKey) + } + } + /** * 智慧路口路网范围 */ @@ -109,7 +139,8 @@ class TravelRealityModel private constructor() { * 智慧道路轨迹 */ fun getCityRoadTrack(onSuccess: ((List?>?>?) -> Unit), onError: ((String) -> Unit)) { - request?>?>?>>{ + trackKey = "getTrack_${System.currentTimeMillis()}" + request?>?>?>>(trackKey) { loader { apiCall{ val time = System.currentTimeMillis().toString() @@ -128,6 +159,37 @@ class TravelRealityModel private constructor() { } } + fun batchRequestCrossLive( + list: MutableList, onSuccess: ((List) -> Unit), + onError: ((String) -> Unit) + ) { + liveKey = "batchLive_${System.currentTimeMillis()}" + request>>(liveKey) { + loader { + apiCall { + val time = System.currentTimeMillis().toString() + val loc = CallerChassisLocationWGS84ListenerManager.getChassisLocationWGS84() + val cityCode = CallerMapUIServiceManager.getCityCode() ?: "0734" + val map = mutableMapOf( + "lon" to loc.longitude, + "lat" to loc.latitude, + "ipList" to list, + "cityCode" to cityCode + ) + val md5String = "/${BATCH_LIVE.uppercase(Locale.getDefault())}$time" + MoGoRetrofitFactory.getInstanceNoCallAdapter(HostConst.getNDEHost()) + .create(INDERoadCameraApiService::class.java).cameraLiveBatchRequest(Md5Util.getMD5Result(md5String), time, map) + } + } + onSuccess { + onSuccess.invoke(it.result) + } + onError { + onError.invoke(it.message.toString()) + } + } + } + fun downloadImage(context: Context, url: String?, latLng: LatLng, onSuccess: ((Bitmap, LatLng) -> Unit), diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt index 842534393a..0b4171b191 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/view/TravelRealityView.kt @@ -27,10 +27,10 @@ import com.amap.api.maps.model.Marker import com.amap.api.maps.model.MarkerOptions import com.amap.api.maps.model.Polyline import com.amap.api.maps.model.PolylineOptions +import com.google.gson.reflect.TypeToken import com.mogo.eagle.core.data.map.MogoLocation import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener -import com.mogo.eagle.core.function.business.roadcross.net.NDERoadCameraNetWorkModel.Companion.ndeRoadCameraNetWorkModel 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 @@ -482,9 +482,9 @@ class TravelRealityView @JvmOverloads constructor( } } } + Log.d(TAG, "过滤掉的事件个数为:${eventList.size - eventOptionsList.size}") // 事件不足3个则用路口设备补齐 completeQuantity() - Log.d(TAG, "过滤掉的事件个数为:${eventList.size - eventOptionsList.size}") // 绘制道路事件 drawMarkers(DRAW_ROAD_EVENT, eventOptionsList) } @@ -492,10 +492,12 @@ class TravelRealityView @JvmOverloads constructor( private fun completeQuantity() { ipPointMap.clear() // 全部展示事件,事件数不足则用路口设备补齐 + Log.d(TAG, "待绘制的道路事件的个数为:${roadEventList.size}") if (roadEventList.size >= 3) { val ipList = mutableListOf() roadEventList[0].let { - it.ip?.let { ip -> + it.ip?.also { ip -> + if (ip.isEmpty()) return@also ipPointMap[ip] = VideoMarkerEntity( coordinateConverterWgsToGcj(it.lat, it.lon), it.title, @@ -505,7 +507,8 @@ class TravelRealityView @JvmOverloads constructor( } } roadEventList[(roadEventList.size - 1) / 2].let { - it.ip?.let { ip -> + it.ip?.also { ip -> + if (ip.isEmpty()) return@also ipPointMap[ip] = VideoMarkerEntity( coordinateConverterWgsToGcj(it.lat, it.lon), it.title, @@ -515,7 +518,8 @@ class TravelRealityView @JvmOverloads constructor( } } roadEventList[roadEventList.size - 1].let { - it.ip?.let { ip -> + it.ip?.also { ip -> + if (ip.isEmpty()) return@also ipPointMap[ip] = VideoMarkerEntity( coordinateConverterWgsToGcj(it.lat, it.lon), it.title, @@ -568,14 +572,14 @@ class TravelRealityView @JvmOverloads constructor( } } - "800006" -> {// 拥堵 - eventOptionsList.add(MarkerOptions().apply { - position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) - anchor(0.5f, 0.5f) - zIndex(0.8f) - icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_yongdu_nor)) - }) - } +// "800006" -> {// 拥堵 +// eventOptionsList.add(MarkerOptions().apply { +// position(coordinateConverterWgsToGcj(eventBean.lat, eventBean.lon)) +// anchor(0.5f, 0.5f) +// zIndex(0.8f) +// icon(BitmapDescriptorFactory.fromResource(R.drawable.mogo_yongdu_nor)) +// }) +// } "800004" -> {// 静止事件 eventOptionsList.add(MarkerOptions().apply { @@ -617,6 +621,7 @@ class TravelRealityView @JvmOverloads constructor( val ipList = mutableListOf() roadEventList.forEach { it.ip?.let { ip -> + if (ip.isEmpty()) return@let ipPointMap[ip] = VideoMarkerEntity( coordinateConverterWgsToGcj(it.lat, it.lon), it.title, @@ -663,7 +668,7 @@ class TravelRealityView @JvmOverloads constructor( private fun reqCrossLive(ipList: MutableList) { Log.d(TAG, "请求获取缩略图!") - ndeRoadCameraNetWorkModel.batchRequestCrossLive(ipList, onSuccess = { + travelNetWorkModel.batchRequestCrossLive(ipList, onSuccess = { val liveOptionsList = ArrayList() var markerOption: MarkerOptions var pair: Pair @@ -686,12 +691,13 @@ class TravelRealityView @JvmOverloads constructor( "绘制时位置为:${ipPointMap[ip]?.latLng},标题为:${ipPointMap[ip]!!.title},方向为:${ipPointMap[ip]!!.orientation},锚点为:${pair}" ) markerOption.anchor(pair.first, pair.second) + view.setPlaceHolder() + markerOption.icon(BitmapDescriptorFactory.fromView(view)) } else { return@let } - view.setPlaceHolder() - markerOption.icon(BitmapDescriptorFactory.fromView(view)) } else { + // 需要下载缩略图 markerOption.icon(null) markerOption.position(ipPointMap[ip]?.latLng) pair = travelNetWorkModel.calculateAnchor(ipPointMap[ip]?.orientation ?: 0) @@ -765,6 +771,7 @@ class TravelRealityView @JvmOverloads constructor( ) } deviceInPathList = arrayListOf(CrossDeviceBean("", 0.0, "", 0.0, deviceInPaths)) + Log.d(TAG, "待绘制的全息路口的个数为:${crossOptionsList.size}") // 绘制路口设备 drawMarkers(DRAW_CROSS_DEVICE, crossOptionsList) } @@ -1071,6 +1078,9 @@ class TravelRealityView @JvmOverloads constructor( lastTime = System.currentTimeMillis() } globalPathResp?.let { globalPath -> + nonFrequentHandler?.removeCallbacksAndMessages(null) + travelNetWorkModel.cancelAllRequest() + val pointList = ArrayList() globalPath.wayPointsList.forEach { loc -> pointList.add(Point(loc.longitude, loc.latitude)) @@ -1171,7 +1181,6 @@ class TravelRealityView @JvmOverloads constructor( DRAW_LIVE_DETAIL -> { removeMessages(DRAW_LIVE_DETAIL) - removeMessages(UPDATE_VIDEO_MARKER) (msg.obj as ArrayList).apply { realDrawLiveMarkers(this) }