diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 4ff10f68a5..83405b8de1 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -91,7 +91,6 @@ diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java index f365363897..f2492e97ba 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java @@ -1,6 +1,7 @@ package com.mogo.module.v2x.scenario.scene.warning; import android.content.Context; + import com.mogo.map.MogoLatLng; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.MogoMarkerOptions; @@ -16,6 +17,10 @@ import com.mogo.module.v2x.entity.model.DrawLineInfo; import com.mogo.module.v2x.scenario.view.IV2XMarker; import com.mogo.utils.WorkThreadHandler; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Handler; + /** * @author liujing * @description 描述 @@ -40,23 +45,14 @@ public class V2XWarningMarker implements IV2XMarker { if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { clearPOI(); WorkThreadHandler.getInstance().postDelayed(() -> { - MogoMarkerOptions options = new MogoMarkerOptions() - .object(markerShowEntity) - .latitude(markerShowEntity.getMarkerLocation().getLat()) - .longitude(markerShowEntity.getMarkerLocation().getLon()); - IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options); - options.icon3DRes(com.mogo.module.service.R.raw.people); - options.anchorColor("#FF4040"); - IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options); - iMarkerView.setMarker(marker); - marker.setToTop(); + IMogoMarker marker = drawMarker(markerShowEntity); + //如果有预警碰撞点,识别物与预警碰撞点之间连线,并执行平移动画 + if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() != 0) { + drawLine(); + smooth(marker); + } }, 0); - //如果有预警碰撞点,识别物与预警碰撞点之间连线,并执行平移动画 - if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() != 0) { - drawLine(); - smooth(); - } } else { } @@ -66,6 +62,20 @@ public class V2XWarningMarker implements IV2XMarker { } + public IMogoMarker drawMarker(MarkerShowEntity markerShowEntity) { + MogoMarkerOptions options = new MogoMarkerOptions() + .object(markerShowEntity) + .latitude(markerShowEntity.getMarkerLocation().getLat()) + .longitude(markerShowEntity.getMarkerLocation().getLon()); + IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options); + options.icon3DRes(com.mogo.module.service.R.raw.people); + options.anchorColor("#FF4040"); + IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options); + iMarkerView.setMarker(marker); + marker.setToTop(); + return marker; + } + public void drawLine() { DrawLineInfo drawLineInfo = new DrawLineInfo(); MogoLatLng slatLng = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon()); @@ -75,12 +85,25 @@ public class V2XWarningMarker implements IV2XMarker { V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, drawLineInfo); } - public void smooth() { + public void smooth(IMogoMarker marker) { + List latLngs = new ArrayList<>(); + MogoLatLng sLocation = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon()); + MogoLatLng endLocation = new MogoLatLng(mMarkerEntity.getCollisionLat(), mMarkerEntity.getCollisionLon()); + latLngs.add(sLocation); + latLngs.add(endLocation); + marker.startSmoothInMs(latLngs, 3000); + WorkThreadHandler.getInstance().postDelayed(() -> { + clearLine(); + }, 3_000); } @Override public void clearPOI() { V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_WARNING_MARKER); } + + public void clearLine() { + V2XServiceManager.getMoGoWarnPolylineManager().clearLine(); + } } 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 d514923ffe..d04415ae80 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 @@ -3,16 +3,16 @@ "lat":39.977148, "lon":116.417478, "distance": 2.22, - "collisionLat": 39.977131, - "collisionLon": 116.417741, + "collisionLat": 39.977094, + "collisionLon": 116.417634, "from": 1, "angle": 120, "direction": 10014, "speed":11.108121, "targetColor": "#FF4040", "stopLineDistance":20, - "stopLineLat": 39.977123, - "stopLineLon": 116.417537, + "stopLineLat": 39.977094, + "stopLineLon": 116.417634, "warningContent": "小心行人", "heading": 30 } \ No newline at end of file