This commit is contained in:
zhongchao
2021-04-06 15:40:50 +08:00
7 changed files with 52 additions and 36 deletions

View File

@@ -67,7 +67,7 @@ public class V2XWaringManager {
}
/**
* TODO 测试数据
* 测试数据
*/
private void testData() {
@@ -86,7 +86,6 @@ public class V2XWaringManager {
// 加载数据源
V2XWarningEntity warningEntity = GsonUtil.objectFromJson(baos.toString(), V2XWarningEntity.class);
V2XServiceManager.getMoGoV2XCloundDataManager().analysisV2XCloundDataEvent(warningEntity);
Logger.d(V2XConst.LOG_NAME_WARN, "testData -----> ");
} catch (Exception e) {
e.printStackTrace();
}

View File

@@ -16,7 +16,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* 当前车辆与道路事件的连接线
* 绘制行人和二轮车连线
*/
@Route(path = MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER)
public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineManager {
@@ -54,9 +54,8 @@ public class MoGoPersonWarnPolylineManager implements IMoGoPersonWarnPolylineMan
}
// 线条粗细,渐变,渐变色值
// Logger.d(V2XConst.LOG_NAME_WARN, "MoGoPersonWarnPolylineManager roadWidth = " + roadWidth);
options.width(60).useGradient(true).colorValues(colors);
// options.width(info.getWidth()).useGradient(true).colorValues(colors);
Log.d(V2XConst.LOG_NAME_WARN, "MoGoPersonWarnPolylineManager width = " + info.getWidth());
options.width(info.getWidth()).useGradient(true).transparency(0.1f).colorValues(colors);
// 当前车辆位置
options.add(info.getStartLocation());
// 目标车辆位置

View File

@@ -17,6 +17,7 @@ import com.mogo.module.v2x.V2XServiceManager;
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;
@@ -29,24 +30,36 @@ import static com.mogo.module.v2x.V2XServiceManager.getContext;
@Route(path = MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER)
public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMogoCarLocationChangedListener2 {
private V2XWarningEntity mCloundWarningInfo;
private static String TAG = "MoGoV2XCloundDataManager";
@Override
public void init(Context context) {
MogoApisHandler.getInstance().getApis().getRegisterCenterApi()
.registerCarLocationChangedListener(TAG, this);
}
@Override
public void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo) {
Log.d(V2XConst.LOG_NAME_WARN, "analysisV2XCloundDataEvent -----> ");
mCloundWarningInfo = cloundWarningInfo;
//绘制识别物与交汇点连线,并且更新连线数据 TODO VR模式无法获取道路宽度
drawOtherObjectLine(cloundWarningInfo);
Logger.d(V2XConst.LOG_NAME_WARN, "analysisV2XCloundDataEvent -----> ");
//绘制识别物与交汇点连线,并且更新连线数据
WorkThreadHandler.getInstance().postDelayed(() -> {
drawOtherObjectLine(cloundWarningInfo);
}, 0);
//二轮车和行人的渲染和移动
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
//延迟3秒清理线
UiThreadHandler.postDelayed( () -> {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
}, 8000 );
}
/**
* 绘制行人和二轮车连线,并且更新数据
* 绘制行人和二轮车连线,并且更新数据 TODO 需要实时给行人当前位置
*/
private void drawOtherObjectLine(V2XWarningEntity info) {
IMogoPolyline polyLine = V2XServiceManager.getMoGoPersonWarnPolylineManager().getMogoPersonWarnPolyline();
@@ -56,7 +69,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
polyLine.setPoints(Arrays.asList(new MogoLatLng(info.getLat(), info.getLon()),
new MogoLatLng(info.getCollisionLat(), info.getCollisionLon())));
} else {
Log.d(V2XConst.LOG_NAME_WARN, "polyLine == null");
Log.e(V2XConst.LOG_NAME_WARN, "polyLine == null");
DrawLineInfo lineInfo = new DrawLineInfo();
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());
@@ -64,21 +77,14 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
lineInfo.setEndLocation(endLatlng);
lineInfo.setHeading(info.heading);
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, "roadWidth = " + roadWidth);
float pixel = V2XServiceManager.getMapUIController().getScalePerPixel();
float width = roadWidth / pixel;
lineInfo.setWidth(width);
// 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());
}
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
}
//延迟3秒清理线
UiThreadHandler.postDelayed( () -> {
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
}, 6000 );
} else {
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
@@ -91,11 +97,11 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
/**
* 自车定位 移动完成需要 3s消失
* 自车定位 移动完成需要 3s消失,这里何时清理,应该是没有数据的时候
*/
@Override
public void onCarLocationChanged2(Location latLng) {
Log.d(V2XConst.LOG_NAME_WARN, "latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude());
Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude());
//当行人经纬度交点 经纬度不为空,开始画线,否则清理
//自车只需要关注移动
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
@@ -105,21 +111,21 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
new MogoLatLng(mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon())));
} else {
Log.e(V2XConst.LOG_NAME_WARN, "mogoPolyline == null");
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(60); //TODO
info.setWidth(mCloundWarningInfo.getRoadwidth()); //TODO 还需要转换比例尺
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
}
//延迟3秒清理线
//延迟3秒清理线 TODO 何时 清理
UiThreadHandler.postDelayed( () -> {
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}, 3000 );
}, 13000 );
} else {
Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 mCloundWarningInfo == null");

View File

@@ -38,8 +38,6 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
mMogoPolyline.remove();
}
Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager --------> ");
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();
List<Integer> colors = new ArrayList<>();
@@ -58,9 +56,9 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
colors.add(0xFFE32F46);
}
// Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager roadWidth = " + roadWidth);
Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager roadWidth = " + info.getWidth());
// 线条粗细,渐变,渐变色值
options.width(60).useGradient(true).colorValues(colors);
options.width(info.getWidth()).useGradient(true).transparency(0.9f).colorValues(colors);
// options.width(info.getWidth()).useGradient(true).colorValues(colors);
// 当前车辆位置
options.add(info.getStartLocation());