477 lines
12 KiB
Java
477 lines
12 KiB
Java
package com.mogo.map;
|
|
|
|
import android.graphics.Point;
|
|
import android.graphics.Rect;
|
|
import android.location.Location;
|
|
import android.view.View;
|
|
|
|
import com.mogo.eagle.core.data.map.CenterLine;
|
|
import com.mogo.eagle.core.data.map.MogoLatLng;
|
|
import com.mogo.eagle.core.data.map.MogoLocation;
|
|
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
|
import com.mogo.map.hdcache.IHdCacheListener;
|
|
import com.mogo.map.uicontroller.AMapUIController;
|
|
import com.mogo.map.uicontroller.CarCursorOption;
|
|
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 java.util.List;
|
|
|
|
|
|
/**
|
|
* @author congtaowang
|
|
* @since 2019-12-26
|
|
* <p>
|
|
* 地图控制
|
|
*/
|
|
public class MogoMapUIController implements IMogoMapUIController {
|
|
|
|
private static final String TAG = "MogoMapUIController";
|
|
|
|
private IMogoMapUIController mDelegate;
|
|
|
|
private static volatile MogoMapUIController sInstance;
|
|
|
|
private MogoMapUIController() {
|
|
initDelegate();
|
|
}
|
|
|
|
private void initDelegate() {
|
|
if (mDelegate == null) {
|
|
mDelegate = AMapUIController.getInstance();
|
|
}
|
|
}
|
|
|
|
public static MogoMapUIController getInstance() {
|
|
if (sInstance == null) {
|
|
synchronized (MogoMapUIController.class) {
|
|
if (sInstance == null) {
|
|
sInstance = new MogoMapUIController();
|
|
}
|
|
}
|
|
}
|
|
return sInstance;
|
|
}
|
|
|
|
public static synchronized void release() {
|
|
sInstance = null;
|
|
}
|
|
|
|
@Override
|
|
public MapControlResult changeZoom(float zoom) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.changeZoom(zoom);
|
|
}
|
|
return MapControlResult.ERROR;
|
|
}
|
|
|
|
@Override
|
|
public void setDebugMode(Boolean debugMode) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setDebugMode(debugMode);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void changeMapVisualAngle(VisualAngleMode angelMode, MogoLatLng mogoLatLng) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
CallerLogger.INSTANCE.d(TAG, "set VisualAngle: " + angelMode.name());
|
|
mDelegate.changeMapVisualAngle(angelMode, mogoLatLng);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setRoamTrajectory(String trajectory) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setRoamTrajectory(trajectory);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setRomaMode(int mode) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
CallerLogger.INSTANCE.d(TAG, "set setRomaMode: " + mode);
|
|
mDelegate.setRomaMode(mode);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public VisualAngleMode getCurrentMapVisualAngle() {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getCurrentMapVisualAngle();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void moveToCenter(MogoLatLng latLng, boolean animate) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.moveToCenter(latLng, animate);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void showMyLocation(boolean visible) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.showMyLocation(visible);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
public void showMyLocation(View view) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.showMyLocation(view);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
public float getScalePerPixel() {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getScalePerPixel();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public float getZoomLevel() {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getZoomLevel();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getRoadWidth(lon, lat, angle, isGpsLocation, isRTK);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public MogoLatLng getCameraNorthEastPosition() {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getCameraNorthEastPosition();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public MogoLatLng getCameraSouthWestPosition() {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getCameraSouthWestPosition();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public MogoLatLng getWindowCenterLocation() {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getWindowCenterLocation();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void setPointToCenter(double mapCenterX, double mapCenterY) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setPointToCenter(mapCenterX, mapCenterY);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Point getLocationPointInScreen(MogoLatLng latLng) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getLocationPointInScreen(latLng);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public MogoLatLng getLocationMogoLatLngInScreen(Point point) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getLocationMogoLatLngInScreen(point);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void setRenderFps(int fps) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setRenderFps(fps);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void showBounds(String tag, MogoLatLng carPosition, List<MogoLatLng> lonLats, Rect bound, boolean lockCarPosition) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.showBounds(tag, carPosition, lonLats, bound, lockCarPosition);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void forceRender() {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.forceRender();
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public float calculateLineDistance(MogoLatLng p1, MogoLatLng p2) throws Exception {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.calculateLineDistance(p1, p2);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public boolean isCarLocked() {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.isCarLocked();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public void setCarCursorOption(CarCursorOption option) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setCarCursorOption(option);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setCarLightsType(int type, int time) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setCarLightsType(type, time);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public MapCameraPosition getMapCameraPosition() {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getMapCameraPosition();
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void changeBearing(float bearing) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.changeBearing(bearing);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void changeMapViewAngle(int type) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.changeMapViewAngle(type);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void changeCurrentIcon(int iconId) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.changeCurrentIcon(iconId);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public long getTileId(double lon, double lat) {
|
|
if (mDelegate != null) {
|
|
return mDelegate.getTileId(lon, lat);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public int getLimitSpeed(double lon, double lat, float angle) {
|
|
if (mDelegate != null) {
|
|
return mDelegate.getLimitSpeed(lon, lat, angle);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
@Override
|
|
public CenterLine getCenterLineInfo(double lon, double lat, float angle) {
|
|
if (mDelegate != null) {
|
|
return mDelegate.getCenterLineInfo(lon, lat, angle);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void rtkEnable(boolean enable) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.rtkEnable(enable);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void destroy() {
|
|
mDelegate = null;
|
|
}
|
|
|
|
@Override
|
|
public void stepInVrMode(boolean isDayMode) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.stepInVrMode(isDayMode);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public String getMarkerInfoResName(String speedVal) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getMarkerInfoResName(speedVal);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public void setMarkerInfoResName(String speedVal, String val) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setMarkerInfoResName(speedVal, val);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setMapDAngle(float angle) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setMapDAngle(angle);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public float getAngle(double startLon, double startLat, double endLon, double endLat) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
return mDelegate.getAngle(startLon, startLat, endLon, endLat);
|
|
}
|
|
return 0.0f;
|
|
}
|
|
|
|
@Override
|
|
public Double getRoadAngle(Double lon, Double lat, float angle) {
|
|
if (mDelegate != null) {
|
|
return mDelegate.getRoadAngle(lon, lat, angle);
|
|
}
|
|
return 0.0;
|
|
}
|
|
|
|
@Override
|
|
public void setLockMode(boolean isLock) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setLockMode(isLock);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setScrollGesturesEnable(boolean isEnable) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setScrollGesturesEnable(isEnable);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setAllGesturesEnabled(boolean isEnable) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setAllGesturesEnabled(isEnable);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setExtraGPSData(MogoLocation gnssInfo) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setExtraGPSData(gnssInfo);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setIsDrawPointCloud(Boolean isDrawPointCloud) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setIsDrawPointCloud(isDrawPointCloud);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setPointCloudSize(Float pointCloudSize) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setPointCloudSize(pointCloudSize);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void setPointCloudColor(String color) {
|
|
initDelegate();
|
|
if (mDelegate != null) {
|
|
mDelegate.setPointCloudColor(color);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void cacheHDDataByCity(IHdCacheListener listener) {
|
|
if (mDelegate != null) {
|
|
mDelegate.cacheHDDataByCity(listener);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public boolean isCityDataCached() {
|
|
if (mDelegate != null) {
|
|
return mDelegate.isCityDataCached();
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public void cancelDownloadCacheData() {
|
|
if (mDelegate != null) {
|
|
mDelegate.cancelDownloadCacheData();
|
|
}
|
|
}
|
|
}
|