[646] feat: 修改全局轨迹展示逻辑,提供对外调用接口;
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
package com.mogo.eagle.core.function.business.trajectoryoverlay;
|
||||
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
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;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager;
|
||||
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;
|
||||
|
||||
@@ -26,10 +28,9 @@ public class MogoTrajectoryOverlayManager implements
|
||||
private MogoTrajectoryOverlayManager() {
|
||||
}
|
||||
|
||||
|
||||
public void init() {
|
||||
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, 1,this);
|
||||
CallerChassisLocationGCJ02ListenerManager.INSTANCE.addListener(TAG, 1, this);
|
||||
}
|
||||
|
||||
public static MogoTrajectoryOverlayManager getInstance() {
|
||||
@@ -45,7 +46,7 @@ public class MogoTrajectoryOverlayManager implements
|
||||
|
||||
@Override
|
||||
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp globalPathResp) {
|
||||
CallerLogger.i(TAG, "onAutopilotRotting size="+globalPathResp.getWayPointsList().size());
|
||||
CallerLogger.i(TAG, "onAutopilotRotting size=" + globalPathResp.getWayPointsList().size());
|
||||
if (globalPathResp != null) {
|
||||
synchronized (queue) {
|
||||
queue.clear();
|
||||
@@ -59,8 +60,8 @@ public class MogoTrajectoryOverlayManager implements
|
||||
if (gnssInfo == null) {
|
||||
return;
|
||||
}
|
||||
int autoPilotState = CallerAutoPilotStatusListenerManager.INSTANCE.getState();
|
||||
boolean isArriveAtStation = CallerAutoPilotStatusListenerManager.INSTANCE.isArriveAtStation();
|
||||
// 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();
|
||||
@@ -73,13 +74,25 @@ public class MogoTrajectoryOverlayManager implements
|
||||
// return;
|
||||
// }
|
||||
// Log.d(TAG, "-- onChassisLocationGCJ02 -- 3 ---");
|
||||
|
||||
}
|
||||
|
||||
public Pair<Boolean, String> drawTrajectoryOverlayOnce() {
|
||||
Pair result = new Pair(false, "全局轨迹未就绪或为空");
|
||||
synchronized (queue) {
|
||||
if (!queue.isEmpty()) {
|
||||
List<MessagePad.Location> items = queue.pollLast();
|
||||
if (items != null && !items.isEmpty()) {
|
||||
TrajectoryOverlayDrawer.getInstance().drawTrajectoryList(items, gnssInfo.getHeading());
|
||||
double heading = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getHeading();
|
||||
TrajectoryOverlayDrawer.getInstance().drawTrajectoryList(items, heading);
|
||||
return new Pair<Boolean, String>(true, "success");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public void clearTrajectoryOverlay() {
|
||||
TrajectoryOverlayDrawer.getInstance().clearMogoTrajectoryOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.mogo.eagle.core.function.business.trajectoryoverlay
|
||||
|
||||
import android.content.Context
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.eagle.core.data.constants.MogoServicePaths
|
||||
import com.mogo.eagle.core.function.api.map.trajectory.IMoGoGlobalTrajectoryDrawListener
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
|
||||
@Route(path = MogoServicePaths.PATH_MAP_GLOBAL_TRAJECTORY)
|
||||
class MogoTrajectoryOverlayProvider : IMoGoGlobalTrajectoryDrawListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MogoTrajectoryOverlayProvider"
|
||||
}
|
||||
|
||||
private var hasDrawn = AtomicReference<Boolean>(false)
|
||||
|
||||
override fun init(context: Context?) {
|
||||
CallerLogger.i(TAG, "---init---")
|
||||
}
|
||||
|
||||
override fun hasDrawnGlobalTrajectory(): Boolean {
|
||||
return hasDrawn.get()
|
||||
}
|
||||
|
||||
override fun drawGlobalTrajectory(): Pair<Boolean, String> {
|
||||
val result = MogoTrajectoryOverlayManager.getInstance().drawTrajectoryOverlayOnce()
|
||||
hasDrawn.set(result.first)
|
||||
return Pair(result.first, result.second)
|
||||
}
|
||||
|
||||
override fun clearGlobalTrajectory() {
|
||||
MogoTrajectoryOverlayManager.getInstance().clearTrajectoryOverlay()
|
||||
hasDrawn.set(false)
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,6 @@ import android.util.Log;
|
||||
import androidx.core.util.Pools;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.map.overlay.IMoGoOverlayManager;
|
||||
@@ -37,7 +36,7 @@ public class TrajectoryOverlayDrawer {
|
||||
private static final byte[] obj = new byte[0];
|
||||
private Polyline.Options mPolylineOptions;
|
||||
private static final int COLOR_LIGHT = Color.parseColor("#BAEBF5");
|
||||
|
||||
private static final int mPolylineWidth = 50;
|
||||
|
||||
//用于taxi乘客屏渐变颜色集合
|
||||
private static List<Integer> colors = null;
|
||||
@@ -48,7 +47,7 @@ public class TrajectoryOverlayDrawer {
|
||||
if (mogoOverlayManager != null) {
|
||||
mPolylineOptions = new Polyline.Options.Builder("trajectory_overlay", Level.TRAJECTORY_LINE)
|
||||
.setUseGps(true)
|
||||
.setWidth(30)
|
||||
.setWidth(mPolylineWidth)
|
||||
.setIsGradient(true)
|
||||
.build();
|
||||
|
||||
@@ -86,10 +85,8 @@ public class TrajectoryOverlayDrawer {
|
||||
|
||||
private class RenderTask implements Runnable {
|
||||
private volatile List<MessagePad.Location> routeList;
|
||||
|
||||
private final Pools.Pool<MogoLatLng> pools;
|
||||
private final LinkedList<MogoLatLng> points;
|
||||
|
||||
private double bearing;
|
||||
|
||||
public RenderTask() {
|
||||
@@ -120,8 +117,8 @@ public class TrajectoryOverlayDrawer {
|
||||
isExcept = true;
|
||||
return;
|
||||
}
|
||||
// boolean isColorfulStrategy = !AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) || !AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode);
|
||||
//TODO
|
||||
//boolean isColorfulStrategy = !AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode) || !AppIdentityModeUtils.isPassenger(FunctionBuildConfig.appIdentityMode);
|
||||
//全局轨迹线 没有颜色策略,使用固定颜色
|
||||
boolean isColorfulStrategy = false;
|
||||
if (isColorfulStrategy) {
|
||||
TrajectoryStrategy.INSTANCE.start();
|
||||
@@ -132,15 +129,15 @@ public class TrajectoryOverlayDrawer {
|
||||
// temps.add(new Pair<>(10, 102));
|
||||
// temps.add(new Pair<>(30, 51));
|
||||
// temps.add(new Pair<>(100, 0));
|
||||
temps.add(new Pair<>(0, 51));
|
||||
temps.add(new Pair<>(10, 51));
|
||||
temps.add(new Pair<>(30, 51));
|
||||
temps.add(new Pair<>(100, 51));
|
||||
temps.add(new Pair<>(0, 100));
|
||||
temps.add(new Pair<>(10, 100));
|
||||
temps.add(new Pair<>(30, 100));
|
||||
temps.add(new Pair<>(100, 100));
|
||||
List<Integer> alphas = MapTools.INSTANCE.getColorAlpha(temps);
|
||||
if (alphas != null && !alphas.isEmpty()) {
|
||||
colors = new ArrayList<>();
|
||||
for (int i : alphas) {
|
||||
colors.add(Color.argb(i, 48,203,251));
|
||||
colors.add(Color.argb(i, 78,121,173));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,41 +165,36 @@ public class TrajectoryOverlayDrawer {
|
||||
acquire.lon = longitude;
|
||||
acquire.lat = latitude;
|
||||
}
|
||||
// acquire.acc = route.getAcceleration();
|
||||
// acquire.speed = route.getVelocity();
|
||||
pps.add(acquire);
|
||||
// if (isColorfulStrategy) {
|
||||
//// RouteStrategy.INSTANCE.check(route.getVelocity(), route.getAcceleration(), routeList.size());
|
||||
// }
|
||||
}
|
||||
double lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
|
||||
double lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
|
||||
// double lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
|
||||
// double lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
|
||||
if (points.size() > 0) {
|
||||
MogoLatLng top = null;
|
||||
while (points.size() != 0) {
|
||||
MogoLatLng first = points.peek();
|
||||
if (first == null) {
|
||||
continue;
|
||||
}
|
||||
if (first == top) {
|
||||
break;
|
||||
}
|
||||
lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
|
||||
lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
|
||||
long angle = isPointOnCarFront(lon, lat, bearing, first.lon, first.lat);
|
||||
if (angle >= 90) {
|
||||
if (isColorfulStrategy) {
|
||||
TrajectoryStrategy.INSTANCE.remove(first.acc);
|
||||
}
|
||||
pools.release(first);
|
||||
points.poll();
|
||||
}
|
||||
top = first;
|
||||
}
|
||||
if (points.size() == 0) {
|
||||
isExcept = true;
|
||||
return;
|
||||
}
|
||||
// MogoLatLng top = null;
|
||||
// while (points.size() != 0) {
|
||||
// MogoLatLng first = points.peek();
|
||||
// if (first == null) {
|
||||
// continue;
|
||||
// }
|
||||
// if (first == top) {
|
||||
// break;
|
||||
// }
|
||||
// lon = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLongitude();
|
||||
// lat = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84().getLatitude();
|
||||
// long angle = isPointOnCarFront(lon, lat, bearing, first.lon, first.lat);
|
||||
// if (angle >= 90) {
|
||||
// if (isColorfulStrategy) {
|
||||
// TrajectoryStrategy.INSTANCE.remove(first.acc);
|
||||
// }
|
||||
// pools.release(first);
|
||||
// points.poll();
|
||||
// }
|
||||
// top = first;
|
||||
// }
|
||||
// if (points.size() == 0) {
|
||||
// isExcept = true;
|
||||
// return;
|
||||
// }
|
||||
// MogoLatLng self = pools.acquire();
|
||||
// if (self == null) {
|
||||
// self = new MogoLatLng(lat, lon);
|
||||
@@ -216,8 +208,8 @@ public class TrajectoryOverlayDrawer {
|
||||
if (mPolylineOptions == null) {
|
||||
builder = new Polyline.Options.Builder("trajectory_overlay", Level.TRAJECTORY_LINE)
|
||||
.setUseGps(true)
|
||||
.setWidth(20)
|
||||
.setIsGradient(true);
|
||||
.setWidth(mPolylineWidth)
|
||||
.setIsGradient(false);
|
||||
} else {
|
||||
builder = mPolylineOptions.builder();
|
||||
}
|
||||
@@ -229,16 +221,15 @@ public class TrajectoryOverlayDrawer {
|
||||
boolean isLightOn = strategy instanceof ColorfulStrategy && ((ColorfulStrategy) strategy).isLightOn();
|
||||
builder.colors(colors);
|
||||
builder.setLightOn(isLightOn);
|
||||
builder.setLightColor(COLOR_LIGHT);
|
||||
builder.setLightSpeed(0.3f);
|
||||
//builder.setLightColor(COLOR_LIGHT);
|
||||
//builder.setLightSpeed(0.3f);
|
||||
} else {
|
||||
if (colors != null && !colors.isEmpty()) {
|
||||
builder.colors(colors);
|
||||
builder.setIsGradient(true);
|
||||
// builder.setLightOn(true);
|
||||
builder.setLightOn(false);
|
||||
builder.setLightColor(COLOR_LIGHT);
|
||||
builder.setLightSpeed(0.3f);
|
||||
//builder.setLightColor(COLOR_LIGHT);
|
||||
//builder.setLightSpeed(0.3f);
|
||||
}
|
||||
}
|
||||
builder.points(points);
|
||||
@@ -289,7 +280,7 @@ public class TrajectoryOverlayDrawer {
|
||||
}
|
||||
}
|
||||
|
||||
public void setVisible(boolean isVisible) {
|
||||
private void setVisible(boolean isVisible) {
|
||||
if (mogoOverlayManager != null) {
|
||||
if (isVisible) {
|
||||
mogoOverlayManager.showAllLinesInLevel(Level.TRAJECTORY_LINE);
|
||||
|
||||
@@ -4,11 +4,12 @@ import android.animation.ArgbEvaluator
|
||||
import android.graphics.Color
|
||||
import android.view.animation.AccelerateInterpolator
|
||||
import com.mogo.eagle.core.data.config.HmiBuildConfig
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_BLUE
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_BLUE_DARK
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_RED_DARK
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.Colors.Companion.COLOR_TRANSPARENT
|
||||
import java.util.*
|
||||
import com.mogo.eagle.core.function.business.trajectoryoverlay.Colors.Companion.COLOR_BLUE
|
||||
import com.mogo.eagle.core.function.business.trajectoryoverlay.Colors.Companion.COLOR_BLUE_DARK
|
||||
import com.mogo.eagle.core.function.business.trajectoryoverlay.Colors.Companion.COLOR_RED_DARK
|
||||
import com.mogo.eagle.core.function.business.trajectoryoverlay.Colors.Companion.COLOR_TRANSPARENT
|
||||
import java.util.NavigableMap
|
||||
import java.util.TreeMap
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
|
||||
@@ -21,7 +22,7 @@ class Colors {
|
||||
companion object {
|
||||
val COLOR_BLUE = Color.parseColor("#FF2ABAD9")
|
||||
val COLOR_BLUE_DARK = Color.parseColor("#FF074EFF")
|
||||
val COLOR_RED_DARK = Color.parseColor("#FFFF5F00")
|
||||
val COLOR_RED_DARK = Color.parseColor("#FF0FF5F0")
|
||||
val COLOR_TRANSPARENT = Color.parseColor("#002ABAD9")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user