This commit is contained in:
zhongchao
2021-04-15 15:13:21 +08:00

View File

@@ -67,13 +67,14 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
isFirstLocation = false;
if (cloundWarningInfo.getDirection() == 1) { //前方
MogoLatLng newLocation = Trigonometric.getNewLocation((MogoLatLng) fillPoints.get(0), 80, cloundWarningInfo.getAngle());
MogoLatLng startLatLng = getMiddleLocationInStopLine();
MogoLatLng warningLocation = Trigonometric.getNewLocation(startLatLng, 80, cloundWarningInfo.getAngle());
//停止线前方画线
WorkThreadHandler.getInstance().postDelayed(() -> {
//二轮车和行人的渲染和移动
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
//绘制识别物与交汇点连线,并且更新连线数据
drawStopLine(cloundWarningInfo, newLocation);
drawStopLine(cloundWarningInfo, startLatLng, warningLocation);
//添加停止线marker
handleStopLine();
}, 500);
@@ -120,25 +121,25 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
/**
* 车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
* 场景如:车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
*/
private void drawStopLine(V2XWarningEntity info, MogoLatLng mogoLatLng) {
private void drawStopLine(V2XWarningEntity info, MogoLatLng startLatLng, MogoLatLng mogoLatLng) {
if (info != null) {
IMogoPolyline polyLine = V2XServiceManager.getMoGoStopPolylineManager().getMogoStopPolyline();
MogoLatLng startLatlng = new MogoLatLng(carLocation.lat, carLocation.lon);
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine endLatlng lon =" + endLatlng.lon + "--lat =" + endLatlng.lat
+ "--startLatlng lon = " + startLatlng.lon + "-lat = " + startLatlng.lat);
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
float distance = CoordinateUtils.calculateLineDistance(startLatLng.lon, startLatLng.lat, endLatlng.lon, endLatlng.lat);
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, distance / 2, mCloundWarningInfo.getAngle());
Log.d(V2XConst.LOG_NAME_WARN, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
if (polyLine != null) {
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng));
polyLine.setTransparency(0.5f);
} else {
DrawLineInfo lineInfo = new DrawLineInfo();
List locations = new ArrayList();
locations.add(startLatlng);
locations.add(startLatLng);
locations.add(addMiddleLoc);
locations.add(endLatlng);
lineInfo.setLocations(locations);
@@ -299,8 +300,15 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
private MogoLatLng getMogoLat(MogoLatLng latlng) {
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getDirection());
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
return newLocation;
}
/*
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
* */
private MogoLatLng getMiddleLocationInStopLine() {
MogoLatLng newLocation = Trigonometric.getNewLocation(carLocation, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
return newLocation;
}
}