[dev_arch_opt_3.0]

[Change]
[
1、修改了高精地图的设置外部坐标的方法
2、修改了基础、出租车、Bus小地图中的位置回调,使用IMoGoChassisLocationGCJ02Listener。
3、TODO 有些需要高德地图的地方需要改为使用IMoGoChassisLocationGCJ02Listener,WGS84的坐标使用IMoGoChassisLocationWGS84Listener
]

Signed-off-by: donghongyu <donghongyu@zhidaoauto.com>
This commit is contained in:
donghongyu
2023-01-13 17:44:04 +08:00
parent 1f3a71e782
commit dd8428fb97
15 changed files with 171 additions and 244 deletions

View File

@@ -23,6 +23,8 @@ import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListener
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBrakeLight
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showTurnLight
import com.mogo.eagle.core.function.call.map.CallerHDMapManager
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager
import com.mogo.eagle.core.function.overview.InfStructureManager
import com.mogo.eagle.core.function.overview.InfStructureManager.savePlanningData
@@ -362,6 +364,9 @@ class MapFragment : MvpFragment<MapView?, MapPresenter?>(),
private var brakeLight = -1
override fun onChassisLocationWGS84(gnssInfo: MessagePad.GnssInfo?) {
// 跟新地图控件
mMogoMapView?.setExtraGPSData(gnssInfo)
if (gnssInfo != null) {
//设置刹车信息
if (gnssInfo.acceleration < SharedPrefsMgr.getInstance(Utils.getApp()).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD, -2.5f)) {

View File

@@ -31,12 +31,11 @@ import com.amap.api.maps.model.Polyline;
import com.amap.api.maps.model.PolylineOptions;
import com.mogo.eagle.core.data.config.FunctionBuildConfig;
import com.mogo.eagle.core.data.map.Infrastructure;
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.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.map.R;
import com.mogo.eagle.core.function.overview.InfStructureManager;
import com.mogo.eagle.core.function.overview.remote.Center;
@@ -64,7 +63,7 @@ import mogo.telematics.pad.MessagePad;
*/
public class AMapCustomView
extends RelativeLayout
implements IMoGoMapLocationListener {
implements IMoGoChassisLocationGCJ02Listener {
public static final String TAG = "AMapCustomView";
private TextureMapView mAMapView;
private AMap mAMap;
@@ -93,7 +92,7 @@ public class AMapCustomView
private List<BitmapDescriptor> textureList = new ArrayList<>();
private List<Integer> texIndexList = new ArrayList<>();
private MogoLocation mLocation;
private MessagePad.GnssInfo mLocation;
private boolean isFirstLocation = true;
CustomMapStyleOptions mCustomMapStyleOptions;
@@ -133,7 +132,7 @@ public class AMapCustomView
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener);
initAMapView(context);
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this);
//设置全览模式
overLayerView.setOnClickListener(v -> {
displayCustomOverView();
@@ -300,7 +299,7 @@ public class AMapCustomView
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.removeListener(TAG);
CallerPlanningRottingListenerManager.INSTANCE.removeListener(TAG);
}
@@ -309,18 +308,6 @@ public class AMapCustomView
return false;
}
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
mLocation = location;
MarkerDrawerManager.INSTANCE.setLonLat(new Pair(location.getLongitude(), location.getLatitude()));
drawCarMarker(location);
if (isFirstLocation) {
displayCustomOverView();
isFirstLocation = false;
}
}
public void onCreateView(Bundle savedInstanceState) {
if (mAMapView != null) {
mAMapView.onCreate(savedInstanceState);
@@ -435,7 +422,6 @@ public class AMapCustomView
*/
private void displayCustomOverView() {
ArrayList<LatLng> linePointsLatLng = MarkerDrawerManager.INSTANCE.getPlanningPoints();
MogoLocation location = mLocation;
if (linePointsLatLng.size() > 1) {
//圈定地图显示范围
//存放经纬度
@@ -443,7 +429,7 @@ public class AMapCustomView
for (int i = 0; i < linePointsLatLng.size(); i++) {
boundsBuilder.include(linePointsLatLng.get(i));
}
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
LatLng currentLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
boundsBuilder.include(currentLatLng);
CameraPosition cameraPosition = new CameraPosition.Builder().tilt(mTilt).build();
@@ -463,15 +449,15 @@ public class AMapCustomView
*
* @param location
*/
private void drawCarMarker(MogoLocation location) {
private void drawCarMarker(MessagePad.GnssInfo location) {
if (location == null) return;
if (mCarMarker != null) {
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
mCarMarker.setRotateAngle(360 - location.getBearing());
mCarMarker.setRotateAngle((float) (360 - location.getHeading()));
mCarMarker.setPosition(currentLatLng);
mCarMarker.setToTop();
if (mCompassMarker != null) {
mCompassMarker.setRotateAngle(360 - location.getBearing());
mCompassMarker.setRotateAngle((float) (360 - location.getHeading()));
mCompassMarker.setPosition(currentLatLng);
}
}
@@ -539,4 +525,15 @@ public class AMapCustomView
}
}
}
@Override
public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) {
mLocation = gnssInfo;
MarkerDrawerManager.INSTANCE.setLonLat(new Pair(gnssInfo.getLongitude(), gnssInfo.getLatitude()));
drawCarMarker(gnssInfo);
if (isFirstLocation) {
displayCustomOverView();
isFirstLocation = false;
}
}
}

View File

@@ -32,9 +32,8 @@ import com.amap.api.maps.model.PolylineOptions;
import com.mogo.cloud.commons.utils.CoordinateUtils;
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.function.api.map.listener.IMoGoMapLocationListener;
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener;
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager;
import com.mogo.eagle.core.function.map.R;
import com.mogo.eagle.core.function.smp.view.ISmallMapDirectionView;
import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils;
@@ -48,6 +47,8 @@ import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import mogo.telematics.pad.MessagePad;
/**
* 小地图的方向View
*
@@ -56,7 +57,7 @@ import java.util.TimerTask;
*/
public class SmallMapDirectionView
extends RelativeLayout
implements IMoGoMapLocationListener, ISmallMapDirectionView {
implements IMoGoChassisLocationGCJ02Listener, ISmallMapDirectionView {
//小地图名称
public static final String TAG = "SmallMapDirectionView";
@@ -74,7 +75,7 @@ public class SmallMapDirectionView
private Polyline mPolyline;
private CameraUpdate mCameraUpdate;
private Context mContext;
private MogoLocation mLocation;
private MessagePad.GnssInfo mLocation;
public SmallMapDirectionView(Context context) {
this(context, null);
@@ -104,7 +105,7 @@ public class SmallMapDirectionView
initAMapView();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.addListener(TAG, this);
startTask();
}
@@ -117,7 +118,7 @@ public class SmallMapDirectionView
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
// 注册定位监听
CallerMapLocationListenerManager.INSTANCE.removeListener(TAG, false);
CallerChassisLocationGCJ20ListenerManager.INSTANCE.removeListener(TAG);
}
private void initAMapView() {
@@ -130,11 +131,11 @@ public class SmallMapDirectionView
// 关闭显示实时路况图层aMap是地图控制器对象。
mAMap.setTrafficEnabled(false);
// 设置 锚点 图标
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)){
if (AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) {
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon))
.anchor(0.5f, 0.5f));
}else{
} else {
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon))
.anchor(0.5f, 0.5f));
@@ -177,30 +178,28 @@ public class SmallMapDirectionView
return true;
}
@Override
public void onLocationChanged(@org.jetbrains.annotations.Nullable MogoLocation location, int from, boolean isGps) {
if (location == null) {
public void onChassisLocationGCJ02(@Nullable MessagePad.GnssInfo gnssInfo) {
if (gnssInfo == null) {
return;
}
mLocation = location;
mLocation = gnssInfo;
}
private class UpdateLocationTask extends TimerTask {
@Override
public void run() {
if (mLocation != null) {
MogoLocation location = mLocation;
if (mCarMarker == null){
if (mCarMarker == null) {
mCarMarker = mAMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_my_location_logo))
.anchor(0.5f, 0.5f));
}
if(mCarMarker == null){
if (mCarMarker == null) {
return;
}
LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude());
float bearing = (float) Math.floor(location.getBearing());
LatLng currentLatLng = new LatLng(mLocation.getLatitude(), mLocation.getLongitude());
float bearing = (float) Math.floor(mLocation.getHeading());
//更新车辆位置
mCarMarker.setPosition(currentLatLng);