[2.13.0_feat]全览地图V2X事件
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
class OverViewConst {
|
||||
companion object {
|
||||
const val CLOUD_HOST = "https://eagle-qa.zhidaozhixing.com"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.mogo.eagle.core.function.overview.remote
|
||||
|
||||
import io.reactivex.Observable
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.Query
|
||||
|
||||
interface OverViewServiceApi {
|
||||
|
||||
@GET("/eagleEye-mis/config/queryV2NInformation")
|
||||
fun queryAllV2XEventsByLineId(@Query("lineId") lineId: String, @Query("sn") sn: String): Observable<V2XEventResult>
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.mogo.eagle.core.function.overview.remote
|
||||
|
||||
import androidx.annotation.Keep
|
||||
|
||||
import com.google.gson.annotations.SerializedName
|
||||
import com.mogo.eagle.core.data.BaseData
|
||||
|
||||
|
||||
@Keep
|
||||
data class V2XEventResult (
|
||||
@SerializedName("result")
|
||||
var result: Result?
|
||||
): BaseData()
|
||||
|
||||
@Keep
|
||||
data class Result(
|
||||
@SerializedName("eventList")
|
||||
var v2XEventList: List<V2XEvent>?
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class V2XEvent(
|
||||
@SerializedName("receiveTime")
|
||||
var receiveTime: Long,
|
||||
|
||||
@SerializedName("detectTime")
|
||||
var detectTime: Long,
|
||||
|
||||
@SerializedName("id")
|
||||
var id: String?,
|
||||
|
||||
@SerializedName("center")
|
||||
var center: Center?,
|
||||
|
||||
@SerializedName("centerRoad")
|
||||
var centerRoad: CenterRoad?,
|
||||
|
||||
@SerializedName("radius")
|
||||
var radius: Double,
|
||||
|
||||
@SerializedName("type")
|
||||
var type: Int
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class Center(
|
||||
@SerializedName("lat")
|
||||
var lat: Double,
|
||||
|
||||
@SerializedName("lon")
|
||||
var lon: Double
|
||||
)
|
||||
|
||||
@Keep
|
||||
data class CenterRoad(
|
||||
@SerializedName("bearing")
|
||||
var bearing: Double,
|
||||
|
||||
@SerializedName("laneNo")
|
||||
var laneNo: Long,
|
||||
|
||||
@SerializedName("roadId")
|
||||
var roadId: String?,
|
||||
|
||||
@SerializedName("roadName")
|
||||
var roadName: String?,
|
||||
|
||||
@SerializedName("tileId")
|
||||
var tileId: Long
|
||||
)
|
||||
@@ -1,16 +1,26 @@
|
||||
package com.mogo.eagle.core.function.overview.vm
|
||||
|
||||
import androidx.lifecycle.*
|
||||
import com.amap.api.maps.model.LatLng
|
||||
import com.mogo.eagle.core.data.map.Infrastructure
|
||||
import com.mogo.eagle.core.function.overview.OverViewConst
|
||||
import com.mogo.eagle.core.function.overview.OverviewDao
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import com.mogo.eagle.core.function.overview.remote.OverViewServiceApi
|
||||
import com.mogo.eagle.core.function.overview.remote.V2XEvent
|
||||
import com.mogo.eagle.core.network.MoGoRetrofitFactory
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.Disposable
|
||||
import io.reactivex.functions.Consumer
|
||||
import io.reactivex.schedulers.Schedulers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
class OverViewModel(
|
||||
private val overviewDao: OverviewDao
|
||||
) : ViewModel() {
|
||||
private val _infStructures = MutableLiveData<List<Infrastructure>>()
|
||||
private val _V2XEvents = MutableLiveData<List<V2XEvent>>()
|
||||
private var disposable: Disposable? = null
|
||||
|
||||
val infStructures
|
||||
get() = _infStructures
|
||||
@@ -64,4 +74,34 @@ class OverViewModel(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getAllV2XEventsByLineId(lineId: String, sn: String) {
|
||||
// 1分钟查询一次
|
||||
disposable = Observable.interval(0, 60000, TimeUnit.SECONDS)
|
||||
.flatMap {
|
||||
MoGoRetrofitFactory.getInstance(OverViewConst.CLOUD_HOST)
|
||||
.create(OverViewServiceApi::class.java)
|
||||
.queryAllV2XEventsByLineId(lineId, sn)
|
||||
.map {
|
||||
if (it.code == 200 || it.code == 0) {
|
||||
return@map it.result?.v2XEventList
|
||||
} else {
|
||||
return@map null
|
||||
}
|
||||
}
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
it?.apply {
|
||||
_V2XEvents.value = this
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getV2XEventLiveData() = _V2XEvents
|
||||
|
||||
fun stopQueryV2XEvents() {
|
||||
disposable?.dispose()
|
||||
}
|
||||
}
|
||||
@@ -39,6 +39,8 @@ import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
|
||||
import com.mogo.eagle.core.function.map.R;
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager;
|
||||
import com.mogo.eagle.core.function.overview.remote.Center;
|
||||
import com.mogo.eagle.core.function.overview.remote.V2XEvent;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
@@ -96,6 +98,8 @@ public class AMapCustomView
|
||||
private boolean isFirstLocation = true;
|
||||
CustomMapStyleOptions mCustomMapStyleOptions;
|
||||
|
||||
ArrayList<Marker> currMarkerList;
|
||||
|
||||
public AMapCustomView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -254,6 +258,51 @@ public class AMapCustomView
|
||||
});
|
||||
}
|
||||
|
||||
public void showV2XEventMarkers(List<V2XEvent> v2XEvents) {
|
||||
if (v2XEvents == null || v2XEvents.size() <= 0) return;
|
||||
ArrayList<MarkerOptions> markerOptionsList = new ArrayList<>();
|
||||
for (V2XEvent event : v2XEvents) {
|
||||
if (event.getType() != 10006) {
|
||||
continue;
|
||||
}
|
||||
Center center = event.getCenter();
|
||||
if (center != null) {
|
||||
center.getLon();
|
||||
MarkerOptions markerOption = new MarkerOptions();
|
||||
LatLng latLng = new LatLng(center.getLat(),
|
||||
center.getLon());
|
||||
markerOption.position(latLng);
|
||||
markerOption.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_warning_v2x_road_construction));
|
||||
markerOptionsList.add(markerOption);
|
||||
}
|
||||
}
|
||||
if (markerOptionsList.size() > 0) {
|
||||
drawV2XMarkers(markerOptionsList);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawV2XMarkers(ArrayList<MarkerOptions> markerOptionsList) {
|
||||
currMarkerList = mAMap.addMarkers(markerOptionsList, false);
|
||||
mAMap.setOnMarkerClickListener(marker -> {
|
||||
List<Infrastructure> infList = posInfMap.get(marker.getPosition());
|
||||
// 如果是摄像头
|
||||
if (infList != null) {
|
||||
CallerHmiManager.INSTANCE.showVideoDialog(infList);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
public void clearV2XMarkers() {
|
||||
if (currMarkerList != null) {
|
||||
for (Marker marker : currMarkerList) {
|
||||
marker.destroy();
|
||||
}
|
||||
currMarkerList = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
|
||||
@@ -2,19 +2,26 @@ package com.mogo.eagle.core.function.smp;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.mvp.BaseFragment;
|
||||
import com.mogo.eagle.core.data.autopilot.AutopilotControlParameters;
|
||||
import com.mogo.eagle.core.data.constants.MoGoFragmentPaths;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.api.map.smp.IMogoSmallMapProvider;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
|
||||
import com.mogo.eagle.core.function.map.R;
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager;
|
||||
import com.mogo.eagle.core.function.overview.ViewModelExtKt;
|
||||
import com.mogo.eagle.core.function.overview.vm.OverViewModel;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -28,6 +35,7 @@ public class OverviewMapFragment extends BaseFragment
|
||||
implements IMogoSmallMapProvider {
|
||||
private final String TAG = "SmallMapFragment";
|
||||
protected AMapCustomView mAMapCustomView;
|
||||
private OverViewModel mViewModel;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
@@ -70,6 +78,18 @@ public class OverviewMapFragment extends BaseFragment
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearV2XMarkers() {
|
||||
if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
|
||||
UiThreadHandler.post(() -> {
|
||||
mAMapCustomView.clearV2XMarkers();
|
||||
});
|
||||
} else {
|
||||
mAMapCustomView.clearV2XMarkers();
|
||||
}
|
||||
mViewModel.stopQueryV2XEvents();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawablePolyline(List<MogoLatLng> coordinates) {
|
||||
}
|
||||
@@ -92,17 +112,36 @@ public class OverviewMapFragment extends BaseFragment
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
// 主动查一次全局路径规划的数据
|
||||
CallerAutoPilotManager.INSTANCE.getGlobalPath();
|
||||
// queryInfStructure();
|
||||
queryV2XEvents();
|
||||
}
|
||||
|
||||
// private void queryInfStructure() {
|
||||
// mViewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class);
|
||||
// mViewModel.getInfStructuresMap().observe(this.getViewLifecycleOwner(), map -> {
|
||||
// mAMapCustomView.updateInfStructures(map);
|
||||
// });
|
||||
// // 本地数据库查询
|
||||
// mViewModel.fetchInfStructures();
|
||||
// }
|
||||
private void queryV2XEvents() {
|
||||
mViewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class);
|
||||
mViewModel.getV2XEventLiveData().observe(this.getViewLifecycleOwner(), v2XEvents -> {
|
||||
mAMapCustomView.showV2XEventMarkers(v2XEvents);
|
||||
});
|
||||
|
||||
long lineId = getLineId();
|
||||
if (lineId > 0) {
|
||||
mViewModel.getAllV2XEventsByLineId("" + lineId, MoGoAiCloudClientConfig.getInstance().getSn());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Taxi的下发的轨迹id
|
||||
*/
|
||||
private long getLineId() {
|
||||
long lineId = -1;
|
||||
AutopilotControlParameters parameter = CallerAutoPilotStatusListenerManager.INSTANCE.getAutoPilotStatusInfo()
|
||||
.getAutopilotControlParameters();
|
||||
if (parameter != null) {
|
||||
if (parameter.autoPilotLine != null) {
|
||||
lineId = parameter.autoPilotLine.getLineId();
|
||||
}
|
||||
}
|
||||
return lineId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
|
||||
@@ -29,4 +29,6 @@ public interface IMogoSmallMapProvider {
|
||||
* 清除路径线
|
||||
*/
|
||||
void clearPolyline();
|
||||
|
||||
default void clearV2XMarkers() {}
|
||||
}
|
||||
|
||||
@@ -47,4 +47,9 @@ object CallerSmpManager : CallerBase() {
|
||||
fun hidePanel() {
|
||||
mogoSmallMapProvider.hidePanel()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun clearV2XMarkers() {
|
||||
mogoSmallMapProvider.clearV2XMarkers()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user