This commit is contained in:
lixiaopeng
2021-04-07 19:16:32 +08:00
parent 2f80a3ca83
commit e3450f20cf
7 changed files with 78 additions and 109 deletions

View File

@@ -26,9 +26,7 @@ import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_
public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedListener {
private static final String TAG = "V2XWarnDataDrawer";
private static volatile V2XWarnDataDrawer sInstance;
private boolean mChangeCarModeStatus;
private V2XWarnDataDrawer() {
@@ -80,21 +78,18 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
markerShowEntity.setMarkerLocation(location);
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA);
WorkThreadHandler.getInstance().postDelayed(() -> {
IMogoMarker marker = drawMarker(markerShowEntity);
Log.d("liyz", "renderWarnData marker != null ");
marker.addDynamicAnchorPosition(new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), (float) data.getHeading(), 5000);
//移动完成以后3s后消失
UiThreadHandler.postDelayed( () -> {
marker.remove();
}, 8000 );
}, 0);
IMogoMarker marker = drawMarker(markerShowEntity);
Log.d("liyz", "renderWarnData marker != null ");
marker.addDynamicAnchorPosition(new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), (float) data.getHeading(), 5000);
//移动完成以后3s后消失
UiThreadHandler.postDelayed(() -> {
marker.remove();
}, 8000);
}
public IMogoMarker drawMarker(MarkerShowEntity markerShowEntity) {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
@@ -104,7 +99,7 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
options.icon3DRes(getModelRes(2)); //TODO
// options.anchorColor("#FF4040");
options.anchorColor("#FF3036"); //红色
options.anchorColor("#FB3C3CFF"); //红色#FF3036 蓝色:#256BFF
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), options);
iMarkerView.setMarker(marker);
marker.setToTop();

View File

@@ -138,27 +138,8 @@ public class V2XWaringManager {
// info1.setHeading(10);
// info1.setStartLocation(startLatlng1);
// info1.setEndLocation(endLatlng1);
//
// //只有在3d模型下高精数据才有值 TODO
// if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
// float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(116.411198243370,
// 39.9809517154582, (float) 3.13919341919472 , true, true);
// Log.d(V2XConst.LOG_NAME_WARN, "roadWidth = " + roadWidth);
// float pixel = V2XServiceManager.getMapUIController().getScalePerPixel();
// float width = roadWidth / pixel;
// Log.d(V2XConst.LOG_NAME_WARN, "width = " + width + "---pixel = " + pixel);
// info1.setWidth(roadWidth);
// }
//
// V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info1);
//
// //延迟3秒清理线
// UiThreadHandler.postDelayed( () -> {
// V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
// }, 3000 );
// adas 每隔一秒传递的他车或行人数据
// adas 每隔一秒传递的他车或行人数据,避免重复
// V2XServiceManager.getmIMogoADASController().addAdasRecognizedDataCallback(resultList -> {
// // 绘制近景识别到的车辆,行人和二轮车
// AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );

View File

@@ -39,26 +39,12 @@ public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineMan
// 渐变色
List<Integer> colors = new ArrayList<>();
// if (info.getType() != null) {
// if (info.getType().equals("1")) { //预警 TODO
// colors.add(0xFFFFA31A);
// colors.add(0xFFFFA31A);
// } else {
// colors.add(0xFFE32F46);
// colors.add(0xFFE32F46);
// }
// } else {
// colors.add(0xFFE32F46);
// colors.add(0xFFE32F46);
// }
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
// 线条粗细,渐变,渐变色值
Log.d(V2XConst.LOG_NAME_WARN, "MoGoPersonWarnPolylineManager width = " + info.getWidth());
options.width(info.getWidth()).useGradient(true).transparency(0.1f).colorValues(colors);
Log.d(V2XConst.LOG_NAME_WARN, "MoGoPersonWarnPolylineManager width = " + info.getWidth());
options.width(info.getWidth()).useGradient(true).colorValues(colors);
// 当前车辆位置
options.add(info.getStartLocation());
// 目标车辆位置
@@ -66,7 +52,7 @@ public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineMan
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
mMogoPolyline.setTransparency(0.5f);
} catch (Exception e) {
e.printStackTrace();
}

View File

@@ -1,15 +1,19 @@
package com.mogo.module.v2x.manager.impl;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.util.Log;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
import com.mogo.module.common.entity.V2XMessageEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.MoGoV2XServicePaths;
import com.mogo.module.v2x.V2XConst;
@@ -18,7 +22,7 @@ import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;
import java.util.Arrays;
@@ -31,6 +35,7 @@ import static com.mogo.module.v2x.V2XServiceManager.getContext;
public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMogoCarLocationChangedListener2 {
private V2XWarningEntity mCloundWarningInfo;
private static String TAG = "MoGoV2XCloundDataManager";
private boolean isSelfLineClear;
@Override
public void init(Context context) {
@@ -44,18 +49,36 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
mCloundWarningInfo = cloundWarningInfo;
//绘制识别物与交汇点连线,并且更新连线数据
//发送预警提示
V2XMessageEntity<V2XWarningEntity> v2xMessageEntity = new V2XMessageEntity<>();
// 控制类型
v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP);
// 设置数据
v2xMessageEntity.setContent(cloundWarningInfo);
// 控制展示状态
v2xMessageEntity.setShowState(true);
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2xMessageEntity);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
isSelfLineClear = false;
WorkThreadHandler.getInstance().postDelayed(() -> {
//绘制识别物与交汇点连线,并且更新连线数据
drawOtherObjectLine(cloundWarningInfo);
//二轮车和行人的渲染和移动
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
}, 0);
//二轮车和行人的渲染和移动
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
//延迟3秒清理线
UiThreadHandler.postDelayed( () -> {
UiThreadHandler.postDelayed(() -> {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
}, 8000 );
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
isSelfLineClear = true;
}, 8000);
}
/**
@@ -68,6 +91,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
Log.d(V2XConst.LOG_NAME_WARN, "polyLine != null");
polyLine.setPoints(Arrays.asList(new MogoLatLng(info.getLat(), info.getLon()),
new MogoLatLng(info.getCollisionLat(), info.getCollisionLon())));
polyLine.setTransparency(0.5f);
} else {
Log.e(V2XConst.LOG_NAME_WARN, "polyLine == null");
DrawLineInfo lineInfo = new DrawLineInfo();
@@ -76,15 +100,14 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
lineInfo.setStartLocation(startLatlng);
lineInfo.setEndLocation(endLatlng);
lineInfo.setHeading(info.heading);
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
// float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(info.getLon(),
// info.getLat(), (float) info.heading, true, true);
Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth());
}
Log.d(V2XConst.LOG_NAME_WARN, "drawOtherObjectLine width = " + info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth());
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
}
} else {
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
@@ -101,35 +124,31 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
*/
@Override
public void onCarLocationChanged2(Location latLng) {
Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude());
// Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear);
//当行人经纬度交点 经纬度不为空,开始画线,否则清理
//自车只需要关注移动
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
if (mCloundWarningInfo != null) {
if (mogoPolyline != null) {
mogoPolyline.setPoints(Arrays.asList(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()),
new MogoLatLng(mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon())));
if (!isSelfLineClear) {
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
if (mCloundWarningInfo != null) {
if (mogoPolyline != null) {
mogoPolyline.setPoints(Arrays.asList(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()),
new MogoLatLng(mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon())));
mogoPolyline.setTransparency(0.5f);
} else {
Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 mogoPolyline == null width = " + mCloundWarningInfo.getRoadwidth());
DrawLineInfo info = new DrawLineInfo(); // 对象
MogoLatLng startLatlng = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
MogoLatLng endLatlng = new MogoLatLng(mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon());
info.setHeading(latLng.getBearing());
info.setStartLocation(startLatlng);
info.setEndLocation(endLatlng);
info.setWidth(mCloundWarningInfo.getRoadwidth()); //TODO 还需要转换比例尺
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
}
} else {
Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 mogoPolyline == null width = " + mCloundWarningInfo.getRoadwidth());
DrawLineInfo info = new DrawLineInfo(); // 对象
MogoLatLng startLatlng = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude());
MogoLatLng endLatlng = new MogoLatLng(mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon());
info.setHeading(latLng.getBearing());
info.setStartLocation(startLatlng);
info.setEndLocation(endLatlng);
info.setWidth(mCloundWarningInfo.getRoadwidth()); //TODO 还需要转换比例尺
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
}
//延迟3秒清理线 TODO 何时 清理
UiThreadHandler.postDelayed( () -> {
Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 mCloundWarningInfo == null");
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}, 13000 );
} else {
Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 mCloundWarningInfo == null");
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}
}
}

View File

@@ -42,34 +42,21 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
MogoPolylineOptions options = new MogoPolylineOptions();
List<Integer> colors = new ArrayList<>();
// if (info.getType() != null) {
// if (info.getType().equals("1")) { //预警 TODO
// colors.add(0xFFFFA31A);
// colors.add(0xFFFFA31A);
// } else {
// colors.add(0xFFE32F46);
// colors.add(0xFFE32F46);
// }
// } else {
// Log.e(V2XConst.LOG_NAME_WARN, "drawWarnPolyline info.getType() == null ");
// colors.add(0xFFE32F46);
// colors.add(0xFFE32F46);
// }
colors.add(0xFFE32F46);
colors.add(0xFFE32F46);
Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager roadWidth = " + info.getWidth());
Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager roadWidth = " + info.getWidth());
// 线条粗细,渐变,渐变色值
options.width(info.getWidth()).useGradient(true).transparency(0.9f).colorValues(colors);
// options.width(info.getWidth()).useGradient(true).colorValues(colors);
// 当前车辆位置
options.width(info.getWidth() == 0.0 ? 60 : info.getWidth()).useGradient(true).colorValues(colors);
// options.width(60).useGradient(true).colorValues(colors);
options.add(info.getStartLocation());
// 目标车辆位置
options.add(info.getEndLocation());
// 绘制线的对象
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
mMogoPolyline.setTransparency(0.5f);
} catch (Exception e) {
e.printStackTrace();

View File

@@ -48,7 +48,7 @@ public class V2XWarningMarker implements IV2XMarker {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
pointsBetween();
//绘制停止线
drawStopLines(fillPoints);
// drawStopLines(fillPoints);
drawSafeLine();
WorkThreadHandler.getInstance().postDelayed(() -> {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_STOP_LINE);
@@ -72,9 +72,9 @@ public class V2XWarningMarker implements IV2XMarker {
//根据到停止线的距离和方向角获取经纬度
MogoLatLng
stopLineLo = LocationUtils.getNewLocation(car, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() > 0) {
drawLine(car, stopLineLo);
}
// if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() > 0) {
// drawLine(car, stopLineLo);
// }
} else {
Log.d(TAG, "自车位置没有拿到");
}
@@ -152,6 +152,7 @@ public class V2XWarningMarker implements IV2XMarker {
DrawLineInfo drawLineInfo = new DrawLineInfo();
drawLineInfo.setStartLocation(s);
drawLineInfo.setEndLocation(e);
drawLineInfo.setWidth(60);
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, drawLineInfo);
}

View File

@@ -26,5 +26,5 @@
"warningContent": "小心行人",
"heading": 30,
"showTime": 3000,
"roadwidth": 65.0
"roadwidth": 60.0
}