[6.5.0][Fix]下新订单高德地图未更新显示
This commit is contained in:
@@ -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<EventBean>) -> Unit), onError: ((String) -> Unit)){
|
||||
request<Response<List<EventBean>?>>{
|
||||
eventKey = "getEvents_${System.currentTimeMillis()}"
|
||||
request<Response<List<EventBean>?>>(eventKey) {
|
||||
loader {
|
||||
apiResponseCall{
|
||||
val time = System.currentTimeMillis().toString()
|
||||
@@ -63,7 +77,8 @@ class TravelRealityModel private constructor() {
|
||||
* 查询路口设备
|
||||
*/
|
||||
fun getCrossDevice(onSuccess: ((List<CrossDeviceBean>) -> Unit), onError: ((String) -> Unit)) {
|
||||
request<BaseResponse<List<CrossDeviceBean>?>>{
|
||||
deviceKey = "getDevice_${System.currentTimeMillis()}"
|
||||
request<BaseResponse<List<CrossDeviceBean>?>>(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<List<List<Double>?>?>?) -> Unit), onError: ((String) -> Unit)) {
|
||||
request<BaseResponse<List<List<List<Double>?>?>?>>{
|
||||
trackKey = "getTrack_${System.currentTimeMillis()}"
|
||||
request<BaseResponse<List<List<List<Double>?>?>?>>(trackKey) {
|
||||
loader {
|
||||
apiCall{
|
||||
val time = System.currentTimeMillis().toString()
|
||||
@@ -128,6 +159,37 @@ class TravelRealityModel private constructor() {
|
||||
}
|
||||
}
|
||||
|
||||
fun batchRequestCrossLive(
|
||||
list: MutableList<String>, onSuccess: ((List<RoadCameraLive>) -> Unit),
|
||||
onError: ((String) -> Unit)
|
||||
) {
|
||||
liveKey = "batchLive_${System.currentTimeMillis()}"
|
||||
request<BaseResponse<List<RoadCameraLive>>>(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),
|
||||
|
||||
@@ -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<String>()
|
||||
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<String>()
|
||||
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<String>) {
|
||||
Log.d(TAG, "请求获取缩略图!")
|
||||
ndeRoadCameraNetWorkModel.batchRequestCrossLive(ipList, onSuccess = {
|
||||
travelNetWorkModel.batchRequestCrossLive(ipList, onSuccess = {
|
||||
val liveOptionsList = ArrayList<MarkerOptions>()
|
||||
var markerOption: MarkerOptions
|
||||
var pair: Pair<Float, Float>
|
||||
@@ -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<Point>()
|
||||
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<MarkerOptions>).apply {
|
||||
realDrawLiveMarkers(this)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user