From 3c4454aec2ebe8286c377ec341eac8d4778f942e Mon Sep 17 00:00:00 2001 From: liujing Date: Tue, 30 Mar 2021 20:02:00 +0800 Subject: [PATCH] =?UTF-8?q?[add]=20=E9=A2=84=E8=AD=A6marker=E6=89=93?= =?UTF-8?q?=E7=82=B9,=E7=B1=BB=E5=9E=8B:=E8=A1=8C=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/entity/V2XWarningEntity.java | 58 +++++++++++++--- .../java/com/mogo/module/v2x/V2XConst.java | 5 ++ .../warning/V2XFrontWarningScenario.java | 7 +- .../scene/warning/V2XWarningMarker.java | 69 +++++++++++++++++++ .../module/v2x/utils/TestOnLineCarUtils.java | 4 +- .../res/raw/scenario_warning_event_data.json | 4 +- 6 files changed, 132 insertions(+), 15 deletions(-) create mode 100644 modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java index 3dc98fe662..0231d8fa6b 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/V2XWarningEntity.java @@ -19,20 +19,37 @@ public class V2XWarningEntity implements Serializable { //预测碰撞点位置 private double collisionLat; private double collisionLon; - //来源 ADAS/云端 - private int from; //朝向 角度 private double angle; //方位 前 后 左 右 private int direction; //速度 private float speed; + //停止线经纬度 + private double stopLineLat; + private double stopLineLon; - //以下为自组字段 //预警文案 private String tipContent; //tts播报 private String tts; + //打点位置 + private MarkerLocation location; + + public void setLocation(MarkerLocation location) { + this.location = location; + } + + public MarkerLocation getLocation() { + if (location == null) { + MarkerLocation location = new MarkerLocation(); + location.setLat(getLat()); + location.setLon(getLon()); + setLocation(location); + } + return location; + } + public void setTipContent(int type) { switch (type) { @@ -96,10 +113,6 @@ public class V2XWarningEntity implements Serializable { this.collisionLon = collisionLon; } - public void setFrom(int from) { - this.from = from; - } - public void setAngle(double angle) { this.angle = angle; } @@ -137,9 +150,6 @@ public class V2XWarningEntity implements Serializable { return distance; } - public int getFrom() { - return from; - } public double getAngle() { return angle; @@ -167,6 +177,30 @@ public class V2XWarningEntity implements Serializable { return tts; } + public void setStopLineLat(double stopLineLat) { + this.stopLineLat = stopLineLat; + } + + public void setStopLineLon(double stopLineLon) { + this.stopLineLon = stopLineLon; + } + + public void setTipContent(String tipContent) { + this.tipContent = tipContent; + } + + public void setTts(String tts) { + this.tts = tts; + } + + public double getStopLineLat() { + return stopLineLat; + } + + public double getStopLineLon() { + return stopLineLon; + } + @Override public String toString() { return "V2XWarningEntity{" + @@ -176,12 +210,14 @@ public class V2XWarningEntity implements Serializable { ", distance=" + distance + ", collisionLat=" + collisionLat + ", collisionLon=" + collisionLon + - ", from=" + from + ", angle=" + angle + ", direction=" + direction + ", speed=" + speed + + ", stopLineLat=" + stopLineLat + + ", stopLineLon=" + stopLineLon + ", tipContent='" + tipContent + '\'' + ", tts='" + tts + '\'' + + ", location=" + location + '}'; } } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XConst.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XConst.java index 49c2f35391..a610ab58d9 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XConst.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XConst.java @@ -140,4 +140,9 @@ public class V2XConst { */ public static final String V2X_OPTIMAL_SPEED_MARKER = "V2X_OPTIMAL_SPEED_MARKER"; + /* + *V2X 车路云前方预警 + * */ + public static final String V2X_FRONT_WARNING_MARKER = "V2X_FRONT_WARNING_MARKER"; + } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java index cbbbee5473..4b58b04e90 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XFrontWarningScenario.java @@ -9,6 +9,7 @@ import android.view.ViewGroup; import androidx.annotation.Nullable; import com.alibaba.android.arouter.facade.annotation.Route; +import com.mogo.map.marker.IMogoMarker; import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.entity.V2XMessageEntity; import com.mogo.module.common.entity.V2XPoiTypeEnum; @@ -44,6 +45,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV public V2XFrontWarningScenario() { setV2XWindow(new V2XWarningWindow()); + setV2XMarker(new V2XWarningMarker()); } @Override @@ -54,6 +56,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV direction = mMarkerEntity.getDirection(); MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(direction, MogoReceiver.ACTION_V2X_FRONT_WARNING); show(); + drawPOI(); } } catch (Exception e) { e.printStackTrace(); @@ -78,6 +81,7 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV .getMogoTopViewManager() .addView(getV2XWindow().getView(), layoutParams, this); getV2XWindow().show(mMarkerEntity); + getV2XMarker().drawPOI(mMarkerEntity); } } @@ -98,7 +102,8 @@ public class V2XFrontWarningScenario extends AbsV2XScenario implements IMogoTopV @Override public void drawPOI() { - + getV2XMarker().drawPOI(mMarkerEntity); + Log.d(TAG, "drawPOI"); } @Override 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 new file mode 100644 index 0000000000..437bf951d2 --- /dev/null +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java @@ -0,0 +1,69 @@ +package com.mogo.module.v2x.scenario.scene.warning; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; +import com.mogo.commons.AbsMogoApplication; +import com.mogo.map.marker.IMogoMarker; +import com.mogo.map.marker.MogoMarkerOptions; +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.module.v2x.R; +import com.mogo.module.v2x.V2XConst; +import com.mogo.module.v2x.V2XServiceManager; +import com.mogo.module.v2x.scenario.view.IV2XMarker; +import com.mogo.utils.WorkThreadHandler; + +/** + * @author liujing + * @description 描述 + * @since: 2021/3/30 + */ +public class V2XWarningMarker implements IV2XMarker { + private V2XWarningEntity mMarkerEntity; + private Context mContext = V2XServiceManager.getContext(); + + @Override + public void drawPOI(Object entity) { + try { + mMarkerEntity = (V2XWarningEntity) entity; + MarkerLocation location = new MarkerLocation(); + location.setLat(mMarkerEntity.getLat()); + location.setLon(mMarkerEntity.getLon()); + + MarkerShowEntity markerShowEntity = new MarkerShowEntity(); + markerShowEntity.setMarkerLocation(location); + markerShowEntity.setMarkerType(V2XConst.V2X_FRONT_WARNING_MARKER); + +// if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { + V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_WARNING_MARKER); + WorkThreadHandler.getInstance().postDelayed(() -> { + MogoMarkerOptions options = new MogoMarkerOptions() + .object(markerShowEntity) + .latitude(markerShowEntity.getMarkerLocation().getLat()) + .longitude(markerShowEntity.getMarkerLocation().getLon()); +// V2XServiceManager.getMoGoV2XMarkerManager().drawableMarker(mContext, markerShowEntity, null); + IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options); + Bitmap bitmap = BitmapFactory.decodeResource(AbsMogoApplication.getApp().getResources(), R.drawable.v2x_road_front_p_warning); + options.icon(bitmap); + IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options); + iMarkerView.setMarker(marker); + marker.setToTop(); + }, 1000); +// } else { +// +// } + } catch (Exception e) { + + } + + } + + @Override + public void clearPOI() { + + } +} diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java index a7b29cdd1f..33eafe8543 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java @@ -1,12 +1,15 @@ package com.mogo.module.v2x.utils; import com.mogo.module.common.entity.MarkerExploreWay; +import com.mogo.module.common.entity.MarkerLocation; import com.mogo.module.common.entity.MarkerResponse; +import com.mogo.module.common.entity.MarkerShowEntity; import com.mogo.module.common.entity.V2XMessageEntity; import com.mogo.module.common.entity.V2XPushMessageEntity; import com.mogo.module.common.entity.V2XRoadEventEntity; import com.mogo.module.common.entity.V2XWarningEntity; import com.mogo.module.v2x.R; +import com.mogo.module.v2x.V2XConst; import com.mogo.module.v2x.entity.net.V2XSpecialCarRes; import com.mogo.utils.network.utils.GsonUtil; @@ -172,7 +175,6 @@ public class TestOnLineCarUtils { // 加载数据源 V2XWarningEntity warningEntity = GsonUtil.objectFromJson(baos.toString(), V2XWarningEntity.class); - V2XMessageEntity v2xMessageEntity = new V2XMessageEntity<>(); // 控制类型 v2xMessageEntity.setType(V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP); 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 aa48b7241f..5e70ce79e8 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 @@ -1,8 +1,8 @@ { "type":0, "targetType": "1", - "lat":39.9760799115428, - "lon":116.411360351446, + "lat":39.977121, + "lon":116.417537, "distance": 2.22, "collisionLat": 39.9760799115429, "collisionLon": 116.411360351446,