[RoutingOpt]修正车前引导线拖尾问题

[RouterOpt]优化代码逻辑
This commit is contained in:
renwj
2022-04-15 19:37:07 +08:00
parent f184dce4a2
commit 14d32eef0a
16 changed files with 472 additions and 240 deletions

View File

@@ -3,11 +3,14 @@ package com.mogo.module.service.routeoverlay;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_OLD_ROUTE;
import android.content.Context;
import android.os.SystemClock;
import android.util.Log;
import androidx.annotation.NonNull;
import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.deva.scene.SceneModule;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener;
@@ -15,15 +18,21 @@ import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener;
import com.mogo.eagle.core.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager;
import com.mogo.eagle.core.function.call.devatools.CallerDevaToolsManager;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant;
import com.mogo.module.common.utils.DrivingDirectionUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import mogo.telematics.pad.MessagePad;
import mogo_msg.MogoReportMsg;
@@ -33,17 +42,19 @@ public class MogoRouteOverlayManager implements
IMoGoMapLocationListener {
private static volatile MogoRouteOverlayManager sInstance;
private Context mContext;
private String TAG = "MogoRouteOverlayManager";
private String TAG2 = "MogoRouteOverlayManager routes";
private String TAG = "route";
private int STATUS_AUTOPILOT = 0;//0 非自动驾驶 ; 1 自动驾驶
private MogoLatLng mEnding;
// private MogoLatLng mEnding;
private MogoLocation mLocation;
private List<MogoLatLng> mTrajectoryList = new ArrayList<>();
private AtomicBoolean isArriveAtStation = new AtomicBoolean(false);
private volatile List<MessagePad.TrajectoryPoint> mTrajectoryList = null;
private MogoRouteOverlayManager(Context context) {
mContext = context;
}
public void init() {
CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this);
CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, this);
@@ -62,50 +73,73 @@ public class MogoRouteOverlayManager implements
return sInstance;
}
private void intiDrawer() {
RouteOverlayDrawer.getInstance(mContext).initDraw();
}
private StringBuilder trajectoryMsg = null;
@Override
public void onAutopilotTrajectory(List<MessagePad.TrajectoryPoint> trajectoryInfos) {
if (trajectoryInfos == null || trajectoryInfos.size() == 0) {
return;
}
StringBuilder builder = new StringBuilder();
builder.append("{");
builder.append(System.currentTimeMillis()).append(";");
builder.append(mLocation.getLongitude()).append(";");
builder.append(mLocation.getLatitude()).append(";");
builder.append(mLocation.getAltitude()).append(";");
builder.append(mLocation.getBearing()).append(";");
builder.append(mLocation.getSpeed()).append(";");
List<MogoLatLng> mogoLatLngs = new ArrayList<>();
for (int i = 0; i < trajectoryInfos.size(); i++) {
// 临时解决车尾拖线问题,丢弃距离车最近的几个经纬度,原因是惯性导航的中心靠近车尾,会导致经纬度靠近尾部,且两个数据不同频
if (i > 5) {
MessagePad.TrajectoryPoint a = trajectoryInfos.get(i);
builder.append(a.getLongitude()).append(",");
builder.append(a.getLatitude()).append(",");
mogoLatLngs.add(new MogoLatLng(a.getLatitude(), a.getLongitude()));
public void onAutopilotTrajectory(@NonNull List<MessagePad.TrajectoryPoint> items) {
long start = SystemClock.elapsedRealtime();
try {
if (isArriveAtStation.get()) {
return;
}
if (items.size() == 0) {
return;
}
MogoLocation location = mLocation;
if (location == null) {
return;
}
mTrajectoryList = items;
Map<String, SceneModule> tags = CallerDevaToolsManager.INSTANCE.getModuleTAG();
boolean isPrintLog = false;
if (tags != null && tags.containsKey(SceneConstant.M_OLD_ROUTE)) {
SceneModule scene = tags.get(M_OLD_ROUTE);
isPrintLog = scene.getLog();
}
if (isPrintLog) {
if (trajectoryMsg == null) {
trajectoryMsg = new StringBuilder(128);
}
if (trajectoryMsg.length() > 0) {
trajectoryMsg.setLength(0);
}
trajectoryMsg.append("{");
trajectoryMsg.append(System.currentTimeMillis()).append(";");
trajectoryMsg.append(location.getLongitude()).append(";");
trajectoryMsg.append(location.getLatitude()).append(";");
trajectoryMsg.append(location.getAltitude()).append(";");
trajectoryMsg.append(location.getBearing()).append(";");
trajectoryMsg.append(location.getSpeed()).append(";");
for (int i = 0; i < items.size(); i++) {
// 临时解决车尾拖线问题,丢弃距离车最近的几个经纬度,原因是惯性导航的中心靠近车尾,会导致经纬度靠近尾部,且两个数据不同频
MessagePad.TrajectoryPoint a = items.get(i);
double lon = a.getLongitude();
double lat = a.getLatitude();
trajectoryMsg.append(lon).append(",");
trajectoryMsg.append(lat).append(",");
}
trajectoryMsg.append("}");
Log.d(M_OLD_ROUTE + TAG, "receive router data:" + items.size());
Log.d(M_OLD_ROUTE + TAG, trajectoryMsg.toString());
} else {
Log.d(M_OLD_ROUTE + TAG, "receive router data:" + items.size());
}
} finally {
Log.d(M_OLD_ROUTE + TAG, "--- onAutopilotTrajectory -- cost:" + (SystemClock.elapsedRealtime() - start) + " ms");
}
mTrajectoryList = mogoLatLngs;
builder.append("}");
}
@Override
public void onAutopilotRotting(MessagePad.GlobalPathResp globalPathResp) {
if (globalPathResp == null || globalPathResp.getWayPointsList().size() == 0) {
return;
}
List<MogoLatLng> latLngList = new ArrayList<>();
for (MessagePad.Location routeModel : globalPathResp.getWayPointsList()) {
latLngList.add(new MogoLatLng(routeModel.getLatitude(), routeModel.getLongitude()));
}
int listSize = latLngList.size();
mEnding = latLngList.get(listSize - 1);
// if (globalPathResp == null || globalPathResp.getWayPointsList().size() == 0) {
// return;
// }
// List<MogoLatLng> latLngList = new ArrayList<>();
// for (MessagePad.Location routeModel : globalPathResp.getWayPointsList()) {
// latLngList.add(new MogoLatLng(routeModel.getLatitude(), routeModel.getLongitude()));
// }
// int listSize = latLngList.size();
// mEnding = latLngList.get(listSize - 1);
// RouteOverlayDrawer.getInstance(mContext).addEndingMarker(latLngList.get(listSize - 1).lat,latLngList.get(listSize - 1).lon);
}
@@ -113,9 +147,13 @@ public class MogoRouteOverlayManager implements
@Override
public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) {
if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData) {
isArriveAtStation.set(false);
return;
}
this.STATUS_AUTOPILOT = autoPilotStatusInfo.getPilotmode();
if (this.STATUS_AUTOPILOT == 1) {
isArriveAtStation.set(false);
}
//CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG ,"onAutopilotStatusResponse:"+STATUS_AUTOPILOT);
// if (STATUS_AUTOPILOT == 1 ){
// if (mEnding != null){
@@ -136,9 +174,15 @@ public class MogoRouteOverlayManager implements
if (arrivalNotification == null) {
return;
}
CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG, "onArriveAt data : " + arrivalNotification.toString());
CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG, "onArriveAt data : " + arrivalNotification);
// //演示模式下 到达终点将忽略 引导线绘制 选项关闭
// FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData = false;
if (!isArriveAtStation.get()) {
isArriveAtStation.set(true);
RouteOverlayDrawer.getInstance(mContext).clearEndingMarker();
RouteOverlayDrawer.getInstance(mContext).clearMogoRouteOverlay();
}
}
@@ -148,67 +192,26 @@ public class MogoRouteOverlayManager implements
}
@Override
public void onLocationChanged(@Nullable MogoLocation location) {
// mLocation = location;
// if (mTrajectoryList.isEmpty()) {
// return;
// }
// CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG , "onLocationChanged : " + mTrajectoryList.size());
// ArrayList list = new ArrayList();
// for (MogoLatLng latLng : mTrajectoryList) {
// if (!isPointOnCarFront(mLocation, latLng)) {
// list.add(latLng);
// }
// }
//
// StringBuilder builder = new StringBuilder();
// for (int i = 0; i < list.size(); i++) {
// MogoLatLng latLng = (MogoLatLng) list.get(i);
// builder.append(latLng.getLon()).append(",");
// builder.append(latLng.getLat()).append(",");
// }
// CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG , "onLocationChanged : " + GsonUtils.toJson(builder.toString()));
// CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG ,"onLocationChanged size = " + list.size() + "---TrajectoryData = " + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData + "----" + STATUS_AUTOPILOT);
// if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || STATUS_AUTOPILOT == 1) {
// RouteOverlayDrawer.getInstance(mContext).drawTrajectoryList(list);
// }
mLocation = location;
List<MogoLatLng> temp = mTrajectoryList;
if (temp.isEmpty()) {
public void onLocationChanged(@Nullable MogoLocation location, int from) {
if (from != 1) {
return;
}
// CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG , "onLocationChanged: size = "+ mTrajectoryList.size()+" ----- "+mLocation.getLongitude()+"-"+mLocation.getLatitude());
ArrayList list = new ArrayList();
MogoLatLng carlatLng = new MogoLatLng(CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat(),CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon());
list.add(carlatLng);
for (MogoLatLng latLng : temp) {
// if(!isPointOnCarFront(mLocation,latLng)){
list.add(latLng);
// }
}
// CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG, "TrajectoryData = " + FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData + "---status = " + STATUS_AUTOPILOT + "----size = " + list.size());
if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || STATUS_AUTOPILOT == 1) {
RouteOverlayDrawer.getInstance(mContext).drawTrajectoryList(list);
}
}
public boolean isPointOnCarFront(MogoLocation carLocal, MogoLatLng pointLocal) {
double carLon = carLocal.getLongitude();
double carLat = carLocal.getLatitude();
double poiLon = pointLocal.lon;
double poiLat = pointLocal.lat;
float carAngle = carLocal.getBearing();
// 计算车辆与点之间的夹角
int diffAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
carLon, carLat, poiLon, poiLat, (int) carAngle);
// CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG,"diffAngle:"+diffAngle);
if (diffAngle <= 90) {
return true;
} else {
return false;
long start = SystemClock.elapsedRealtime();
boolean isExcept = false;
try {
if (location == null) {
isExcept = true;
return;
}
if (FunctionBuildConfig.isIgnoreConditionsDrawAutopilotTrajectoryData || STATUS_AUTOPILOT == 1) {
RouteOverlayDrawer.getInstance(mContext).drawTrajectoryList(location, mTrajectoryList);
}
} finally {
mLocation = location;
if (isExcept) {
RouteOverlayDrawer.getInstance(mContext).setVisible(false);
}
Log.d(M_OLD_ROUTE + TAG, "--- onLocationChanged -- cost:" + (SystemClock.elapsedRealtime() - start) + " ms");
}
}

View File

@@ -1,13 +1,18 @@
package com.mogo.module.service.routeoverlay;
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_OLD_ROUTE;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.SystemClock;
import android.util.Log;
import androidx.core.util.Pools;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.util.ColorUtils;
@@ -18,22 +23,23 @@ import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.overlay.IMogoOverlayManager;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.map.overlay.MogoPolylineOptions;
import com.mogo.module.common.utils.DrivingDirectionUtils;
import com.mogo.module.service.R;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import mogo.telematics.pad.MessagePad;
public class RouteOverlayDrawer {
private static final String TAG = "MogoRouteOverlayManager";
private IMogoPolyline mMoGoPolyline;
private volatile IMogoPolyline mMoGoPolyline;
// 连接线参数
private final MogoPolylineOptions mPolylineOptions;
// 线路径集合
private final List<MogoLatLng> mPolylinePointList;
// 渐变色
private final List<Integer> mPolylineColors;
private Handler mRenderHandler;
private final Bitmap endingBitmap;
private final Context mContext;
IMogoOverlayManager mogoOverlayManager;
@@ -46,14 +52,28 @@ public class RouteOverlayDrawer {
mPolylineOptions = new MogoPolylineOptions();
mPolylineOptions.zIndex(75000f);
mPolylineOptions.setGps(true);
// 绘制路径集合
mPolylinePointList = new ArrayList<>();
// 引导线颜色,
mPolylineColors = new ArrayList<>();
// 渐变色
mContext = context;
mogoOverlayManager = MogoOverlayManager.getInstance();
endingBitmap = BitmapFactory.decodeResource(context.getResources(),
R.drawable.icon_route_ending);
List<Integer> list = new ArrayList<>();
int[] startColor = ColorUtils.hexToArgb("#CC64C3EA");
int[] endColor = ColorUtils.hexToArgb("#0064C3EA");
list.add(Color.argb(startColor[0], startColor[1], startColor[2], startColor[3]));
list.add(Color.argb(endColor[0], endColor[1], endColor[2], endColor[3]));
// 线条粗细,渐变,渐变色值
mPolylineOptions.width(20).useGradient(true).colorValues(list);
HandlerThread renderTask = new HandlerThread("routing_render") {
@Override
protected void onLooperPrepared() {
super.onLooperPrepared();
mRenderHandler = new Handler(getLooper());
}
};
renderTask.start();
}
public static RouteOverlayDrawer getInstance(Context context) {
@@ -103,8 +123,10 @@ public class RouteOverlayDrawer {
if (mMoGoPolyline != null) {
mMoGoPolyline.remove();
mMoGoPolyline = null;
mPolylinePointList.clear();
mPolylineColors.clear();
}
if (mRenderTask != null) {
mRenderHandler.removeCallbacks(mRenderTask);
}
}
@@ -114,57 +136,191 @@ public class RouteOverlayDrawer {
MogoMarkerManager.getInstance(mContext).removeMarkers(markerType);
}
private class RenderTask implements Runnable {
private volatile List<MessagePad.TrajectoryPoint> routeList;
private volatile MogoLocation location;
public void drawTrajectoryList(List<MogoLatLng> routeList) {
// clearMogoRouteOverlay();
mPolylinePointList.clear();
if (routeList != null && routeList.size() > 0) {
for (MogoLatLng latLng : routeList) {
mPolylinePointList.add(latLng);
private final Pools.Pool<MogoLatLng> pools;
private final LinkedList<MogoLatLng> points;
public RenderTask() {
this.pools = new Pools.SimplePool<>(500);
this.points = new LinkedList<>();
}
public void setData(MogoLocation location, List<MessagePad.TrajectoryPoint> routeList) {
this.location = location;
this.routeList = routeList;
}
@SuppressLint("LongLogTag")
@Override
public void run() {
LinkedList<MogoLatLng> points = this.points;
points.clear();
try {
long drawStart = SystemClock.elapsedRealtime();
List<MessagePad.TrajectoryPoint> routes = this.routeList;
if (routes == null || routes.size() < 2) {
setVisible(false);
return;
}
for (int i = 0; i < routes.size(); i++) {
MessagePad.TrajectoryPoint route = routes.get(i);
if (route == null) {
continue;
}
MogoLatLng acquire = pools.acquire();
double latitude = route.getLatitude();
double longitude = route.getLongitude();
if (acquire == null) {
acquire = new MogoLatLng(latitude, longitude);
} else {
acquire.lon = longitude;
acquire.lat = latitude;
}
points.add(acquire);
}
MogoLocation location = this.location;
double lon = CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon();
double lat = CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat();
if (lon == 0.0 || lat == 0.0) {
return;
}
if (location != null && points.size() > 0) {
int i = 0;
int max = Math.min(20, points.size() / 2);
MogoLatLng top = null;
int remove = 0;
long angle;
while (i++ < max) {
MogoLatLng first = points.peek();
if (first == null) {
continue;
}
if (first == top) {
break;
}
angle = isPointOnCarFront(lon, lat, location.getBearing(), first.lon, first.lat);
if (angle >= 90) {
Log.d(M_OLD_ROUTE + TAG, "render - removeCount:" + (++remove));
points.poll();
}
top = first;
}
//distance
// if (top != null) {
// double distance = DrivingDirectionUtils.distance(top.lon, top.lat, lon, lat) * 10_0000;
// angle = isPointOnCarFront(lon, lat, location.getBearing(), top.lon, top.lat);
// Log.d(M_OLD_ROUTE + TAG, "render - distance:" + distance + ",angle:" + angle);
// if (distance > 4.0 && angle >= 80) {
// float bearing = location.getBearing();
// Pair<Double, Double> p_car_f = DrivingDirectionUtils.calculateNewPoint(lon, lat, bearing, 5);
// Pair<Double, Double> p_rout_f = DrivingDirectionUtils.calculateNewPoint(top.lon, top.lat, bearing, 5);
// if (p_car_f != null && p_rout_f != null) {
// Stack<MogoLatLng> stack = new Stack<>();
// stack.add(new MogoLatLng(p_car_f.second, p_car_f.first));
// double new_bear = bearing + 90;
// while (distance > 0.1) {
// distance /= 2;
// Pair<Double, Double> p = DrivingDirectionUtils.calculateNewPoint(p_car_f.first, p_car_f.second, new_bear, distance);
// if (p == null) {
// break;
// }
// stack.push(new MogoLatLng(p.second, p.first));
// }
// Log.d("XXXX", "----stack:" + stack.size());
// long newAngle = DrivingDirectionUtils.getDegreeOfCar2Poi2(p_rout_f.first, p_rout_f.second, top.lon, top.lat, bearing);
// Log.d("XXXX", "----newAngle:" + newAngle);
// while (newAngle > 90) {
// Log.d("XXXX", "----newAngle:" + newAngle);
// points.poll();
// MogoLatLng peek = points.peek();
// if (peek == null) {
// points.poll();
// continue;
// }
// newAngle = DrivingDirectionUtils.getDegreeOfCar2Poi2(p_rout_f.first, p_rout_f.second, peek.lon, peek.lat, bearing);
// }
// while (!stack.isEmpty()) {
// MogoLatLng pop = stack.pop();
// points.addFirst(pop);
// }
// }
// }
// }
MogoLatLng self = pools.acquire();
if (self == null) {
self = new MogoLatLng(lat, lon);
} else {
self.lat = lat;
self.lon = lon;
}
points.addFirst(self);
if (mMoGoPolyline == null || mMoGoPolyline.isDestroyed()) {
mPolylineOptions.points(points);
mMoGoPolyline = mogoOverlayManager.addPolyline(mPolylineOptions);
} else {
mPolylineOptions.points(points);
mMoGoPolyline.setOption(mPolylineOptions);
}
if (mMoGoPolyline != null && !mMoGoPolyline.isDestroyed() && !mMoGoPolyline.isVisible()) {
mMoGoPolyline.setVisible(true);
}
} else {
if(mMoGoPolyline != null) {
mMoGoPolyline.setVisible(false);
}
}
long drawEnd = SystemClock.elapsedRealtime();
Log.d(M_OLD_ROUTE + TAG, "drawTrajectoryList cost : " + (drawEnd - drawStart));
} catch (Throwable t) {
Log.d(M_OLD_ROUTE + TAG, "drawTrajectoryList error : " + t);
} finally {
if (points.size() > 0) {
for (int i = 0; i < points.size(); i++) {
MogoLatLng latLng = points.get(i);
if (latLng == null) {
continue;
}
pools.release(latLng);
}
}
}
mPolylineColors.clear();
// mPolylineColors.addAll(ColorUtils.gradientAlpha_("#FF2AAFFD", "#7b2965ED", "#002965ED", mPolylinePointList.size()));
List<Integer> list = new ArrayList<>();
// list = ColorUtils.gradientAlpha("#FF2AAFFD", "#002965ED", mPolylinePointList.size());
int[] startColor = ColorUtils.hexToArgb("#CC64C3EA");
int[] endColor = ColorUtils.hexToArgb("#0064C3EA");
list.add(Color.argb(startColor[0], startColor[1], startColor[2], startColor[3]));
list.add(Color.argb(endColor[0], endColor[1], endColor[2], endColor[3]));
}
mPolylineColors.addAll(list);
// 线条粗细,渐变,渐变色值
mPolylineOptions.width(20).useGradient(true).colorValues(mPolylineColors);
if (mMoGoPolyline == null || mMoGoPolyline.isDestroyed()) {
mPolylineOptions.points(mPolylinePointList);
mMoGoPolyline = mogoOverlayManager.addPolyline(mPolylineOptions);
} else {
mPolylineOptions.points(mPolylinePointList);
mMoGoPolyline.setOption(mPolylineOptions);
private long isPointOnCarFront(double car_lon, double car_lat, double car_head, double lon, double lat) {
long start = SystemClock.elapsedRealtime();
try {
// 计算车辆与点之间的夹角
long diffAngle = DrivingDirectionUtils.getDegreeOfCar2Poi2(
car_lon, car_lat, lon, lat, car_head);
CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG, "isPointOnCarFront: angle->" + diffAngle);
return diffAngle;
} finally {
CallerLogger.INSTANCE.d(M_OLD_ROUTE + TAG, "isPointOnCarFront cost:" + (SystemClock.elapsedRealtime() - start) + "ms");
}
}
}
public void initDraw() {
mPolylinePointList.clear();
MogoLatLng latLng = new MogoLatLng(
CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lat(),
CallerAutoPilotStatusListenerManager.INSTANCE.getCurWgs84Lon());
mPolylinePointList.add(latLng);
mPolylinePointList.add(latLng);
mPolylineColors.clear();
long start = System.currentTimeMillis();
List<Integer> list = new ArrayList<>();
list = ColorUtils.gradientAlpha("#FF2AAFFD", "#002965ED", mPolylinePointList.size());
private volatile RenderTask mRenderTask;
mPolylineColors.addAll(list);
// 线条粗细,渐变,渐变色值
mPolylineOptions.width(12).useGradient(true).colorValues(mPolylineColors);
if (mMoGoPolyline == null || mMoGoPolyline.isDestroyed()) {
mPolylineOptions.points(mPolylinePointList);
mMoGoPolyline = mogoOverlayManager.addPolyline(mPolylineOptions);
} else {
mPolylineOptions.points(mPolylinePointList);
mMoGoPolyline.setOption(mPolylineOptions);
public void drawTrajectoryList(MogoLocation carLoc, List<MessagePad.TrajectoryPoint> routeList) {
if (mRenderTask == null) {
mRenderTask = new RenderTask();
}
mRenderTask.setData(carLoc, routeList);
if (mRenderHandler != null) {
mRenderHandler.removeCallbacks(mRenderTask);
mRenderHandler.post(mRenderTask);
}
}
public void setVisible(boolean isVisible) {
if (mMoGoPolyline != null && !mMoGoPolyline.isDestroyed()) {
mMoGoPolyline.setVisible(isVisible);
}
}
}