Merge branch 'dev_arch_opt_3.0' of gitlab.zhidaoauto.com:zhjt/AndroidApp/MoGoEagleEye into dev_arch_opt_3.0
This commit is contained in:
@@ -1,36 +1,22 @@
|
||||
package com.mogo.eagle.core.function.datacenter.autopilot.adapter;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_DEVA;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.eagle.core.data.constants.MoGoConfig;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotCarConfigListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssInfoListener;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotCarConfigListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssInfoListenerManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager;
|
||||
import com.mogo.eagle.core.function.call.bindingcar.CallerBindingcarManager;
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import chassis.Chassis;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
public class MoGoHandAdasMsgManager implements
|
||||
IMoGoAutopilotCarConfigListener,
|
||||
IMoGoChassisGnssInfoListener,
|
||||
IMoGoChassisLamplightListener {
|
||||
IMoGoAutopilotCarConfigListener{
|
||||
|
||||
private final String TAG = "AdasEventManager";
|
||||
|
||||
@@ -39,8 +25,6 @@ public class MoGoHandAdasMsgManager implements
|
||||
|
||||
private MoGoHandAdasMsgManager(Context context) {
|
||||
CallerAutopilotCarConfigListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerChassisGnssInfoListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerChassisLamplightListenerManager.INSTANCE.addListener(TAG, this);
|
||||
mContext = context;
|
||||
}
|
||||
|
||||
@@ -55,13 +39,6 @@ public class MoGoHandAdasMsgManager implements
|
||||
return moGoHandAdasMsgManager;
|
||||
}
|
||||
|
||||
private int turnLightTimes = 0;
|
||||
private boolean isOnTurnLight = false;
|
||||
private int turnLight = 0;
|
||||
private volatile boolean isShowTurnLight = false;
|
||||
private int brakeLight = -1;
|
||||
|
||||
|
||||
public void getConfig() {
|
||||
com.elegant.utils.UiThreadHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
@@ -71,51 +48,6 @@ public class MoGoHandAdasMsgManager implements
|
||||
}, 0);
|
||||
}
|
||||
|
||||
private int setTurnLightState(int turn_light) {
|
||||
if (turn_light == 0) {
|
||||
if (isOnTurnLight) {
|
||||
if (turnLightTimes >= 10) {
|
||||
isOnTurnLight = false;
|
||||
turnLight = 0;
|
||||
}
|
||||
turnLightTimes++;
|
||||
}
|
||||
} else if (turn_light == 1) {
|
||||
turnLightTimes = 0;
|
||||
isOnTurnLight = true;
|
||||
turnLight = 1;
|
||||
} else if (turn_light == 2) {
|
||||
turnLightTimes = 0;
|
||||
isOnTurnLight = true;
|
||||
turnLight = 2;
|
||||
}
|
||||
return turnLight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotLightSwitchData(Chassis.LightSwitch lightSwitch) {
|
||||
// TODO @李小鹏 这里需要修改为:由HMI 监听数据变换来更新UI,而不是由数据驱动UI
|
||||
//can数据转发 转向灯状态 0是正常 1是左转 2是右转
|
||||
// if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示
|
||||
if (lightSwitch != null) {
|
||||
int state = setTurnLightState(lightSwitch.getNumber());
|
||||
CallerLogger.INSTANCE.d(M_DEVA + "TurnLight", "---onAutopilotLightSwitchData ---state = " + state + "---lightSwitch.getNumber() = " + lightSwitch.getNumber());
|
||||
if (state == 1 || state == 2) {
|
||||
isShowTurnLight = true;
|
||||
CallerHmiManager.INSTANCE.showBrakeLight(0);
|
||||
} else {
|
||||
isShowTurnLight = false;
|
||||
}
|
||||
CallerHmiManager.INSTANCE.showTurnLight(state);
|
||||
}
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotBrakeLightData(boolean brakeLight) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotCarConfig(@NotNull MessagePad.CarConfigResp carConfigResp) {
|
||||
if (carConfigResp != null && !TextUtils.isEmpty(carConfigResp.getMacAddress())) {
|
||||
@@ -124,23 +56,5 @@ public class MoGoHandAdasMsgManager implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotCarStateData(@Nullable MessagePad.GnssInfo gnssInfo) {
|
||||
//根据加速度判断 是否刹车
|
||||
// if (!AppIdentityModeUtils.isBus(FunctionBuildConfig.appIdentityMode)) { //小巴不展示
|
||||
if (gnssInfo != null) {
|
||||
//设置刹车信息
|
||||
if (gnssInfo.getAcceleration() < SharedPrefsMgr.getInstance(mContext).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD, -2.5F)) {
|
||||
brakeLight = 1;
|
||||
} else {
|
||||
brakeLight = 0;
|
||||
}
|
||||
CallerLogger.INSTANCE.d(M_DEVA + "BrakeLight", "---onAutopilotLightSwitchData ---Acceleration = " + gnssInfo.getAcceleration() + "-- brakeLight = " + brakeLight);
|
||||
if (!isShowTurnLight) {
|
||||
CallerHmiManager.INSTANCE.showBrakeLight(brakeLight);
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,9 +4,7 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBindingcarDialog
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showBrakeLight
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showModifyBindingcarDialog
|
||||
import com.mogo.eagle.core.function.call.hmi.CallerHmiManager.showTurnLight
|
||||
|
||||
/**
|
||||
* 绑定车辆
|
||||
|
||||
@@ -1453,39 +1453,10 @@ class MoGoHmiFragment : MvpFragment<MoGoHmiContract.View?, HmiPresenter?>(),
|
||||
}
|
||||
}
|
||||
|
||||
private var isBrake: Boolean = false
|
||||
|
||||
/**
|
||||
* 显示刹车效果
|
||||
*/
|
||||
override fun showBrakeLight(light: Int) {
|
||||
if (HmiBuildConfig.isShowBrakeLightView) {
|
||||
ThreadUtils.runOnUiThread {
|
||||
if (light == 1) { //刹车灯亮
|
||||
if (!isBrake) {
|
||||
isBrake = true
|
||||
CallerLogger.d(
|
||||
"${SceneConstant.M_DEVA}${"BrakeLight"}",
|
||||
" showBrakeLight light = 1 "
|
||||
)
|
||||
CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(0, 500)
|
||||
}
|
||||
} else {
|
||||
if (isBrake) {//默认 不亮灯
|
||||
isBrake = false
|
||||
CallerLogger.d(
|
||||
"${SceneConstant.M_DEVA}${"BrakeLight"}",
|
||||
" showBrakeLight light != 1 "
|
||||
)
|
||||
CallerMapUIServiceManager.getMapUIController()?.setCarLightsType(3, 500)
|
||||
}
|
||||
}
|
||||
|
||||
// brakeView?.let {
|
||||
// brakeView.setBrakeLight(light)
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private var modifyBindingCarDialog: ModifyBindingCarDialog? = null
|
||||
|
||||
@@ -1,359 +0,0 @@
|
||||
package com.mogo.eagle.core.function.map;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_MAP;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.commons.mvp.MvpFragment;
|
||||
import com.mogo.eagle.core.data.constants.MoGoFragmentPaths;
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener;
|
||||
import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider;
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener;
|
||||
import com.mogo.eagle.core.function.business.MapPointCloudSubscriber;
|
||||
import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber;
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerHDMapManager;
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager;
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager;
|
||||
import com.mogo.eagle.core.function.overview.ViewModelExtKt;
|
||||
import com.mogo.eagle.core.function.overview.vm.OverViewModel;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoUiSettings;
|
||||
import com.mogo.map.MogoMapView;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi;
|
||||
import com.zhidaoauto.map.sdk.open.business.PointCloudHelper;
|
||||
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @since 2021-11-09
|
||||
* 高精度地图层UI
|
||||
* <p>
|
||||
* 地图图层,地图操作都在这个图层完成
|
||||
*/
|
||||
@Route(path = MoGoFragmentPaths.PATH_FRAGMENT_MAP)
|
||||
public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
implements MapView, IMoGoMapFragmentProvider, IMoGoSkinModeChangeListener {
|
||||
|
||||
private static final String TAG = "MapFragment";
|
||||
|
||||
private MogoMapView mMogoMapView;
|
||||
private IMogoMap mMogoMap;
|
||||
|
||||
private final boolean mIsControllerByOthersStatus = false;
|
||||
|
||||
@Override
|
||||
protected int getLayoutId() {
|
||||
return R.layout.module_map_fragment_map;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTagName() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stepInVrMode(boolean isDayMode) {
|
||||
try {
|
||||
if (mMogoMapView != null
|
||||
&& mMogoMapView.getMap() != null
|
||||
&& mMogoMapView.getMap().getUIController() != null) {
|
||||
mMogoMapView.getMap().getUIController().stepInVrMode(isDayMode);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Context context) {
|
||||
// do not implement
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initViews(Bundle savedInstanceState) {
|
||||
super.initViews(savedInstanceState);
|
||||
mMogoMapView = findViewById(R.id.module_map_id_map);
|
||||
mMogoMapView.onCreate(savedInstanceState);
|
||||
mMogoMap = mMogoMapView.getMap();
|
||||
if (mMogoMap != null) {
|
||||
mMogoMap.getUIController().showMyLocation(true);
|
||||
}
|
||||
// 添加换肤监听
|
||||
CallerSkinModeListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerPlanningRottingListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected MapPresenter createPresenter() {
|
||||
return new MapPresenter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
initMapView();
|
||||
queryInfStructure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView.onSaveInstanceState(outState);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (mIsControllerByOthersStatus) {
|
||||
return;
|
||||
}
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView.onPause();
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (mIsControllerByOthersStatus) {
|
||||
return;
|
||||
}
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView.onResume();
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLowMemory() {
|
||||
super.onLowMemory();
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView.onLowMemory();
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null");
|
||||
}
|
||||
}
|
||||
|
||||
private void initMapView() {
|
||||
mMogoMap = mMogoMapView.getMap();
|
||||
if (mMogoMap == null) {
|
||||
return;
|
||||
}
|
||||
IMogoUiSettings uiSettings = mMogoMap.getUiSettings();
|
||||
if (uiSettings != null) {
|
||||
//设置所有手势是否可用
|
||||
uiSettings.setAllGesturesEnabled(true);
|
||||
//设置指南针是否可见。
|
||||
uiSettings.setCompassEnabled(false);
|
||||
//设置室内地图楼层切换控件是否可见。
|
||||
uiSettings.setIndoorSwitchEnabled(true);
|
||||
//设置定位按钮是否可见。
|
||||
uiSettings.setMyLocationButtonEnabled(false);
|
||||
//设置旋转手势是否可用。
|
||||
uiSettings.setRotateGesturesEnabled(false);
|
||||
//设置比例尺控件是否可见
|
||||
uiSettings.setScaleControlsEnabled(true);
|
||||
//设置拖拽手势是否可用。
|
||||
uiSettings.setScrollGesturesEnabled(true);
|
||||
//设置倾斜手势是否可用。
|
||||
uiSettings.setTiltGesturesEnabled(true);
|
||||
//设置缩放按钮是否可见。
|
||||
uiSettings.setZoomControlsEnabled(false);
|
||||
//设置双指缩放手势是否可用。
|
||||
uiSettings.setZoomGesturesEnabled(true);
|
||||
}
|
||||
|
||||
// TODO 临时初始化地图监听工控机、OBU等数据监听器,用于感知元素绘制
|
||||
MapIdentifySubscriber.Companion.getInstance();
|
||||
MogoRouteOverlayManager.getInstance().init();
|
||||
MapPointCloudSubscriber.Companion.getInstance();
|
||||
}
|
||||
|
||||
private void queryInfStructure() {
|
||||
OverViewModel viewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class);
|
||||
// viewModel.getInfStructures().observe(this.getViewLifecycleOwner(), infrastructures -> {
|
||||
// if (isFirst) {
|
||||
// for (Infrastructure entity : infrastructures) {
|
||||
// Double lat = Double.parseDouble(entity.getLat());
|
||||
// Double lon = Double.parseDouble(entity.getLon());
|
||||
// if (lat < 0 || lat > 90 || lon < 0 || lon > 180) {
|
||||
// continue;
|
||||
// }
|
||||
// String geoHash = GeoHash.withCharacterPrecision(lat, lon, 7).toBase32();
|
||||
// viewModel.updateGeoHash(entity.getId(), geoHash);
|
||||
// }
|
||||
// isFirst = false;
|
||||
// }
|
||||
// });
|
||||
|
||||
viewModel.getInfStructuresMap().observe(this.getViewLifecycleOwner(), InfStructureManager.INSTANCE::saveData);
|
||||
viewModel.fetchInfStructures();
|
||||
}
|
||||
|
||||
private final IMoGoPlanningRottingListener moGoAutopilotPlanningListener = new IMoGoPlanningRottingListener() {
|
||||
|
||||
@Override
|
||||
public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp globalPathResp) {
|
||||
UiThreadHandler.post(() -> {
|
||||
InfStructureManager.INSTANCE.savePlanningData(globalPathResp.getWayPointsList());
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public IMogoMapUIController getUIController() {
|
||||
return mMogoMap.getUIController();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
CallerSkinModeListenerManager.INSTANCE.removeListener(TAG);
|
||||
CallerPlanningRottingListenerManager.INSTANCE.removeListener(TAG);
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView.onDestroy();
|
||||
mMogoMapView = null;
|
||||
mMogoMap = null;
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null");
|
||||
}
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String getFunctionName() {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeMaoViewAngle(int type) {
|
||||
if (mMogoMapView != null && mMogoMapView.getMap() != null && mMogoMapView.getMap().getUIController() != null) {
|
||||
mMogoMapView.getMap().getUIController().changeMapViewAngle(type);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeCurrentIcon(int iconId) {
|
||||
if (mMogoMapView != null && mMogoMapView.getMap() != null && mMogoMapView.getMap().getUIController() != null) {
|
||||
mMogoMapView.getMap().getUIController().changeCurrentIcon(iconId);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* sight mode
|
||||
*
|
||||
* @param mode
|
||||
*/
|
||||
public static final int SIGHT_MODE_NORMAL = 0;
|
||||
public static final int SIGHT_MODE_TOP = 1;
|
||||
public static final int SIGHT_MODE_BACK = 2;
|
||||
public static final int SIGHT_MODE_CROSS = 3;
|
||||
public static final int SIGHT_MODE_FAR = 4;
|
||||
|
||||
@Override
|
||||
public void setMapDAngle(int mode) {
|
||||
float angle = getSightModeAngle(mode);
|
||||
if (mMogoMapView != null && mMogoMapView.getMap() != null && mMogoMapView.getMap().getUIController() != null) {
|
||||
mMogoMapView.getMap().getUIController().setMapDAngle(angle);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null");
|
||||
}
|
||||
}
|
||||
|
||||
private float getSightModeAngle(int mode) {
|
||||
float angle = 0.0f;
|
||||
switch (mode) {
|
||||
case SIGHT_MODE_NORMAL:
|
||||
angle = 16.5f;
|
||||
case SIGHT_MODE_TOP:
|
||||
angle = 16.5f;
|
||||
case SIGHT_MODE_BACK:
|
||||
angle = 16.5f;
|
||||
case SIGHT_MODE_CROSS:
|
||||
angle = 16.5f;
|
||||
case SIGHT_MODE_FAR:
|
||||
angle = 16.5f;
|
||||
}
|
||||
return angle;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public CenterLine getCenterLineInfo(double lon, double lat, float angle) {
|
||||
if (mMogoMapView != null && mMogoMapView.getMap() != null && mMogoMapView.getMap().getUIController() != null) {
|
||||
return mMogoMapView.getMap().getUIController().getCenterLineInfo(lon, lat, angle);
|
||||
} else {
|
||||
CallerLogger.INSTANCE.e(M_MAP + TAG, "mMogoMapView is null");
|
||||
return null; //上层使用应该判空
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSkinModeChange(int skinMode) {
|
||||
if (skinMode == 0) {
|
||||
CallerHDMapManager.INSTANCE.stepInVrMode(false);
|
||||
} else if (skinMode == 1) {
|
||||
CallerHDMapManager.INSTANCE.stepInVrMode(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointCloudSize(float pointCloudSize) {
|
||||
//设置点云大小
|
||||
PointCloudHelper.INSTANCE.setPointCloudSize(pointCloudSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointCloudColor(@NonNull String color) {
|
||||
// 设置点云颜色
|
||||
PointCloudHelper.INSTANCE.setPointCloudColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setIsDrawPointCloud(boolean isDrawPointCloud) {
|
||||
try {
|
||||
// 是否绘制点云
|
||||
PointCloudHelper.INSTANCE.setIsDrawPointCloud(isDrawPointCloud);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图是否是Debug模式
|
||||
* @param debugMode 是否开启Debug模式
|
||||
*/
|
||||
@Override
|
||||
public void setDebugMode(boolean debugMode) {
|
||||
MapAutoApi.INSTANCE.setDebugMode(debugMode);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,420 @@
|
||||
package com.mogo.eagle.core.function.map
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import chassis.Chassis
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.eagle.core.data.constants.MoGoConfig
|
||||
import com.mogo.eagle.core.data.constants.MoGoFragmentPaths
|
||||
import com.mogo.eagle.core.data.map.CenterLine
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisGnssInfoListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLamplightListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoPlanningRottingListener
|
||||
import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider
|
||||
import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener
|
||||
import com.mogo.eagle.core.function.business.MapPointCloudSubscriber
|
||||
import com.mogo.eagle.core.function.business.identify.MapIdentifySubscriber
|
||||
import com.mogo.eagle.core.function.business.routeoverlay.MogoRouteOverlayManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisGnssInfoListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLamplightListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerPlanningRottingListenerManager
|
||||
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.setting.CallerSkinModeListenerManager
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager
|
||||
import com.mogo.eagle.core.function.overview.InfStructureManager.savePlanningData
|
||||
import com.mogo.eagle.core.function.overview.obtainViewModel
|
||||
import com.mogo.eagle.core.function.overview.vm.OverViewModel
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.eagle.core.utilcode.util.Utils
|
||||
import com.mogo.map.IMogoMap
|
||||
import com.mogo.map.MogoMapView
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
import com.zhidaoauto.map.sdk.open.business.PointCloudHelper
|
||||
import mogo.telematics.pad.MessagePad
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @since 2021-11-09
|
||||
* 高精度地图层UI
|
||||
*
|
||||
*
|
||||
* 地图图层,地图操作都在这个图层完成
|
||||
*/
|
||||
@Route(path = MoGoFragmentPaths.PATH_FRAGMENT_MAP)
|
||||
class MapFragment : MvpFragment<MapView?, MapPresenter?>(),
|
||||
MapView,
|
||||
IMoGoMapFragmentProvider,
|
||||
IMoGoSkinModeChangeListener,
|
||||
IMoGoChassisGnssInfoListener,
|
||||
IMoGoPlanningRottingListener,
|
||||
IMoGoChassisLamplightListener {
|
||||
|
||||
private var mMogoMapView: MogoMapView? = null
|
||||
private var mMogoMap: IMogoMap? = null
|
||||
private val mIsControllerByOthersStatus = false
|
||||
|
||||
companion object {
|
||||
val functionName = "MapFragment"
|
||||
|
||||
/**
|
||||
* sight mode
|
||||
*
|
||||
* @param mode
|
||||
*/
|
||||
const val SIGHT_MODE_NORMAL = 0
|
||||
const val SIGHT_MODE_TOP = 1
|
||||
const val SIGHT_MODE_BACK = 2
|
||||
const val SIGHT_MODE_CROSS = 3
|
||||
const val SIGHT_MODE_FAR = 4
|
||||
}
|
||||
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.module_map_fragment_map
|
||||
}
|
||||
|
||||
override fun getTagName(): String {
|
||||
return Companion.functionName
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
|
||||
}
|
||||
|
||||
override fun stepInVrMode(isDayMode: Boolean) {
|
||||
try {
|
||||
if (mMogoMapView != null && mMogoMapView!!.map != null && mMogoMapView!!.map.uiController != null) {
|
||||
mMogoMapView!!.map.uiController.stepInVrMode(isDayMode)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun init(context: Context) {
|
||||
// do not implement
|
||||
}
|
||||
|
||||
override fun initViews(savedInstanceState: Bundle?) {
|
||||
super.initViews(savedInstanceState)
|
||||
mMogoMapView = findViewById(R.id.module_map_id_map)
|
||||
mMogoMapView!!.onCreate(savedInstanceState)
|
||||
mMogoMap = mMogoMapView!!.map
|
||||
if (mMogoMap != null) {
|
||||
mMogoMap!!.uiController.showMyLocation(true)
|
||||
}
|
||||
// 添加换肤监听
|
||||
CallerSkinModeListenerManager.addListener(Companion.functionName, this)
|
||||
CallerPlanningRottingListenerManager.addListener(Companion.functionName, this)
|
||||
CallerChassisGnssInfoListenerManager.addListener(Companion.functionName, this)
|
||||
CallerChassisLamplightListenerManager.addListener(Companion.functionName, this)
|
||||
}
|
||||
|
||||
override fun createPresenter(): MapPresenter {
|
||||
return MapPresenter(this)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
initMapView()
|
||||
queryInfStructure()
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView!!.onSaveInstanceState(outState)
|
||||
} else {
|
||||
e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
if (mIsControllerByOthersStatus) {
|
||||
return
|
||||
}
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView!!.onPause()
|
||||
} else {
|
||||
e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (mIsControllerByOthersStatus) {
|
||||
return
|
||||
}
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView!!.onResume()
|
||||
} else {
|
||||
e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null")
|
||||
}
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView!!.onLowMemory()
|
||||
} else {
|
||||
e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null")
|
||||
}
|
||||
}
|
||||
|
||||
private fun initMapView() {
|
||||
mMogoMap = mMogoMapView!!.map
|
||||
if (mMogoMap == null) {
|
||||
return
|
||||
}
|
||||
val uiSettings = mMogoMap!!.uiSettings
|
||||
if (uiSettings != null) {
|
||||
//设置所有手势是否可用
|
||||
uiSettings.setAllGesturesEnabled(true)
|
||||
//设置指南针是否可见。
|
||||
uiSettings.setCompassEnabled(false)
|
||||
//设置室内地图楼层切换控件是否可见。
|
||||
uiSettings.setIndoorSwitchEnabled(true)
|
||||
//设置定位按钮是否可见。
|
||||
uiSettings.setMyLocationButtonEnabled(false)
|
||||
//设置旋转手势是否可用。
|
||||
uiSettings.setRotateGesturesEnabled(false)
|
||||
//设置比例尺控件是否可见
|
||||
uiSettings.setScaleControlsEnabled(true)
|
||||
//设置拖拽手势是否可用。
|
||||
uiSettings.setScrollGesturesEnabled(true)
|
||||
//设置倾斜手势是否可用。
|
||||
uiSettings.setTiltGesturesEnabled(true)
|
||||
//设置缩放按钮是否可见。
|
||||
uiSettings.setZoomControlsEnabled(false)
|
||||
//设置双指缩放手势是否可用。
|
||||
uiSettings.setZoomGesturesEnabled(true)
|
||||
}
|
||||
|
||||
// TODO 临时初始化地图监听工控机、OBU等数据监听器,用于感知元素绘制
|
||||
MapIdentifySubscriber.instance
|
||||
MogoRouteOverlayManager.getInstance().init()
|
||||
MapPointCloudSubscriber.instance
|
||||
}
|
||||
|
||||
private fun queryInfStructure() {
|
||||
val viewModel = this.obtainViewModel(OverViewModel::class.java)
|
||||
// viewModel.getInfStructures().observe(this.getViewLifecycleOwner(), infrastructures -> {
|
||||
// if (isFirst) {
|
||||
// for (Infrastructure entity : infrastructures) {
|
||||
// Double lat = Double.parseDouble(entity.getLat());
|
||||
// Double lon = Double.parseDouble(entity.getLon());
|
||||
// if (lat < 0 || lat > 90 || lon < 0 || lon > 180) {
|
||||
// continue;
|
||||
// }
|
||||
// String geoHash = GeoHash.withCharacterPrecision(lat, lon, 7).toBase32();
|
||||
// viewModel.updateGeoHash(entity.getId(), geoHash);
|
||||
// }
|
||||
// isFirst = false;
|
||||
// }
|
||||
// });
|
||||
viewModel.infStructuresMap.observe(this.viewLifecycleOwner) { t -> InfStructureManager.saveData(t) }
|
||||
|
||||
viewModel.fetchInfStructures()
|
||||
}
|
||||
|
||||
override fun getUIController(): IMogoMapUIController {
|
||||
return mMogoMap!!.uiController
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
CallerSkinModeListenerManager.removeListener(Companion.functionName)
|
||||
CallerPlanningRottingListenerManager.removeListener(Companion.functionName)
|
||||
CallerChassisGnssInfoListenerManager.removeListener(Companion.functionName)
|
||||
CallerChassisLamplightListenerManager.removeListener(Companion.functionName)
|
||||
|
||||
if (mMogoMapView != null) {
|
||||
mMogoMapView!!.onDestroy()
|
||||
mMogoMapView = null
|
||||
mMogoMap = null
|
||||
} else {
|
||||
e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null")
|
||||
}
|
||||
super.onDestroyView()
|
||||
}
|
||||
|
||||
override fun changeMaoViewAngle(type: Int) {
|
||||
if (mMogoMapView != null && mMogoMapView!!.map != null && mMogoMapView!!.map.uiController != null) {
|
||||
mMogoMapView!!.map.uiController.changeMapViewAngle(type)
|
||||
} else {
|
||||
e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null")
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeCurrentIcon(iconId: Int) {
|
||||
if (mMogoMapView != null && mMogoMapView!!.map != null && mMogoMapView!!.map.uiController != null) {
|
||||
mMogoMapView!!.map.uiController.changeCurrentIcon(iconId)
|
||||
} else {
|
||||
e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null")
|
||||
}
|
||||
}
|
||||
|
||||
override fun setMapDAngle(mode: Int) {
|
||||
val angle = getSightModeAngle(mode)
|
||||
if (mMogoMapView != null && mMogoMapView!!.map != null && mMogoMapView!!.map.uiController != null) {
|
||||
mMogoMapView!!.map.uiController.setMapDAngle(angle)
|
||||
} else {
|
||||
e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null")
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSightModeAngle(mode: Int): Float {
|
||||
var angle = 0.0f
|
||||
when (mode) {
|
||||
SIGHT_MODE_NORMAL -> {
|
||||
angle = 16.5f
|
||||
angle = 16.5f
|
||||
angle = 16.5f
|
||||
angle = 16.5f
|
||||
angle = 16.5f
|
||||
}
|
||||
SIGHT_MODE_TOP -> {
|
||||
angle = 16.5f
|
||||
angle = 16.5f
|
||||
angle = 16.5f
|
||||
angle = 16.5f
|
||||
}
|
||||
SIGHT_MODE_BACK -> {
|
||||
angle = 16.5f
|
||||
angle = 16.5f
|
||||
angle = 16.5f
|
||||
}
|
||||
SIGHT_MODE_CROSS -> {
|
||||
angle = 16.5f
|
||||
angle = 16.5f
|
||||
}
|
||||
SIGHT_MODE_FAR -> angle = 16.5f
|
||||
}
|
||||
return angle
|
||||
}
|
||||
|
||||
override fun getCenterLineInfo(lon: Double, lat: Double, angle: Float): CenterLine? {
|
||||
return if (mMogoMapView != null && mMogoMapView!!.map != null && mMogoMapView!!.map.uiController != null) {
|
||||
mMogoMapView!!.map.uiController.getCenterLineInfo(lon, lat, angle)
|
||||
} else {
|
||||
e(SceneConstant.M_MAP + Companion.functionName, "mMogoMapView is null")
|
||||
null //上层使用应该判空
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSkinModeChange(skinMode: Int) {
|
||||
if (skinMode == 0) {
|
||||
CallerHDMapManager.stepInVrMode(false)
|
||||
} else if (skinMode == 1) {
|
||||
CallerHDMapManager.stepInVrMode(true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setPointCloudSize(pointCloudSize: Float) {
|
||||
//设置点云大小
|
||||
PointCloudHelper.setPointCloudSize(pointCloudSize)
|
||||
}
|
||||
|
||||
override fun setPointCloudColor(color: String) {
|
||||
// 设置点云颜色
|
||||
PointCloudHelper.setPointCloudColor(color)
|
||||
}
|
||||
|
||||
override fun setIsDrawPointCloud(isDrawPointCloud: Boolean) {
|
||||
try {
|
||||
// 是否绘制点云
|
||||
PointCloudHelper.setIsDrawPointCloud(isDrawPointCloud)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图是否是Debug模式
|
||||
*
|
||||
* @param debugMode 是否开启Debug模式
|
||||
*/
|
||||
override fun setDebugMode(debugMode: Boolean) {
|
||||
MapAutoApi.setDebugMode(debugMode)
|
||||
}
|
||||
|
||||
override val functionName: String
|
||||
get() = functionName
|
||||
|
||||
override fun onAutopilotRotting(globalPathResp: MessagePad.GlobalPathResp?) {
|
||||
UiThreadHandler.post { savePlanningData(globalPathResp!!.wayPointsList) }
|
||||
}
|
||||
|
||||
private var turnLightTimes = 0
|
||||
private var isOnTurnLight = false
|
||||
private var turnLight = 0
|
||||
|
||||
private var isShowTurnLight = false
|
||||
private var brakeLight = -1
|
||||
|
||||
override fun onAutopilotCarStateData(gnssInfo: MessagePad.GnssInfo?) {
|
||||
if (gnssInfo != null) {
|
||||
//设置刹车信息
|
||||
if (gnssInfo.acceleration < SharedPrefsMgr.getInstance(Utils.getApp()).getFloat(MoGoConfig.BRAKE_ACCELERATION_THRESHOLD, -2.5f)) {
|
||||
brakeLight = 1
|
||||
} else {
|
||||
brakeLight = 0
|
||||
}
|
||||
d(SceneConstant.M_DEVA + "BrakeLight", "---onAutopilotLightSwitchData ---Acceleration = " + gnssInfo.acceleration + "-- brakeLight = " + brakeLight)
|
||||
if (!isShowTurnLight) {
|
||||
showBrakeLight(brakeLight)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotLightSwitchData(lightSwitch: Chassis.LightSwitch?) {
|
||||
//can数据转发 转向灯状态 0是正常 1是左转 2是右转
|
||||
if (lightSwitch != null) {
|
||||
val state: Int = setTurnLightState(lightSwitch.number)
|
||||
d(SceneConstant.M_DEVA + "TurnLight", "---onAutopilotLightSwitchData ---state = " + state + "---lightSwitch.getNumber() = " + lightSwitch.number)
|
||||
if (state == 1 || state == 2) {
|
||||
isShowTurnLight = true
|
||||
showBrakeLight(0)
|
||||
} else {
|
||||
isShowTurnLight = false
|
||||
}
|
||||
showTurnLight(state)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutopilotBrakeLightData(brakeLight: Boolean) {
|
||||
d(SceneConstant.M_DEVA + "TurnLight", "---onAutopilotBrakeLightData ---brakeLight = $brakeLight")
|
||||
|
||||
}
|
||||
|
||||
private fun setTurnLightState(turn_light: Int): Int {
|
||||
if (turn_light == 0) {
|
||||
if (isOnTurnLight) {
|
||||
if (turnLightTimes >= 10) {
|
||||
isOnTurnLight = false
|
||||
turnLight = 0
|
||||
}
|
||||
turnLightTimes++
|
||||
}
|
||||
} else if (turn_light == 1) {
|
||||
turnLightTimes = 0
|
||||
isOnTurnLight = true
|
||||
turnLight = 1
|
||||
} else if (turn_light == 2) {
|
||||
turnLightTimes = 0
|
||||
isOnTurnLight = true
|
||||
turnLight = 2
|
||||
}
|
||||
return turnLight
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user