[8.0.0][Opt]优化决策、预测地图渲染
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
package com.mogo.map.utils
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.MogoMap
|
||||
import com.mogo.map.MogoMap.Companion.mapInstance
|
||||
|
||||
object LocationUtils {
|
||||
/**
|
||||
* 必须先根据定位计算度带,即调用switchData(gnssInfo.longitude, gnssInfo.latitude, true)
|
||||
*/
|
||||
fun generateLocation(x: Double, y: Double, heading: Double): MogoLocation? {
|
||||
val mogoMap = mapInstance.getMogoMap(MogoMap.DEFAULT)
|
||||
if (mogoMap != null) {
|
||||
val lonLat = mogoMap.switchData(x, y, false)
|
||||
if (lonLat == null || lonLat.size < 2) return null
|
||||
val location = MogoLocation()
|
||||
location.longitude = lonLat[0]
|
||||
location.latitude = lonLat[1]
|
||||
location.heading = heading
|
||||
return location
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同上,必须先根据定位计算度带
|
||||
*/
|
||||
fun generateLocation(x: Double, y: Double, preX: Double, preY: Double): MogoLocation? {
|
||||
val mogoMap = mapInstance.getMogoMap(MogoMap.DEFAULT)
|
||||
if (mogoMap != null) {
|
||||
val lonLat = mogoMap.switchData(x, y, false)
|
||||
val preLonLat = mogoMap.switchData(preX, preY, false)
|
||||
if (lonLat == null || lonLat.size < 2 || preLonLat == null || preLonLat.size < 2) return null
|
||||
val location = MogoLocation()
|
||||
location.longitude = lonLat[0]
|
||||
location.latitude = lonLat[1]
|
||||
location.heading = DrivingDirectionUtils.getLineAngle(lonLat[0], lonLat[1], preLonLat[0], preLonLat[1])
|
||||
return location
|
||||
} else {
|
||||
return null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@ import android.view.View;
|
||||
|
||||
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.map.uicontroller.MapCameraPosition;
|
||||
@@ -196,14 +196,16 @@ public class ObjectUtils {
|
||||
return null;
|
||||
}
|
||||
MarkerSimpleData markerOptions = null;
|
||||
MogoLocation location = getPreLocation(preData);
|
||||
if (location == null) return null;
|
||||
try {
|
||||
markerOptions = new MarkerSimpleData();
|
||||
markerOptions.setId(preData.getMNid());
|
||||
markerOptions.setId(preData.getMNid()-800000);
|
||||
markerOptions.setMarkerType(trackedObjectTypeTransform(preData.getClasstype()));
|
||||
markerOptions.setRotateAngle(getPredictionHeading(preData));
|
||||
markerOptions.setRotateAngle((float) location.getHeading());
|
||||
// 自车2条轨迹,它车1条轨迹;每条轨迹的第一个点为位置,其它点为预测轨迹点
|
||||
markerOptions.setLat(preData.getPredictionTrajectoryList().get(0).getTrajectoryPointsList().get(0).getX());
|
||||
markerOptions.setLon(preData.getPredictionTrajectoryList().get(0).getTrajectoryPointsList().get(0).getY());
|
||||
markerOptions.setLat(location.getLatitude());
|
||||
markerOptions.setLon(location.getLongitude());
|
||||
// marker做动画时需用到(要么一直不传,要么一直都传)
|
||||
// markerOptions.setTime(Double.valueOf(preData.getSatelliteTime() * 1000).longValue());
|
||||
markerOptions.setColor("#90ABCAFF");
|
||||
@@ -231,12 +233,12 @@ public class ObjectUtils {
|
||||
return classID.getNumber();
|
||||
}
|
||||
|
||||
private static float getPredictionHeading(Prediction2025.mPredictionObjectApp preData) {
|
||||
private static MogoLocation getPreLocation(Prediction2025.mPredictionObjectApp preData) {
|
||||
List<geometry.Geometry.Point> pointList = preData.getPredictionTrajectoryList().get(0).getTrajectoryPointsList();
|
||||
if (pointList.size() >= 2) {
|
||||
return (float) DrivingDirectionUtils.getLineAngle(pointList.get(0).getX(), pointList.get(0).getY(), pointList.get(1).getX(), pointList.get(1).getY());
|
||||
return LocationUtils.INSTANCE.generateLocation(pointList.get(0).getX(), pointList.get(0).getY(), pointList.get(1).getX(), pointList.get(1).getY());
|
||||
} else {
|
||||
return 0;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user