This commit is contained in:
zhongchao
2021-04-15 15:42:09 +08:00
6 changed files with 123 additions and 40 deletions

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;
}