diff --git a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XWarningMarker.java b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XWarningMarker.java index a4d8606382..6c75c97edd 100644 --- a/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XWarningMarker.java +++ b/core/function-impl/mogo-core-function-v2x/src/main/java/com/mogo/eagle/core/function/v2x/events/scenario/scene/warning/V2XWarningMarker.java @@ -24,8 +24,9 @@ import com.mogo.map.marker.IMogoMarkerManager; 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.V2XWarningEntity; import com.mogo.module.common.utils.Trigonometric; +import com.mogo.v2x.data.V2XLocation; +import com.mogo.v2x.data.V2XWarningTarget; import java.util.ArrayList; import java.util.Arrays; @@ -39,7 +40,7 @@ import java.util.List; public class V2XWarningMarker implements IV2XMarker { private static final String TAG = "V2XWarningMarker"; private static final String WARNING_ARROWS = "WARNING_ARROWS"; - private V2XWarningEntity mCloundWarningInfo; + private V2XWarningTarget mCloundWarningInfo; private boolean isSelfLineClear = true;//绘制线是否已被清除 private final List fillPoints = new ArrayList();//停止线经纬度合集 private boolean isFirstLocation = false; @@ -60,7 +61,7 @@ public class V2XWarningMarker implements IV2XMarker { public void drawPOI(Object entity) { try { CallerLogger.INSTANCE.d(M_V2X + TAG, "===drawPOI"); - mCloundWarningInfo = (V2XWarningEntity) entity; + mCloundWarningInfo = (V2XWarningTarget) entity; drawLineWithEntity(); } catch (Exception e) { @@ -109,7 +110,7 @@ public class V2XWarningMarker implements IV2XMarker { warningLocation); */ - V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo); + V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo.getLon(), mCloundWarningInfo.getLat(), mCloundWarningInfo.getType(), mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon(), mCloundWarningInfo.getAngle(), mCloundWarningInfo.getShowTime()); //添加停止线marker //衡阳交付-取消划线需求,只渲染识别物红色模型移动过程 @@ -133,7 +134,7 @@ public class V2XWarningMarker implements IV2XMarker { CallerLogger.INSTANCE.d(M_V2X + TAG, "数据为空carLocation == null"); } */ - V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo); + V2XWarnDataDrawer.getInstance().renderWarnData(mCloundWarningInfo.getLon(), mCloundWarningInfo.getLat(), mCloundWarningInfo.getType(), mCloundWarningInfo.getCollisionLat(), mCloundWarningInfo.getCollisionLon(), mCloundWarningInfo.getAngle(), mCloundWarningInfo.getShowTime()); }, 0); @@ -157,7 +158,7 @@ public class V2XWarningMarker implements IV2XMarker { * startLatLng: 划线起点=停止线上的坐标点 * mogoLatLng: 停止线前方50m坐标点 * */ - private void drawRedWarningLineFrontOfStopLine(V2XWarningEntity info, MogoLatLng + private void drawRedWarningLineFrontOfStopLine(V2XWarningTarget info, MogoLatLng startLatLng, MogoLatLng mogoLatLng) { if (info != null) { double angle = Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, mogoLatLng.lon, mogoLatLng.lat); @@ -166,7 +167,7 @@ public class V2XWarningMarker implements IV2XMarker { if (stopPolyLineMnager != null) { IMogoPolyline polyLine = stopPolyLineMnager.getMogoStopPolyline(); MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon); - MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng, 25, angle); + MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatLng.lon, startLatLng.lat, 25, angle); if (polyLine != null) { CallerLogger.INSTANCE.d(M_V2X + TAG, "drawStopLine polyLine != null"); polyLine.setPoints(Arrays.asList(startLatLng, addMiddleLoc, endLatlng)); @@ -178,8 +179,8 @@ public class V2XWarningMarker implements IV2XMarker { locations.add(addMiddleLoc); locations.add(endLatlng); lineInfo.setLocations(locations); - lineInfo.setHeading(info.heading); - CallerLogger.INSTANCE.d(M_V2X + TAG, "drawStopLine width = " + info.getRoadwidth()); + lineInfo.setHeading(info.getHeading()); + CallerLogger.INSTANCE.d(TAG, "drawStopLine width = " + info.getRoadwidth()); lineInfo.setWidth(info.getRoadwidth() * 14 + 5); stopPolyLineMnager.drawStopPolyline(BridgeApi.INSTANCE.context(), lineInfo); } @@ -231,17 +232,17 @@ public class V2XWarningMarker implements IV2XMarker { fillPoints.clear(); List stopLines = mCloundWarningInfo.getStopLines(); if (stopLines != null && stopLines.size() > 1) { - MogoLatLng x = mCloundWarningInfo.getStopLines().get(0); - MogoLatLng y = mCloundWarningInfo.getStopLines().get(1); + V2XLocation x = mCloundWarningInfo.getStopLines().get(0); + V2XLocation y = mCloundWarningInfo.getStopLines().get(1); //两点间的距离 - float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat); + float distance = CoordinateUtils.calculateLineDistance(x.getLon(), x.getLat(), y.getLon(), y.getLat()); float average = distance / 3; //两点间的角度 - double angle = Trigonometric.getAngle(x.lon, x.lat, y.lon, y.lat); + double angle = Trigonometric.getAngle(x.getLon(), x.getLat(), y.getLon(), y.getLat()); //根据距离和角度获取下个点的经纬度 fillPoints.add(x); for (int i = 1; i < 3; i++) { - MogoLatLng newLocation = Trigonometric.getNewLocation(x, average * i, angle); + MogoLatLng newLocation = Trigonometric.getNewLocation(x.getLon(), x.getLat(), average * i, angle); fillPoints.add(newLocation); } fillPoints.add(y); @@ -265,12 +266,12 @@ public class V2XWarningMarker implements IV2XMarker { marker.removeMarkers(TYPE_MARKER_CLOUD_STOP_LINE_DATA); } for (int i = 0; i < fillPoints.size(); i++) { - V2XWarningEntity entity = new V2XWarningEntity(); + V2XWarningTarget entity = new V2XWarningTarget(); MogoLatLng latLng = (MogoLatLng) fillPoints.get(i); entity.setLat(latLng.lat); entity.setLon(latLng.lon); - entity.heading = mCloundWarningInfo.heading; - V2XWarnDataDrawer.getInstance().renderStopLineData(entity); + entity.setHeading(mCloundWarningInfo.getHeading()); + V2XWarnDataDrawer.getInstance().renderStopLineData(entity.getLon(), entity.getLat()); } } } catch (Exception e) { @@ -279,7 +280,7 @@ public class V2XWarningMarker implements IV2XMarker { } private MogoLatLng getMogoLat(MogoLatLng latlng) { - MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), + MogoLatLng newLocation = Trigonometric.getNewLocation(latlng.lon, latlng.lat, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle()); return newLocation; } @@ -293,11 +294,11 @@ public class V2XWarningMarker implements IV2XMarker { } MogoLatLng newLocation = new MogoLatLng(0, 0); if (mCloundWarningInfo != null && mCloundWarningInfo.getStopLines() != null && mCloundWarningInfo.getStopLines().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); - double angle = Trigonometric.getAngle(x.lon, x.lat, y.lon, y.lat); - newLocation = Trigonometric.getNewLocation(x, distance * 0.5, angle); + V2XLocation x = mCloundWarningInfo.getStopLines().get(0); + V2XLocation y = mCloundWarningInfo.getStopLines().get(1); + float distance = CoordinateUtils.calculateLineDistance(x.getLon(), x.getLat(), y.getLat(), y.getLat()); + double angle = Trigonometric.getAngle(x.getLat(), x.getLat(), y.getLon(), y.getLat()); + newLocation = Trigonometric.getNewLocation(x.getLon(), x.getLat(), distance * 0.5, angle); } else { CallerLogger.INSTANCE.d(M_V2X + TAG, "停止线返回坐标点数量不正确" + mCloundWarningInfo.getStopLines().size()); } @@ -335,7 +336,7 @@ public class V2XWarningMarker implements IV2XMarker { startLatlng = new MogoLatLng(lat, lon); float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat); //扩展点为了渐变色添加 - addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, + addMiddleLoc = Trigonometric.getNewLocation(startLatlng.getLon(), startLatlng.getLat(), distance / 2, Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat)); CallerLogger.INSTANCE.d(M_V2X + TAG, "angle==扩展点为了渐变色添加:" + String.valueOf(Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat))); @@ -368,7 +369,7 @@ public class V2XWarningMarker implements IV2XMarker { /** * 侧方目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置 */ - private void drawOtherObjectLine(V2XWarningEntity info) { + private void drawOtherObjectLine(V2XWarningTarget info) { if (info != null) { CallerLogger.INSTANCE.d(M_V2X + TAG, "info != null"); IMoGoPersonWarnPolylineManager personWarnPolylineManager = BridgeApi.INSTANCE.v2xPersonWarnPolyline(); @@ -379,7 +380,7 @@ public class V2XWarningMarker implements IV2XMarker { MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());//识别物坐标 MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());//预碰撞点坐标 float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);//识别物到碰撞点之间的距离 - MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, + MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng.getLon(), startLatlng.getLat(), distance / 2, Trigonometric.getAngle(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat));//补点 if (polyLine != null) { CallerLogger.INSTANCE.d(M_V2X + TAG, "目标物与碰撞点连线 != null"); @@ -394,7 +395,7 @@ public class V2XWarningMarker implements IV2XMarker { locations.add(addMiddleLoc); locations.add(endLatlng); lineInfo.setLocations(locations); - lineInfo.setHeading(info.heading); + lineInfo.setHeading(info.getHeading()); lineInfo.setWidth(info.getRoadwidth() * 14 + 5); personWarnPolylineManager.drawPersonWarnPolyline(BridgeApi.INSTANCE.context(), lineInfo); CallerLogger.INSTANCE.d(M_V2X + TAG, "目标物与预碰撞点画线点为" + "起点:" + startLatlng + "中间点:" + addMiddleLoc + "终点:" + endLatlng); @@ -415,7 +416,7 @@ public class V2XWarningMarker implements IV2XMarker { int count = (int) (distance / 5); for (int i = 0; i < count; i++) { MogoLatLng newLo = Trigonometric.getNewLocation( - startLatLng, 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat)); + startLatLng.getLon(), startLatLng.getLat(), 5 * (i + 1), Trigonometric.getAngle(startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat)); V2XWarnDataDrawer.getInstance().drawerArrowsMarkerWithLocation(newLo, WARNING_ARROWS, 10, new Double(rotate).intValue()); CallerLogger.INSTANCE.d(M_V2X + TAG, "小箭头位置" + newLo); } @@ -428,7 +429,10 @@ public class V2XWarningMarker implements IV2XMarker { carLocation = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()); if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() && isSelfLineClear == false) { if (mCloundWarningInfo != null) { - mCloundWarningInfo.setCarLocation(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude())); + V2XLocation v2XLocation = new V2XLocation(); + v2XLocation.setLat(latLng.getLatitude()); + v2XLocation.setLon(latLng.getLongitude()); + mCloundWarningInfo.setCarLocation(v2XLocation); } //衡阳交付-取消划线需求,只渲染识别物红色模型移动过程 //drawSelfCarLine(latLng.getLongitude(), latLng.getLatitude(), latLng.getBearing()); diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java index c30c8cf2ea..4dcb9fcc65 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/V2XWarnDataDrawer.java @@ -15,7 +15,6 @@ import com.mogo.module.common.drawer.marker.IMarkerView; import com.mogo.module.common.drawer.marker.MapMarkerAdapter; import com.mogo.module.common.entity.MarkerLocation; import com.mogo.module.common.entity.MarkerShowEntity; -import com.mogo.module.common.entity.V2XWarningEntity; import com.mogo.service.statusmanager.IMogoStatusChangedListener; import com.mogo.service.statusmanager.StatusDescriptor; @@ -65,21 +64,20 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL /** * 识别物移动 * - * @param data */ - public void renderWarnData(V2XWarningEntity data) { + public void renderWarnData(double lon, double lat, int type, double collisionlat, double collisionLon, double angle, long showTime) { MarkerLocation location = new MarkerLocation(); - location.setLat(data.getLat()); - location.setLon(data.getLon()); - + location.setLat(lat); + location.setLon(lon); + location.setAngle(angle); MarkerShowEntity markerShowEntity = new MarkerShowEntity(); markerShowEntity.setMarkerLocation(location); markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA); - IMogoMarker marker = drawMarker(markerShowEntity, modeResType(data.getType())); - marker.addDynamicAnchorPosition(new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), (float) data.getHeading(), (long) (data.getShowTime() * 1000)); + IMogoMarker marker = drawMarker(markerShowEntity, modeResType(type)); +// marker.addDynamicAnchorPosition(new MogoLatLng(collisionlat, collisionLon), (float) heading, showTime * 1000); UiThreadHandler.postDelayed(() -> { marker.remove(); - }, data.getShowTime() * 1000); + }, showTime * 1000); } @@ -103,6 +101,8 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL .data(markerShowEntity) .latitude(markerShowEntity.getMarkerLocation().getLat()) .longitude(markerShowEntity.getMarkerLocation().getLon()) + .controlAngle(true) + .rotate((float) markerShowEntity.getMarkerLocation().getAngle()) .setGps(true); IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options); options.icon3DRes(getModelRes(modeResType)); //TODO @@ -132,12 +132,11 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL /** * 绘制停止线 marker * - * @param data */ - public void renderStopLineData(V2XWarningEntity data) { + public void renderStopLineData(double lon, double lat) { MarkerLocation location = new MarkerLocation(); - location.setLat(data.getLat()); - location.setLon(data.getLon()); + location.setLat(lat); + location.setLon(lon); MarkerShowEntity markerShowEntity = new MarkerShowEntity(); markerShowEntity.setMarkerLocation(location); diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/utils/Trigonometric.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/utils/Trigonometric.java index beb1ef3083..c7d6be65d5 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/utils/Trigonometric.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/utils/Trigonometric.java @@ -37,10 +37,10 @@ public class Trigonometric { /** * 根据角度获取指定距离点的经纬度 */ - public static MogoLatLng getNewLocation(MogoLatLng st, double distance, double angle) { - mRadLo = st.getLon() * Math.PI / 180.; - mRadLa = st.getLat() * Math.PI / 180.; - Ec = radius_s + (radius_b - radius_s) * (90. - st.lat) / 90; + public static MogoLatLng getNewLocation(double lon, double lat, double distance, double angle) { + mRadLo = lon * Math.PI / 180.; + mRadLa = lat * Math.PI / 180.; + Ec = radius_s + (radius_b - radius_s) * (90. - lat) / 90; Ed = Ec * Math.cos(mRadLa); double dx = distance * Math.sin(Math.toRadians(angle));