diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.java index 80daca40c3..6f1e3c704a 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/map/MapFragment.java @@ -12,7 +12,6 @@ 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.data.map.Infrastructure; import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; import com.mogo.eagle.core.function.api.map.hd.IMoGoMapFragmentProvider; import com.mogo.eagle.core.function.api.setting.IMoGoSkinModeChangeListener; @@ -30,11 +29,8 @@ import com.mogo.map.uicontroller.IMogoMapUIController; import com.zhidaoauto.map.sdk.open.MapAutoApi; import com.zhidaoauto.map.sdk.open.business.PointCloudHelper; -import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import ch.hsr.geohash.GeoHash; import mogo.telematics.pad.MessagePad; /** @@ -96,6 +92,7 @@ public class MapFragment extends MvpFragment } // 添加换肤监听 CallerSkinModeListenerManager.INSTANCE.addListener(TAG, this); + CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); } @NonNull @@ -212,6 +209,17 @@ public class MapFragment extends MvpFragment viewModel.fetchInfStructures(); } + private final IMoGoAutopilotPlanningListener moGoAutopilotPlanningListener = new IMoGoAutopilotPlanningListener() { + + @Override + public void onAutopilotRotting(@Nullable MessagePad.GlobalPathResp globalPathResp) { + InfStructureManager.INSTANCE.savePlanningData(globalPathResp.getWayPointsList()); + } + + @Override + public void onAutopilotTrajectory(@NonNull List trajectoryInfos) {} + }; + @Override public IMogoMapUIController getUIController() { return mMogoMap.getUIController(); diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt index b249f7d1df..b355165c92 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/overview/InfStructureManager.kt @@ -1,6 +1,7 @@ package com.mogo.eagle.core.function.overview import com.mogo.eagle.core.data.map.Infrastructure +import mogo.telematics.pad.MessagePad /** * 本地数据库查询出来的红绿灯、摄像头等数据 @@ -17,6 +18,10 @@ object InfStructureManager { HashMap>() } + private val _planningList by lazy { + ArrayList() + } + fun saveData(map: HashMap>) { if (_infMap.isNotEmpty()) { _infMap.clear() @@ -34,4 +39,13 @@ object InfStructureManager { } fun getPathData(): Map> = _pathMap + + fun savePlanningData(planningList: List) { + if (_planningList.isNotEmpty()) { + _planningList.clear() + } + _planningList.addAll(planningList) + } + + fun getPlanningData() = _planningList } \ No newline at end of file diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java index 41b6c130dc..96aca1cc99 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/AMapCustomView.java @@ -12,7 +12,6 @@ import android.view.View; import android.widget.RelativeLayout; import android.widget.TextView; -import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.amap.api.maps.AMap; @@ -30,43 +29,18 @@ import com.amap.api.maps.model.Marker; import com.amap.api.maps.model.MarkerOptions; import com.amap.api.maps.model.Polyline; import com.amap.api.maps.model.PolylineOptions; -import com.amap.api.navi.AMapNaviListener; -import com.amap.api.navi.AMapNaviViewListener; -import com.amap.api.navi.model.AMapCalcRouteResult; -import com.amap.api.navi.model.AMapLaneInfo; -import com.amap.api.navi.model.AMapModelCross; -import com.amap.api.navi.model.AMapNaviCameraInfo; -import com.amap.api.navi.model.AMapNaviCross; -import com.amap.api.navi.model.AMapNaviLocation; -import com.amap.api.navi.model.AMapNaviPathGroup; -import com.amap.api.navi.model.AMapNaviRouteNotifyData; -import com.amap.api.navi.model.AMapNaviTrafficFacilityInfo; -import com.amap.api.navi.model.AMapServiceAreaInfo; -import com.amap.api.navi.model.AimLessModeCongestionInfo; -import com.amap.api.navi.model.AimLessModeStat; -import com.amap.api.navi.model.NaviInfo; -import com.amap.api.navi.model.NaviLatLng; -import com.amap.api.navi.model.NaviPoi; -import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; import com.mogo.eagle.core.data.config.FunctionBuildConfig; import com.mogo.eagle.core.data.map.Infrastructure; -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; -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.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.smp.view.ISmallMapDirectionView; import com.mogo.eagle.core.utilcode.mogo.AppIdentityModeUtils; import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.zhidaoauto.map.sdk.open.query.LonLatPoint; -import com.zhidaoauto.map.sdk.open.tools.MapTools; import org.jetbrains.annotations.NotNull; @@ -78,8 +52,6 @@ import java.util.Map; import ch.hsr.geohash.GeoHash; import kotlin.Pair; import mogo.telematics.pad.MessagePad; -import mogo_msg.MogoReportMsg; -import system_master.SystemStatusInfo; /** * 小地图的方向View @@ -90,22 +62,14 @@ import system_master.SystemStatusInfo; */ public class AMapCustomView extends RelativeLayout - implements IMoGoMapLocationListener, ISmallMapDirectionView, AMapNaviListener, AMapNaviViewListener { + implements IMoGoMapLocationListener { public static final String TAG = "AMapCustomView"; private TextureMapView mAMapView; private AMap mAMap; - protected NaviLatLng mStartLatlng = new NaviLatLng(); - protected NaviLatLng mEndLatlng = new NaviLatLng(); - protected final List sList = new ArrayList(); - protected final List eList = new ArrayList(); private int zoomLevel = 15; - private final List mCoordinatesLatLng = new ArrayList<>(); - private final List mCoordinatesLatLngCurrent = new ArrayList<>(); - protected List mWayPointList = new ArrayList(); - private Polyline mPolyline; private CameraUpdate mCameraUpdate; private Context mContext; - private float tilt = 30f; + private float mTilt = 60f; private TextView overLayerView; private boolean calculate = false; @@ -113,17 +77,13 @@ public class AMapCustomView private Map> pathMap = new HashMap(); private Map> posInfMap = new HashMap(); - // 独立路径导航 - private NaviPoi mStartPoi = null; - private NaviPoi mEndPoi = null; - private AMapNaviPathGroup mIndependentPathGroup = null; - private List mIndependentPointList = new ArrayList<>(); - // =============绘制轨迹线相关============= private Marker mCarMarker; + private Marker mCompassMarker; private Marker mStartMarker; private Marker mEndMarker; - private Polyline mCustomPolyline; + private Polyline mBottomPolyline; + private Polyline mCoveredPolyline; // 计算索引并设置对应的Bitmap BitmapDescriptor arrivedBitmap; BitmapDescriptor unArrivedBitmap; @@ -160,21 +120,18 @@ public class AMapCustomView overLayerView.setBackground(getResources().getDrawable(R.drawable.amap_reset)); arrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.arrow_arrived_img); unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_smooth_route); -// unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.amap_custom_smooth_route); } else { overLayerView.setBackground(getResources().getDrawable(R.drawable.amap_reset_bus)); arrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.arrow_arrived_img); unArrivedBitmap = BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_smooth_route); } - CallerAutoPilotStatusListenerManager.INSTANCE.addListener(TAG, mGoAutopilotStatusListener); CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, moGoAutopilotPlanningListener); initAMapView(context); // 注册定位监听 CallerMapLocationListenerManager.INSTANCE.addListener(TAG, this); //设置全览模式 overLayerView.setOnClickListener(v -> { -// mAMapView.displayOverview(); - CallerHmiManager.INSTANCE.hideSmallFragment(); + displayCustomOverView(); }); } @@ -229,120 +186,28 @@ public class AMapCustomView * 自定义导航View和路况状态 */ private void customOptions() { -// AMapNaviViewOptions options = mAMapView.getViewOptions(); - //关闭自动绘制路线,自行绘制路线 -// options.setAutoDrawRoute(false); - //不显示导航界面 -// options.setLayoutVisible(false); -// options.setTilt(60); -// //黑夜模式 -// options.setNaviNight(true); -// //导航全程光柱 -// options.setTrafficBarEnabled(false); -// //隐藏摄像头 -// options.setCameraBubbleShow(false); -// //转向箭头 -// options.setNaviArrowVisible(false); -// // 算路成功后自动进入全览模式 -// options.setAutoDisplayOverview(true); - //指南针 -// options.setCompassEnabled(false); -// options.setTilt((int) tilt); - //路线纹理自定义 -// RouteOverlayOptions routeOverlayOptions = new RouteOverlayOptions(); if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { - // TODO:("导航的配置需要删除") mCarMarker = mAMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_car_icon)) .anchor(0.5f, 0.5f)); - -// //自车车标 -// options.setCarBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.map_car_icon)); -// options.setFourCornersBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.amap_custom_corner)); - // 未知路段和导航路段颜色一样 -// routeOverlayOptions.setUnknownTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.amap_custom_smooth_route));//未知路段 -// routeOverlayOptions.setSmoothTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.amap_custom_smooth_route)); + mCompassMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.amap_custom_corner)) + .anchor(0.5f, 0.5f)); } else { - // TODO:("导航的配置需要删除") mCarMarker = mAMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.map_bus_icon)) .anchor(0.5f, 0.5f)); - -// options.setCarBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.map_bus_icon)); -// options.setFourCornersBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.amap_bus_corner)); -// routeOverlayOptions.setUnknownTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.amap_bus_smooth_route));//未知路段 -// routeOverlayOptions.setSmoothTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.amap_bus_smooth_route)); + mCompassMarker = mAMap.addMarker(new MarkerOptions() + .icon(BitmapDescriptorFactory.fromResource(R.drawable.amap_bus_corner)) + .anchor(0.5f, 0.5f)); } mStartMarker = mAMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_start))); mEndMarker = mAMap.addMarker(new MarkerOptions() .icon(BitmapDescriptorFactory.fromResource(R.drawable.module_small_map_view_dir_end))); - -// options.setStartPointBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.module_small_map_view_dir_start)); -// options.setWayPointBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.icon_module_small_map_four_corners)); -// options.setEndPointBitmap(BitmapFactory.decodeResource(this.getResources(), R.drawable.module_small_map_view_dir_end)); -// //与走过的路线 -// options.setAfterRouteAutoGray(true); -// routeOverlayOptions.setTurnArrowIs3D(false); -// routeOverlayOptions.setJamTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.custtexture_bad));//拥堵路段 -// routeOverlayOptions.setVeryJamTraffic(BitmapFactory.decodeResource(getResources(), R.drawable.custtexture_grayred));//超级拥堵路段 -// routeOverlayOptions.setPassRoute(BitmapFactory.decodeResource(getResources(), R.drawable.amap_custom_pass_route));//走过的路段 -// options.setRouteOverlayOptions(routeOverlayOptions); -// mAMapView.setTrafficLightsVisible(true); -// mAMapView.setViewOptions(options); } - private final IMoGoAutopilotStatusListener mGoAutopilotStatusListener = new IMoGoAutopilotStatusListener() { - - @Override - public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) { - - } - - @Override - public void onAutopilotIpcConnectStatusChanged(int status, @org.jetbrains.annotations.Nullable String reason) { - - } - - @Override - public void onAutopilotGuardian(@org.jetbrains.annotations.Nullable MogoReportMsg.MogoReportMessage guardianInfo) { - - } - - @Override - public void onAutopilotSNRequest() { - - } - - @Override - public void onAutopilotArriveAtStation(@org.jetbrains.annotations.Nullable MessagePad.ArrivalNotification arrivalNotification) { - - } - - @Override - public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) { -// ThreadUtils.runOnUiThread(() -> { -// if (autoPilotStatusInfo == null) return; -// int state = autoPilotStatusInfo.getState(); -// //0 不能自动驾驶 1 可以自动驾驶,但是在人工干预 2 自动驾驶中 -// if (state == IMoGoAutopilotStatusListener.STATUS_AUTOPILOT_RUNNING) { -//// Log.d(TAG, "自动驾驶中 state=" + String.valueOf(state)); -// if (sList.size() == 0 && eList.size() == 0 && mWayPointList.size() == 0) { -// Log.d(TAG, "sendGlobalPathReq"); -// AdasManager.getInstance().sendGlobalPathReq(); -// } -// } else { -// int type = mAMapNavi.getNaviType(); -// Log.d(TAG, "非自动驾驶状态,导航类型==" + String.valueOf(type)); -// if (type == NaviType.GPS || type == NaviType.EMULATOR) { -// mAMapNavi.stopNavi(); -// } -// } -// }); - } - }; - private final IMoGoAutopilotPlanningListener moGoAutopilotPlanningListener = new IMoGoAutopilotPlanningListener() { @Override @@ -357,77 +222,35 @@ public class AMapCustomView */ @Override public void onAutopilotRotting(@org.jetbrains.annotations.Nullable MessagePad.GlobalPathResp globalPathResp) { - if (calculate == true && sList.size() == 0 && eList.size() == 0 && mWayPointList.size() == 0) { - return; - } - calculate = true; Log.d(TAG, "onAutopilotRotting"); - List list = globalPathResp.getWayPointsList(); -// int minCount = 2; -// if (list.size() >= minCount && sList.size() == 0 && eList.size() == 0 && mWayPointList.size() == 0) { -// calculate = true; -// MessagePad.Location sLocation = (MessagePad.Location) list.get(0); -// MessagePad.Location eLocation = (MessagePad.Location) list.get(list.size() - 1); -// mStartLatlng = new NaviLatLng(sLocation.getLatitude(), sLocation.getLongitude()); -// mEndLatlng = new NaviLatLng(eLocation.getLatitude(), eLocation.getLongitude()); -// mStartPoi = new NaviPoi("", new LatLng(sLocation.getLatitude(), sLocation.getLongitude()), ""); -// mEndPoi = new NaviPoi("", new LatLng(eLocation.getLatitude(), eLocation.getLongitude()), ""); -// sList.clear(); -// eList.clear(); -// sList.add(mStartLatlng); -// eList.add(mEndLatlng); -// -// mWayPointList.clear(); -// mIndependentPointList.clear(); -// for (int i = 1; i < list.size() - minCount; i++) { -// MessagePad.Location wayLoc = (MessagePad.Location) list.get(i); -// NaviLatLng way = new NaviLatLng(wayLoc.getLatitude(), wayLoc.getLongitude()); -// NaviPoi naviPoi = new NaviPoi("", new LatLng(wayLoc.getLatitude(), wayLoc.getLongitude()), ""); -// mWayPointList.add(way); -// mIndependentPointList.add(naviPoi); -// } -// } -// int strategy = 0; -// try { -// //再次强调,最后一个参数为true时代表多路径,否则代表单路径 -// strategy = mAMapNavi.strategyConvert(true, false, false, false, false); -// } catch (Exception e) { -// e.printStackTrace(); -// } -// Log.d(TAG, "全局路径" + list.size() + ",起点:" + sList.toString() + ",终点:" + eList.toString() + ",经点:" + mWayPointList.toString()); -// //指定路径绘制导航路线 -// mAMapNavi.calculateDriveRoute(sList, eList, mWayPointList, strategy); - - // 转成高德坐标系并存储 - MarkerDrawerManager.INSTANCE.updateRoutePoints(list, mContext); - List planningPointList = MarkerDrawerManager.INSTANCE.getPlanningPoints(); - UiThreadHandler.post(() -> { - displayCustomOverView(); - drawStartAndEndMarker(planningPointList); - }); - MarkerDrawerManager.INSTANCE.setCallback((points, locIndex) -> { - UiThreadHandler.post(() -> { - // 每1s刷新一下轨迹线 - if (points.size() > 0) { - drawPolyline(points , locIndex); - } else { - clearCustomPolyline(); - } - }); - }); - MarkerDrawerManager.INSTANCE.startLoopCalCarLocation(); - UiThreadHandler.post(() -> { - drawInfrastructureMarkers(globalPathResp); - }); + handlePlanningData(globalPathResp.getWayPointsList()); } }; + public void handlePlanningData(List locationList) { + List list = locationList; + // 转成高德坐标系并存储 + MarkerDrawerManager.INSTANCE.updateRoutePoints(list, mContext); + List planningPointList = MarkerDrawerManager.INSTANCE.getPlanningPoints(); + displayCustomOverView(); + drawStartAndEndMarker(planningPointList); + MarkerDrawerManager.INSTANCE.setCallback((points, locIndex) -> { + // 每1s刷新一下轨迹线 + if (points.size() > 0) { + drawPolyline(points, locIndex); + } else { + clearCustomPolyline(); + } + }); + MarkerDrawerManager.INSTANCE.startLoopCalCarLocation(); + drawInfrastructureMarkers(locationList); + } + @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); // 注册定位监听 CallerMapLocationListenerManager.INSTANCE.removeListener(TAG); - CallerAutoPilotStatusListenerManager.INSTANCE.removeListener(TAG); CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG); } @@ -448,30 +271,6 @@ public class AMapCustomView } } - @Override - public void drawablePolyline() { - } - - @Override - public void clearPolyline() { - if (mPolyline != null) { - mPolyline.remove(); - } - } - - public void clearCustomPolyline() { - if (mCustomPolyline != null) { - mCustomPolyline.remove(); - } - } - - public void resetPolyLine() { - mCoordinatesLatLng.clear(); - if (mPolyline != null) { - mPolyline.remove(); - } - } - public void onCreateView(Bundle savedInstanceState) { if (mAMapView != null) { mAMapView.onCreate(savedInstanceState); @@ -494,310 +293,45 @@ public class AMapCustomView if (mAMapView != null) { mAMapView.onDestroy(); } -// //since 1.6.0 不再在naviview destroy的时候自动执行AMapNavi.stopNavi();请自行执行 -// if (mAMapNavi != null) { -// mAMapNavi.stopNavi(); -// mAMapNavi.destroy(); -// } + if (mAMapView != null) { mAMapView.onDestroy(); } } - public void convert(List coordinates) { - - } - - //多路径算路成功回调 - @Override - public void onCalculateRouteSuccess(int[] ints) { - Log.d(TAG, "onCalculateRouteSuccess int"); - } - - - @Override - public void onInitNaviFailure() { - calculate = false; - Log.d(TAG, "onInitNaviFailure"); - } - - @Override - public void onInitNaviSuccess() { - Log.d(TAG, "onInitNaviSuccess"); - - } - - @Override - public void onStartNavi(int i) { - Log.d(TAG, "onStartNavi"); - - } - - @Override - public void onTrafficStatusUpdate() { - - } - - @Override - public void onLocationChange(AMapNaviLocation aMapNaviLocation) { -// Log.d(TAG, "高德地图经纬度:" + aMapNaviLocation.getCoord().getLongitude() + "," + aMapNaviLocation.getCoord().getLatitude()); - - } - - @Override - public void onGetNavigationText(int i, String s) { - Log.d(TAG, "onGetNavigationText int"); - } - - @Override - public void onGetNavigationText(String s) { - Log.d(TAG, "onGetNavigationText ss"); - - } - - @Override - public void onEndEmulatorNavi() { - Log.d(TAG, "onEndEmulatorNavi"); - } - - @Override - public void onArriveDestination() { - Log.d(TAG, "onArriveDestination"); - } - - @Override - public void onCalculateRouteFailure(int i) { - Log.d(TAG, "onCalculateRouteFailure"); - } - - @Override - public void onReCalculateRouteForYaw() { - Log.d(TAG, "onReCalculateRouteForYaw"); - } - - @Override - public void onReCalculateRouteForTrafficJam() { - Log.d(TAG, "onReCalculateRouteForTrafficJam"); - } - - @Override - public void onArrivedWayPoint(int i) { - Log.d(TAG, "onArrivedWayPoint"); - } - - @Override - public void onGpsOpenStatus(boolean b) { - Log.d(TAG, "onGpsOpenStatus"); - } - - @Override - public void onNaviInfoUpdate(NaviInfo naviInfo) { - Log.d(TAG, "onNaviInfoUpdate"); - } - - @Override - public void updateCameraInfo(AMapNaviCameraInfo[] aMapNaviCameraInfos) { - Log.d(TAG, "updateCameraInfo"); - } - - @Override - public void updateIntervalCameraInfo(AMapNaviCameraInfo aMapNaviCameraInfo, AMapNaviCameraInfo aMapNaviCameraInfo1, int i) { - Log.d(TAG, "updateIntervalCameraInfo"); - } - - @Override - public void onServiceAreaUpdate(AMapServiceAreaInfo[] aMapServiceAreaInfos) { - Log.d(TAG, "onServiceAreaUpdate"); - } - - @Override - public void showCross(AMapNaviCross aMapNaviCross) { - Log.d(TAG, "showCross"); - } - - @Override - public void hideCross() { - Log.d(TAG, "hideCross"); - } - - @Override - public void showModeCross(AMapModelCross aMapModelCross) { - Log.d(TAG, "showModeCross"); - } - - @Override - public void hideModeCross() { - Log.d(TAG, "hideModeCross"); - } - - @Override - public void showLaneInfo(AMapLaneInfo[] aMapLaneInfos, byte[] bytes, byte[] bytes1) { - Log.d(TAG, "showLaneInfo"); - } - - @Override - public void showLaneInfo(AMapLaneInfo aMapLaneInfo) { - Log.d(TAG, "showLaneInfo"); - } - - @Override - public void hideLaneInfo() { - Log.d(TAG, "hideLaneInfo"); - } - - @Override - public void notifyParallelRoad(int i) { - - } - - @Override - public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo[] aMapNaviTrafficFacilityInfos) { - - } - - @Override - public void OnUpdateTrafficFacility(AMapNaviTrafficFacilityInfo aMapNaviTrafficFacilityInfo) { - - } - - @Override - public void updateAimlessModeStatistics(AimLessModeStat aimLessModeStat) { - - } - - @Override - public void updateAimlessModeCongestionInfo(AimLessModeCongestionInfo aimLessModeCongestionInfo) { - - } - - @Override - public void onPlayRing(int i) { - - } - - //算路详情 - @Override - public void onCalculateRouteSuccess(AMapCalcRouteResult aMapCalcRouteResult) { - Log.d(TAG, "onCalculateRouteSuccess aMapCalcRouteResult" + aMapCalcRouteResult.toString()); -// mAMapNavi.startNavi(NaviType.GPS); -// UiThreadHandler.postDelayed(() -> { -// mAMapView.displayOverview(); -// }, 500); - } - - @Override - public void onCalculateRouteFailure(AMapCalcRouteResult aMapCalcRouteResult) { - Log.d(TAG, "onCalculateRouteFailure"); - } - - @Override - public void onNaviRouteNotify(AMapNaviRouteNotifyData aMapNaviRouteNotifyData) { - Log.d(TAG, "onNaviRouteNotify"); - } - - @Override - public void onGpsSignalWeak(boolean b) { - - } - - @Override - public void onNaviSetting() { - - } - - @Override - public void onNaviCancel() { - - } - - @Override - public boolean onNaviBackClick() { - return false; - } - - @Override - public void onNaviMapMode(int i) { - - } - - @Override - public void onNaviTurnClick() { - - } - - @Override - public void onNextRoadClick() { - - } - - @Override - public void onScanViewButtonClick() { - - } - - @Override - public void onLockMap(boolean b) { - - } - - @Override - public void onNaviViewLoaded() { - Log.d(TAG, "---onNaviViewLoaded---"); - CustomMapStyleOptions customMapStyleOptions = new CustomMapStyleOptions(); - // 加载自定义样式 - customMapStyleOptions.setEnable(true); - if (AppIdentityModeUtils.isTaxi(FunctionBuildConfig.appIdentityMode)) { - customMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style.data")); - customMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra.data")); - } else { - customMapStyleOptions.setStyleData(MapAssetStyleUtils.getAssetsStyle(getContext(), "over_view_style_bus.data")); - customMapStyleOptions.setStyleExtraData(MapAssetStyleUtils.getAssetsExtraStyle(getContext(), "over_view_style_extra_bus.data")); + public void clearCustomPolyline() { + if (mBottomPolyline != null) { + mBottomPolyline.remove(); + } + if (mCoveredPolyline != null) { + mCoveredPolyline.remove(); } - // 设置自定义样式 - mAMap.setCustomMapStyle(customMapStyleOptions); - // 实时路况图层关闭,必须添加在loaded结束之后,其他位置不生效 - mAMap.setTrafficEnabled(false); - } - - @Override - public void onMapTypeChanged(int i) { - - } - - @Override - public void onNaviViewShowMode(int i) { - } /** * 绘制新基建Markers(比如:摄像头) - * @param globalPathResp + * + * @param locationList */ - private void drawInfrastructureMarkers(MessagePad.GlobalPathResp globalPathResp) { - if (globalPathResp != null) { - if (!pathMap.isEmpty()) { - pathMap.clear(); - } - String geoHash; - ArrayList infList; - StringBuilder sb1 = new StringBuilder(); - for (MessagePad.Location location : globalPathResp.getWayPointsList()) { - LonLatPoint p = new LonLatPoint(location.getLongitude(), location.getLatitude()); - p = MapTools.INSTANCE.switchLonLatWGS84(p); - sb1.append(p.getLongitude()).append(",").append(p.getLatitude()).append("\n"); - geoHash = GeoHash.withCharacterPrecision(location.getLatitude(), location.getLongitude(), 7).toBase32(); - // 网格内的轨迹点只取一次 - if (!pathMap.containsKey(geoHash)) { - // 从缓存的新基建数据中去取对应geoHash的新基建数据集合 - infList = InfStructureManager.INSTANCE.getData().get(geoHash); - if (infList != null) { - pathMap.put(geoHash, infList); - } + private void drawInfrastructureMarkers(List locationList) { + if (!pathMap.isEmpty()) { + pathMap.clear(); + } + String geoHash; + ArrayList infList; + for (MessagePad.Location location : locationList) { + LatLng latLng = MarkerDrawerManager.INSTANCE.coordinateConverterWgsToGcj(mContext, location); + geoHash = GeoHash.withCharacterPrecision(latLng.latitude, latLng.longitude, 7).toBase32(); + // 网格内的轨迹点只取一次s + if (!pathMap.containsKey(geoHash)) { + // 从缓存的新基建数据中去取对应geoHash的新基建数据集合 + infList = InfStructureManager.INSTANCE.getData().get(geoHash); + if (infList != null) { + pathMap.put(geoHash, infList); } } - String str1 = sb1.toString(); - drawInfMarkers(pathMap); } + drawInfMarkers(pathMap); } public void drawInfMarkers(Map> infStruMap) { @@ -851,7 +385,7 @@ public class AMapCustomView private void displayCustomOverView() { ArrayList linePointsLatLng = MarkerDrawerManager.INSTANCE.getPlanningPoints(); MogoLocation location = mLocation; - if (linePointsLatLng.size() > 1){ + if (linePointsLatLng.size() > 1) { //圈定地图显示范围 //存放经纬度 LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); @@ -860,18 +394,22 @@ public class AMapCustomView } LatLng currentLatLng = new LatLng(location.getLatitude(), location.getLongitude()); boundsBuilder.include(currentLatLng); + + CameraPosition cameraPosition = new CameraPosition.Builder().tilt(mTilt).build(); //第二个参数为四周留空宽度 - mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(),50,50,50,50)); - }else { + mAMap.moveCamera(CameraUpdateFactory.newLatLngBoundsRect(boundsBuilder.build(), 100, 100, 100, 100)); + mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); + } else { //设置希望展示的地图缩放级别 CameraPosition cameraPosition = new CameraPosition.Builder() - .target(mCarMarker.getPosition()).tilt(0).bearing(location.getBearing()).zoom(zoomLevel).build(); + .target(mCarMarker.getPosition()).tilt(0).zoom(zoomLevel).build(); mAMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } } /** * 绘制自车 + * * @param location */ private void drawCarMarker(MogoLocation location) { @@ -881,6 +419,10 @@ public class AMapCustomView mCarMarker.setRotateAngle(360 - location.getBearing()); mCarMarker.setPosition(currentLatLng); mCarMarker.setToTop(); + if (mCompassMarker != null) { + mCompassMarker.setRotateAngle(360 - location.getBearing()); + mCompassMarker.setPosition(currentLatLng); + } } } @@ -909,18 +451,19 @@ public class AMapCustomView /** * 绘制轨迹线 + * * @param coordinates * @param locIndex */ - private void drawPolyline(List coordinates,int locIndex) { + private void drawPolyline(List coordinates, int locIndex) { if (textureList.size() > 0) { textureList.clear(); } if (texIndexList.size() > 0) { texIndexList.clear(); } - for (int i = 0; i < coordinates.size(); i++){ - if (i <= locIndex){ + for (int i = 0; i < coordinates.size(); i++) { + if (i <= locIndex) { // 已走过的置灰 textureList.add(arrivedBitmap); } else { @@ -929,22 +472,20 @@ public class AMapCustomView } texIndexList.add(i); } - - if (mCustomPolyline != null) { - mCustomPolyline.remove(); - } if (mAMap != null && coordinates.size() > 2) { //设置线段纹理 PolylineOptions polylineOptions = new PolylineOptions(); polylineOptions.addAll(coordinates); -// polylineOptions.useGradient(true); - polylineOptions.width(12); //线段宽度 - polylineOptions.isUseTexture(); + polylineOptions.width(14); //线段宽度 polylineOptions.lineCapType(PolylineOptions.LineCapType.LineCapRound); polylineOptions.setCustomTextureList(textureList); polylineOptions.setCustomTextureIndex(texIndexList); // 绘制线 - mCustomPolyline = mAMap.addPolyline(polylineOptions); + mBottomPolyline = mCoveredPolyline; + mCoveredPolyline = mAMap.addPolyline(polylineOptions); + if (mBottomPolyline != null) { + mBottomPolyline.remove(); + } } } } diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt index 9d4771f2f2..08f04fdb0e 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/MarkerDrawerManager.kt @@ -59,9 +59,7 @@ object MarkerDrawerManager { private fun getLoopCalCarObservable(): Observable { return Observable.create(ObservableOnSubscribe { emitter -> if (emitter.isDisposed) return@ObservableOnSubscribe - synchronized(this) { - loopRouteAndWipe(planningPoints, lonLat.first, lonLat.second) - } + loopRouteAndWipe(planningPoints, lonLat.first, lonLat.second) emitter.onComplete() }) } @@ -80,10 +78,8 @@ object MarkerDrawerManager { fun updateRoutePoints(routePoints: List?, context: Context) { if (routePoints == null || routePoints.isEmpty()) return val latLngModels = coordinateConverterWgsToGcjListCommon(context, routePoints) - synchronized(this) { - planningPoints.clear() - planningPoints.addAll(latLngModels) - } + planningPoints.clear() + planningPoints.addAll(latLngModels) // float remainingSumLength = calculateRemainingSumLength(mRoutePoints); } @@ -156,7 +152,7 @@ object MarkerDrawerManager { return list } - private fun coordinateConverterWgsToGcj( + fun coordinateConverterWgsToGcj( mContext: Context, mogoLatLng: MessagePad.Location ): LatLng { diff --git a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java index c864632956..c1862a7485 100644 --- a/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java +++ b/core/function-impl/mogo-core-function-map/src/main/java/com/mogo/eagle/core/function/smp/OverviewMapFragment.java @@ -1,41 +1,21 @@ package com.mogo.eagle.core.function.smp; import android.content.Context; -import android.location.Location; import android.os.Bundle; import android.view.View; -import androidx.annotation.NonNull; import androidx.annotation.Nullable; import com.alibaba.android.arouter.facade.annotation.Route; import com.mogo.commons.mvp.BaseFragment; -import com.mogo.eagle.core.data.autopilot.AutopilotStatusInfo; import com.mogo.eagle.core.data.constants.MoGoFragmentPaths; import com.mogo.eagle.core.data.map.MogoLatLng; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotPlanningListener; -import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener; import com.mogo.eagle.core.function.api.map.smp.IMogoSmallMapProvider; import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotPlanningListenerManager; import com.mogo.eagle.core.function.map.R; import com.mogo.eagle.core.function.overview.InfStructureManager; -import com.mogo.eagle.core.data.map.Infrastructure; -import com.mogo.eagle.core.function.overview.ViewModelExtKt; -import com.mogo.eagle.core.function.overview.vm.OverViewModel; -import com.mogo.eagle.core.utilcode.util.UiThreadHandler; -import com.mogo.map.navi.IMogoCarLocationChangedListener2; -import com.mogo.module.common.MogoApisHandler; -import org.jetbrains.annotations.NotNull; - -import java.util.ArrayList; import java.util.List; -import java.util.Map; - -import kotlin.Pair; -import mogo.telematics.pad.MessagePad; -import mogo_msg.MogoReportMsg; -import system_master.SystemStatusInfo; /** * @author donghongyu @@ -44,8 +24,7 @@ import system_master.SystemStatusInfo; */ @Route(path = MoGoFragmentPaths.PATH_FRAGMENT_OVERVIEW) public class OverviewMapFragment extends BaseFragment - implements IMogoSmallMapProvider, IMoGoAutopilotPlanningListener, - IMoGoAutopilotStatusListener { + implements IMogoSmallMapProvider { private final String TAG = "SmallMapFragment"; protected AMapCustomView mAMapCustomView; @@ -74,7 +53,6 @@ public class OverviewMapFragment extends BaseFragment super.initViews(savedInstanceState); mAMapCustomView = mRootView.findViewById(R.id.smallMapDirectionView); mAMapCustomView.onCreateView(savedInstanceState); - CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this); } @Override @@ -93,17 +71,10 @@ public class OverviewMapFragment extends BaseFragment @Override public void drawablePolyline(List coordinates) { - if (mAMapCustomView != null) { - mAMapCustomView.convert(coordinates); - UiThreadHandler.post(() -> mAMapCustomView.drawablePolyline()); - } } @Override public void clearPolyline() { - if (mAMapCustomView != null) { - UiThreadHandler.post(() -> mAMapCustomView.clearPolyline()); - } } @Override @@ -112,6 +83,7 @@ public class OverviewMapFragment extends BaseFragment if (mAMapCustomView != null) { mAMapCustomView.onResume(); } + mAMapCustomView.handlePlanningData(InfStructureManager.INSTANCE.getPlanningData()); } @Override @@ -146,56 +118,4 @@ public class OverviewMapFragment extends BaseFragment } CallerAutopilotPlanningListenerManager.INSTANCE.removeListener(TAG); } - - @Override - public void onAutopilotTrajectory(List trajectoryInfos) { - - } - - @Override - public void onAutopilotStatusResponse(@NotNull AutopilotStatusInfo autoPilotStatusInfo) { - if (autoPilotStatusInfo.getPilotmode() != 1) { - clearPolyline(); - } - } - - @Override - public void onAutopilotArriveAtStation(MessagePad.ArrivalNotification arrivalNotification) { - - } - - @Override - public void onAutopilotSNRequest() { - - } - - @Override - public void onAutopilotGuardian(MogoReportMsg.MogoReportMessage guardianInfo) { - - } - - @Override - public void onAutopilotIpcConnectStatusChanged(int status, @Nullable String reason) { - } - - @Override - public void onAutopilotRotting(MessagePad.GlobalPathResp globalPathResp) { - if (globalPathResp == null || globalPathResp.getWayPointsList().size() == 0) { - return; - } - List latLngList = new ArrayList<>(); - for (MessagePad.Location routeModel : globalPathResp.getWayPointsList()) { - latLngList.add(new MogoLatLng(routeModel.getLatitude(), routeModel.getLongitude())); - } - if (latLngList.size() > 0) { - drawablePolyline(latLngList); - } else { - clearPolyline(); - } - } - - @Override - public void onAutopilotStatusRespByQuery(@NonNull SystemStatusInfo.StatusInfo status) { - - } } diff --git a/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_custom_smooth_route.png b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_custom_smooth_route.png new file mode 100644 index 0000000000..1dcfe1d5a3 Binary files /dev/null and b/core/function-impl/mogo-core-function-map/src/main/res/drawable-xhdpi/amap_custom_smooth_route.png differ