Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk

This commit is contained in:
董宏宇
2021-04-15 16:47:03 +08:00
10 changed files with 165 additions and 76 deletions

View File

@@ -13,6 +13,8 @@ import com.mogo.module.common.entity.MarkerCarPois;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerOnlineCar;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
@@ -26,7 +28,7 @@ public
*
* 描述
*/
class OnlineCarDrawer {
class OnlineCarDrawer implements IMogoStatusChangedListener {
private static final String TAG = "OnlineCarDrawer";
@@ -36,6 +38,9 @@ class OnlineCarDrawer {
private static volatile OnlineCarDrawer sInstance;
private OnlineCarDrawer() {
MogoApisHandler.getInstance().getApis()
.getStatusManagerApi()
.registerStatusChangedListener( TAG, StatusDescriptor.VR_MODE, this );
}
public static OnlineCarDrawer getInstance() {
@@ -53,11 +58,6 @@ class OnlineCarDrawer {
sInstance = null;
}
private Object readResolve() {
// 阻止反序列化,必须实现 Serializable 接口
return sInstance;
}
public void clearMarkers(){
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
}
@@ -196,5 +196,8 @@ class OnlineCarDrawer {
return false;
}
@Override
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
clearMarkers();
}
}

View File

@@ -92,7 +92,6 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
mLastPositions.clear();
}
AdasRecognizedResultDrawer.getInstance().notifyVrModeChanged(); //清除ADAS old marker data
OnlineCarDrawer.getInstance().clearMarkers(); //清除在线车辆 old marker data
}
public boolean isVrMode() {

View File

@@ -1,14 +1,11 @@
package com.mogo.module.common.drawer;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
import com.mogo.module.common.drawer.marker.IMarkerView;
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;

View File

@@ -0,0 +1,42 @@
package com.mogo.module.common.drawer.marker;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.R;
import com.mogo.module.common.entity.MarkerShowEntity;
/**
* author : 李小鹏
* desc : 地图2dMarker 在3d下的展示
* 前方碰撞
*/
public class AheadCollisionView extends MapMarkerBaseView {
public AheadCollisionView(Context context) {
super(context);
}
public AheadCollisionView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public AheadCollisionView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void initView(Context context) {
LayoutInflater.from(context).inflate(R.layout.module_common_warning_marker_front, this);
}
@Override
public void updateView(MarkerShowEntity markerShowEntity) {
}
}

View File

@@ -0,0 +1,26 @@
package com.mogo.module.common.drawer.marker;
import android.content.Context;
import android.view.View;
import com.mogo.map.marker.IMogoInfoWindowAdapter;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
/**
* @author lixiaopeng
* @since 2021/4/15
* 描述 前方碰撞预警marker
*/
public class AheadCollisionWindow3DAdapter implements IMogoInfoWindowAdapter {
private Context mContext;
public AheadCollisionWindow3DAdapter(Context context) {
this.mContext = context;
}
@Override
public View getInfoWindow(IMogoMarker marker) {
return new AheadCollisionView(mContext);
}
}

View File

@@ -24,10 +24,8 @@ import com.mogo.module.common.utils.CloudPoiManager;
import com.mogo.utils.logger.Logger;
/**
* author : donghongyu
* e-mail : 1358506549@qq.com
* date : 2020-01-0619:55
* desc : 地图Marker图标带文本信息
* author : 李小鹏
* desc : 地图2dMarker 在3d下的展示
* version: 1.0
*/
public class MapCameraInfoView extends MapMarkerBaseView {

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/common_marker_bottom_floor" />
</LinearLayout>

View File

@@ -4,16 +4,27 @@ import android.content.Context;
import android.util.Log;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
import com.mogo.module.common.drawer.MarkerDrawer;
import com.mogo.module.common.drawer.marker.AheadCollisionView;
import com.mogo.module.common.drawer.marker.AheadCollisionWindow3DAdapter;
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
import com.mogo.module.common.drawer.marker.SimpleWindow3DAdapter;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.common.utils.Trigonometric;
import com.mogo.module.common.view.MarkerBaseFloor;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.listener.V2XWarnMessageListener;
import com.mogo.module.v2x.utils.V2XUtils;
import com.mogo.realtime.entity.ADASRecognizedResult;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.ViewUtils;
import com.mogo.utils.logger.Logger;
import com.mogo.utils.network.utils.GsonUtil;
@@ -130,44 +141,41 @@ public class V2XWaringManager {
//测试数据
testData();
// 绘制连接线
// DrawLineInfo info1 = new DrawLineInfo();
// MogoLatLng startLatlng1 = new MogoLatLng(39.968919,116.407642);
// MogoLatLng endLatlng1 = new MogoLatLng(40.010906,116.423821);
// info1.setHeading(10);
// info1.setStartLocation(startLatlng1);
// info1.setEndLocation(endLatlng1);
// adas 每隔一秒传递的他车或行人数据,避免重复
// adas 每隔一秒传递的他车或行人数据,避免重复。
// V2XServiceManager.getmIMogoADASController().addAdasRecognizedDataCallback(resultList -> {
// // 绘制近景识别到的车辆,行人和二轮车
// // 处理他车车身变色,这个可以使用 TODO
// AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );
//
// //清理
// V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
//
// // 绘制连接线
// DrawLineInfo info = new DrawLineInfo();
// MogoLatLng startLatlng = new MogoLatLng(39.969247,116.407299);
// MogoLatLng endLatlng = new MogoLatLng(39.971089,116.407384);
// info.setStartLocation(startLatlng);
// info.setEndLocation(endLatlng);
// V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, info);
//
// //更新数据
// for (ADASRecognizedResult result : resultList) {
// MogoLatLng latLng = new MogoLatLng(result.lat, result.lon);
// lonLats.add(latLng);
// }
// IMogoPolyline mMogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
// mMogoPolyline.setPoints(lonLats);
// // adas自车定位显示红色碰撞预警图以及解除碰撞
// double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
// double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
// //需要把自车的经纬度前移到车头然后打点红色的marker
//
// } );
//
//adas自车定位
// MogoApisHandler.getInstance().getApis().getMapServiceApi().getSingletonLocationClient().getLastKnowLocation()
// double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon();
// double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat();
}
/**
* 添加2d的碰撞 marker
* @param markerShowEntity
* @return
*/
private IMogoMarker drawMarker2dResource(MarkerShowEntity markerShowEntity) {
MogoLatLng mogoLatLng = new MogoLatLng(markerShowEntity.getMarkerLocation().getLat(), markerShowEntity.getMarkerLocation().getLon());
MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 8, 180);
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
.latitude(newLocation.getLat())
.longitude(newLocation.getLon())
.anchor(1.0f, 1.0f)
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
optionsRipple
.icon(ViewUtils.fromView(new EmptyMarkerView(mContext)));
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), optionsRipple);
marker.setInfoWindowAdapter(new AheadCollisionWindow3DAdapter(mContext));
marker.showInfoWindow();
return marker;
}

View File

@@ -112,16 +112,7 @@ public class V2XPushLiveCarWindow extends V2XBasWindow implements IV2XWindow<V2X
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
runnableV2XEvent = null;
}
//移除窗体
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
V2XServiceManager
.getMogoTopViewManager()
.removeViewNoLinkage(this);
}else{
V2XServiceManager
.getMogoTopViewManager()
.removeView(this);
}
remove();
}
@Override
@@ -140,14 +131,9 @@ public class V2XPushLiveCarWindow extends V2XBasWindow implements IV2XWindow<V2X
public void countDownV2XEvent(V2XPushMessageEntity v2XPushMessageEntity) {
// 倒计时
if (runnableV2XEvent == null) {
runnableV2XEvent = () -> {
//Logger.d(MODULE_NAME, "V2X=== Window 30秒倒计时结束。。。");
//移出Window详细信息
//移除窗体
V2XServiceManager
.getMogoTopViewManager()
.removeViewNoLinkage(this);
};
//Logger.d(MODULE_NAME, "V2X=== Window 30秒倒计时结束。。。");
//移出Window详细信息
runnableV2XEvent = this::close;
} else {
handlerV2XEvent.removeCallbacks(runnableV2XEvent);
}
@@ -155,4 +141,18 @@ public class V2XPushLiveCarWindow extends V2XBasWindow implements IV2XWindow<V2X
//Logger.d(MODULE_NAME, "V2X=== Window 展示开始倒计时:" + expireTime);
handlerV2XEvent.postDelayed(runnableV2XEvent, expireTime);
}
//移除窗体
private void remove(){
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
V2XServiceManager
.getMogoTopViewManager()
.removeViewNoLinkage(this);
}else{
V2XServiceManager
.getMogoTopViewManager()
.removeView(this);
}
}
}

View File

@@ -88,16 +88,7 @@ public class V2XVoiceCallLiveCarWindow extends V2XBasWindow
public void close() {
// 停止倒计时
stopCountDown();
//移除窗体
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
V2XServiceManager
.getMogoTopViewManager()
.removeViewNoLinkage(this);
}else{
V2XServiceManager
.getMogoTopViewManager()
.removeView(this);
}
remove();
}
@Override
@@ -142,4 +133,17 @@ public class V2XVoiceCallLiveCarWindow extends V2XBasWindow
EXPIRE_TIMER = ALL_EXPIRE_TIMER;
}
}
//移除窗体
private void remove(){
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
V2XServiceManager
.getMogoTopViewManager()
.removeViewNoLinkage(this);
}else{
V2XServiceManager
.getMogoTopViewManager()
.removeView(this);
}
}
}