[Feat]全览模式本地数据库查数据
This commit is contained in:
@@ -3,33 +3,23 @@ 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.graphics.BitmapFactory;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.amap.api.maps.AMap;
|
||||
import com.amap.api.maps.TextureMapView;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
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.IMoGoAutopilotPlanningListener;
|
||||
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.call.autopilot.CallerAutopilotPlanningListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerHDMapManager;
|
||||
import com.mogo.eagle.core.function.call.monitor.CallerMonitorManager;
|
||||
import com.mogo.eagle.core.function.call.setting.CallerSkinModeListenerManager;
|
||||
import com.mogo.eagle.core.function.overview.Infrastructure;
|
||||
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.function.smp.AMapCustomView;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoUiSettings;
|
||||
@@ -38,15 +28,6 @@ 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 java.util.Map;
|
||||
|
||||
import ch.hsr.geohash.GeoHash;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @since 2021-11-09
|
||||
@@ -56,19 +37,12 @@ import mogo.telematics.pad.MessagePad;
|
||||
*/
|
||||
@Route(path = MoGoFragmentPaths.PATH_FRAGMENT_MAP)
|
||||
public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
implements MapView, IMoGoMapFragmentProvider, IMoGoSkinModeChangeListener
|
||||
, IMoGoAutopilotPlanningListener {
|
||||
implements MapView, IMoGoMapFragmentProvider, IMoGoSkinModeChangeListener {
|
||||
|
||||
private static final String TAG = "MapFragment";
|
||||
|
||||
private MogoMapView mMogoMapView;
|
||||
private IMogoMap mMogoMap;
|
||||
private AMapCustomView mAMapCustomView;
|
||||
// 每个GeoHash网格对应的新基建Bean
|
||||
private Map<String, ArrayList<Infrastructure>> infMap = new HashMap();
|
||||
// 全局路径规划中的GeoHash网格
|
||||
private Map<String, ArrayList<Infrastructure>> pathMap = new HashMap();
|
||||
private Map<LatLng, Infrastructure> posInfMap = new HashMap();
|
||||
|
||||
private final boolean mIsControllerByOthersStatus = false;
|
||||
|
||||
@@ -111,10 +85,8 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
if (mMogoMap != null) {
|
||||
mMogoMap.getUIController().showMyLocation(true);
|
||||
}
|
||||
mAMapCustomView = findViewById(R.id.module_gaode_id_map);
|
||||
// 添加换肤监听
|
||||
CallerSkinModeListenerManager.INSTANCE.addListener(TAG, this);
|
||||
CallerAutopilotPlanningListenerManager.INSTANCE.addListener(TAG, this);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -210,8 +182,6 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
MapPointCloudSubscriber.Companion.getInstance();
|
||||
}
|
||||
|
||||
private boolean isFirst = true;
|
||||
|
||||
private void queryInfStructure() {
|
||||
OverViewModel viewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class);
|
||||
// viewModel.getInfStructures().observe(this.getViewLifecycleOwner(), infrastructures -> {
|
||||
@@ -229,12 +199,7 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
// }
|
||||
// });
|
||||
|
||||
viewModel.getInfStructuresMap().observe(this.getViewLifecycleOwner(), map -> {
|
||||
if (!infMap.isEmpty()) {
|
||||
infMap.clear();
|
||||
}
|
||||
infMap.putAll(map);
|
||||
});
|
||||
viewModel.getInfStructuresMap().observe(this.getViewLifecycleOwner(), InfStructureManager.INSTANCE::saveData);
|
||||
viewModel.fetchInfStructures();
|
||||
}
|
||||
|
||||
@@ -357,50 +322,6 @@ public class MapFragment extends MvpFragment<MapView, MapPresenter>
|
||||
PointCloudHelper.INSTANCE.setIsDrawPointCloud(isDrawPointCloud);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotTrajectory(@NonNull List<MessagePad.TrajectoryPoint> trajectoryInfos) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAutopilotRotting(MessagePad.GlobalPathResp globalPathResp) {
|
||||
if (globalPathResp != null) {
|
||||
if (!pathMap.isEmpty()) {
|
||||
pathMap.clear();
|
||||
}
|
||||
String geoHash;
|
||||
ArrayList<Infrastructure> infList;
|
||||
for (MessagePad.Location location : globalPathResp.getWayPointsList()) {
|
||||
geoHash = GeoHash.withCharacterPrecision(location.getLatitude(), location.getLongitude(), 7).toBase32();
|
||||
// 网格内的轨迹点只取一次
|
||||
if (!pathMap.containsKey(geoHash)) {
|
||||
// 从缓存的新基建数据中去取对应geoHash的新基建数据集合
|
||||
infList = infMap.get(geoHash);
|
||||
if (infList != null) {
|
||||
pathMap.put(geoHash, infList);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 绘制新基建数据
|
||||
if (!posInfMap.isEmpty()) {
|
||||
posInfMap.clear();
|
||||
}
|
||||
ArrayList<MarkerOptions> markerOptionsList = new ArrayList();
|
||||
for (ArrayList<Infrastructure> structureList : pathMap.values()) {
|
||||
for (Infrastructure structure : structureList) {
|
||||
MarkerOptions markerOption = new MarkerOptions();
|
||||
LatLng latLng = new LatLng(Double.valueOf(structure.getLat()),
|
||||
Double.valueOf(structure.getLon()));
|
||||
markerOption.position(latLng);
|
||||
markerOption.icon(BitmapDescriptorFactory.fromBitmap(
|
||||
BitmapFactory.decodeResource(getResources(), R.drawable.icon_shexiangtou_nor)
|
||||
));
|
||||
posInfMap.put(latLng, structure);
|
||||
markerOptionsList.add(markerOption);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置地图是否是Debug模式
|
||||
* @param debugMode 是否开启Debug模式
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.mogo.eagle.core.function.overview
|
||||
|
||||
/**
|
||||
* 本地数据库查询出来的红绿灯、摄像头等数据
|
||||
*/
|
||||
object InfStructureManager {
|
||||
|
||||
// 每个GeoHash网格对应的新基建Bean
|
||||
private val _infMap by lazy {
|
||||
HashMap<String, ArrayList<Infrastructure>>()
|
||||
}
|
||||
|
||||
fun saveData(map: HashMap<String, java.util.ArrayList<Infrastructure>>) {
|
||||
if (_infMap.isNotEmpty()) {
|
||||
_infMap.clear()
|
||||
}
|
||||
_infMap.putAll(map)
|
||||
}
|
||||
|
||||
fun getData(): Map<String, ArrayList<Infrastructure>> = _infMap
|
||||
}
|
||||
@@ -19,8 +19,10 @@ import com.amap.api.maps.CameraUpdate;
|
||||
import com.amap.api.maps.CameraUpdateFactory;
|
||||
import com.amap.api.maps.CoordinateConverter;
|
||||
import com.amap.api.maps.UiSettings;
|
||||
import com.amap.api.maps.model.BitmapDescriptorFactory;
|
||||
import com.amap.api.maps.model.CustomMapStyleOptions;
|
||||
import com.amap.api.maps.model.LatLng;
|
||||
import com.amap.api.maps.model.MarkerOptions;
|
||||
import com.amap.api.maps.model.Polyline;
|
||||
import com.amap.api.navi.AMapNavi;
|
||||
import com.amap.api.navi.AMapNaviListener;
|
||||
@@ -53,8 +55,11 @@ 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.overview.Infrastructure;
|
||||
import com.mogo.eagle.core.function.smp.view.ISmallMapDirectionView;
|
||||
import com.mogo.eagle.core.utilcode.mogo.MapAssetStyleUtils;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
@@ -65,8 +70,11 @@ import com.zhidao.support.adas.high.AdasManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import ch.hsr.geohash.GeoHash;
|
||||
import mogo.telematics.pad.MessagePad;
|
||||
import mogo_msg.MogoReportMsg;
|
||||
|
||||
@@ -97,6 +105,10 @@ public class AMapCustomView
|
||||
private TextView overLayerView;
|
||||
private boolean calculate = false;
|
||||
|
||||
// 全局路径规划中的GeoHash网格
|
||||
private Map<String, ArrayList<Infrastructure>> pathMap = new HashMap();
|
||||
private Map<LatLng, Infrastructure> posInfMap = new HashMap();
|
||||
|
||||
public AMapCustomView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
@@ -298,6 +310,8 @@ public class AMapCustomView
|
||||
Log.d(TAG, "全局路径" + list.size() + ",起点:" + sList.toString() + ",终点:" + eList.toString() + ",经点:" + mWayPointList.toString());
|
||||
//指定路径绘制导航路线
|
||||
mAMapNavi.calculateDriveRoute(sList, eList, mWayPointList, strategy);
|
||||
|
||||
drawInfrastructureMarkers(globalPathResp);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -601,7 +615,7 @@ public class AMapCustomView
|
||||
mAMapNavi.startNavi(NaviType.GPS);
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
mAMapNaviView.displayOverview();
|
||||
}, 20000);
|
||||
}, 2000);
|
||||
//停止导航测试代码
|
||||
// UiThreadHandler.postDelayed(() -> {
|
||||
// mAMapNavi.stopNavi();
|
||||
@@ -681,4 +695,52 @@ public class AMapCustomView
|
||||
|
||||
}
|
||||
|
||||
private void drawInfrastructureMarkers(MessagePad.GlobalPathResp globalPathResp) {
|
||||
if (globalPathResp != null) {
|
||||
if (!pathMap.isEmpty()) {
|
||||
pathMap.clear();
|
||||
}
|
||||
String geoHash;
|
||||
ArrayList<Infrastructure> infList;
|
||||
for (MessagePad.Location location : globalPathResp.getWayPointsList()) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 绘制新基建数据
|
||||
if (!posInfMap.isEmpty()) {
|
||||
posInfMap.clear();
|
||||
}
|
||||
ArrayList<MarkerOptions> markerOptionsList = new ArrayList();
|
||||
for (ArrayList<Infrastructure> structureList : pathMap.values()) {
|
||||
for (Infrastructure structure : structureList) {
|
||||
MarkerOptions markerOption = new MarkerOptions();
|
||||
LatLng latLng = new LatLng(Double.valueOf(structure.getLat()),
|
||||
Double.valueOf(structure.getLon()));
|
||||
markerOption.position(latLng);
|
||||
markerOption.icon(BitmapDescriptorFactory.fromBitmap(
|
||||
BitmapFactory.decodeResource(getResources(), R.drawable.video_nor)
|
||||
));
|
||||
posInfMap.put(latLng, structure);
|
||||
markerOptionsList.add(markerOption);
|
||||
}
|
||||
}
|
||||
mAMap.addMarkers(markerOptionsList, false);
|
||||
mAMap.setOnMarkerClickListener(marker -> {
|
||||
Infrastructure infrastructure = posInfMap.get(marker.getPosition());
|
||||
// 如果是摄像头
|
||||
if (0 == infrastructure.getCategory() && infrastructure.getIp() != null) {
|
||||
CallerHmiManager.INSTANCE.showVideoDialog(infrastructure.getIp());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ 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.ViewModelExtKt;
|
||||
import com.mogo.eagle.core.function.overview.vm.OverViewModel;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -36,6 +38,7 @@ public class SmallMapFragment extends BaseFragment
|
||||
IMoGoAutopilotStatusListener {
|
||||
private final String TAG = "SmallMapFragment";
|
||||
protected AMapCustomView mAMapCustomView;
|
||||
// private OverViewModel mViewModel;
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
@@ -83,24 +86,14 @@ public class SmallMapFragment extends BaseFragment
|
||||
public void drawablePolyline(List<MogoLatLng> coordinates) {
|
||||
if (mAMapCustomView != null) {
|
||||
mAMapCustomView.convert(coordinates);
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mAMapCustomView.drawablePolyline();
|
||||
}
|
||||
});
|
||||
UiThreadHandler.post(() -> mAMapCustomView.drawablePolyline());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPolyline() {
|
||||
if (mAMapCustomView != null) {
|
||||
UiThreadHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mAMapCustomView.clearPolyline();
|
||||
}
|
||||
});
|
||||
UiThreadHandler.post(() -> mAMapCustomView.clearPolyline());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +105,21 @@ public class SmallMapFragment extends BaseFragment
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
// queryInfStructure();
|
||||
}
|
||||
|
||||
// private void queryInfStructure() {
|
||||
// mViewModel = ViewModelExtKt.obtainViewModel(this, OverViewModel.class);
|
||||
// mViewModel.getInfStructuresMap().observe(this.getViewLifecycleOwner(), map -> {
|
||||
// mAMapCustomView.updateInfStructures(map);
|
||||
// });
|
||||
// // 本地数据库查询
|
||||
// mViewModel.fetchInfStructures();
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
<alpha
|
||||
android:duration="1000"
|
||||
android:fromAlpha="1.0"
|
||||
android:toAlpha="0"
|
||||
/>
|
||||
</set>
|
||||
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
>
|
||||
<alpha
|
||||
android:duration="1000"
|
||||
android:fromAlpha="0"
|
||||
android:toAlpha="1.0"
|
||||
/>
|
||||
</set>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 5.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
@@ -1,20 +1,13 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
>
|
||||
|
||||
<com.mogo.map.MogoMapView
|
||||
android:id="@+id/module_map_id_map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.mogo.eagle.core.function.smp.AMapCustomView
|
||||
android:id="@+id/module_gaode_id_map"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
|
||||
/>
|
||||
android:visibility="visible"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -6,10 +6,8 @@
|
||||
|
||||
<com.mogo.eagle.core.function.smp.AMapCustomView
|
||||
android:id="@+id/smallMapDirectionView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="30px"
|
||||
android:layout_marginBottom="30px"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent" />
|
||||
|
||||
|
||||
@@ -2,19 +2,19 @@
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:parentTag="RelativeLayout">
|
||||
|
||||
<View
|
||||
android:layout_width="@dimen/module_small_map_view_border_width"
|
||||
android:layout_height="@dimen/module_small_map_view_border_width"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true" />
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rlSmallMapBorder"
|
||||
android:layout_width="@dimen/module_small_map_view_width"
|
||||
android:layout_height="@dimen/module_small_map_view_width"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true">
|
||||
|
||||
<com.amap.api.navi.AMapNaviView
|
||||
@@ -24,8 +24,8 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/overLayer"
|
||||
android:layout_width="@dimen/dp_80"
|
||||
android:layout_height="@dimen/dp_80"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentBottom="true"
|
||||
android:background="@color/blue"
|
||||
|
||||
Reference in New Issue
Block a user