|
|
|
|
@@ -58,7 +58,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
/*
|
|
|
|
|
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
|
|
|
|
* */
|
|
|
|
|
private MogoLatLng middleLocationInStopLine = new MogoLatLng(0,0);
|
|
|
|
|
private MogoLatLng middleLocationInStopLine = new MogoLatLng(0, 0);
|
|
|
|
|
private static long showTime = 5000;
|
|
|
|
|
private float bearing;
|
|
|
|
|
|
|
|
|
|
@@ -75,8 +75,9 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void drawLineWithEntity() {
|
|
|
|
|
showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime()*1000 : 5000;
|
|
|
|
|
Log.d(TAG, "显示时间为++" + String.valueOf(showTime)+"识别物类型:"+String.valueOf(mCloundWarningInfo.getType()));
|
|
|
|
|
showTime = mCloundWarningInfo.getShowTime() > 0 ? mCloundWarningInfo.getShowTime() * 1000 : 5000;
|
|
|
|
|
Log.d(TAG, "显示时间为++" + String.valueOf(showTime) + "识别物类型:" +
|
|
|
|
|
String.valueOf(mCloundWarningInfo.getType()));
|
|
|
|
|
pointsBetween();
|
|
|
|
|
bearing = V2XLocationListener.getInstance().getLastCarLocation().getBearing();
|
|
|
|
|
isSelfLineClear = false;
|
|
|
|
|
@@ -85,29 +86,28 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
if (fillPoints.size() > 0) { //存在停止线的情况 TODO
|
|
|
|
|
middleLocationInStopLine = getMiddleLocationInStopLine();
|
|
|
|
|
//如果是正前方类型,红色绘制区域从停止线向前绘制50米
|
|
|
|
|
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine, 50, mCloundWarningInfo.getAngle());
|
|
|
|
|
MogoLatLng warningLocation = Trigonometric.getNewLocation(middleLocationInStopLine,
|
|
|
|
|
50, mCloundWarningInfo.getAngle());
|
|
|
|
|
//停止线前方画线
|
|
|
|
|
WorkThreadHandler.getInstance().postDelayed(() -> {
|
|
|
|
|
//二轮车和行人的渲染和移动
|
|
|
|
|
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
|
|
|
|
V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo);
|
|
|
|
|
//绘制识别物与交汇点连线,并且更新连线数据
|
|
|
|
|
drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine, warningLocation);
|
|
|
|
|
drawRedWarningLineFrontOfStopLine(mCloundWarningInfo, middleLocationInStopLine,
|
|
|
|
|
warningLocation);
|
|
|
|
|
//添加停止线marker
|
|
|
|
|
handleStopLine();
|
|
|
|
|
if (carLocation.lat != 0 && carLocation.lon != 0){
|
|
|
|
|
if (carLocation.lat != 0 && carLocation.lon != 0) {
|
|
|
|
|
//自车画线
|
|
|
|
|
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
|
|
|
|
}else {
|
|
|
|
|
Log.d(TAG,"自车定位数据为空carLocation == null");
|
|
|
|
|
} else {
|
|
|
|
|
Log.d(TAG, "自车定位数据为空carLocation == null");
|
|
|
|
|
}
|
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
|
UiThreadHandler.postDelayed(() -> {
|
|
|
|
|
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
|
|
|
|
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
|
|
|
|
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
|
|
|
|
isSelfLineClear = true;
|
|
|
|
|
clearAllLine();
|
|
|
|
|
}, showTime);
|
|
|
|
|
|
|
|
|
|
} else { //无停止线
|
|
|
|
|
@@ -118,24 +118,22 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
V2XServiceManager.getMarkerManager().removeMarkers(TYPE_MARKER_CLOUD_WARN_DATA);
|
|
|
|
|
V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo);
|
|
|
|
|
//车辆静止的时候
|
|
|
|
|
if (carLocation.lat != 0 && carLocation.lon != 0){
|
|
|
|
|
if (carLocation.lat != 0 && carLocation.lon != 0) {
|
|
|
|
|
drawSelfCarLine(carLocation.lon, carLocation.lat, bearing);
|
|
|
|
|
}else {
|
|
|
|
|
Log.d(TAG,"数据为空carLocation == null");
|
|
|
|
|
} else {
|
|
|
|
|
Log.d(TAG, "数据为空carLocation == null");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}, 0);
|
|
|
|
|
|
|
|
|
|
//延迟3秒清理线
|
|
|
|
|
UiThreadHandler.postDelayed(() -> {
|
|
|
|
|
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
|
|
|
|
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
|
|
|
|
isSelfLineClear = true;
|
|
|
|
|
clearAllLine();
|
|
|
|
|
}, showTime);
|
|
|
|
|
}
|
|
|
|
|
//预警蒙层
|
|
|
|
|
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(mCloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
|
|
|
|
|
|
|
|
|
MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection
|
|
|
|
|
(mCloundWarningInfo.getDirection(), MogoReceiver.ACTION_V2X_FRONT_WARNING);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
@@ -146,8 +144,10 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
if (info != null) {
|
|
|
|
|
IMogoPolyline polyLine = V2XServiceManager.getMoGoStopPolylineManager().getMogoStopPolyline();
|
|
|
|
|
MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
|
|
|
|
|
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(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat +
|
|
|
|
|
"中间点坐标:" + addMiddleLoc.lon + "," + addMiddleLoc.lat
|
|
|
|
|
+ "终点" + endLatlng.lon + "," + endLatlng.lat);
|
|
|
|
|
@@ -167,12 +167,21 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
lineInfo.setWidth(info.getRoadwidth() * 14 + 5);
|
|
|
|
|
V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
|
|
|
|
|
}
|
|
|
|
|
UiThreadHandler.postDelayed(() -> {
|
|
|
|
|
clearAllLine();
|
|
|
|
|
}, showTime);
|
|
|
|
|
} else {
|
|
|
|
|
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
|
|
|
|
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
|
|
|
|
clearAllLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void clearAllLine() {
|
|
|
|
|
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
|
|
|
|
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
|
|
|
|
V2XServiceManager.getMoGoStopPolylineManager().clearLine();
|
|
|
|
|
isSelfLineClear = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 补点后的停止线经纬度合集
|
|
|
|
|
*/
|
|
|
|
|
@@ -227,7 +236,8 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
|
|
|
|
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
|
|
|
|
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(),
|
|
|
|
|
mCloundWarningInfo.getAngle());
|
|
|
|
|
return newLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -235,37 +245,45 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
* 自车前方的点,在停止线上--通过自车位置与距离停止线之间的距离计算
|
|
|
|
|
* */
|
|
|
|
|
private MogoLatLng getMiddleLocationInStopLine() {
|
|
|
|
|
Log.d(TAG, "计算停止线上的某个点" + String.valueOf(carLocation.lat + "," + String.valueOf(carLocation.lon)));
|
|
|
|
|
Log.d(TAG, "计算停止线上的某个点" + String.valueOf(carLocation.lat + "," +
|
|
|
|
|
String.valueOf(carLocation.lon)));
|
|
|
|
|
if (carLocation.lat == 0 || carLocation.lon == 0) {
|
|
|
|
|
Log.d(TAG, "获取不到车的位置");
|
|
|
|
|
}
|
|
|
|
|
MogoLatLng newLocation = Trigonometric.getNewLocation(carLocation, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle());
|
|
|
|
|
MogoLatLng newLocation = Trigonometric.getNewLocation(carLocation, mCloundWarningInfo.getStopLineDistance(),
|
|
|
|
|
mCloundWarningInfo.getAngle());
|
|
|
|
|
return newLocation;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
|
|
|
|
|
* 自车为起点绘制(根据设计,前方行人/弱势交通参与者预警 getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP
|
|
|
|
|
* 自车与停止线之间为蓝色预警;其他侧方预警自车与预碰撞点之间显示红色预警)
|
|
|
|
|
* lon 自车经度
|
|
|
|
|
* lat 自车纬度
|
|
|
|
|
*/
|
|
|
|
|
public void drawSelfCarLine(double lon, double lat, float bearing) {
|
|
|
|
|
if (!isSelfLineClear) {
|
|
|
|
|
IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline();
|
|
|
|
|
if (mCloundWarningInfo != null) {
|
|
|
|
|
MogoLatLng startLatlng = new MogoLatLng(0,0);
|
|
|
|
|
MogoLatLng endLatlng = new MogoLatLng(0,0);
|
|
|
|
|
MogoLatLng addMiddleLoc = new MogoLatLng(0,0);
|
|
|
|
|
MogoLatLng startLatlng = new MogoLatLng(0, 0);
|
|
|
|
|
MogoLatLng endLatlng = new MogoLatLng(0, 0);
|
|
|
|
|
MogoLatLng addMiddleLoc = new MogoLatLng(0, 0);
|
|
|
|
|
|
|
|
|
|
if (!isFirstLocation) {
|
|
|
|
|
carLocation = getMogoLat(new MogoLatLng(lat, lon));
|
|
|
|
|
isFirstLocation = true;
|
|
|
|
|
}
|
|
|
|
|
//绘制线的终点(在停止线上或者预碰撞点上)
|
|
|
|
|
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
|
|
|
|
|
mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ? middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
|
|
|
|
|
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ?
|
|
|
|
|
middleLocationInStopLine.lat : mCloundWarningInfo.getCollisionLat(),
|
|
|
|
|
mCloundWarningInfo.getDirection() == ALERT_THE_FRONT_CRASH_WARNING_TOP ?
|
|
|
|
|
middleLocationInStopLine.lon : mCloundWarningInfo.getCollisionLon());
|
|
|
|
|
//自车位置
|
|
|
|
|
startLatlng = new MogoLatLng(lat, lon);
|
|
|
|
|
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
|
|
|
|
//扩展点为了渐变色添加
|
|
|
|
|
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
|
|
|
|
|
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2,
|
|
|
|
|
Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));
|
|
|
|
|
Log.d(TAG, "自车为起点绘制 自车;" + startLatlng.lon + "," + startLatlng.lat +
|
|
|
|
|
"中间扩展点" + addMiddleLoc.lon + "," + addMiddleLoc.lat + "终点:" + endLatlng.lon + "," + endLatlng.lat);
|
|
|
|
|
|
|
|
|
|
@@ -285,8 +303,11 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
info.setDirection(mCloundWarningInfo.getDirection());
|
|
|
|
|
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
|
|
|
|
|
}
|
|
|
|
|
UiThreadHandler.postDelayed(() -> {
|
|
|
|
|
clearAllLine();
|
|
|
|
|
}, showTime+3000);
|
|
|
|
|
} else {
|
|
|
|
|
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
|
|
|
|
|
clearAllLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -323,7 +344,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
|
|
|
|
|
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
|
|
|
|
|
clearAllLine();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -344,7 +365,6 @@ public class V2XWarningMarker implements IV2XMarker {
|
|
|
|
|
}
|
|
|
|
|
//延迟3秒清理线
|
|
|
|
|
UiThreadHandler.postDelayed(() -> {
|
|
|
|
|
|
|
|
|
|
V2XServiceManager.getMarkerManager().removeMarkers(WARNING_ARROWS);
|
|
|
|
|
}, showTime);
|
|
|
|
|
|
|
|
|
|
|