diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 83405b8de1..4ff10f68a5 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -91,6 +91,7 @@
+
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/MoGoV2XServicePaths.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/MoGoV2XServicePaths.java
index 483ac4e448..04ebf4aa95 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/MoGoV2XServicePaths.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/MoGoV2XServicePaths.java
@@ -43,6 +43,13 @@ public class MoGoV2XServicePaths {
@Keep
public static final String PATH_V2X_PERSON_WARN_POLYLINE_MANAGER = "/v2xPersonWarnPolylineManager/api";
+ /**
+ * V2X 停止线连接线
+ */
+ @Keep
+ public static final String PATH_V2X_STOP_POLYLINE_MANAGER = "/v2xStopPolylineManager/api";
+
+
/**
* V2X 云端数据处理
*/
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java
index 2df6f55679..7166bb0fa1 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XServiceManager.java
@@ -17,6 +17,7 @@ import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
import com.mogo.module.service.MarkerServiceHandler;
import com.mogo.module.v2x.alarm.V2XCalculateServer;
import com.mogo.module.v2x.manager.IMoGoPersonWarnPolylineManager;
+import com.mogo.module.v2x.manager.IMoGoStopPolylineManager;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
import com.mogo.module.v2x.manager.IMoGoV2XMarkerManager;
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
@@ -114,6 +115,7 @@ public class V2XServiceManager {
private static IMoGoV2XStatusManager moGoV2XStatusManager;
private static IMoGoWarnPolylineManager moGoWarnPolylineManager;
private static IMoGoPersonWarnPolylineManager moGoPersonWarnPolylineManager;
+ private static IMoGoStopPolylineManager moGoStopPolylineManager;
private static IMoGoV2XCloundDataManager moGoV2XCloundDataManager;
private V2XServiceManager() {
@@ -170,6 +172,7 @@ public class V2XServiceManager {
moGoWarnPolylineManager = (IMoGoWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_POLYLINE_MANAGER).navigation(context);
moGoV2XCloundDataManager = (IMoGoV2XCloundDataManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_WARN_CLOUND_DATA_MANAGER).navigation(context);
moGoPersonWarnPolylineManager = (IMoGoPersonWarnPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_PERSON_WARN_POLYLINE_MANAGER).navigation(context);
+ moGoStopPolylineManager = (IMoGoStopPolylineManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STOP_POLYLINE_MANAGER).navigation(context);
moGoV2XStatusManager = (IMoGoV2XStatusManager) ARouter.getInstance().build(MoGoV2XServicePaths.PATH_V2X_STATUS_MANAGER).navigation(context);
}
@@ -351,4 +354,11 @@ public class V2XServiceManager {
V2XServiceManager.moGoPersonWarnPolylineManager = moGoPersonWarnPolylineManager;
}
+ public static IMoGoStopPolylineManager getMoGoStopPolylineManager() {
+ return moGoStopPolylineManager;
+ }
+
+ public static void setMoGoStopPolylineManager(IMoGoStopPolylineManager moGoStopPolylineManager) {
+ V2XServiceManager.moGoStopPolylineManager = moGoStopPolylineManager;
+ }
}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/entity/model/DrawLineInfo.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/entity/model/DrawLineInfo.java
index e6a68b6331..f2d9fe9e43 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/entity/model/DrawLineInfo.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/entity/model/DrawLineInfo.java
@@ -1,6 +1,5 @@
package com.mogo.module.v2x.entity.model;
-
import com.mogo.map.MogoLatLng;
@@ -22,6 +21,8 @@ public class DrawLineInfo {
private float width;
+ private int direction;
+
public String getType() {
return type;
}
@@ -61,4 +62,12 @@ public class DrawLineInfo {
public void setWidth(float width) {
this.width = width;
}
+
+ public int getDirection() {
+ return direction;
+ }
+
+ public void setDirection(int direction) {
+ this.direction = direction;
+ }
}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/IMoGoStopPolylineManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/IMoGoStopPolylineManager.java
new file mode 100644
index 0000000000..86aa8fb677
--- /dev/null
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/IMoGoStopPolylineManager.java
@@ -0,0 +1,27 @@
+package com.mogo.module.v2x.manager;
+
+import android.content.Context;
+
+import com.alibaba.android.arouter.facade.template.IProvider;
+import com.mogo.map.overlay.IMogoPolyline;
+import com.mogo.module.v2x.entity.model.DrawLineInfo;
+
+/**
+ * 绘制可变宽度和渐变的线
+ */
+public interface IMoGoStopPolylineManager extends IProvider {
+ /**
+ * 绘制连接线,目标车,与当前车辆间连线
+ *
+ * @param context
+ * @param info
+ */
+ void drawStopPolyline(Context context, DrawLineInfo info);
+
+ /**
+ * 移除连接线
+ */
+ void clearLine();
+
+ IMogoPolyline getMogoStopPolyline();
+}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoStopPolylineManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoStopPolylineManager.java
new file mode 100644
index 0000000000..1e957b2199
--- /dev/null
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoStopPolylineManager.java
@@ -0,0 +1,79 @@
+package com.mogo.module.v2x.manager.impl;
+
+import android.content.Context;
+import android.util.Log;
+
+import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.map.overlay.IMogoPolyline;
+import com.mogo.map.overlay.MogoPolylineOptions;
+import com.mogo.module.v2x.MoGoV2XServicePaths;
+import com.mogo.module.v2x.V2XConst;
+import com.mogo.module.v2x.V2XServiceManager;
+import com.mogo.module.v2x.entity.model.DrawLineInfo;
+import com.mogo.module.v2x.manager.IMoGoStopPolylineManager;
+import com.mogo.module.v2x.manager.IMoGoWarnPolylineManager;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 当前车辆与道路事件的连接线
+ */
+@Route(path = MoGoV2XServicePaths.PATH_V2X_STOP_POLYLINE_MANAGER)
+public class MoGoStopPolylineManager implements IMoGoStopPolylineManager {
+ private static IMogoPolyline mMogoPolyline;
+
+
+ @Override
+ public void drawStopPolyline(Context context, DrawLineInfo info) {
+ if (info == null) {
+ return;
+ }
+
+ try {
+ if (mMogoPolyline != null) {
+ mMogoPolyline.remove();
+ }
+
+ // 连接线参数
+ MogoPolylineOptions options = new MogoPolylineOptions();
+ List colors = new ArrayList<>();
+ colors.add(0xFFE32F46);
+ colors.add(0xFFE32F46);
+
+ Log.d(V2XConst.LOG_NAME_WARN, "MoGoStopPolylineManager roadWidth = " + info.getWidth());
+ // 线条粗细,渐变,渐变色值
+ // 当前车辆位置
+ options.width(info.getWidth() == 0.0 ? 60 : info.getWidth()).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();
+ }
+ }
+
+ @Override
+ public void clearLine() {
+ if (mMogoPolyline != null) {
+ mMogoPolyline.remove();
+ mMogoPolyline = null;
+ }
+ }
+
+ @Override
+ public void init(Context context) {
+
+ }
+
+
+ @Override
+ public IMogoPolyline getMogoStopPolyline() {
+ return mMogoPolyline;
+ }
+}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java
index e4722c5036..4f2eebf316 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java
@@ -8,6 +8,7 @@ import android.util.Log;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import com.alibaba.android.arouter.facade.annotation.Route;
+import com.mogo.cloud.commons.utils.CoordinateUtils;
import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.map.overlay.IMogoPolyline;
@@ -20,11 +21,14 @@ import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
+import com.mogo.module.v2x.utils.LocationUtils;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.WorkThreadHandler;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import static com.mogo.module.v2x.V2XServiceManager.getContext;
@@ -36,6 +40,8 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
private V2XWarningEntity mCloundWarningInfo;
private static String TAG = "MoGoV2XCloundDataManager";
private boolean isSelfLineClear;
+ private List fillPoints = new ArrayList();//停止线经纬度合集
+
@Override
public void init(Context context) {
@@ -48,6 +54,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
Log.d(V2XConst.LOG_NAME_WARN, "analysisV2XCloundDataEvent -----> ");
mCloundWarningInfo = cloundWarningInfo;
+ pointsBetween();
//发送预警提示
V2XMessageEntity v2xMessageEntity = new V2XMessageEntity<>();
@@ -64,23 +71,95 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
isSelfLineClear = false;
- WorkThreadHandler.getInstance().postDelayed(() -> {
- //绘制识别物与交汇点连线,并且更新连线数据
- drawOtherObjectLine(cloundWarningInfo);
+ Log.d(V2XConst.LOG_NAME_WARN, "direction = " + cloundWarningInfo.getDirection());
+ if (cloundWarningInfo.getDirection() == 1) { //前方
+ //添加停止线marker
+ for (int i = 0; i < fillPoints.size(); i++) {
+ V2XWarningEntity entity = new V2XWarningEntity();
+ MogoLatLng latLng = (MogoLatLng) fillPoints.get(i);
+ entity.setLat(latLng.lat);
+ entity.setLat(latLng.lon);
+ entity.setCollisionLat(cloundWarningInfo.getCollisionLat());
+ entity.setCollisionLon(cloundWarningInfo.getCollisionLon());
+ entity.heading = cloundWarningInfo.heading;
+ V2XWarnDataDrawer.getInstance().renderWarnData(entity);
+ }
- //二轮车和行人的渲染和移动
- V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
+ //自车和停止线画线 定位
- }, 0);
+ //停止线前方画线
+ MogoLatLng newLocation = LocationUtils.getNewLocation((MogoLatLng) fillPoints.get(0), 80, cloundWarningInfo.heading);
+ WorkThreadHandler.getInstance().postDelayed(() -> {
+ //绘制识别物与交汇点连线,并且更新连线数据
+ drawStopLine(cloundWarningInfo, newLocation);
+
+ }, 0);
+
+ UiThreadHandler.postDelayed(() -> {
+ V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
+ V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
+ V2XServiceManager.getMoGoStopPolylineManager().clearLine();
+
+ isSelfLineClear = true;
+ }, 8000);
+
+ } else { //左侧或者右侧
+ WorkThreadHandler.getInstance().postDelayed(() -> {
+ //绘制识别物与交汇点连线,并且更新连线数据
+ drawOtherObjectLine(cloundWarningInfo);
+
+ //二轮车和行人的渲染和移动
+ V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
+
+ }, 0);
+
+ //延迟3秒清理线
+ UiThreadHandler.postDelayed(() -> {
+ V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
+ V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
+
+ isSelfLineClear = true;
+ }, 8000);
+ }
- //延迟3秒清理线
- UiThreadHandler.postDelayed(() -> {
- V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
- V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
- isSelfLineClear = true;
- }, 8000);
}
+ /**
+ * 绘制停止线前方线 TODO 需要实时给行人当前位置
+ */
+ private void drawStopLine(V2XWarningEntity info, MogoLatLng mogoLatLng) {
+ IMogoPolyline polyLine = V2XServiceManager.getMoGoStopPolylineManager().getMogoStopPolyline();
+ if (info != null) {
+ if (polyLine != null) {
+ Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine 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, "drawStopLine polyLine == null");
+ DrawLineInfo lineInfo = new DrawLineInfo();
+ MogoLatLng startLatlng = new MogoLatLng(
+ ((MogoLatLng) fillPoints.get(0)).lat,
+ ((MogoLatLng) fillPoints.get(0)).lon);
+ Log.d(V2XConst.LOG_NAME_WARN, "stop drawStopLine lon =" + startLatlng.lon + "--lat =" + startLatlng.lat);
+ MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon);
+ Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine lon =" + mogoLatLng.lon + "--lat =" + mogoLatLng.lat);
+ Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine lon =" + endLatlng.lon + "--lat =" + endLatlng.lat);
+
+ lineInfo.setStartLocation(startLatlng);
+ lineInfo.setEndLocation(endLatlng);
+ lineInfo.setHeading(info.heading);
+ Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine width = " + info.getRoadwidth());
+ lineInfo.setWidth(info.getRoadwidth());
+ V2XServiceManager.getMoGoStopPolylineManager().drawStopPolyline(getContext(), lineInfo);
+ }
+ } else {
+ Log.e(V2XConst.LOG_NAME_WARN, "drawStopLine info == null");
+ V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
+ }
+ }
+
+
/**
* 绘制行人和二轮车连线,并且更新数据 TODO 需要实时给行人当前位置
*/
@@ -100,10 +179,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
lineInfo.setStartLocation(startLatlng);
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, "drawOtherObjectLine width = " + info.getRoadwidth());
lineInfo.setWidth(info.getRoadwidth());
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
@@ -132,17 +207,20 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
if (mCloundWarningInfo != null) {
if (mogoPolyline != null) {
mogoPolyline.setPoints(Arrays.asList(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()),
- new MogoLatLng(mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon())));
+ new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lat : mCloundWarningInfo.getCollisionLat(),
+ mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lon : 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());
+ MogoLatLng endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lat : mCloundWarningInfo.getCollisionLat(),
+ mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lon : mCloundWarningInfo.getCollisionLon());
info.setHeading(latLng.getBearing());
info.setStartLocation(startLatlng);
info.setEndLocation(endLatlng);
info.setWidth(mCloundWarningInfo.getRoadwidth()); //TODO 还需要转换比例尺
+ info.setDirection(mCloundWarningInfo.getDirection());
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(getContext(), info);
}
} else {
@@ -158,4 +236,33 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
}
+ /**
+ * 补点后的停止线经纬度合集
+ */
+ public void pointsBetween() {
+ try {
+ fillPoints.clear();
+ List stopLines = mCloundWarningInfo.getStopLines();
+ if (stopLines.size() > 1) {
+ MogoLatLng x = mCloundWarningInfo.getStopLines().get(0);
+ MogoLatLng y = mCloundWarningInfo.getStopLines().get(1);
+ //两点间的距离
+ float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
+ float average = distance / 3;
+ //两点间的角度
+ double angle = LocationUtils.getAngle(x.lon, x.lat, y.lon, y.lat);
+ //根据距离和角度获取下个点的经纬度
+ fillPoints.add(x);
+ for (int i = 1; i < 3; i++) {
+ MogoLatLng newLocation = LocationUtils.getNewLocation(x, average * i, angle);
+ fillPoints.add(newLocation);
+ }
+ fillPoints.add(y);
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
}
diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoWarnPolylineManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoWarnPolylineManager.java
index 00af025217..51a9fcb00d 100644
--- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoWarnPolylineManager.java
+++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoWarnPolylineManager.java
@@ -42,8 +42,13 @@ public class MoGoWarnPolylineManager implements IMoGoWarnPolylineManager {
MogoPolylineOptions options = new MogoPolylineOptions();
List colors = new ArrayList<>();
- colors.add(0xFFE32F46);
- colors.add(0xFFE32F46);
+ if (info.getDirection() == 1) {
+ colors.add(0xFF3036FF);
+ colors.add(0xFF3036FF);
+ } else {
+ colors.add(0xFFE32F46);
+ colors.add(0xFFE32F46);
+ }
Log.d(V2XConst.LOG_NAME_WARN, "MoGoWarnPolylineManager roadWidth = " + info.getWidth());
// 线条粗细,渐变,渐变色值
diff --git a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json
index 04f046887c..a01111e3c1 100644
--- a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json
+++ b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json
@@ -17,12 +17,12 @@
],
"from": 1,
"angle": 0,
- "direction": 10014,
+ "direction": 1,
"speed": 11.108121,
"targetColor": "#FF4040",
"stopLineDistance": 30,
"warningContent": "小心行人",
- "heading": 30,
+ "heading": 0,
"showTime": 3000,
"roadwidth": 60.0
}
\ No newline at end of file
diff --git a/modules/mogo-module-v2x/src/main/res/values/colors.xml b/modules/mogo-module-v2x/src/main/res/values/colors.xml
index f3c8c733f3..b3a90791e3 100644
--- a/modules/mogo-module-v2x/src/main/res/values/colors.xml
+++ b/modules/mogo-module-v2x/src/main/res/values/colors.xml
@@ -20,6 +20,5 @@
#4C83FF
#FF3036
-
#F63A35
\ No newline at end of file