[3.4.0-map-sdk] update ,wait to test
This commit is contained in:
@@ -1,960 +0,0 @@
|
||||
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.text.TextUtils;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum;
|
||||
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.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
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.MogoMapUtils;
|
||||
import com.mogo.map.utils.ObjectUtils;
|
||||
import com.mogo.map.utils.ResIdCache;
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint;
|
||||
import com.zhidaoauto.map.data.road.RoadCross;
|
||||
import com.zhidaoauto.map.data.road.StopLine;
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi;
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener;
|
||||
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.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.OnMarkClickListener;
|
||||
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,
|
||||
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 volatile EnumMapUI mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_VR;
|
||||
private VisualAngleMode mVisualAngleMode = MODE_MEDIUM_SIGHT;
|
||||
|
||||
public AMapViewWrapper(MapAutoView mMapView) {
|
||||
CallerLogger.INSTANCE.i(M_MAP + TAG, "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 = mMapView.getMapStyleParams().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 initListeners() {
|
||||
mMapView.setOnMarkClickListener(this);
|
||||
mMapView.setOnMapLoadedListener(this);
|
||||
mMapView.setOnMapTouchListener(this);
|
||||
mMapView.setOnMapClickListener(this);
|
||||
mMapView.setOnCameraChangeListener(this);
|
||||
mMapView.setOnMapStyleListener(this);
|
||||
mMapView.setOnRoamStatusListener(this);
|
||||
mMapView.setOnMapViewVisualAngleChangeListener(this);
|
||||
mMapView.setOnRoadInfoListener(this, 1);
|
||||
MapAutoApi.INSTANCE.registerLogListener(this, mMapView.getEventController());
|
||||
CallerLogger.INSTANCE.d(M_MAP + TAG, "styleop - initListeners - setOnMapStyleListener - view " + mMapView);
|
||||
}
|
||||
|
||||
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);
|
||||
mMapView.setOnMapStyleListener(null);
|
||||
mMapView.setOnMapViewVisualAngleChangeListener(null);
|
||||
MapAutoApi.INSTANCE.unregisterLogListener(this, mMapView.getEventController());
|
||||
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() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改获取当前车道号
|
||||
*
|
||||
* @param roadId
|
||||
* @param s1
|
||||
*/
|
||||
@Override
|
||||
public void onRoadIdInfo(@androidx.annotation.Nullable String roadId, @androidx.annotation.Nullable String s1) {
|
||||
if (roadId != null && !TextUtils.isEmpty(roadId)) {
|
||||
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnRoadIdGet(roadId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoadCrossInfo(@androidx.annotation.Nullable RoadCross roadCross) {
|
||||
|
||||
}
|
||||
|
||||
//todo 多实例 对象替换
|
||||
@Override
|
||||
public void onStopLineInfo(@androidx.annotation.Nullable StopLine stopLine) {
|
||||
MogoLocation carLoc = CallerChassisLocationWGS84ListenerManager.INSTANCE.getChassisLocationWGS84();
|
||||
if (stopLine != null && stopLine.getRoad_id() != null && !stopLine.getRoad_id().isEmpty() && stopLine.getPoints() != null && stopLine.getPoints().size() > 0) {
|
||||
ArrayList<LonLatPoint> points = stopLine.getPoints();
|
||||
if (carLoc != null) {
|
||||
CallerLogger.INSTANCE.d(M_MAP + TAG, "onStopLineInfo:stop_line" + stopLine);
|
||||
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.getLongitude(), p1.getLatitude(), p2.getLongitude(), p2.getLatitude()) * 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.getDistance());
|
||||
ret.setLaneId(line.getLane_id());
|
||||
ret.setRoadId(line.getRoad_id());
|
||||
ret.setTieId(line.getTile_id());
|
||||
ArrayList<LonLatPoint> points = line.getPoints();
|
||||
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.getLatitude(), lonLatPoint.getLongitude());
|
||||
latLng.duration = lonLatPoint.getDuration();
|
||||
latLng.angle = lonLatPoint.getAngle();
|
||||
latLng.speed = lonLatPoint.getSpeed();
|
||||
latLng.altitude = lonLatPoint.getAltitude();
|
||||
latLng.provider = lonLatPoint.getProvider();
|
||||
newPoints.add(latLng);
|
||||
}
|
||||
ret.setPoints(newPoints);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapControlResult changeZoom(float zoom) {
|
||||
MapAutoViewHelper mapAutoViewHelper = mMapView.getMapAutoViewHelper();
|
||||
if (mapAutoViewHelper != null) {
|
||||
mapAutoViewHelper.setZoom((int) zoom);
|
||||
}
|
||||
return MapControlResult.SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeZoom2(float zoom) {
|
||||
MapAutoViewHelper mapAutoViewHelper = mMapView.getMapAutoViewHelper();
|
||||
if (mapAutoViewHelper != null) {
|
||||
mapAutoViewHelper.setZoomVal(zoom);
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getScalePerPixel() {
|
||||
if (checkAMapView()) {
|
||||
return mMapView.getMapAutoViewHelper().getScalePerPixel();
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getZoomLevel() {
|
||||
if (checkAMapView()) {
|
||||
return mMapView.getMapAutoViewHelper().getZoom();
|
||||
}
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraNorthEastPosition() {
|
||||
return ObjectUtils.fromAMap(MapTools.INSTANCE.getVisibleRegion(mMapView.getMapController()).getRightTopPoint());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraSouthWestPosition() {
|
||||
try {
|
||||
return ObjectUtils.fromAMap(MapTools.INSTANCE.getVisibleRegion(mMapView.getMapController()).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), mMapView.getMapController());
|
||||
} 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, mMapView.getMapController()));
|
||||
} 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 changeCurrentIcon(int iconId) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper().getMyLocationStyle().myLocationIcon(iconId, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void result(@NonNull String filePath) {
|
||||
CallerMapDevaListenerManager.INSTANCE.invokeUploadLogFile(filePath);
|
||||
}
|
||||
|
||||
//渲染第一帧
|
||||
@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, "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, "onMapLoaded: ");
|
||||
if (checkAMapView()) {
|
||||
CameraPosition cameraPosition = mMapView.getMapAutoViewHelper().getCameraPosition();
|
||||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapChanged(ObjectUtils.fromAMap(cameraPosition.getTarget()),
|
||||
cameraPosition.getZoom(),
|
||||
cameraPosition.getTilt(),
|
||||
cameraPosition.getBearing());
|
||||
loadPreVehicleModel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onTouch(@Nullable MotionEvent motionEvent) {
|
||||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onTouch(motionEvent);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick(@Nullable LonLatPoint lonLatPoint) {
|
||||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapClick(ObjectUtils.fromAMap(lonLatPoint));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapViewVisualAngleChange(int i) {
|
||||
CallerLogger.INSTANCE.d(M_MAP + TAG, " 地图自动更改视距 currentThread : " + Thread.currentThread().getName());
|
||||
mVisualAngleMode = getVisualAngleMode(i);
|
||||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapVisualAngleChanged(mVisualAngleMode);
|
||||
}
|
||||
|
||||
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 + " , current = " + mCurrentUI);
|
||||
// 映射地图样式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 {
|
||||
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapModeChanged(mCurrentUI);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMarkClick(@NotNull Marker markerInfo) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoamStatus(int status, @NonNull String msg) {
|
||||
CallerMapRomaListener.INSTANCE.invokeMapRomaStatus(status, msg);
|
||||
}
|
||||
|
||||
|
||||
// 是否使用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 {
|
||||
// if (mMapView != null && mMapView.getMapAutoViewHelper() != null) {
|
||||
// mMapView.getMapAutoViewHelper().setMapStyle();
|
||||
// }
|
||||
// } 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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载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 =
|
||||
// 添加模型到地图中
|
||||
getMap().addPreVehicleModel(typeTrafficId.getType(), typeTrafficId.getTraffic3DIconId());
|
||||
} else {
|
||||
preVehicleStrWeiZhi =
|
||||
// 添加模型到地图中
|
||||
getMap().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(isLock);
|
||||
}
|
||||
}
|
||||
|
||||
@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, mMapView.getMapController());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointCloudSize(Float pointCloudSize) {
|
||||
//设置点云大小
|
||||
PointCloudHelper.INSTANCE.setPointCloudSize(pointCloudSize, mMapView.getMapController());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPointCloudColor(String color) {
|
||||
// 设置点云颜色
|
||||
PointCloudHelper.INSTANCE.setPointCloudColor(color, mMapView.getMapController());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCityCode() {
|
||||
return GDLocationClient.Companion.getGdLocationClient().getLastCityCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateTo(double lon, double lat, float rotateAngle, int duration, boolean isGps) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper().animateTo(lon, lat, rotateAngle, duration, isGps);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void animateTo(double lon, double lat, float v1, float v2, float v3, float v4, int duration, boolean isGps) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper().animateTo(lon, lat, v1, v2, v3, v4, duration, isGps);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
if(checkAMapView()){
|
||||
mMapView.getMapAutoViewHelper().clearPanel();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRoadLoaded(@androidx.annotation.Nullable String roadInfo) {
|
||||
|
||||
}
|
||||
}
|
||||
820
libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.kt
Normal file
820
libraries/mogo-map/src/main/java/com/mogo/map/AMapViewWrapper.kt
Normal file
@@ -0,0 +1,820 @@
|
||||
package com.mogo.map
|
||||
|
||||
import android.graphics.Point
|
||||
import android.graphics.Rect
|
||||
import android.os.Bundle
|
||||
import android.text.TextUtils
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import com.mogo.eagle.core.data.deva.chain.ChainConstant
|
||||
import com.mogo.eagle.core.data.enums.TrafficTypeEnum
|
||||
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.getChassisLocationWGS84
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager.setIsInit
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapDevaListenerManager.invokeUploadLogFile
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.invokeListenersOnRoadIdGet
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager.invokeListenersOnStopLineGet
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRomaListener.invokeMapRomaStatus
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.w
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.map.listener.MogoMapListenerHandler.Companion.mogoMapListenerHandler
|
||||
import com.mogo.map.uicontroller.*
|
||||
import com.mogo.map.utils.MogoMapUtils
|
||||
import com.mogo.map.utils.ObjectUtils
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.data.road.RoadCross
|
||||
import com.zhidaoauto.map.data.road.StopLine
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi.registerLogListener
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi.unregisterLogListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.*
|
||||
import com.zhidaoauto.map.sdk.open.abs.log.ILog
|
||||
import com.zhidaoauto.map.sdk.open.business.PointCloudHelper.setIsDrawPointCloud
|
||||
import com.zhidaoauto.map.sdk.open.business.PointCloudHelper.setPointCloudColor
|
||||
import com.zhidaoauto.map.sdk.open.business.PointCloudHelper.setPointCloudSize
|
||||
import com.zhidaoauto.map.sdk.open.business.PointCloudHelper.updatePointCloudDataByPb
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraUpdateFactory.newLatLngBounds
|
||||
import com.zhidaoauto.map.sdk.open.data.MapDataApi.getNearstFromPointToSegment
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptorFactory.convertViewToBitmap
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker
|
||||
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener
|
||||
import com.zhidaoauto.map.sdk.open.tools.MapTools.fromScreenLocation
|
||||
import com.zhidaoauto.map.sdk.open.tools.MapTools.getVisibleRegion
|
||||
import com.zhidaoauto.map.sdk.open.tools.MapTools.toScreenLocation
|
||||
import com.zhidaoauto.map.sdk.open.view.MapAutoView
|
||||
import com.zhjt.service.chain.ChainLog
|
||||
|
||||
class AMapViewWrapper(mMapView: MapAutoView) : IMogoMapView, IMogoMapUIController,
|
||||
OnMapLoadedListener, OnCameraChangeListener, OnMapClickListener, OnMapTouchListener,
|
||||
OnMarkClickListener, OnMapStyleListener, OnMapViewVisualAngleChangeListener, OnRoadInfoListener,
|
||||
ILog, OnRoamStatusListener {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "AMapViewWrapper"
|
||||
}
|
||||
|
||||
private var mMapView: MapAutoView
|
||||
private val mIMap: IMogoMap
|
||||
private val DEFAULT_OPTION = CarCursorOption.Builder()
|
||||
.carCursorRes(R.drawable.map_api_ic_current_location2)
|
||||
.naviCursorRes(R.drawable.ic_amap_navi_cursor)
|
||||
.build()
|
||||
private var mCarCursorOption = DEFAULT_OPTION
|
||||
|
||||
@Volatile
|
||||
private var mCurrentUI: EnumMapUI = EnumMapUI.MAP_STYLE_NIGHT_VR
|
||||
override var currentMapVisualAngle: VisualAngleMode = VisualAngleMode.MODE_MEDIUM_SIGHT
|
||||
private set
|
||||
|
||||
init {
|
||||
i(SceneConstant.M_MAP + TAG, "AMapViewWrapper: init")
|
||||
this.mMapView = mMapView
|
||||
initViews()
|
||||
initListeners()
|
||||
mIMap = AMapWrapper(this.mMapView.getMapAutoViewHelper(), this.mMapView, this)
|
||||
}
|
||||
|
||||
private fun initViews() {
|
||||
// 初始化首次地图进入的时候的样式, MapAutoApi.INSTANCE.init(context, mapParams);将影响这里的数据
|
||||
val mapStyle = mMapView.getMapStyleParams()!!.getStyleMode()
|
||||
d(SceneConstant.M_MAP + TAG, "默认配置地图模式:mapStyle=$mapStyle")
|
||||
when (mapStyle) {
|
||||
MapAutoApi.MAP_STYLE_DAY -> mCurrentUI = EnumMapUI.MAP_STYLE_DAY
|
||||
MapAutoApi.MAP_STYLE_DAY_NAV -> mCurrentUI = EnumMapUI.MAP_STYLE_DAY_NAV
|
||||
MapAutoApi.MAP_STYLE_NIGHT -> mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT
|
||||
MapAutoApi.MAP_STYLE_NIGHT_NAV -> mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_NAV
|
||||
MapAutoApi.MAP_STYLE_DAY_VR -> mCurrentUI = EnumMapUI.MAP_STYLE_DAY_VR
|
||||
MapAutoApi.MAP_STYLE_NIGHT_VR -> mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_VR
|
||||
else -> e(SceneConstant.M_MAP + TAG, "暂不支持此地图模式,默认使用VR夜间模式")
|
||||
}
|
||||
}
|
||||
|
||||
private fun initListeners() {
|
||||
mMapView.setOnMarkClickListener(this)
|
||||
mMapView.setOnMapLoadedListener(this)
|
||||
mMapView.setOnMapTouchListener(this)
|
||||
mMapView.setOnMapClickListener(this)
|
||||
mMapView.setOnCameraChangeListener(this)
|
||||
mMapView.setOnMapStyleListener(this)
|
||||
mMapView.setOnRoamStatusListener(this)
|
||||
mMapView.setOnMapViewVisualAngleChangeListener(this)
|
||||
mMapView.setOnRoadInfoListener(this, 1)
|
||||
registerLogListener(this, mMapView.getEventController())
|
||||
d(SceneConstant.M_MAP + TAG, "initListeners - setOnMapStyleListener - view $mMapView")
|
||||
}
|
||||
|
||||
override fun getMapView(): View {
|
||||
return mMapView
|
||||
}
|
||||
|
||||
override fun getMap(): IMogoMap {
|
||||
return mIMap
|
||||
}
|
||||
|
||||
override fun onCreate(bundle: Bundle?) {
|
||||
mMapView.onCreate(bundle)
|
||||
d(SceneConstant.M_MAP + TAG, "map onCreate")
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
mMapView.onResume()
|
||||
d(SceneConstant.M_MAP + TAG, "map onResume")
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
mMapView.onPause()
|
||||
d(SceneConstant.M_MAP + TAG, "map onPause")
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
mMapView.onDestroy()
|
||||
mMapView.setOnMarkClickListener(null)
|
||||
mMapView.setOnMapLoadedListener(null)
|
||||
mMapView.setOnMapTouchListener(null)
|
||||
mMapView.setOnMapClickListener(null)
|
||||
mMapView.setOnCameraChangeListener(null)
|
||||
mMapView.setOnMapStyleListener(null)
|
||||
mMapView.setOnMapViewVisualAngleChangeListener(null)
|
||||
unregisterLogListener(this, mMapView.getEventController())
|
||||
d(SceneConstant.M_MAP + TAG, "map onDestroy")
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
mMapView.onSaveInstanceState(outState)
|
||||
d(SceneConstant.M_MAP + TAG, "map onSaveInstanceState")
|
||||
}
|
||||
|
||||
override fun onLowMemory() {}
|
||||
|
||||
//渲染第一帧
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_INIT_STATUS,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_INIT,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_INIT_ON_MAP_INIT,
|
||||
paramIndexes = [-1]
|
||||
)
|
||||
override fun onMapInit() {
|
||||
i(SceneConstant.M_MAP + TAG, "onMapInit: ")
|
||||
mogoMapListenerHandler.onMapLoaded()
|
||||
}
|
||||
|
||||
//地图视图准备
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_INIT_STATUS,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_INIT,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_INIT_ON_MAP_LOADED,
|
||||
paramIndexes = [-1]
|
||||
)
|
||||
override fun onMapLoaded() {
|
||||
i(SceneConstant.M_MAP + TAG, "onMapLoaded: ")
|
||||
if (checkAMapView()) {
|
||||
val cameraPosition = mMapView.getMapAutoViewHelper()!!
|
||||
.getCameraPosition()
|
||||
mogoMapListenerHandler.onMapChanged(
|
||||
ObjectUtils.fromAMap(cameraPosition.target),
|
||||
cameraPosition.zoom,
|
||||
cameraPosition.tilt,
|
||||
cameraPosition.bearing
|
||||
)
|
||||
loadPreVehicleModel()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改获取当前车道号
|
||||
*
|
||||
* @param roadId
|
||||
* @param laneId
|
||||
*/
|
||||
override fun onRoadIdInfo(roadId: String?, laneId: String?) {
|
||||
if (roadId != null && !TextUtils.isEmpty(roadId)) {
|
||||
invokeListenersOnRoadIdGet(roadId)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRoadCrossInfo(roadCross: RoadCross?) {
|
||||
d(SceneConstant.M_MAP + TAG, "onRoadCrossInfo:roadCross$roadCross")
|
||||
}
|
||||
|
||||
//todo 多实例 对象替换
|
||||
override fun onStopLineInfo(stopLine: StopLine?) {
|
||||
val carLoc = getChassisLocationWGS84()
|
||||
if (stopLine != null && !stopLine.road_id.isEmpty() && stopLine.points.size > 0) {
|
||||
val points = stopLine.points
|
||||
d(SceneConstant.M_MAP + TAG, "onStopLineInfo:stop_line$stopLine")
|
||||
val stopInfo = convert(stopLine)
|
||||
val p1 = points[0]
|
||||
val p2 = points[points.size - 1]
|
||||
val distanceOfCarToStopLine = getNearstFromPointToSegment(
|
||||
carLoc.longitude,
|
||||
carLoc.latitude,
|
||||
p1.longitude,
|
||||
p1.latitude,
|
||||
p2.longitude,
|
||||
p2.latitude
|
||||
) * 100000
|
||||
stopInfo.distanceOfCarToStopLine = distanceOfCarToStopLine
|
||||
d(SceneConstant.M_MAP + TAG, "onStopLineInfo: --- distance: $distanceOfCarToStopLine")
|
||||
invokeListenersOnStopLineGet(stopInfo)
|
||||
}
|
||||
}
|
||||
|
||||
private fun convert(line: StopLine): MapRoadInfo.StopLine {
|
||||
val ret = MapRoadInfo.StopLine()
|
||||
ret.distance = line.distance
|
||||
ret.laneId = line.lane_id
|
||||
ret.roadId = line.road_id
|
||||
ret.tieId = line.tile_id
|
||||
val points = line.points
|
||||
if (points.size > 0) {
|
||||
val newPoints: MutableList<MogoLatLng> = ArrayList()
|
||||
for (i in points.indices) {
|
||||
val lonLatPoint = points[i]
|
||||
val latLng = 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.points = newPoints
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
override fun changeZoom(zoom: Float): MapControlResult {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.setZoom(zoom.toInt())
|
||||
}
|
||||
return MapControlResult.SUCCESS
|
||||
}
|
||||
|
||||
override fun changeZoom2(zoom: Float) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.setZoomVal(zoom)
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeMapVisualAngle(angelMode: VisualAngleMode, mogoLatLng: MogoLatLng?) {
|
||||
val mapAutoViewHelper = mMapView.getMapAutoViewHelper()
|
||||
if (mapAutoViewHelper != null) {
|
||||
currentMapVisualAngle = angelMode
|
||||
if (angelMode == VisualAngleMode.MODE_CLOSE_SIGHT) {
|
||||
if (mogoLatLng == null) {
|
||||
e(SceneConstant.M_MAP + TAG, "切换地图近景需要传入要移动的经纬度数据")
|
||||
return
|
||||
}
|
||||
// 近景传入经纬度为点击地图上静态marker经纬度数据,为GPS坐标点。
|
||||
mapAutoViewHelper.setNearViewAnglePosition(
|
||||
LonLatPoint(
|
||||
mogoLatLng.lon,
|
||||
mogoLatLng.lat
|
||||
), true
|
||||
)
|
||||
} else {
|
||||
mapAutoViewHelper.setMapViewVisualAngle(angelMode.code)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_HD_MAP,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_MAP,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_HD_MAP_CALL,
|
||||
paramIndexes = [0]
|
||||
)
|
||||
override fun setRoamTrajectory(trajectory: String) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.setRoamTrajectory(trajectory)
|
||||
}
|
||||
}
|
||||
|
||||
@ChainLog(
|
||||
linkChainLog = ChainConstant.CHAIN_TYPE_HD_MAP,
|
||||
linkCode = ChainConstant.CHAIN_SOURCE_MAP,
|
||||
parentNodeAliasCode = ChainConstant.CHAIN_CODE_ROMA_REQUEST_OK,
|
||||
nodeAliasCode = ChainConstant.CHAIN_CODE_ROMA_MODE_INVOKE,
|
||||
paramIndexes = [0],
|
||||
endPoint = false
|
||||
)
|
||||
override fun setRomaMode(mode: Int) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.setRoamStyle(mode, 1800f, MapAutoApi.ROAM_SPEED_40)
|
||||
}
|
||||
}
|
||||
|
||||
override fun moveToCenter(latLng: MogoLatLng) {
|
||||
moveToCenter(latLng, true)
|
||||
}
|
||||
|
||||
private fun checkAMapView(): Boolean {
|
||||
if (mMapView.getMapAutoViewHelper() == null) {
|
||||
e(SceneConstant.M_MAP + TAG, "自研mapView实例为空,请检查")
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun moveToCenter(latLng: MogoLatLng, animate: Boolean) {
|
||||
d(SceneConstant.M_MAP + TAG, "move to center $latLng")
|
||||
if (latLng.lat == 0.0 || latLng.lon == 0.0) {
|
||||
e(SceneConstant.M_MAP + TAG, "latLng = null or is illegal")
|
||||
return
|
||||
}
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!
|
||||
.animateCamera(LonLatPoint(latLng.lon, latLng.lat))
|
||||
}
|
||||
}
|
||||
|
||||
override fun showMyLocation(visible: Boolean) {
|
||||
d(SceneConstant.M_MAP + TAG, "showMyLocation1 $visible")
|
||||
// 如果是VR模式
|
||||
if (isVrMold) {
|
||||
return
|
||||
}
|
||||
// 不是VR模式情况强制刷新下
|
||||
if (checkAMapView()) {
|
||||
val style = mMapView.getMapAutoViewHelper()!!
|
||||
.getMyLocationStyle()
|
||||
if (visible) {
|
||||
// 强制刷新一遍车标
|
||||
style!!.myLocationIcon(mCarCursorOption!!.carCursorRes)
|
||||
}
|
||||
mMapView.getMapAutoViewHelper()!!.setMyLocationStyle(style!!)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true-是,false=不是
|
||||
*/
|
||||
private val isVrMold: Boolean
|
||||
get() {
|
||||
val isVrMode =
|
||||
mCurrentUI === EnumMapUI.MAP_STYLE_NIGHT_VR || mCurrentUI === EnumMapUI.MAP_STYLE_DAY_VR
|
||||
d(SceneConstant.M_MAP + TAG, "是否是VR模式: $isVrMode")
|
||||
return isVrMode
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否是白天模式
|
||||
*
|
||||
* @return true-是,false-不是
|
||||
*/
|
||||
override val isDayMode: Boolean
|
||||
get() = mCurrentUI === EnumMapUI.MAP_STYLE_DAY_VR || mCurrentUI === EnumMapUI.MAP_STYLE_DAY || mCurrentUI === EnumMapUI.MAP_STYLE_DAY_NAV
|
||||
|
||||
override fun showMyLocation(view: View) {
|
||||
if (checkAMapView()) {
|
||||
val style = mMapView.getMapAutoViewHelper()!!.getMyLocationStyle()
|
||||
style!!.myLocationIcon(convertViewToBitmap(view))
|
||||
mMapView.getMapAutoViewHelper()!!.setMyLocationStyle(style)
|
||||
}
|
||||
}
|
||||
|
||||
override val scalePerPixel: Float
|
||||
get() = if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.getScalePerPixel()
|
||||
} else 0.0f
|
||||
override val zoomLevel: Float
|
||||
get() = if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.getZoom().toFloat()
|
||||
} else 0.0f
|
||||
override val cameraNorthEastPosition: MogoLatLng?
|
||||
get() = ObjectUtils.fromAMap(getVisibleRegion(mMapView.getMapController()).rightTopPoint)
|
||||
override val cameraSouthWestPosition: MogoLatLng?
|
||||
get() {
|
||||
try {
|
||||
return ObjectUtils.fromAMap(getVisibleRegion(mMapView.getMapController()).leftBottomPoint)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
override val windowCenterLocation: MogoLatLng?
|
||||
get() {
|
||||
try {
|
||||
if (checkAMapView()) {
|
||||
return ObjectUtils.fromAMap(mMapView.getMapAutoViewHelper()!!.getCenter())
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun setPointToCenter(mapCenterX: Double, mapCenterY: Double) {
|
||||
if (checkAMapView()) {
|
||||
if (isVrMold) {
|
||||
return
|
||||
}
|
||||
mMapView.getMapAutoViewHelper()!!
|
||||
.setPointToCenter(mapCenterX.toFloat(), mapCenterY.toFloat())
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLocationPointInScreen(latLng: MogoLatLng): Point? {
|
||||
return if (checkAMapView()) {
|
||||
try {
|
||||
toScreenLocation(ObjectUtils.fromMogo(latLng), mMapView.getMapController())
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
} else null
|
||||
}
|
||||
|
||||
override fun getLocationMogoLatLngInScreen(point: Point): MogoLatLng? {
|
||||
return if (checkAMapView()) {
|
||||
try {
|
||||
ObjectUtils.fromAMap(fromScreenLocation(point, mMapView.getMapController()))
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
null
|
||||
}
|
||||
} else null
|
||||
}
|
||||
|
||||
override fun setRenderFps(fps: Int) {
|
||||
if (checkAMapView()) {
|
||||
if (mMapView.getMapAutoViewHelper() != null) {
|
||||
mMapView.getMapAutoViewHelper()!!.setRenderFps(fps)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun showBounds(
|
||||
tag: String,
|
||||
carPosition: MogoLatLng,
|
||||
lonLats: List<MogoLatLng>,
|
||||
bound: Rect,
|
||||
lockCarPosition: Boolean
|
||||
) {
|
||||
if (!checkAMapView()) {
|
||||
return
|
||||
}
|
||||
if (isVrMold) {
|
||||
w(SceneConstant.M_MAP + TAG, "vr 模式下忽略该设置")
|
||||
return
|
||||
}
|
||||
i(
|
||||
SceneConstant.M_MAP + TAG,
|
||||
"showBounds : " + carPosition.toString() + " , " + bound.toShortString() + " , " + lockCarPosition
|
||||
)
|
||||
try {
|
||||
val latLngBounds = MogoMapUtils.getLatLngBounds(carPosition, lonLats, lockCarPosition)
|
||||
mMapView.getMapAutoViewHelper()!!.setCenter(ObjectUtils.fromMogo(carPosition))
|
||||
mMapView.getMapAutoViewHelper()!!.moveCamera(
|
||||
newLatLngBounds(
|
||||
latLngBounds,
|
||||
bound.left,
|
||||
bound.right,
|
||||
bound.top,
|
||||
bound.bottom
|
||||
)
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
e(SceneConstant.M_MAP + TAG, " error : $e")
|
||||
}
|
||||
}
|
||||
|
||||
override fun forceRender() {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.runOnDrawFrame()
|
||||
}
|
||||
}
|
||||
|
||||
override fun calculateLineDistance(p1: MogoLatLng, p2: MogoLatLng): Float {
|
||||
return MogoMapUtils.calculateLineDistance(
|
||||
ObjectUtils.fromMogo(p1),
|
||||
ObjectUtils.fromMogo(p2)
|
||||
)
|
||||
}
|
||||
|
||||
@get:Synchronized
|
||||
override val isCarLocked: Boolean
|
||||
get() = mMapView.getMapAutoViewHelper()!!.getLockMode()
|
||||
|
||||
override fun setCarCursorOption(option: CarCursorOption) {
|
||||
if (isVrMold) {
|
||||
return
|
||||
}
|
||||
if (!checkAMapView()) {
|
||||
return
|
||||
}
|
||||
if (mCarCursorOption != null && mCarCursorOption !== DEFAULT_OPTION) {
|
||||
mCarCursorOption!!.destroy()
|
||||
}
|
||||
mCarCursorOption = try {
|
||||
option.clone()
|
||||
} catch (e: Exception) {
|
||||
DEFAULT_OPTION
|
||||
}
|
||||
val style = mMapView.getMapAutoViewHelper()!!.getMyLocationStyle()
|
||||
if (mCarCursorOption!!.carCursorBmp != null && !mCarCursorOption!!.carCursorBmp.isRecycled) {
|
||||
style!!.myLocationIcon(mCarCursorOption!!.carCursorBmp)
|
||||
} else {
|
||||
if (mCarCursorOption!!.carCursorRes != 0) {
|
||||
style!!.myLocationIcon(mCarCursorOption!!.carCursorRes)
|
||||
}
|
||||
}
|
||||
mMapView.getMapAutoViewHelper()!!.setMyLocationStyle(style!!)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置转向灯和刹车灯
|
||||
*
|
||||
* @param type :车尾灯类型
|
||||
* @param time 闪烁时间 最小500ms 小于500ms 默认为500ms
|
||||
*/
|
||||
override fun setCarLightsType(type: Int, time: Int) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.setTailLightsType(type, time)
|
||||
}
|
||||
}
|
||||
|
||||
override val mapCameraPosition: MapCameraPosition?
|
||||
get() {
|
||||
if (checkAMapView()) {
|
||||
val cameraPosition = mMapView.getMapAutoViewHelper()!!.getCameraPosition()
|
||||
return ObjectUtils.fromAMap(cameraPosition)
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun changeBearing(bearing: Float) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.setMapViewRotation(bearing)
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeCurrentIcon(iconId: Int) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.getMyLocationStyle()!!.myLocationIcon(iconId, true)
|
||||
}
|
||||
}
|
||||
|
||||
override fun result(path: String) {
|
||||
invokeUploadLogFile(path)
|
||||
}
|
||||
|
||||
override fun onTouch(event: MotionEvent): Boolean {
|
||||
mogoMapListenerHandler.onTouch(event)
|
||||
return false
|
||||
}
|
||||
|
||||
override fun onMapClick(lonLatPoint: LonLatPoint) {
|
||||
mogoMapListenerHandler.onMapClick(ObjectUtils.fromAMap(lonLatPoint))
|
||||
}
|
||||
|
||||
override fun onMapViewVisualAngleChange(type: Int) {
|
||||
d(SceneConstant.M_MAP + TAG, " 地图自动更改视距 currentThread : " + Thread.currentThread().name)
|
||||
currentMapVisualAngle = getVisualAngleMode(type)
|
||||
mogoMapListenerHandler.onMapVisualAngleChanged(currentMapVisualAngle)
|
||||
}
|
||||
|
||||
private fun getVisualAngleMode(mode: Int): VisualAngleMode {
|
||||
return when (mode) {
|
||||
0 -> VisualAngleMode.MODE_CLOSE_SIGHT
|
||||
1 -> VisualAngleMode.MODE_MEDIUM_SIGHT
|
||||
2 -> VisualAngleMode.MODE_LONG_SIGHT
|
||||
3 -> VisualAngleMode.MAP_STYLE_VR_ANGLE_300
|
||||
4 -> VisualAngleMode.MAP_STYLE_VR_ANGLE_TOP
|
||||
5 -> VisualAngleMode.MAP_STYLE_VR_ANGLE_CROSS
|
||||
7 -> VisualAngleMode.MAP_STYLE_VR_ROMA
|
||||
else -> VisualAngleMode.MODE_MEDIUM_SIGHT
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCameraChange(type: Int, value: Int) {}
|
||||
override fun onCameraChangeFinish(position: CameraPosition?) {
|
||||
position?.let {
|
||||
mogoMapListenerHandler.onMapChanged(
|
||||
ObjectUtils.fromAMap(position.target),
|
||||
position.zoom,
|
||||
position.tilt,
|
||||
position.bearing
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onChangeMapStyle(style: Int) {
|
||||
// CallerLogger.INSTANCE.d(M_MAP + TAG, "currentMapStyle = " + styleId + " , current = " + mCurrentUI);
|
||||
// 映射地图样式ID到鹰眼样式ID
|
||||
when (style) {
|
||||
MapAutoApi.MAP_STYLE_DAY, MapAutoApi.MAP_STYLE_DAY_NAV -> {
|
||||
mCurrentUI = EnumMapUI.MAP_STYLE_DAY_NAV
|
||||
}
|
||||
MapAutoApi.MAP_STYLE_NIGHT -> {
|
||||
mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT
|
||||
}
|
||||
MapAutoApi.MAP_STYLE_NIGHT_NAV -> {
|
||||
mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_NAV
|
||||
}
|
||||
MapAutoApi.MAP_STYLE_NIGHT_VR -> {
|
||||
mCurrentUI = EnumMapUI.MAP_STYLE_NIGHT_VR
|
||||
}
|
||||
MapAutoApi.MAP_STYLE_DAY_VR -> {
|
||||
mCurrentUI = EnumMapUI.MAP_STYLE_DAY_VR
|
||||
}
|
||||
}
|
||||
loadPreVehicleModel()
|
||||
mogoMapListenerHandler.onMapModeChanged(mCurrentUI)
|
||||
}
|
||||
|
||||
override fun onMarkClick(marker: Marker) {
|
||||
|
||||
}
|
||||
|
||||
override fun onRoamStatus(status: Int, msg: String) {
|
||||
invokeMapRomaStatus(status, msg)
|
||||
}
|
||||
|
||||
override fun rtkEnable(enable: Boolean) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getLocationClient()!!.rtkEnable(enable)
|
||||
}
|
||||
}
|
||||
|
||||
override fun stepInDayMode(isDayMode: Boolean) {
|
||||
// try {
|
||||
// if (mMapView != null && mMapView.getMapAutoViewHelper() != null) {
|
||||
// mMapView.getMapAutoViewHelper().setMapStyle();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
}
|
||||
|
||||
override fun setMapDAngle(angle: Float) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.setMapDAngle(angle)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载3D模型
|
||||
*/
|
||||
private fun loadPreVehicleModel() {
|
||||
d(SceneConstant.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 fun addPreVehicleModelWeiZhi(typeTrafficId: TrafficTypeEnum, logMsg: String) {
|
||||
// 根据当前的地图皮肤模式动态替换
|
||||
val preVehicleStrWeiZhi: String? = if (isDayMode) {
|
||||
map.addPreVehicleModel(typeTrafficId.type, typeTrafficId.traffic3DIconId)
|
||||
} else {
|
||||
map.addPreVehicleModel(typeTrafficId.type, typeTrafficId.traffic3DNightIconId)
|
||||
}
|
||||
d(SceneConstant.M_MAP + TAG, logMsg + preVehicleStrWeiZhi)
|
||||
if (preVehicleStrWeiZhi == null) {
|
||||
UiThreadHandler.postDelayed({
|
||||
w(SceneConstant.M_MAP + TAG, "添加感知模型到地图中失败,尝试重复添加……")
|
||||
addPreVehicleModelWeiZhi(typeTrafficId, logMsg)
|
||||
}, 1000L)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setLockMode(isLock: Boolean) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.setLockMode(isLock)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setScrollGesturesEnable(isEnable: Boolean) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.setScrollGesturesEnabled(isEnable)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setAllGesturesEnabled(isEnable: Boolean) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.setAllGesturesEnabled(isEnable)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setExtraGPSData(gnssInfo: MogoLocation) {
|
||||
val locationClient = mMapView.getLocationClient()
|
||||
if (locationClient != null) {
|
||||
locationClient.setIsUseExtraGPSData(true) //设置是否使用外界坐标
|
||||
locationClient.rtkEnable(true) //设置是否是高精定位
|
||||
val lonLatPoint = LonLatPoint()
|
||||
lonLatPoint.angle = gnssInfo.heading
|
||||
lonLatPoint.altitude = gnssInfo.altitude
|
||||
lonLatPoint.longitude = gnssInfo.longitude
|
||||
lonLatPoint.latitude = gnssInfo.latitude
|
||||
lonLatPoint.satelliteTime =
|
||||
java.lang.Double.valueOf((gnssInfo.satelliteTime * 1000).toDouble()).toLong()
|
||||
lonLatPoint.speed = gnssInfo.gnssSpeed.toDouble()
|
||||
locationClient.updateLocation(lonLatPoint) //更新新自动驾驶RTK相关数据
|
||||
setIsInit()
|
||||
}
|
||||
}
|
||||
|
||||
// 是否绘制点云
|
||||
override fun setIsDrawPointCloud(isDrawPointCloud: Boolean) {
|
||||
try {
|
||||
setIsDrawPointCloud(isDrawPointCloud, mMapView.getMapController())
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
//设置点云大小
|
||||
override fun setPointCloudSize(pointCloudSize: Float) {
|
||||
setPointCloudSize(pointCloudSize, mMapView.getMapController())
|
||||
}
|
||||
|
||||
// 设置点云颜色
|
||||
override fun setPointCloudColor(color: String) {
|
||||
setPointCloudColor(color, mMapView.getMapController())
|
||||
}
|
||||
|
||||
//更新点云
|
||||
override fun updatePointCloud(
|
||||
dataArray: ByteArray?, isTrasformer: Boolean, isResidual: Boolean, isReset: Boolean
|
||||
): Boolean {
|
||||
return updatePointCloudDataByPb(
|
||||
dataArray, isTrasformer, isResidual, isReset, mMapView.getMapController()
|
||||
)
|
||||
}
|
||||
|
||||
override fun animateTo(
|
||||
lon: Double,
|
||||
lat: Double,
|
||||
rotateAngle: Float,
|
||||
duration: Int,
|
||||
isGps: Boolean
|
||||
) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.animateTo(lon, lat, rotateAngle, duration, isGps)
|
||||
}
|
||||
}
|
||||
|
||||
override fun animateTo(
|
||||
lon: Double,
|
||||
lat: Double,
|
||||
v1: Float,
|
||||
v2: Float,
|
||||
v3: Float,
|
||||
v4: Float,
|
||||
duration: Int,
|
||||
isGps: Boolean
|
||||
) {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.animateTo(lon, lat, v1, v2, v3, v4, duration, isGps)
|
||||
}
|
||||
}
|
||||
|
||||
override fun clear() {
|
||||
if (checkAMapView()) {
|
||||
mMapView.getMapAutoViewHelper()!!.clearPanel()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,8 @@ package com.mogo.map;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.overlay.proxy.line.IMapPolylineOverlay;
|
||||
import com.mogo.map.overlay.proxy.point.IMapPointOverlay;
|
||||
@@ -57,7 +59,7 @@ public class AMapWrapper implements IMogoMap {
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMogoMapUIController getUIController() {
|
||||
public IMogoMapUIController getUiController() {
|
||||
return mMapUIController;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,12 +9,9 @@ import android.widget.FrameLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.zhidaoauto.map.sdk.open.HDTypes;
|
||||
import com.zhidaoauto.map.sdk.open.MapParams;
|
||||
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
|
||||
import com.zhidaoauto.map.sdk.open.view.MapStyleParams;
|
||||
|
||||
@@ -52,33 +49,6 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
|
||||
mapAutoView = new MapAutoView(context, getStyleParams());
|
||||
}
|
||||
}
|
||||
//基础统一配置,如果各个样式地图有修改,此处需要改动
|
||||
if (mapAutoView.getMapStyleParams() != null) {
|
||||
mapAutoView.getMapStyleParams()
|
||||
.setIsWeatherEnable(false)
|
||||
.setLocationIcon3DRes(HdMapBuildConfig.currentCarVrIconRes)
|
||||
.setPerspectiveMode(MapParams.MAP_PERSPECTIVE_UP_CAR)
|
||||
.setHDVisibileArray(new int[]{HDTypes.DIVIDER.getType(), //onSurfaceCreate设置
|
||||
HDTypes.ROAD_AREA.getType(),
|
||||
HDTypes.STOP_LINE.getType(),
|
||||
HDTypes.ARROW.getType(),
|
||||
HDTypes.STATION_BRIDGE.getType(),
|
||||
HDTypes.ZEBRA_LINE.getType(),
|
||||
HDTypes.GREEN_BELT.getType(),
|
||||
HDTypes.DIVERSION.getType(),
|
||||
HDTypes.SAFE_ISLAND.getType(),
|
||||
HDTypes.ALPHANUMERIC.getType(),
|
||||
HDTypes.GUARDBAR.getType(),
|
||||
HDTypes.TRAFFIC_DEVICE.getType(),
|
||||
HDTypes.CABLE.getType(),
|
||||
HDTypes.SIGNAL_LINE.getType(),
|
||||
HDTypes.building.getType(),
|
||||
HDTypes.streetLight.getType(),
|
||||
HDTypes.area.getType(),
|
||||
HDTypes.regional.getType(),
|
||||
HDTypes.geometricLinear.getType(),
|
||||
HDTypes.geometricSurface.getType()});
|
||||
}
|
||||
if (mMapView == null) {
|
||||
mMapView = new AMapViewWrapper(mapAutoView);
|
||||
final View mapView = mMapView.getMapView();
|
||||
@@ -101,7 +71,7 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
|
||||
}
|
||||
|
||||
protected IMogoMapUIController getUIController(){
|
||||
return mMapView.getMap().getUIController();
|
||||
return mMapView.getMap().getUiController();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -144,7 +114,7 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
|
||||
}
|
||||
|
||||
public void setExtraGPSData(MogoLocation gnssInfo) {
|
||||
getMap().getUIController().setExtraGPSData(gnssInfo);
|
||||
getMap().getUiController().setExtraGPSData(gnssInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,9 +3,7 @@ package com.mogo.map.overlay
|
||||
import android.graphics.*
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.function.call.autopilot.*
|
||||
import com.mogo.eagle.core.function.call.map.*
|
||||
import com.mogo.eagle.core.utilcode.util.*
|
||||
import com.mogo.map.MogoMap.Companion.DEFAULT
|
||||
import com.mogo.map.overlay.point.Point.Options
|
||||
import com.mogo.map.MogoMap.Companion.mapInstance
|
||||
import com.mogo.map.overlay.core.*
|
||||
@@ -261,7 +259,7 @@ internal class MoGoOverlayManagerImpl: IMoGoOverlayManager {
|
||||
|
||||
private fun moveToCenter(mapTag:String, id: String, eventLon: Double, eventLat: Double, carLon: Double, carLat: Double) {
|
||||
try {
|
||||
mapInstance.getMogoMap(mapTag).uiController.showBounds(
|
||||
mapInstance.getMogoMap(mapTag).uiController?.showBounds(
|
||||
id,
|
||||
MogoLatLng(carLat, carLon),
|
||||
listOf(MogoLatLng(eventLat, eventLon)),
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.map.overlay.point.Point.Options
|
||||
import com.mogo.map.overlay.proxy.point.*
|
||||
import com.mogo.map.utils.ObjectUtils
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.open.marker.*
|
||||
import com.zhidaoauto.map.sdk.open.view.MapAutoView
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
|
||||
@@ -62,8 +62,8 @@ public class MogoMapUtils {
|
||||
final double dLon1 = Math.abs( carPosition.lon - latLngBounds.getSouthwest().getLongitude() );
|
||||
final double dLat2 = Math.abs( carPosition.lat - latLngBounds.getNortheast().getLatitude() );
|
||||
final double dLon2 = Math.abs( carPosition.lon - latLngBounds.getNortheast().getLongitude() );
|
||||
dLat = dLat1 > dLat2 ? dLat1 : dLat2;
|
||||
dLon = dLon1 > dLon2 ? dLon1 : dLon2;
|
||||
dLat = Math.max(dLat1, dLat2);
|
||||
dLon = Math.max(dLon1, dLon2);
|
||||
}
|
||||
|
||||
west = carPosition.lat - dLat;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.mogo.map.utils;
|
||||
|
||||
import com.mogo.eagle.core.data.map.LonLatPoint;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.CoordinateUtils;
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package com.mogo.map.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/3/8
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
public class ResIdCache {
|
||||
|
||||
public static Map< String, String > sMarkerCachesResMd5Values = new HashMap<>();
|
||||
|
||||
public static String getVal( String name ) {
|
||||
return sMarkerCachesResMd5Values.get( name );
|
||||
}
|
||||
|
||||
public static void putVal( String name, String val ) {
|
||||
sMarkerCachesResMd5Values.put( name, val );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user