1164 lines
43 KiB
Java
1164 lines
43 KiB
Java
package com.mogo.map;
|
||
|
||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_CODE_HD_MAP_CALL;
|
||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_CODE_INIT_ON_MAP_INIT;
|
||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_CODE_INIT_ON_MAP_LOADED;
|
||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_CODE_ROMA_MODE_INVOKE;
|
||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_CODE_ROMA_REQUEST_OK;
|
||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_SOURCE_INIT;
|
||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_SOURCE_MAP;
|
||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_TYPE_HD_MAP;
|
||
import static com.mogo.eagle.core.data.deva.chain.ChainConstant.CHAIN_TYPE_INIT_STATUS;
|
||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_MAP;
|
||
import static com.mogo.map.uicontroller.VisualAngleMode.MAP_STYLE_VR_ANGLE_300;
|
||
import static com.mogo.map.uicontroller.VisualAngleMode.MAP_STYLE_VR_ANGLE_CROSS;
|
||
import static com.mogo.map.uicontroller.VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP;
|
||
import static com.mogo.map.uicontroller.VisualAngleMode.MAP_STYLE_VR_ROMA;
|
||
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_CLOSE_SIGHT;
|
||
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_LONG_SIGHT;
|
||
import static com.mogo.map.uicontroller.VisualAngleMode.MODE_MEDIUM_SIGHT;
|
||
|
||
import android.content.Context;
|
||
import android.graphics.Point;
|
||
import android.graphics.Rect;
|
||
import android.os.Bundle;
|
||
import android.os.Looper;
|
||
import android.text.TextUtils;
|
||
import android.util.Log;
|
||
import android.view.MotionEvent;
|
||
import android.view.View;
|
||
|
||
import androidx.annotation.NonNull;
|
||
|
||
import com.mogo.commons.debug.DebugConfig;
|
||
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
|
||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum;
|
||
import com.mogo.eagle.core.data.map.CenterLine;
|
||
import com.mogo.eagle.core.data.map.MapRoadInfo;
|
||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationWGS84ListenerManager;
|
||
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager;
|
||
import com.mogo.eagle.core.function.call.map.CallerMapDevaListenerManager;
|
||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager;
|
||
import com.mogo.eagle.core.function.call.map.CallerMapRomaListener;
|
||
import com.mogo.eagle.core.function.call.map.CallerMapStyleListenerManager;
|
||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||
import com.mogo.map.hdcache.IHdCacheListener;
|
||
import com.mogo.map.identify.MogoIdentifyManager;
|
||
import com.mogo.map.listener.MogoMapListenerHandler;
|
||
import com.mogo.map.location.GDLocationClient;
|
||
import com.mogo.map.uicontroller.CarCursorOption;
|
||
import com.mogo.map.uicontroller.EnumMapUI;
|
||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||
import com.mogo.map.uicontroller.MapCameraPosition;
|
||
import com.mogo.map.uicontroller.MapControlResult;
|
||
import com.mogo.map.uicontroller.VisualAngleMode;
|
||
import com.mogo.map.utils.HDMapUtils;
|
||
import com.mogo.map.utils.MogoMapUtils;
|
||
import com.mogo.map.utils.ObjectUtils;
|
||
import com.mogo.map.utils.ResIdCache;
|
||
import com.zhidaoauto.map.sdk.open.MapAutoApi;
|
||
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener;
|
||
import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener;
|
||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener;
|
||
import com.zhidaoauto.map.sdk.open.abs.OnMapClickListener;
|
||
import com.zhidaoauto.map.sdk.open.abs.OnMapLoadedListener;
|
||
import com.zhidaoauto.map.sdk.open.abs.OnMapStyleListener;
|
||
import com.zhidaoauto.map.sdk.open.abs.OnMapTouchListener;
|
||
import com.zhidaoauto.map.sdk.open.abs.OnMapViewVisualAngleChangeListener;
|
||
import com.zhidaoauto.map.sdk.open.abs.OnRoadInfoListener;
|
||
import com.zhidaoauto.map.sdk.open.abs.OnRoamStatusListener;
|
||
import com.zhidaoauto.map.sdk.open.abs.log.ILog;
|
||
import com.zhidaoauto.map.sdk.open.business.PointCloudHelper;
|
||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition;
|
||
import com.zhidaoauto.map.sdk.open.camera.CameraUpdateFactory;
|
||
import com.zhidaoauto.map.sdk.open.camera.LatLngBounds;
|
||
import com.zhidaoauto.map.sdk.open.data.CityInfo;
|
||
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
|
||
import com.zhidaoauto.map.sdk.open.location.LocationClient;
|
||
import com.zhidaoauto.map.sdk.open.location.MyLocationStyle;
|
||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptorFactory;
|
||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||
import com.zhidaoauto.map.sdk.open.marker.MarkerHelper;
|
||
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener;
|
||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||
import com.zhidaoauto.map.sdk.open.road.RoadCross;
|
||
import com.zhidaoauto.map.sdk.open.road.StopLine;
|
||
import com.zhidaoauto.map.sdk.open.tools.MapTools;
|
||
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
|
||
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper;
|
||
import com.zhjt.service.chain.ChainLog;
|
||
|
||
import org.jetbrains.annotations.NotNull;
|
||
import org.jetbrains.annotations.Nullable;
|
||
|
||
import java.util.ArrayList;
|
||
import java.util.List;
|
||
|
||
|
||
public class AMapViewWrapper implements IMogoMapView,
|
||
IMogoMapUIController,
|
||
OnMapLoadedListener,
|
||
MapStatusListener,
|
||
OnCameraChangeListener,
|
||
OnMapClickListener,
|
||
OnMapTouchListener,
|
||
OnMarkClickListener,
|
||
OnMapStyleListener,
|
||
OnMapViewVisualAngleChangeListener,
|
||
OnRoadInfoListener,
|
||
ILog, OnRoamStatusListener {
|
||
|
||
private static final String TAG = "AMapViewWrapper";
|
||
private final MapAutoView mMapView;
|
||
private final IMogoMap mIMap;
|
||
private final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder()
|
||
.carCursorRes(R.drawable.map_api_ic_current_location2)
|
||
.naviCursorRes(R.drawable.ic_amap_navi_cursor)
|
||
.build();
|
||
private CarCursorOption mCarCursorOption = DEFAULT_OPTION;
|
||
private EnumMapUI mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_VR;
|
||
private VisualAngleMode mVisualAngleMode = MODE_MEDIUM_SIGHT;
|
||
|
||
private IHdCacheListener hdCacheListener;
|
||
|
||
public AMapViewWrapper(MapAutoView mMapView) {
|
||
CallerLogger.INSTANCE.i(M_MAP + TAG, "autoop--AMapViewWrapper: init");
|
||
this.mMapView = mMapView;
|
||
initViews();
|
||
initListeners();
|
||
this.mIMap = new AMapWrapper(this.mMapView.getMapAutoViewHelper(), this.mMapView, this);
|
||
}
|
||
|
||
private void initViews() {
|
||
// 初始化首次地图进入的时候的样式, MapAutoApi.INSTANCE.init(context, mapParams);将影响这里的数据
|
||
int mapStyle = MapAutoApi.INSTANCE.getMapParams().getStyleMode();
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "默认配置地图模式:mapStyle=" + mapStyle);
|
||
switch (mapStyle) {
|
||
case MapAutoApi.MAP_STYLE_DAY:
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_DAY;
|
||
break;
|
||
case MapAutoApi.MAP_STYLE_DAY_NAV:
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_DAY_NAV;
|
||
break;
|
||
case MapAutoApi.MAP_STYLE_NIGHT:
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT;
|
||
break;
|
||
case MapAutoApi.MAP_STYLE_NIGHT_NAV:
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_NAV;
|
||
break;
|
||
case MapAutoApi.MAP_STYLE_DAY_VR:
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_DAY_VR;
|
||
break;
|
||
case MapAutoApi.MAP_STYLE_NIGHT_VR:
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_VR;
|
||
break;
|
||
default:
|
||
CallerLogger.INSTANCE.e(M_MAP + TAG, "暂不支持此地图模式,默认使用VR夜间模式");
|
||
}
|
||
|
||
}
|
||
|
||
private void initMapView() {
|
||
if (mMapView == null) {
|
||
return;
|
||
}
|
||
MapAutoViewHelper options = mMapView.getMapAutoViewHelper();
|
||
ThreadUtils.getIoPool().submit(() -> {
|
||
if (options != null) {
|
||
//设置手势是否可以缩放 isCanZoom true 可缩放 false 不可缩放
|
||
options.setZoomGesturesEnabled(true);
|
||
options.setScaleVRMode(true);
|
||
options.setWeatherEnable(false);
|
||
// options.setAllGesturesEnabled(false); //禁止全部手势
|
||
if (options.getMyLocationStyle() != null) {
|
||
options.getMyLocationStyle().setDisplayAnimEnable(true);
|
||
}
|
||
//修改自车模型,未来需区分车的类型
|
||
options.setMyLocationStyle(options.getMyLocationStyle().myLocationIcon(HdMapBuildConfig.currentCarVrIconRes, true));
|
||
}
|
||
});
|
||
}
|
||
|
||
private void initListeners() {
|
||
mMapView.setOnMarkClickListener(this);
|
||
mMapView.setOnMapLoadedListener(this);
|
||
mMapView.setOnMapTouchListener(this);
|
||
mMapView.setOnMapClickListener(this);
|
||
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ZOOM);
|
||
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_ROTATE);
|
||
mMapView.registerListener(this, MapAutoApi.LISTENER_TYPE_3D);
|
||
mMapView.setOnCameraChangeListener(this);
|
||
mMapView.setOnMapStyleListener(this);
|
||
mMapView.setOnRoamStatusListener(this);
|
||
mMapView.setOnMapViewVisualAngleChangeListener(this);
|
||
mMapView.setOnRoadInfoListener(this, 1);
|
||
MapAutoApi.INSTANCE.registerLogListener(this);
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "styleop - initListeners - setOnMapStyleListener - view " + mMapView);
|
||
}
|
||
|
||
/**
|
||
* 修改获取当前车道号
|
||
*
|
||
* @param roadId
|
||
* @param s1
|
||
*/
|
||
@Override
|
||
public void onRoadIdInfo(@androidx.annotation.Nullable String roadId, @androidx.annotation.Nullable String s1) {
|
||
if (roadId != null && !TextUtils.isEmpty(roadId)) {
|
||
// CallerLogger.INSTANCE.d(M_MAP + TAG, "onRoadIdInfo::" + roadId);
|
||
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnRoadIdGet(roadId);
|
||
} else {
|
||
//CallerLogger.INSTANCE.d(M_MAP + TAG, "onRoadIdInfo::null");
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onRoadCrossInfo(@androidx.annotation.Nullable RoadCross roadCross) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onStopLineInfo(@androidx.annotation.Nullable StopLine stopLine) {
|
||
MogoLocation carLoc = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84();
|
||
if (stopLine != null && stopLine.road_id != null && !stopLine.road_id.isEmpty() && stopLine.points != null && stopLine.points.size() > 0) {
|
||
ArrayList<LonLatPoint> points = stopLine.points;
|
||
if (carLoc != null) {
|
||
// //CallerLogger.INSTANCE.d(M_MAP + TAG, "onStopLineInfo:stop_line" + stopLine + ", car_loc:{lon: " + carLoc.getLatitude() + ", lat: " + carLoc.getLongitude() + "}");
|
||
MapRoadInfo.StopLine stopInfo = convert(stopLine);
|
||
LonLatPoint p1 = points.get(0);
|
||
LonLatPoint p2 = points.get(points.size() - 1);
|
||
double distanceOfCarToStopLine = MapDataApi.INSTANCE.getNearstFromPointToSegment(carLoc.getLongitude(), carLoc.getLatitude(), p1.longitude, p1.latitude, p2.longitude, p2.latitude) * 10_0000;
|
||
stopInfo.setDistanceOfCarToStopLine(distanceOfCarToStopLine);
|
||
//CallerLogger.INSTANCE.d(M_MAP + TAG, "onStopLineInfo: --- distance: " + distanceOfCarToStopLine);
|
||
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnStopLineGet(stopInfo);
|
||
}
|
||
} else {
|
||
if (carLoc != null) {
|
||
//CallerLogger.INSTANCE.d(M_MAP + TAG, "onStopLineInfo::null, car_loc:{lon: " + carLoc.getLatitude() + ", lat: " + carLoc.getLongitude() + "}");
|
||
}
|
||
}
|
||
}
|
||
|
||
private MapRoadInfo.StopLine convert(StopLine line) {
|
||
MapRoadInfo.StopLine ret = new MapRoadInfo.StopLine();
|
||
ret.setDistance(line.distance);
|
||
ret.setLaneId(line.lane_id);
|
||
ret.setRoadId(line.road_id);
|
||
ret.setTieId(line.tile_id);
|
||
ArrayList<LonLatPoint> points = line.points;
|
||
if (points != null && points.size() > 0) {
|
||
List<MogoLatLng> newPoints = new ArrayList<>();
|
||
for (int i = 0; i < points.size(); i++) {
|
||
LonLatPoint lonLatPoint = points.get(i);
|
||
MogoLatLng latLng = new MogoLatLng(lonLatPoint.latitude, lonLatPoint.longitude);
|
||
latLng.duration = lonLatPoint.duration;
|
||
latLng.angle = lonLatPoint.angle;
|
||
latLng.speed = lonLatPoint.speed;
|
||
latLng.altitude = lonLatPoint.altitude;
|
||
latLng.provider = lonLatPoint.provider;
|
||
newPoints.add(latLng);
|
||
}
|
||
ret.setPoints(newPoints);
|
||
}
|
||
return ret;
|
||
}
|
||
|
||
|
||
private Context getContext() {
|
||
return mMapView.getContext();
|
||
}
|
||
|
||
@Override
|
||
public View getMapView() {
|
||
return mMapView;
|
||
}
|
||
|
||
@Override
|
||
public IMogoMap getMap() {
|
||
return mIMap;
|
||
}
|
||
|
||
@Override
|
||
public void onCreate(Bundle bundle) {
|
||
if (mMapView != null) {
|
||
mMapView.onCreate(bundle);
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "map onCreate");
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onResume() {
|
||
if (mMapView != null) {
|
||
mMapView.onResume();
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "map onResume");
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onPause() {
|
||
if (mMapView != null) {
|
||
mMapView.onPause();
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "map onPause");
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onDestroy() {
|
||
if (mMapView != null) {
|
||
mMapView.onDestroy();
|
||
mMapView.setOnMarkClickListener(null);
|
||
mMapView.setOnMapLoadedListener(null);
|
||
mMapView.setOnMapTouchListener(null);
|
||
mMapView.setOnMapClickListener(null);
|
||
mMapView.setOnCameraChangeListener(null);
|
||
MapAutoApi.INSTANCE.unregisterLogListener(this);
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "map onDestroy");
|
||
}
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onSaveInstanceState(Bundle outState) {
|
||
if (mMapView != null) {
|
||
mMapView.onSaveInstanceState(outState);
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "map onSaveInstanceState");
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onLowMemory() {
|
||
|
||
}
|
||
|
||
@Override
|
||
public MapControlResult changeZoom(float zoom) {
|
||
if (isVrMold()) {
|
||
return MapControlResult.ERROR;
|
||
}
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "changeZoom : " + zoom);
|
||
getMap().changeZoom(zoom);
|
||
return MapControlResult.SUCCESS;
|
||
}
|
||
|
||
@Override
|
||
public void changeZoom2(float zoom) {
|
||
// if (isVrMold()) {
|
||
// return;
|
||
// }
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "changeZoom2 : " + zoom);
|
||
getMap().changeZoom2(zoom);
|
||
}
|
||
|
||
@Override
|
||
public void setDebugMode(Boolean debugMode) {
|
||
MapAutoApi.INSTANCE.setDebugMode(debugMode);
|
||
}
|
||
|
||
@Override
|
||
public void changeMapVisualAngle(VisualAngleMode angelMode, MogoLatLng mogoLatLng) {
|
||
MapAutoViewHelper mapAutoViewHelper = mMapView.getMapAutoViewHelper();
|
||
if (mapAutoViewHelper != null) {
|
||
mVisualAngleMode = angelMode;
|
||
if (angelMode == MODE_CLOSE_SIGHT) {
|
||
if (mogoLatLng == null) {
|
||
CallerLogger.INSTANCE.e(M_MAP + TAG, "切换地图近景需要传入要移动的经纬度数据");
|
||
return;
|
||
}
|
||
// 近景传入经纬度为点击地图上静态marker经纬度数据,为GPS坐标点。
|
||
mapAutoViewHelper.setNearViewAnglePosition(new LonLatPoint(mogoLatLng.lon, mogoLatLng.lat), true);
|
||
} else {
|
||
mapAutoViewHelper.setMapViewVisualAngle(angelMode.getCode());
|
||
}
|
||
}
|
||
}
|
||
|
||
@ChainLog(
|
||
linkChainLog = CHAIN_TYPE_HD_MAP,
|
||
linkCode = CHAIN_SOURCE_MAP,
|
||
nodeAliasCode = CHAIN_CODE_HD_MAP_CALL,
|
||
paramIndexes = {0}
|
||
)
|
||
@Override
|
||
public void setRoamTrajectory(String trajectory) {
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().setRoamTrajectory(trajectory);
|
||
}
|
||
}
|
||
|
||
@ChainLog(
|
||
linkChainLog = CHAIN_TYPE_HD_MAP,
|
||
linkCode = CHAIN_SOURCE_MAP,
|
||
parentNodeAliasCode = CHAIN_CODE_ROMA_REQUEST_OK,
|
||
nodeAliasCode = CHAIN_CODE_ROMA_MODE_INVOKE,
|
||
paramIndexes = {0},
|
||
endPoint = false
|
||
)
|
||
@Override
|
||
public void setRomaMode(int mode) {
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().setRoamStyle(mode, 1800, MapAutoApi.ROAM_SPEED_40);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public VisualAngleMode getCurrentMapVisualAngle() {
|
||
return mVisualAngleMode;
|
||
}
|
||
|
||
@Override
|
||
public void moveToCenter(MogoLatLng latLng) {
|
||
moveToCenter(latLng, true);
|
||
}
|
||
|
||
private boolean checkAMapView() {
|
||
if (mMapView == null || mMapView.getMapAutoViewHelper() == null) {
|
||
CallerLogger.INSTANCE.e(M_MAP + TAG, "自研mapView实例为空,请检查");
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
@Override
|
||
public void moveToCenter(MogoLatLng latLng, boolean animate) {
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "move to center " + latLng);
|
||
if (latLng == null || latLng.lat == 0.0d || latLng.lon == 0.0d) {
|
||
CallerLogger.INSTANCE.e(M_MAP + TAG, "latLng = null or is illegal");
|
||
return;
|
||
}
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().animateCamera(new LonLatPoint(latLng.lon, latLng.lat));
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void showMyLocation(boolean visible) {
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "showMyLocation1 " + visible);
|
||
// 如果是VR模式
|
||
if (isVrMold()) {
|
||
return;
|
||
}
|
||
// 不是VR模式情况强制刷新下
|
||
if (checkAMapView()) {
|
||
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
|
||
if (visible) {
|
||
// 强制刷新一遍车标
|
||
style.myLocationIcon(mCarCursorOption.getCarCursorRes());
|
||
}
|
||
mMapView.getMapAutoViewHelper().setMyLocationStyle(style);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @return true-是,false=不是
|
||
*/
|
||
private boolean isVrMold() {
|
||
boolean isVrMode = mCurrentUI == EnumMapUI.MAP_STYLE_NIGHT_VR || mCurrentUI == EnumMapUI.MAP_STYLE_DAY_VR;
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "是否是VR模式: " + isVrMode);
|
||
return isVrMode;
|
||
}
|
||
|
||
/**
|
||
* 是否是白天模式
|
||
*
|
||
* @return true-是,false-不是
|
||
*/
|
||
@Override
|
||
public boolean isDayMode() {
|
||
return mCurrentUI == EnumMapUI.MAP_STYLE_DAY_VR
|
||
|| mCurrentUI == EnumMapUI.MAP_STYLE_DAY
|
||
|| mCurrentUI == EnumMapUI.MAP_STYLE_DAY_NAV;
|
||
}
|
||
|
||
@Override
|
||
public void showMyLocation(View view) {
|
||
if (checkAMapView()) {
|
||
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
|
||
style.myLocationIcon(BitmapDescriptorFactory.INSTANCE.convertViewToBitmap(view));
|
||
mMapView.getMapAutoViewHelper().setMyLocationStyle(style);
|
||
}
|
||
}
|
||
|
||
public void initMyLocation() {
|
||
if (checkAMapView()) {
|
||
MarkerHelper.INSTANCE.addPreModel(R.raw.guangquan);
|
||
// MarkerHelper.addPreModel(R.raw.guangquan_day)
|
||
mMapView.getMapAutoViewHelper().setMyLocationEnabled(true);
|
||
}
|
||
}
|
||
|
||
|
||
@Override
|
||
public float getScalePerPixel() {
|
||
return getMap().getScalePerPixel();
|
||
}
|
||
|
||
@Override
|
||
public float getZoomLevel() {
|
||
return getMap().getZoomLevel();
|
||
}
|
||
|
||
@Override
|
||
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
|
||
return getMap().getRoadWidth(lon, lat, angle, isGpsLocation, isRTK);
|
||
}
|
||
|
||
@Override
|
||
public MogoLatLng getCameraNorthEastPosition() {
|
||
return ObjectUtils.fromAMap(MapTools.INSTANCE.getVisibleRegion().getRightTopPoint());
|
||
}
|
||
|
||
@Override
|
||
public MogoLatLng getCameraSouthWestPosition() {
|
||
try {
|
||
return ObjectUtils.fromAMap(MapTools.INSTANCE.getVisibleRegion().getLeftBottomPoint());
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return null;
|
||
}
|
||
|
||
@Override
|
||
public MogoLatLng getWindowCenterLocation() {
|
||
try {
|
||
if (checkAMapView()) {
|
||
return ObjectUtils.fromAMap(mMapView.getMapAutoViewHelper().getCenter());
|
||
}
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
return null;
|
||
}
|
||
|
||
@Override
|
||
public void setPointToCenter(double mapCenterX, double mapCenterY) {
|
||
if (checkAMapView()) {
|
||
if (isVrMold()) {
|
||
return;
|
||
}
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "setPointToCenter x : " + mapCenterX + " y : " + mapCenterY);
|
||
mMapView.getMapAutoViewHelper().setPointToCenter((float) mapCenterX, (float) mapCenterY);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public Point getLocationPointInScreen(MogoLatLng latLng) {
|
||
if (checkAMapView()) {
|
||
try {
|
||
return MapTools.INSTANCE.toScreenLocation(ObjectUtils.fromMogo(latLng));
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
return null;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
@Override
|
||
public MogoLatLng getLocationMogoLatLngInScreen(Point point) {
|
||
if (checkAMapView()) {
|
||
try {
|
||
return ObjectUtils.fromAMap(
|
||
MapTools.INSTANCE.fromScreenLocation(point));
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
return null;
|
||
}
|
||
}
|
||
return null;
|
||
}
|
||
|
||
@Override
|
||
public void setRenderFps(int fps) {
|
||
if (checkAMapView()) {
|
||
if (mMapView.getMapAutoViewHelper() != null) {
|
||
mMapView.getMapAutoViewHelper().setRenderFps(fps);
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "设置刷新帧率 fps = " + fps);
|
||
}
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void showBounds(String tag, MogoLatLng carPosition, List<MogoLatLng> lonLats, Rect bound, boolean lockCarPosition) {
|
||
if (!checkAMapView()) {
|
||
return;
|
||
}
|
||
if (isVrMold()) {
|
||
CallerLogger.INSTANCE.w(M_MAP + TAG, "vr 模式下忽略该设置");
|
||
return;
|
||
}
|
||
CallerLogger.INSTANCE.i(M_MAP + TAG, "showBounds : " + M_MAP + TAG + " , " + carPosition.toString() + " , " + bound.toShortString() + " , " + lockCarPosition);
|
||
try {
|
||
LatLngBounds latLngBounds = MogoMapUtils.getLatLngBounds(carPosition, lonLats, lockCarPosition);
|
||
mMapView.getMapAutoViewHelper().setCenter(ObjectUtils.fromMogo(carPosition));
|
||
mMapView.getMapAutoViewHelper().moveCamera(CameraUpdateFactory.INSTANCE.newLatLngBounds(latLngBounds, bound.left, bound.right, bound.top, bound.bottom));
|
||
} catch (Exception e) {
|
||
CallerLogger.INSTANCE.e(M_MAP + TAG, "M_MAP+TAG : " + M_MAP + TAG + " error : " + e);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void forceRender() {
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().runOnDrawFrame();
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public float calculateLineDistance(MogoLatLng p1, MogoLatLng p2) throws Exception {
|
||
if (p1 == null || p2 == null) {
|
||
throw new Exception("计算距离的点不能为 null");
|
||
}
|
||
return MogoMapUtils.calculateLineDistance(ObjectUtils.fromMogo(p1), ObjectUtils.fromMogo(p2));
|
||
}
|
||
|
||
@Override
|
||
public synchronized boolean isCarLocked() {
|
||
return mMapView.getMapAutoViewHelper().getLockMode();
|
||
}
|
||
|
||
@Override
|
||
public void setCarCursorOption(CarCursorOption option) {
|
||
if (isVrMold()) {
|
||
return;
|
||
}
|
||
if (mCarCursorOption != null && mCarCursorOption != DEFAULT_OPTION) {
|
||
mCarCursorOption.destroy();
|
||
}
|
||
if (option != null) {
|
||
try {
|
||
mCarCursorOption = option.clone();
|
||
} catch (Exception e) {
|
||
mCarCursorOption = DEFAULT_OPTION;
|
||
}
|
||
} else {
|
||
mCarCursorOption = DEFAULT_OPTION;
|
||
}
|
||
if (!checkAMapView()) {
|
||
return;
|
||
}
|
||
|
||
if (mMapView.getMapAutoViewHelper() == null) {
|
||
return;
|
||
}
|
||
MyLocationStyle style = mMapView.getMapAutoViewHelper().getMyLocationStyle();
|
||
if (mCarCursorOption.getCarCursorBmp() != null && !mCarCursorOption.getCarCursorBmp().isRecycled()) {
|
||
style.myLocationIcon(mCarCursorOption.getCarCursorBmp());
|
||
} else {
|
||
if (mCarCursorOption.getCarCursorRes() != 0) {
|
||
style.myLocationIcon(mCarCursorOption.getCarCursorRes());
|
||
}
|
||
}
|
||
mMapView.getMapAutoViewHelper().setMyLocationStyle(style);
|
||
}
|
||
|
||
/**
|
||
* 设置转向灯和刹车灯
|
||
*
|
||
* @param type :车尾灯类型
|
||
* @param time 闪烁时间 最小500ms 小于500ms 默认为500ms
|
||
*/
|
||
@Override
|
||
public void setCarLightsType(int type, int time) {
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().setTailLightsType(type, time);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public MapCameraPosition getMapCameraPosition() {
|
||
if (checkAMapView()) {
|
||
CameraPosition cameraPosition = mMapView.getMapAutoViewHelper().getCameraPosition();
|
||
return ObjectUtils.fromAMap(cameraPosition);
|
||
}
|
||
return null;
|
||
}
|
||
|
||
@Override
|
||
public void changeBearing(float bearing) {
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().setMapViewRotation(bearing);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void changeMapViewAngle(int type) {
|
||
}
|
||
|
||
@Override
|
||
public void changeCurrentIcon(int iconId) {
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().getMyLocationStyle().myLocationIcon(iconId, true);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public long getTileId(double lon, double lat) {
|
||
return getMap().getUIController().getTileId(lon, lat);
|
||
}
|
||
|
||
@Override
|
||
public int getLimitSpeed(double lon, double lat, float angle) {
|
||
return MapDataApi.INSTANCE.getLimitSpeed(lon, lat, angle);
|
||
}
|
||
|
||
@Override
|
||
public CenterLine getCenterLineInfo(double lon, double lat, float angle) {
|
||
return ObjectUtils.transformCenterLine(MapDataApi.INSTANCE.getCenterLineInfo(lon, lat, angle));
|
||
}
|
||
|
||
@Override
|
||
public void result(@NonNull String filePath) {
|
||
CallerMapDevaListenerManager.INSTANCE.invokeUploadLogFile(filePath);
|
||
}
|
||
|
||
|
||
@Override
|
||
public void onMapClick(@Nullable LonLatPoint lonLatPoint) {
|
||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapClick(ObjectUtils.fromAMap(lonLatPoint));
|
||
}
|
||
|
||
|
||
@ChainLog(
|
||
linkChainLog = CHAIN_TYPE_INIT_STATUS,
|
||
linkCode = CHAIN_SOURCE_INIT,
|
||
nodeAliasCode = CHAIN_CODE_INIT_ON_MAP_INIT,
|
||
paramIndexes = {-1}
|
||
)
|
||
@Override
|
||
public void onMapInit() {
|
||
CallerLogger.INSTANCE.i(M_MAP + TAG, "autoop--onMapInit: ");
|
||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapLoaded();
|
||
}
|
||
|
||
@ChainLog(
|
||
linkChainLog = CHAIN_TYPE_INIT_STATUS,
|
||
linkCode = CHAIN_SOURCE_INIT,
|
||
nodeAliasCode = CHAIN_CODE_INIT_ON_MAP_LOADED,
|
||
paramIndexes = {-1}
|
||
)
|
||
@Override
|
||
public void onMapLoaded() {
|
||
CallerLogger.INSTANCE.i(M_MAP + TAG, "autoop--onMapLoaded: ");
|
||
if (checkAMapView()) {
|
||
CameraPosition cameraPosition = mMapView.getMapAutoViewHelper().getCameraPosition();
|
||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapChanged(ObjectUtils.fromAMap(cameraPosition.getTarget()),
|
||
cameraPosition.getZoom(),
|
||
cameraPosition.getTilt(),
|
||
cameraPosition.getBearing());
|
||
initMapView();
|
||
initMyLocation();
|
||
loadPreVehicleModel();
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public boolean onTouch(@Nullable MotionEvent motionEvent) {
|
||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onTouch(motionEvent);
|
||
return false;
|
||
}
|
||
|
||
@Override
|
||
public void onMarkClick(@NotNull Marker markerInfo) {
|
||
// mMarkerClickHandler.handleMarkerClicked(markerInfo);
|
||
}
|
||
|
||
@Override
|
||
public void onRoadLoaded(@Nullable String s) {
|
||
}
|
||
|
||
@Override
|
||
public void onMapStatusChanged(int type, int value) {
|
||
}
|
||
|
||
@Override
|
||
public void onRoamStatus(int status, @NonNull String msg) {
|
||
CallerMapRomaListener.INSTANCE.invokeMapRomaStatus(status, msg);
|
||
}
|
||
|
||
@Override
|
||
public void onMapViewVisualAngleChange(int i) {
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, " 地图自动更改视距 currentThread : " + Thread.currentThread().getName());
|
||
mVisualAngleMode = getVisualAngleMode(i);
|
||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapVisualAngleChanged(mVisualAngleMode);
|
||
}
|
||
|
||
/**
|
||
* 获取当前视距类型
|
||
*
|
||
* @param mode 当前类型
|
||
* @return 当前类型
|
||
*/
|
||
private VisualAngleMode getVisualAngleMode(int mode) {
|
||
switch (mode) {
|
||
case 0:
|
||
return MODE_CLOSE_SIGHT;
|
||
case 1:
|
||
return MODE_MEDIUM_SIGHT;
|
||
case 2:
|
||
return MODE_LONG_SIGHT;
|
||
case 3:
|
||
return MAP_STYLE_VR_ANGLE_300;
|
||
case 4:
|
||
return MAP_STYLE_VR_ANGLE_TOP;
|
||
case 5:
|
||
return MAP_STYLE_VR_ANGLE_CROSS;
|
||
case 7:
|
||
return MAP_STYLE_VR_ROMA;
|
||
default:
|
||
return MODE_MEDIUM_SIGHT;
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onCameraChange(int type, int value) {
|
||
}
|
||
|
||
@Override
|
||
public void onCameraChangeFinish(@Nullable CameraPosition cameraPosition) {
|
||
if (cameraPosition != null) {
|
||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapChanged(ObjectUtils.fromAMap(cameraPosition.getTarget()),
|
||
cameraPosition.getZoom(),
|
||
cameraPosition.getTilt(),
|
||
cameraPosition.getBearing());
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onChangeMapStyle(int styleId) {
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "currentMapStyle = " + styleId);
|
||
// 映射地图样式ID到鹰眼样式ID
|
||
if (styleId == MapAutoApi.MAP_STYLE_DAY
|
||
|| styleId == MapAutoApi.MAP_STYLE_DAY_NAV) {
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_DAY_NAV;
|
||
} else if (styleId == MapAutoApi.MAP_STYLE_NIGHT) {
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT;
|
||
} else if (styleId == MapAutoApi.MAP_STYLE_NIGHT_NAV) {
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_NAV;
|
||
} else if (styleId == MapAutoApi.MAP_STYLE_NIGHT_VR) {
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_VR;
|
||
} else if (styleId == MapAutoApi.MAP_STYLE_DAY_VR) {
|
||
mCurrentUI = EnumMapUI.MAP_STYLE_DAY_VR;
|
||
}
|
||
|
||
loadPreVehicleModel();
|
||
|
||
if (mCurrentUI != null) {
|
||
UiThreadHandler.post(() -> {
|
||
try {
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "currentUI = " + mCurrentUI);
|
||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapModeChanged(mCurrentUI);
|
||
CallerMapStyleListenerManager.INSTANCE.invokeMapStyleChange(styleId);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
// 是否使用RTK数据
|
||
private boolean mRtkEnable = false;
|
||
|
||
@Override
|
||
public void rtkEnable(boolean enable) {
|
||
try {
|
||
mRtkEnable = !mRtkEnable;
|
||
if (mMapView != null && mMapView.getLocationClient() != null) {
|
||
mMapView.getLocationClient().rtkEnable(mRtkEnable);
|
||
}
|
||
} catch (Exception e) {
|
||
CallerLogger.INSTANCE.e(M_MAP + TAG, "rtkEnable has exception : " + e);
|
||
}
|
||
}
|
||
|
||
|
||
@Override
|
||
public void stepInVrMode(boolean isDayMode) {
|
||
// try {
|
||
// int mapStyle;
|
||
// if (isDayMode) {
|
||
// mCurrentUI = EnumMapUI.MAP_STYLE_DAY_VR;
|
||
// mapStyle = MapAutoApi.MAP_STYLE_DAY_VR;
|
||
// } else {
|
||
// mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_VR;
|
||
// mapStyle = MapAutoApi.MAP_STYLE_NIGHT_VR;
|
||
// }
|
||
// if (mMapView != null && mMapView.getMapAutoViewHelper() != null) {
|
||
// mMapView.getMapAutoViewHelper().setMapStyle(mapStyle);
|
||
// }
|
||
// } catch (Exception e) {
|
||
// e.printStackTrace();
|
||
// }
|
||
}
|
||
|
||
@Override
|
||
public String getMarkerInfoResName(String speedVal) {
|
||
return ResIdCache.getVal(speedVal);
|
||
}
|
||
|
||
@Override
|
||
public void setMarkerInfoResName(String speedVal, String val) {
|
||
ResIdCache.putVal(speedVal, val);
|
||
}
|
||
|
||
@Override
|
||
public void setMapDAngle(float angle) {
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().setMapDAngle(angle);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public float getAngle(double startLon, double startLat, double endLon, double endLat) {
|
||
return MapAutoApi.INSTANCE.getAngle(startLon, startLat, endLon, endLat);
|
||
}
|
||
|
||
@Override
|
||
public Double getRoadAngle(Double lon, Double lat, float angle) {
|
||
return MapDataApi.INSTANCE.getRoadRectInfo(lon, lat, angle).getAngle();
|
||
}
|
||
|
||
/**
|
||
* 加载3D模型
|
||
*/
|
||
private void loadPreVehicleModel() {
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, "添加感知模型到地图中……");
|
||
ThreadUtils.getIoPool().submit(() -> {
|
||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_WEI_ZHI, "添加感知模型到地图中……preVehicleStrWeiZhi=");
|
||
|
||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_PEOPLE, "添加感知模型到地图中……preVehicleStrPeople=");
|
||
|
||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_BICYCLE, "添加感知模型到地图中……preVehicleStrBicycle=");
|
||
|
||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_TA_CHE, "添加感知模型到地图中……preVehicleStrTaChe=");
|
||
|
||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_MOTO, "添加感知模型到地图中……preVehicleStrMoto=");
|
||
|
||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_BUS, "添加感知模型到地图中……preVehicleStrBus=");
|
||
|
||
addPreVehicleModelWeiZhi(TrafficTypeEnum.TYPE_TRAFFIC_ID_TRUCK, "添加感知模型到地图中……preVehicleStrTruck=");
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 添加模型到地图中
|
||
*
|
||
* @param typeTrafficId 障碍物类型ID
|
||
* @param logMsg 日志消息
|
||
*/
|
||
private void addPreVehicleModelWeiZhi(TrafficTypeEnum typeTrafficId, String logMsg) {
|
||
String preVehicleStrWeiZhi;
|
||
// 根据当前的地图皮肤模式动态替换
|
||
if (isDayMode()) {
|
||
preVehicleStrWeiZhi =
|
||
// 添加模型到地图中
|
||
MogoIdentifyManager.getInstance(getContext())
|
||
.addPreVehicleModel(typeTrafficId.getType(), typeTrafficId.getTraffic3DIconId());
|
||
} else {
|
||
preVehicleStrWeiZhi =
|
||
// 添加模型到地图中
|
||
MogoIdentifyManager.getInstance(getContext())
|
||
.addPreVehicleModel(typeTrafficId.getType(), typeTrafficId.getTraffic3DNightIconId());
|
||
}
|
||
|
||
CallerLogger.INSTANCE.d(M_MAP + TAG, logMsg + preVehicleStrWeiZhi);
|
||
|
||
if (preVehicleStrWeiZhi == null) {
|
||
UiThreadHandler.postDelayed(() -> {
|
||
CallerLogger.INSTANCE.w(M_MAP + TAG, "添加感知模型到地图中失败,尝试重复添加……");
|
||
addPreVehicleModelWeiZhi(typeTrafficId, logMsg);
|
||
}, 1000L);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void setLockMode(boolean isLock) {
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().setLockMode(true);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void setScrollGesturesEnable(boolean isEnable) {
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().setScrollGesturesEnabled(isEnable);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void setAllGesturesEnabled(boolean isEnable) {
|
||
if (checkAMapView()) {
|
||
mMapView.getMapAutoViewHelper().setAllGesturesEnabled(isEnable);
|
||
}
|
||
}
|
||
|
||
|
||
@Override
|
||
public void setExtraGPSData(MogoLocation gnssInfo) {
|
||
LocationClient locationClient = mMapView.getLocationClient();
|
||
if (locationClient != null) {
|
||
locationClient.setIsUseExtraGPSData(true);//设置是否使用外界坐标
|
||
locationClient.rtkEnable(true);//设置是否是高精定位
|
||
|
||
LonLatPoint lonLatPoint = new LonLatPoint();
|
||
lonLatPoint.setAngle(gnssInfo.getHeading());
|
||
lonLatPoint.setAltitude(gnssInfo.getAltitude());
|
||
lonLatPoint.setLongitude(gnssInfo.getLongitude());
|
||
lonLatPoint.setLatitude(gnssInfo.getLatitude());
|
||
lonLatPoint.setSatelliteTime(Double.valueOf(gnssInfo.getSatelliteTime() * 1000).longValue());
|
||
lonLatPoint.setSpeed((float) gnssInfo.getGnssSpeed());
|
||
|
||
locationClient.updateLocation(lonLatPoint);//更新新自动驾驶RTK相关数据
|
||
|
||
CallerMapDataCollectorManager.INSTANCE.setIsInit();
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void setIsDrawPointCloud(Boolean isDrawPointCloud) {
|
||
try {
|
||
// 是否绘制点云
|
||
PointCloudHelper.INSTANCE.setIsDrawPointCloud(isDrawPointCloud);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void setPointCloudSize(Float pointCloudSize) {
|
||
//设置点云大小
|
||
PointCloudHelper.INSTANCE.setPointCloudSize(pointCloudSize);
|
||
}
|
||
|
||
@Override
|
||
public void setPointCloudColor(String color) {
|
||
// 设置点云颜色
|
||
PointCloudHelper.INSTANCE.setPointCloudColor(color);
|
||
}
|
||
|
||
@Override
|
||
public void cacheHDDataByCity(IHdCacheListener listener) {
|
||
if (mMapView.getMapAutoViewHelper() != null) {
|
||
String gdCityCode = GDLocationClient.getInstance(getContext()).getLastCityCode();
|
||
CallerLogger.INSTANCE.i(M_MAP + TAG, "gdCityCode is:" + gdCityCode);
|
||
Integer id = HDMapUtils.getHDCityCode(gdCityCode);
|
||
if (id != null) {
|
||
hdCacheListener = listener;
|
||
mMapView.getMapAutoViewHelper().cacheHDDataByCity(id, new OnHdDataDownByCityListener() {
|
||
@Override
|
||
public void onMapHDDataCacheProgressByCity(int cityId, double progress) {
|
||
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
|
||
if (hdCacheListener != null) {
|
||
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
|
||
}
|
||
} else {
|
||
UiThreadHandler.post(() -> {
|
||
if (hdCacheListener != null) {
|
||
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
|
||
}
|
||
}, UiThreadHandler.MODE.QUEUE);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onMapHDDataCacheStateByCity(int i, int state) {// 0失败,1成功
|
||
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
|
||
if (hdCacheListener != null) {
|
||
hdCacheListener.onMapHdCacheResult(i, state);
|
||
}
|
||
} else {
|
||
UiThreadHandler.post(() -> {
|
||
if (hdCacheListener != null) {
|
||
hdCacheListener.onMapHdCacheResult(i, state);
|
||
}
|
||
}, UiThreadHandler.MODE.QUEUE);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void cacheHDDataByCity(IHdCacheListener listener, MogoLocation location) {
|
||
if (mMapView.getMapAutoViewHelper() != null) {
|
||
hdCacheListener = listener;
|
||
CallerLogger.INSTANCE.i(M_MAP + TAG, "location lon is:" + location.getLongitude() + ",lat is:" + location.getLatitude());
|
||
mMapView.getMapAutoViewHelper().cacheHDDataByCityByLonLat(location.getLongitude(), location.getLatitude(), new OnHdDataDownByCityListener() {
|
||
@Override
|
||
public void onMapHDDataCacheProgressByCity(int cityId, double progress) {
|
||
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
|
||
if (hdCacheListener != null) {
|
||
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
|
||
}
|
||
} else {
|
||
UiThreadHandler.post(() -> {
|
||
if (hdCacheListener != null) {
|
||
hdCacheListener.onMapHdCacheProgress(cityId, progress * 100);
|
||
}
|
||
}, UiThreadHandler.MODE.QUEUE);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onMapHDDataCacheStateByCity(int i, int state) {// 0失败,1成功
|
||
if (Thread.currentThread() == Looper.getMainLooper().getThread()) {
|
||
if (hdCacheListener != null) {
|
||
hdCacheListener.onMapHdCacheResult(i, state);
|
||
}
|
||
} else {
|
||
UiThreadHandler.post(() -> {
|
||
if (hdCacheListener != null) {
|
||
hdCacheListener.onMapHdCacheResult(i, state);
|
||
}
|
||
}, UiThreadHandler.MODE.QUEUE);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public boolean isCityDataCached() {
|
||
if (mMapView.getMapAutoViewHelper() != null) {
|
||
String gdCityCode = GDLocationClient.getInstance(getContext()).getLastCityCode();
|
||
CallerLogger.INSTANCE.i(M_MAP + TAG, "gdCityCode is:" + gdCityCode);
|
||
Integer id = HDMapUtils.getHDCityCode(gdCityCode);
|
||
if (id != null) {
|
||
List<CityInfo> cityInfoList = mMapView.getMapAutoViewHelper().getAllCityCode();
|
||
if (cityInfoList != null) {
|
||
for (CityInfo cityInfo : cityInfoList) {
|
||
if (id == cityInfo.getCityCode()) {
|
||
return cityInfo.isCache;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
|
||
@Override
|
||
public void cancelDownloadCacheData() {
|
||
if (mMapView.getMapAutoViewHelper() != null) {
|
||
mMapView.getMapAutoViewHelper().cancelCacheHDData();
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public String getCityCode() {
|
||
return GDLocationClient.getInstance(getContext()).getLastCityCode();
|
||
}
|
||
|
||
@Override
|
||
public void animateTo(double lon, double lat, float rotateAngle, int duration, boolean isGps) {
|
||
if (mMapView.getMapAutoViewHelper() != null) {
|
||
mMapView.getMapAutoViewHelper().animateTo(lon, lat, rotateAngle, duration, isGps);
|
||
}
|
||
}
|
||
}
|