[646]feat: 增加全局轨迹调用的埋点,修复第一次调用时实际不绘制的问题,增加相关日志打印;
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
package com.mogo.eagle.core.function.business.trajectoryoverlay;
|
||||
|
||||
import android.util.Log;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.commons.utils.MogoAnalyticUtils;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener;
|
||||
@@ -11,19 +13,21 @@ import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02Lis
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
public class MogoTrajectoryOverlayManager implements
|
||||
IMoGoPlanningRottingListener,
|
||||
IMoGoChassisLocationGCJ02Listener {
|
||||
public class MogoTrajectoryOverlayManager implements IMoGoPlanningRottingListener, IMoGoChassisLocationGCJ02Listener {
|
||||
private static volatile MogoTrajectoryOverlayManager sInstance;
|
||||
private static final String TAG = "MogoTrajectoryOverlayManager";
|
||||
private static final String ANALYTICS_KEY = "mogo_map_trajectory_overlay_manager";
|
||||
|
||||
private final LinkedList<List<MessagePad.Location>> queue = new LinkedList<>();
|
||||
private final List<MessagePad.Location> queue = new ArrayList<>();
|
||||
|
||||
private MogoTrajectoryOverlayManager() {
|
||||
}
|
||||
@@ -38,6 +42,8 @@ public class MogoTrajectoryOverlayManager implements
|
||||
synchronized (MogoTrajectoryOverlayManager.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MogoTrajectoryOverlayManager();
|
||||
//需要先初始化,否则第一次调用drawTrajectoryOverlayOnce()会因为mRenderHandler=null实际不会绘制
|
||||
TrajectoryOverlayDrawer.getInstance();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,53 +52,52 @@ public class MogoTrajectoryOverlayManager implements
|
||||
|
||||
@Override
|
||||
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp globalPathResp) {
|
||||
CallerLogger.i(TAG, "onAutopilotRotting size=" + globalPathResp.getWayPointsList().size());
|
||||
if (globalPathResp != null) {
|
||||
CallerLogger.i(TAG, "onAutopilotRotting size=" + globalPathResp.getWayPointsList().size());
|
||||
synchronized (queue) {
|
||||
queue.clear();
|
||||
queue.offer(globalPathResp.getWayPointsList());
|
||||
queue.addAll(globalPathResp.getWayPointsList());
|
||||
}
|
||||
trackEvent("onAutopilotRotting", "接收到全局轨迹规划, size=" + globalPathResp.getWayPointsList().size());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChassisLocationGCJ02(@Nullable MogoLocation gnssInfo) {
|
||||
if (gnssInfo == null) {
|
||||
return;
|
||||
}
|
||||
// int autoPilotState = CallerAutoPilotStatusListenerManager.INSTANCE.getState();
|
||||
// boolean isArriveAtStation = CallerAutoPilotStatusListenerManager.INSTANCE.isArriveAtStation();
|
||||
// Log.d(TAG, "-- onChassisLocationGCJ02 -- 1 ---" + ":auto-mode:" + autoPilotState + ", isArriveAtStation: " + isArriveAtStation);
|
||||
// if (isArriveAtStation && autoPilotState != 2) {
|
||||
// RouteOverlayDrawer.getInstance().clearMogoRouteOverlay();
|
||||
// return;
|
||||
// }
|
||||
// Log.d(TAG, "-- onChassisLocationGCJ02 -- 2 ---" + "auto-mode:" + autoPilotState + ", isDemoMode:" + FunctionBuildConfig.isDemoMode + ", force:" + FunctionBuildConfig.isForceDrawAutopilotTrajectoryByDebugSettingView);
|
||||
// boolean force = FunctionBuildConfig.isForceDrawAutopilotTrajectoryByDebugSettingView || FunctionBuildConfig.isDemoMode && FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData;
|
||||
// if (!force && autoPilotState != 2) {
|
||||
// RouteOverlayDrawer.getInstance().clearMogoRouteOverlay();
|
||||
// return;
|
||||
// }
|
||||
// Log.d(TAG, "-- onChassisLocationGCJ02 -- 3 ---");
|
||||
|
||||
}
|
||||
|
||||
public Pair<Boolean, String> drawTrajectoryOverlayOnce() {
|
||||
Pair result = new Pair(false, "全局轨迹未就绪或为空");
|
||||
CallerLogger.i(TAG, "drawTrajectoryOverlayOnce");
|
||||
trackEvent("drawTrajectoryOverlayOnce", "开始执行");
|
||||
synchronized (queue) {
|
||||
if (!queue.isEmpty()) {
|
||||
List<MessagePad.Location> items = queue.pollLast();
|
||||
if (items != null && !items.isEmpty()) {
|
||||
double heading = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getHeading();
|
||||
TrajectoryOverlayDrawer.getInstance().drawTrajectoryList(items, heading);
|
||||
return new Pair<Boolean, String>(true, "success");
|
||||
}
|
||||
if (queue != null && !queue.isEmpty()) {
|
||||
double heading = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getHeading();
|
||||
TrajectoryOverlayDrawer.getInstance().drawTrajectoryList(queue, heading);
|
||||
trackEvent("drawTrajectoryOverlayOnce", "执行结果(result=true, msg=success)");
|
||||
return new Pair(true, "success");
|
||||
}
|
||||
return result;
|
||||
trackEvent("drawTrajectoryOverlayOnce", "执行结果(result=false, msg=全局轨迹未就绪或为空)");
|
||||
return new Pair(false, "全局轨迹未就绪或为空");
|
||||
}
|
||||
}
|
||||
|
||||
public void clearTrajectoryOverlay() {
|
||||
CallerLogger.i(TAG, "clearTrajectoryOverlay");
|
||||
trackEvent("clearTrajectoryOverlay", "开始执行");
|
||||
TrajectoryOverlayDrawer.getInstance().clearMogoTrajectoryOverlay();
|
||||
trackEvent("clearTrajectoryOverlay", "success");
|
||||
}
|
||||
|
||||
public void trackEvent(String eventKey, String eventValue) {
|
||||
ThreadUtils.getIoPool().submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Log.i(TAG, eventKey + "-->" + eventValue);
|
||||
Map map = new HashMap();
|
||||
map.put(eventKey, eventValue);
|
||||
MogoAnalyticUtils.INSTANCE.track(ANALYTICS_KEY, map);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,17 +21,23 @@ class MogoTrajectoryOverlayProvider : IMoGoGlobalTrajectoryDrawListener {
|
||||
}
|
||||
|
||||
override fun hasDrawnGlobalTrajectory(): Boolean {
|
||||
return hasDrawn.get()
|
||||
val result = hasDrawn.get()
|
||||
CallerLogger.i(TAG, "hasDrawnGlobalTrajectory --> hasDrawn=$result")
|
||||
return result
|
||||
}
|
||||
|
||||
override fun drawGlobalTrajectory(): Pair<Boolean, String> {
|
||||
val result = MogoTrajectoryOverlayManager.getInstance().drawTrajectoryOverlayOnce()
|
||||
hasDrawn.set(result.first)
|
||||
if (result.first) {
|
||||
hasDrawn.set(result.first)
|
||||
}
|
||||
CallerLogger.i(TAG, "drawGlobalTrajectory --> hasDrawn=$hasDrawn, result.first=${result.first}, result.second=${result.second}")
|
||||
return Pair(result.first, result.second)
|
||||
}
|
||||
|
||||
override fun clearGlobalTrajectory() {
|
||||
MogoTrajectoryOverlayManager.getInstance().clearTrajectoryOverlay()
|
||||
hasDrawn.set(false)
|
||||
CallerLogger.i(TAG, "clearGlobalTrajectory --> hasDrawn=$hasDrawn")
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class TrajectoryOverlayDrawer {
|
||||
if (mRenderTask != null) {
|
||||
mRenderHandler.removeCallbacks(mRenderTask);
|
||||
}
|
||||
mogoOverlayManager.removeAllLinesInLevel(Level.TRAJECTORY_LINE);
|
||||
mogoOverlayManager.hideAllLinesInLevel(Level.TRAJECTORY_LINE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,14 +125,10 @@ public class TrajectoryOverlayDrawer {
|
||||
} else {
|
||||
if (colors == null) {
|
||||
ArrayList<Pair<Integer, Integer>> temps = new ArrayList<>();
|
||||
// temps.add(new Pair<>(0, 51));
|
||||
// temps.add(new Pair<>(10, 102));
|
||||
// temps.add(new Pair<>(30, 51));
|
||||
// temps.add(new Pair<>(100, 0));
|
||||
temps.add(new Pair<>(0, 100));
|
||||
temps.add(new Pair<>(10, 100));
|
||||
temps.add(new Pair<>(30, 100));
|
||||
temps.add(new Pair<>(100, 100));
|
||||
temps.add(new Pair<>(0, 70));
|
||||
temps.add(new Pair<>(2, 100));
|
||||
temps.add(new Pair<>(98, 100));
|
||||
temps.add(new Pair<>(100, 70));
|
||||
List<Integer> alphas = MapTools.INSTANCE.getColorAlpha(temps);
|
||||
if (alphas != null && !alphas.isEmpty()) {
|
||||
colors = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user