From 351bda6e8a5a7ab5376a9d0281ff1b66c4bd1eca Mon Sep 17 00:00:00 2001 From: donghongyu Date: Wed, 12 Jan 2022 15:27:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=81=93=E8=B7=AF=E5=90=B8?= =?UTF-8?q?=E9=99=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: donghongyu --- .../mogo/module/common/drawer/BaseDrawer.java | 234 +----------------- .../common/drawer/IdentifyDataDrawer.java | 13 - 2 files changed, 2 insertions(+), 245 deletions(-) diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/BaseDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/BaseDrawer.java index c9ba764b07..b60fdd712c 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/BaseDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/BaseDrawer.java @@ -1,35 +1,27 @@ package com.mogo.module.common.drawer; import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS; -import static java.lang.Math.PI; import android.content.Context; import android.graphics.Color; import android.graphics.Typeface; -import android.os.Handler; -import android.os.Message; import android.text.TextUtils; -import android.util.Log; import android.view.ViewGroup; import android.widget.TextView; import com.mogo.commons.AbsMogoApplication; -import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler; import com.mogo.map.marker.IMogoMarker; import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.R; import com.mogo.module.common.constants.AdasRecognizedType; import com.mogo.module.common.datacenter.SnapshotLocationDataCenter; -import com.mogo.module.common.drawer.bean.SpeedData; import java.util.Collection; import java.util.Iterator; import java.util.Map; -import java.util.Random; -import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -/* +/** * @author congtaowang * @since 2020/10/30 *

@@ -42,21 +34,6 @@ public class BaseDrawer { */ public static final int MSG_REMOVE_DIRTY_MARKERS = 9990; - /** - * 地图刷新频率 - */ - public static final int MAP_RENDER_FRAME_FREQUENCY = 30; - - /** - * 显示速度 - */ - public static final int MSG_DISPLAY_SPEED = 11; - - /** - * 移动点的时间间隔 - */ - public static final int MAP_MARKER_MOVE_INTERVAL = MAP_RENDER_FRAME_FREQUENCY; - /** * 地图内部资源md5缓存,便于资源复用 */ @@ -64,77 +41,8 @@ public class BaseDrawer { protected final Context mContext; - private static TextView mSpeedView; - public BaseDrawer() { mContext = AbsMogoApplication.getApp(); - initWorkThreadHandler(); - initView(); - } - - private void initView() { - if (mSpeedView == null) { - mSpeedView = new TextView(mContext); - mSpeedView.setSingleLine(false); - mSpeedView.setTextColor(Color.WHITE); - mSpeedView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD)); - mSpeedView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT)); - } - } - - private static Handler mWorkThreadHandler; - protected static Handler mRenderThreadHandler = null; - - /** - * 处理 marker 移除的线程 - */ - private static void initWorkThreadHandler() { - if (mWorkThreadHandler == null) { - mWorkThreadHandler = new Handler(WorkThreadHandler.newInstance("3d-marker-work-thread").getLooper()) { - @Override - public void handleMessage(Message msg) { - super.handleMessage(msg); - if (msg.what == MSG_REMOVE_DIRTY_MARKERS) { - if (msg.obj instanceof Map) { - removeDirtyMarkers(((Map) msg.obj)); - Set key = ((Map) msg.obj).keySet(); - for (String id : key) { - // 清除道路缓存 - clearRoadCacheById(id); - } - } else if (msg.obj instanceof String) { - MogoApisHandler.getInstance().getApis() - .getMapServiceApi() - .getMarkerManager(AbsMogoApplication.getApp()) - .removeMarkers(((String) msg.obj)); - } - } - } - }; - } - - if (mRenderThreadHandler == null) { - mRenderThreadHandler = new Handler(WorkThreadHandler.newInstance("render-thread-" + new Random().nextLong()).getLooper()) { - @Override - public void handleMessage(Message msg) { - super.handleMessage(msg); - if (msg.what == MSG_DISPLAY_SPEED) { - if (msg.obj instanceof SpeedData) { - showSpeed((SpeedData) msg.obj); - } - } - } - }; - } - } - - public static void showSpeed(SpeedData speedData) { - showIdentitySpeed(speedData.getMarker() - , speedData.getSpeed() - , speedData.getUuid() - , speedData.getType() - , speedData.getHeading() - , speedData.getIsVrMode()); } /** @@ -162,10 +70,7 @@ public class BaseDrawer { * @param data 数据体 */ public void sendMessage(int msg, Object data) { - Message message = Message.obtain(); - message.what = msg; - message.obj = data; - mWorkThreadHandler.sendMessage(message); + } /** @@ -185,20 +90,6 @@ public class BaseDrawer { && recognizedType != AdasRecognizedType.classIdUnKnow; } - /** - * 是否展示车速,UUID以及类型 - * - * @param type {@link AdasRecognizedType} - * @return showSpeed - */ - public boolean shouldShowSpeed(int type) { - return true; //todo 验证行人预警,对行人和自行车不做infoWindow过滤 - // AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type); - // return recognizedType != AdasRecognizedType.classIdPerson; - // &&recognizedType != AdasRecognizedType.classIdBicycle //todo Bicycle显示 - // && recognizedType != AdasRecognizedType.classIdMoto //todo moto显示 - } - /** * 获取3D锚点模型资源 * @@ -258,19 +149,6 @@ public class BaseDrawer { return Car3DModelColor.Normal.color; } - /** - * 返回当前自车速度 - * - * @return isCurSpeed - */ - protected double getCurSpeed() { - double speed = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastSpeed(); - if (speed <= 0) { - speed = SnapshotLocationDataCenter.getInstance().getCurSpeed(); - } - return speed; - } - /** * 返回当前自车经纬度 * @@ -305,45 +183,15 @@ public class BaseDrawer { * 模型颜色 */ public enum Car3DModelColor { - Normal("#D8D8D8FF"), Warming("#FFD53EFF"), Dangerous("#FF3C45FF"), Error("#7fb80e"); - private final String color; Car3DModelColor(String color) { this.color = color; } - - } - - /** - * 展示车辆速度 - * - * @param mogoMarker {@link IMogoMarker} - * @param speed 是否显示速度 - * @param isVrMode 是否是vrMode - */ - public static void showIdentitySpeed(IMogoMarker mogoMarker, double speed, String uuid, - int type, double heading, boolean isVrMode) { - Log.d("EmArrow", "showSelf uuid : " + uuid + " speed : " + speed); - if (mogoMarker == null || mogoMarker.isDestroyed()) { - return; - } - if (!isVrMode) { - mogoMarker.hideInfoWindow(); - return; - } - int speedIntVal = (int) (speed * 3.6); - mogoMarker.setInfoWindowOffset(0, 20); - String text = "uuid : " + uuid + "\n" - + "speed : " + speedIntVal + "\n" - + "type : " + type + "\n" - + "heading : " + heading; - mSpeedView.setText(text); - mogoMarker.updateInfoWindowView(mSpeedView); } /** @@ -386,35 +234,6 @@ public class BaseDrawer { mMarkerCachesResMd5Values.put(id, md5); } - /** - * 道路匹配到车道中心点 - * - * @param lon 经度 - * @param lat 纬度 - * @param angle 方向角 - * @param isRtk 是否是RTK - * @return 匹配经纬度值 - */ - public double[] matchRoad(String id, double lon, double lat, double angle, boolean isRtk) { - final long start = System.currentTimeMillis(); - double[] matchRoad = MogoApisHandler.getInstance() - .getApis() - .getMapServiceApi() - .getMapUIController() - .matchRoad(id, lon, lat, angle, true, isRtk); - Log.i("timer-matchRoad", "cost " + (System.currentTimeMillis() - start) + "ms"); - return matchRoad; - } - - /** - * 清理缓存路段数据 - * - * @param id 缓存数据Key - */ - public static void clearRoadCacheById(String id) { - MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().clearRoadCacheById(id); - } - /** * 使用系统时间或卫星时间计算出动画的运动时间,最小值45,防止两个点距离过近设置的最小动画执行时间 * @@ -435,53 +254,4 @@ public class BaseDrawer { return interval; } - /** - * 根据位置信息、车头朝向计算道路吸附 - * - * @param id UUID - * @param lon 经度 - * @param lat 纬度 - * @param heading 方向角 - * @param lastLon 上一个点经度 - * @param lastLat 上一个点纬度 - * @return 匹配经纬度 - */ - protected double[] getMatchLonLat(String id, double lon, double lat, double heading, double lastLon, double lastLat) { - double[] matchedPoint = matchRoad(id, lon, - lat, - heading, - true - ); - - boolean match; - if (matchedPoint != null) { - // Logger.d( TAG, "matchPoint %s distance = %s",lineCounter, matchedPoint[2] ); - match = matchedPoint[2] < 1 && matchedPoint[2] > 0; - - if (lastLon != -1) { - double clearAngle; - if (heading > 0 && heading <= 90) { - clearAngle = heading; - } else if (heading > 90 && heading <= 180) { - clearAngle = 180 - heading; - } else if (heading > 180 && heading <= 270) { - clearAngle = heading - 180; - } else { - clearAngle = 360 - heading; - } - double _angle = Math.atan2(Math.abs(matchedPoint[0] - lastLon), Math.abs(matchedPoint[1] - lastLat)) * (180 / PI); - _angle = Math.abs(clearAngle - _angle); - // Logger.d(TAG, "matchPoint %s angel = %s", lineCounter, _angle); - if (_angle > 22.5) { - match = false; - } - } - if (match) { - lon = matchedPoint[0]; - lat = matchedPoint[1]; - } - } - - return new double[]{lon, lat}; - } } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/IdentifyDataDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/IdentifyDataDrawer.java index 42a45e51c1..06fd0d1077 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/IdentifyDataDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/IdentifyDataDrawer.java @@ -118,7 +118,6 @@ public class IdentifyDataDrawer extends BaseDrawer { renderAdasOneFrame(marker, uniqueKey, recognizedListResult, newAdasRecognizedMarkersCaches); } } - sendMessage(MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches); mMarkersCaches.clear(); mMarkersCaches = newAdasRecognizedMarkersCaches; // Log.d(TAG, "ADAS数据延时绘制 render 接收数据 -> 处理结束 " + TimeUnit.NANOSECONDS.toMillis((System.nanoTime() - start)) + "ms"); @@ -213,17 +212,6 @@ public class IdentifyDataDrawer extends BaseDrawer { marker.setAnchorColor(carColor); newAdasRecognizedMarkersCaches.put(uniqueKey, marker); - - // 显示目标车的信息,但是数据多的时候会导致崩溃,不建议打开 -// if (shouldShowSpeed(recognizedListResult.getType().getType())) { -// SpeedData speedData = new SpeedData(marker -// , recognizedListResult.getSpeed() -// , recognizedListResult.getUuid() -// , recognizedListResult.getType().getType() -// , recognizedListResult.getHeading() -// , MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()); -// showSpeed(speedData); -// } } /** @@ -265,6 +253,5 @@ public class IdentifyDataDrawer extends BaseDrawer { mMarkersCaches.clear(); } mLastPositions.clear(); - sendMessage(MSG_REMOVE_DIRTY_MARKERS, DataTypes.TYPE_MARKER_ADAS); } }