[base_3.4.0-map-sdk]
This commit is contained in:
@@ -12,7 +12,7 @@ import java.lang.reflect.Method;
|
||||
*/
|
||||
public class AMapUiSettingsWrapper implements IMogoUiSettings {
|
||||
|
||||
private MapAutoViewHelper mUiSettings;
|
||||
private final MapAutoViewHelper mUiSettings;
|
||||
|
||||
public AMapUiSettingsWrapper( MapAutoViewHelper mUiSettings ) {
|
||||
this.mUiSettings = mUiSettings;
|
||||
@@ -21,6 +21,11 @@ public class AMapUiSettingsWrapper implements IMogoUiSettings {
|
||||
@Override
|
||||
public void setScaleControlsEnabled( boolean enabled ) {
|
||||
if ( mUiSettings != null ) {
|
||||
if(enabled){
|
||||
mUiSettings.showScale();
|
||||
}else{
|
||||
mUiSettings.hiddenScale();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,8 +57,10 @@ 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.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.IResult;
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener;
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener;
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapClickListener;
|
||||
@@ -91,7 +93,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操作对象
|
||||
public class AMapViewWrapper implements IMogoMapView, //代理地图实例和接口操作对象
|
||||
IMogoMapUIController,
|
||||
OnMapLoadedListener,
|
||||
OnCameraChangeListener,
|
||||
@@ -163,7 +165,6 @@ public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操
|
||||
mMapView.setOnRoamStatusListener(this);
|
||||
mMapView.setOnMapViewVisualAngleChangeListener(this);
|
||||
mMapView.setOnRoadInfoListener(this, 1);
|
||||
//todo 多实例改造
|
||||
MapAutoApi.INSTANCE.registerLogListener(this, mMapView.getEventController());
|
||||
CallerLogger.INSTANCE.d(M_MAP + TAG, "styleop - initListeners - setOnMapStyleListener - view " + mMapView);
|
||||
}
|
||||
@@ -239,7 +240,6 @@ public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操
|
||||
mMapView.setOnCameraChangeListener(null);
|
||||
mMapView.setOnMapStyleListener(null);
|
||||
mMapView.setOnMapViewVisualAngleChangeListener(null);
|
||||
//todo 多实例改造
|
||||
MapAutoApi.INSTANCE.unregisterLogListener(this, mMapView.getEventController());
|
||||
CallerLogger.INSTANCE.d(M_MAP + TAG, "map onDestroy");
|
||||
}
|
||||
@@ -290,7 +290,7 @@ public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操
|
||||
MapRoadInfo.StopLine stopInfo = convert(stopLine);
|
||||
LonLatPoint p1 = points.get(0);
|
||||
LonLatPoint p2 = points.get(points.size() - 1);
|
||||
double distanceOfCarToStopLine = MapDataApi.INSTANCE.getClosestFromPointToSegment(carLoc.getLongitude(), carLoc.getLatitude(), p1.getLongitude(), p1.getLatitude(), p2.getLongitude(), p2.getLatitude()) * 10_0000;
|
||||
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);
|
||||
@@ -328,9 +328,6 @@ public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操
|
||||
|
||||
@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;
|
||||
@@ -476,11 +473,6 @@ public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操
|
||||
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(mMapView.getMapController()).getRightTopPoint());
|
||||
@@ -659,10 +651,6 @@ public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeMapViewAngle(int type) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeCurrentIcon(int iconId) {
|
||||
if (checkAMapView()) {
|
||||
@@ -888,12 +876,12 @@ public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操
|
||||
if (isDayMode()) {
|
||||
preVehicleStrWeiZhi =
|
||||
// 添加模型到地图中
|
||||
MogoIdentifyManager.getInstance(getContext())
|
||||
MogoIdentifyManager.getInstance()
|
||||
.addPreVehicleModel(typeTrafficId.getType(), typeTrafficId.getTraffic3DIconId());
|
||||
} else {
|
||||
preVehicleStrWeiZhi =
|
||||
// 添加模型到地图中
|
||||
MogoIdentifyManager.getInstance(getContext())
|
||||
MogoIdentifyManager.getInstance()
|
||||
.addPreVehicleModel(typeTrafficId.getType(), typeTrafficId.getTraffic3DNightIconId());
|
||||
}
|
||||
|
||||
@@ -910,7 +898,6 @@ public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操
|
||||
@Override
|
||||
public void setLockMode(boolean isLock) {
|
||||
if (checkAMapView()) {
|
||||
Log.d("TTTTT", "setLockMode:" + isLock);
|
||||
mMapView.getMapAutoViewHelper().setLockMode(isLock);
|
||||
}
|
||||
}
|
||||
@@ -929,7 +916,6 @@ public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setExtraGPSData(MogoLocation gnssInfo) {
|
||||
LocationClient locationClient = mMapView.getLocationClient();
|
||||
@@ -973,123 +959,9 @@ public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操
|
||||
PointCloudHelper.INSTANCE.setPointCloudColor(color, mMapView.getMapController());
|
||||
}
|
||||
|
||||
//todo 多实例改造
|
||||
@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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//todo 多实例改造
|
||||
@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) {
|
||||
//TODO 回调改造
|
||||
mMapView.getMapAutoViewHelper().getAllCityCode((code, cityInfoList) -> {
|
||||
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();
|
||||
return GDLocationClient.Companion.getGdLocationClient().getLastCityCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -7,12 +7,11 @@ 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;
|
||||
import com.mogo.map.overlay.wrapper.point.AMapPointWrapper;
|
||||
import com.mogo.map.road.RoadNameInfo;
|
||||
import com.mogo.map.uicontroller.AMapUIController;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
import com.mogo.map.utils.ObjectUtils;
|
||||
import com.zhidaoauto.map.sdk.open.data.MapDataApi;
|
||||
import com.zhidaoauto.map.sdk.open.data.SinglePointRoadInfo;
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint;
|
||||
import com.zhidaoauto.map.data.road.CenterLine;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BatchMarkerOptions;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
|
||||
@@ -261,25 +260,4 @@ public class AMapWrapper implements IMogoMap {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
|
||||
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad(lon, lat, angle, isGpsLocation, isRTK);
|
||||
return singlePointRoadInfo != null ? singlePointRoadInfo.getLaneWidth() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CenterLine getCenterLineRangeInfo(double lon, double lat, float angle, float distance) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public RoadNameInfo getRoadName(double lon, double lat, float angle) {
|
||||
// com.zhidaoauto.map.sdk.open.road.RoadNameInfo info = MapDataApi.INSTANCE.getRoadName(lon, lat, angle);
|
||||
// RoadNameInfo ret = null;
|
||||
// if (info != null) {
|
||||
// ret = new RoadNameInfo(info.tile_id, info.road_id, info.road_name);
|
||||
// }
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +1,35 @@
|
||||
package com.mogo.map
|
||||
|
||||
import android.util.Pair
|
||||
import com.mogo.eagle.core.data.map.CenterLine
|
||||
import com.mogo.map.utils.ObjectUtils
|
||||
import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
|
||||
import com.mogo.map.MogoData.Companion.mogoMapData
|
||||
import com.mogo.map.location.GDLocationClient.Companion.gdLocationClient
|
||||
import com.mogo.map.utils.HDMapUtils.getHDCityCode
|
||||
import com.zhidaoauto.map.data.road.CenterLine
|
||||
import com.zhidaoauto.map.data.road.RoadRectInfos
|
||||
import com.zhidaoauto.map.data.routeinfo.RoadInfo
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
import com.zhidaoauto.map.sdk.open.abs.IResult
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
import com.zhidaoauto.map.sdk.open.data.CityInfo
|
||||
import com.zhidaoauto.map.sdk.open.data.MapDataApi
|
||||
import com.zhidaoauto.map.sdk.open.road.RoadRectInfos
|
||||
import com.zhidaoauto.map.sdk.open.routeinfo.RoadInfo
|
||||
|
||||
/**
|
||||
* 地图数据工具
|
||||
*/
|
||||
object MapDataWrapper {
|
||||
object MapDataWrapper : IMogoData {
|
||||
|
||||
private const val TAG = "MapDataWrapper"
|
||||
|
||||
fun init() {
|
||||
mogoMapData.init(this)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置debug模式
|
||||
*/
|
||||
fun setDebugMode(debugMode: Boolean) {
|
||||
override fun setDebugMode(debugMode: Boolean) {
|
||||
MapAutoApi.setDebugMode(debugMode)
|
||||
}
|
||||
|
||||
@@ -29,17 +41,22 @@ object MapDataWrapper {
|
||||
* @param call 回调
|
||||
*/
|
||||
@Synchronized
|
||||
fun getCenterLineInfo(lon: Double, lat: Double, angle: Float,call:((Int, CenterLine?) -> Unit)){
|
||||
override fun getCenterLineInfo(
|
||||
lon: Double,
|
||||
lat: Double,
|
||||
angle: Float,
|
||||
call: ((CenterLine?) -> Unit)
|
||||
) {
|
||||
MapDataApi.getCenterLineInfo(
|
||||
lon,
|
||||
lat,
|
||||
angle,
|
||||
object : IResult<com.zhidaoauto.map.sdk.open.road.CenterLine> {
|
||||
object : IResult<CenterLine> {
|
||||
override fun result(
|
||||
code: Int,
|
||||
result: com.zhidaoauto.map.sdk.open.road.CenterLine?
|
||||
result: CenterLine?
|
||||
) {
|
||||
call.invoke(0,ObjectUtils.transformCenterLine(result))
|
||||
call.invoke(result)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -51,36 +68,18 @@ object MapDataWrapper {
|
||||
* @param angle 角度
|
||||
* @param call 回调
|
||||
*/
|
||||
fun getCenterLineRangeInfo(
|
||||
override fun getCenterLineRangeInfo(
|
||||
lon: Double,
|
||||
lat: Double,
|
||||
angle: Float,
|
||||
distance: Float,
|
||||
call:((Int,com.mogo.map.center.CenterLine?) -> Unit)
|
||||
call: ((CenterLine?) -> Unit)
|
||||
) {
|
||||
try {
|
||||
MapDataApi.getCenterLineRangeInfo(
|
||||
lon,
|
||||
lat,
|
||||
angle,
|
||||
distance,
|
||||
object : IResult<com.zhidaoauto.map.sdk.open.road.CenterLine> {
|
||||
override fun result(
|
||||
code: Int,
|
||||
info: com.zhidaoauto.map.sdk.open.road.CenterLine?
|
||||
) {
|
||||
var ret: com.mogo.map.center.CenterLine? = null
|
||||
if (info != null) {
|
||||
ret = com.mogo.map.center.CenterLine(
|
||||
info.id,
|
||||
info.tile_id,
|
||||
info.road_id,
|
||||
info.lane_id,
|
||||
convert(info.points),
|
||||
info.angle?:0.0
|
||||
)
|
||||
}
|
||||
call.invoke(code,ret)
|
||||
MapDataApi.getCenterLineRangeInfo(lon, lat, angle, distance,
|
||||
object : IResult<CenterLine> {
|
||||
override fun result(code: Int, result: CenterLine?) {
|
||||
call.invoke(result)
|
||||
}
|
||||
})
|
||||
} catch (t: Throwable) {
|
||||
@@ -88,17 +87,6 @@ object MapDataWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
private fun convert(points: List<LonLatPoint>?): List<Pair<Double, Double>> {
|
||||
if (points == null || points.isEmpty()) {
|
||||
return emptyList()
|
||||
}
|
||||
val ret: MutableList<Pair<Double, Double>> = ArrayList(points.size)
|
||||
for (p in points) {
|
||||
ret.add(Pair.create(p.longitude, p.latitude))
|
||||
}
|
||||
return ret
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车道限速
|
||||
* @param lon 经度
|
||||
@@ -106,10 +94,10 @@ object MapDataWrapper {
|
||||
* @param angle 角度
|
||||
* @param call 回调
|
||||
*/
|
||||
fun getLimitSpeed(lon: Double, lat: Double, angle: Float,call : ((Int) -> Unit)) {
|
||||
override fun getLimitSpeed(lon: Double, lat: Double, angle: Float, call: ((Int) -> Unit)) {
|
||||
MapDataApi.getLimitSpeed(lon, lat, angle, object : IResult<RoadInfo> {
|
||||
override fun result(code: Int, result: RoadInfo?) {
|
||||
call.invoke(result?.speed?:0)
|
||||
call.invoke(result?.speed ?: 0)
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -121,20 +109,40 @@ object MapDataWrapper {
|
||||
* @param angle 角度
|
||||
* @param call 回调
|
||||
*/
|
||||
fun getRoadAngle(lon: Double, lat: Double, angle: Float,call : IResult<Double>) {
|
||||
override fun getRoadAngle(lon: Double, lat: Double, angle: Float, call: ((Double) -> Unit)) {
|
||||
MapDataApi.getRoadRectInfo(lon, lat, angle, object : IResult<RoadRectInfos> {
|
||||
override fun result(code: Int, result: RoadRectInfos?) {
|
||||
call.result(code,result?.angle?:0.0)
|
||||
call.invoke(result?.angle ?: 0.0)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取道路宽度
|
||||
*/
|
||||
override fun getRoadWidth(
|
||||
lon: Double,
|
||||
lat: Double,
|
||||
angle: Float,
|
||||
isGpsLocation: Boolean,
|
||||
isRTK: Boolean
|
||||
): Float {
|
||||
val singlePointRoadInfo =
|
||||
MapDataApi.getSinglePointMatchRoad(lon, lat, angle, isGpsLocation, isRTK)
|
||||
return singlePointRoadInfo?.laneWidth ?: 0.0f
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取行车方向
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
fun getAngle(startLon: Double, startLat: Double, endLon: Double, endLat: Double): Float {
|
||||
override fun getAngle(
|
||||
startLon: Double,
|
||||
startLat: Double,
|
||||
endLon: Double,
|
||||
endLat: Double
|
||||
): Float {
|
||||
return MapAutoApi.getAngle(startLon, startLat, endLon, endLat)
|
||||
}
|
||||
|
||||
@@ -145,8 +153,84 @@ object MapDataWrapper {
|
||||
* @param lat 纬度
|
||||
* @return 瓦片id
|
||||
*/
|
||||
fun getTileId(lon: Double, lat: Double): Long {
|
||||
override fun getTileId(lon: Double, lat: Double): Long {
|
||||
return MapAutoApi.getTileID(lon, lat, 13) // 13为默认获取瓦片层级级别
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过cityCode获取HDMap对应缓存城市
|
||||
*/
|
||||
override fun cacheHDDataByCity(
|
||||
progress: (cityId: Int, progress: Double) -> Unit,
|
||||
result: (cityId: Int, state: Int) -> Unit
|
||||
) {
|
||||
val gdCityCode = gdLocationClient.lastCityCode
|
||||
i(M_MAP + TAG, "gdCityCode is:$gdCityCode")
|
||||
val id = getHDCityCode(gdCityCode)
|
||||
id?.let {
|
||||
MapDataApi.cacheHDDataByCity(it, object : OnHdDataDownByCityListener {
|
||||
override fun onMapHDDataCacheProgressByCity(id: Int, p: Double) {
|
||||
progress.invoke(id, p)
|
||||
}
|
||||
|
||||
override fun onMapHDDataCacheStateByCity(id: Int, state: Int) {
|
||||
result.invoke(id, state)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过经纬度信息,获取HDMap对应缓存城市
|
||||
*/
|
||||
override fun cacheHDDataByCityByLonLat(
|
||||
location: MogoLocation,
|
||||
progress: (cityId: Int, progress: Double) -> Unit,
|
||||
result: (cityId: Int, state: Int) -> Unit
|
||||
) {
|
||||
i(M_MAP + TAG, "location lon is:" + location.longitude + ",lat is:" + location.latitude)
|
||||
MapDataApi.cacheHDDataByCityByLonLat(
|
||||
location.longitude, location.latitude,
|
||||
object : OnHdDataDownByCityListener {
|
||||
override fun onMapHDDataCacheProgressByCity(id: Int, p: Double) {
|
||||
progress.invoke(id, p)
|
||||
}
|
||||
|
||||
override fun onMapHDDataCacheStateByCity(id: Int, state: Int) {
|
||||
result.invoke(id, state)
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前城市离线数据是否已缓存
|
||||
*/
|
||||
override fun isCityDataCached(cache: ((Boolean) -> Unit)) {
|
||||
val cityCode = gdLocationClient.lastCityCode
|
||||
i(M_MAP + TAG, "gdCityCode is:$cityCode")
|
||||
val id = getHDCityCode(cityCode)
|
||||
if (id != null) {
|
||||
MapDataApi.getAllCityCode(object : IResult<ArrayList<CityInfo>> {
|
||||
override fun result(code: Int, result: ArrayList<CityInfo>?) {
|
||||
if (result != null) {
|
||||
for (cityInfo in result) {
|
||||
if (id == cityInfo.cityCode) {
|
||||
cache.invoke(cityInfo.isCache)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
})
|
||||
} else {
|
||||
cache.invoke(false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun cancelDownloadCacheData() {
|
||||
MapDataApi.cancelCacheHDData()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,14 +2,11 @@ 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;
|
||||
@@ -164,16 +161,6 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
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();
|
||||
@@ -302,14 +289,6 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeMapViewAngle(int type) {
|
||||
initDelegate();
|
||||
if (mDelegate != null) {
|
||||
mDelegate.changeMapViewAngle(type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeCurrentIcon(int iconId) {
|
||||
initDelegate();
|
||||
@@ -420,35 +399,6 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cacheHDDataByCity(IHdCacheListener listener) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.cacheHDDataByCity(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cacheHDDataByCity(IHdCacheListener listener, MogoLocation location) {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.cacheHDDataByCity(listener, location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCityDataCached() {
|
||||
if (mDelegate != null) {
|
||||
return mDelegate.isCityDataCached();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelDownloadCacheData() {
|
||||
if (mDelegate != null) {
|
||||
mDelegate.cancelDownloadCacheData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCityCode() {
|
||||
if (mDelegate != null) {
|
||||
|
||||
@@ -54,6 +54,11 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getInstanceTag() {
|
||||
return MogoMap.DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
|
||||
@@ -20,13 +20,13 @@ public class MogoIdentifyManager implements IMogoIdentifyManager {
|
||||
|
||||
private static volatile MogoIdentifyManager sInstance;
|
||||
|
||||
private MogoIdentifyManager(Context context) {}
|
||||
private MogoIdentifyManager() {}
|
||||
|
||||
public static MogoIdentifyManager getInstance(Context context) {
|
||||
public static MogoIdentifyManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (MogoIdentifyManager.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new MogoIdentifyManager(context);
|
||||
sInstance = new MogoIdentifyManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ public class MogoIdentifyManager implements IMogoIdentifyManager {
|
||||
@Override
|
||||
public void removeMarker(String uuidString) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().removeMarker(uuidString);
|
||||
MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT).removeMarker(uuidString);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -48,7 +48,7 @@ public class MogoIdentifyManager implements IMogoIdentifyManager {
|
||||
@Override
|
||||
public void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().updateBatchMarkerPosition(optionsArrayList);
|
||||
MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT).updateBatchMarkerPosition(optionsArrayList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -57,7 +57,7 @@ public class MogoIdentifyManager implements IMogoIdentifyManager {
|
||||
@Override
|
||||
public void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList) {
|
||||
try {
|
||||
MogoMap.getInstance().getMogoMap().updateBatchAiMarkerPosition(optionsArrayList);
|
||||
MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT).updateBatchAiMarkerPosition(optionsArrayList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -66,7 +66,7 @@ public class MogoIdentifyManager implements IMogoIdentifyManager {
|
||||
@Override
|
||||
public String addPreVehicleModel(int type, int modelRes) {
|
||||
try {
|
||||
return MogoMap.getInstance().getMogoMap().addPreVehicleModel(type, modelRes);
|
||||
return MogoMap.Companion.getMapInstance().getMogoMap(MogoMap.DEFAULT).addPreVehicleModel(type, modelRes);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import com.zhjt.service.chain.ChainLog
|
||||
* 封装高德地图通过设备GPS获取到的位置信息,频率1s一次,坐标系为CJC20
|
||||
* 这里的数据仅用于非高精度业务
|
||||
*/
|
||||
class GDLocationClient private constructor(context: Context) : AMapLocationListener,
|
||||
class GDLocationClient private constructor() : AMapLocationListener,
|
||||
IMogoGDLocationClient {
|
||||
//声明LocationClient对象
|
||||
private lateinit var mLocationClient: AMapLocationClient
|
||||
@@ -40,7 +40,7 @@ class GDLocationClient private constructor(context: Context) : AMapLocationListe
|
||||
Handler(thread.looper)
|
||||
}
|
||||
|
||||
init {
|
||||
override fun start(context: Context) {
|
||||
AMapLocationClient.updatePrivacyShow(context, true, true)
|
||||
AMapLocationClient.updatePrivacyAgree(context, true)
|
||||
try {
|
||||
@@ -60,9 +60,6 @@ class GDLocationClient private constructor(context: Context) : AMapLocationListe
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
override fun start() {
|
||||
if (mLocationClient != null) {
|
||||
mLocationClient.startLocation()
|
||||
}
|
||||
@@ -169,20 +166,8 @@ class GDLocationClient private constructor(context: Context) : AMapLocationListe
|
||||
}
|
||||
|
||||
companion object {
|
||||
@Volatile
|
||||
private var gdLocationClient: GDLocationClient? = null
|
||||
private val obj = ByteArray(0)
|
||||
|
||||
@JvmStatic
|
||||
fun getInstance(context: Context): GDLocationClient? {
|
||||
if (gdLocationClient == null) {
|
||||
synchronized(obj) {
|
||||
if (gdLocationClient == null) {
|
||||
gdLocationClient = GDLocationClient(context)
|
||||
}
|
||||
}
|
||||
}
|
||||
return gdLocationClient
|
||||
val gdLocationClient by lazy(LazyThreadSafetyMode.SYNCHRONIZED){
|
||||
GDLocationClient()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ 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.overlay.point.Point.Options
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.MogoMap.Companion.mapInstance
|
||||
import com.mogo.map.overlay.core.*
|
||||
import com.mogo.map.overlay.line.*
|
||||
import com.mogo.map.overlay.point.Point
|
||||
@@ -29,7 +29,7 @@ internal class MoGoOverlayManagerImpl: IMoGoOverlayManager {
|
||||
point.setOptions(options)
|
||||
return key
|
||||
} else {
|
||||
val p = MogoMap.getInstance().mogoMap.addPoint(options)
|
||||
val p = mapInstance.getMogoMap().addPoint(options)
|
||||
if (p != null) {
|
||||
p.onRemove { removed ->
|
||||
val keys = points.filterKeys { it.id == removed }
|
||||
@@ -232,7 +232,7 @@ internal class MoGoOverlayManagerImpl: IMoGoOverlayManager {
|
||||
line.setOptions(options)
|
||||
return key
|
||||
} else {
|
||||
val newLine = MogoMap.getInstance().mogoMap.addLine(options)
|
||||
val newLine = mapInstance.getMogoMap().addLine(options)
|
||||
if (newLine != null) {
|
||||
newLine.onRemove { removed ->
|
||||
val keys = lines.filterKeys { it.id == removed }
|
||||
|
||||
@@ -4,11 +4,8 @@ import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.hdcache.IHdCacheListener;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -47,7 +44,6 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public MapControlResult changeZoom(float zoom) {
|
||||
if (mClient != null) {
|
||||
@@ -138,14 +134,6 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
|
||||
if (mClient != null) {
|
||||
return mClient.getRoadWidth(lon, lat, angle, isGpsLocation, isRTK);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MogoLatLng getCameraNorthEastPosition() {
|
||||
if (mClient != null) {
|
||||
@@ -261,13 +249,6 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeMapViewAngle(int type) {
|
||||
if (mClient != null) {
|
||||
mClient.changeMapViewAngle(type);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeCurrentIcon(int iconId) {
|
||||
if (mClient != null) {
|
||||
@@ -361,35 +342,6 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cacheHDDataByCity(IHdCacheListener listener) {
|
||||
if (mClient != null) {
|
||||
mClient.cacheHDDataByCity(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cacheHDDataByCity(IHdCacheListener listener, MogoLocation location) {
|
||||
if (mClient != null) {
|
||||
mClient.cacheHDDataByCity(listener, location);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCityDataCached() {
|
||||
if (mClient != null) {
|
||||
return mClient.isCityDataCached();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelDownloadCacheData() {
|
||||
if (mClient != null) {
|
||||
mClient.cancelDownloadCacheData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCityCode() {
|
||||
if (mClient != null) {
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.map.utils;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.exception.MogoMapException;
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint;
|
||||
import com.zhidaoauto.map.sdk.open.camera.LatLngBounds;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -5,11 +5,11 @@ import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import com.mogo.eagle.core.data.map.CenterLine;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.overlay.line.Polyline;
|
||||
import com.mogo.map.overlay.point.Point;
|
||||
import com.mogo.map.uicontroller.MapCameraPosition;
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint;
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptor;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptorFactory;
|
||||
@@ -213,38 +213,4 @@ public class ObjectUtils {
|
||||
}
|
||||
return new MapCameraPosition(fromAMap(position.getTarget()), position.getBearing(), position.getTilt(), position.getZoom());
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换对象
|
||||
*
|
||||
* @return 转换后的对象
|
||||
*/
|
||||
public static CenterLine transformCenterLine(com.zhidaoauto.map.sdk.open.road.CenterLine centerLine) {
|
||||
CenterLine resultCenterLine = null;
|
||||
if (centerLine != null) {
|
||||
resultCenterLine = new CenterLine();
|
||||
resultCenterLine.setId(centerLine.getId());
|
||||
resultCenterLine.setLane_id(centerLine.getLane_id());
|
||||
resultCenterLine.setAngle(centerLine.getAngle());
|
||||
resultCenterLine.setRoad_id(centerLine.getRoad_id());
|
||||
resultCenterLine.setTile_id(centerLine.getTile_id());
|
||||
ArrayList<com.mogo.eagle.core.data.map.LonLatPoint> arrayList = new ArrayList<>();
|
||||
if (centerLine.getPoints() != null) {
|
||||
for (com.zhidaoauto.map.sdk.open.query.LonLatPoint point : centerLine.getPoints()) {
|
||||
com.mogo.eagle.core.data.map.LonLatPoint lonLatPoint = new com.mogo.eagle.core.data.map.LonLatPoint();
|
||||
lonLatPoint.setAltitude(point.getAltitude());
|
||||
lonLatPoint.setAngle(point.getAngle());
|
||||
lonLatPoint.setDistance(point.getDistance());
|
||||
lonLatPoint.setLatitude(point.getLatitude());
|
||||
lonLatPoint.setLongitude(point.getLongitude());
|
||||
lonLatPoint.setProvider(point.getProvider());
|
||||
lonLatPoint.setSpeed(point.getSpeed());
|
||||
lonLatPoint.setDuration(point.getDuration());
|
||||
arrayList.add(lonLatPoint);
|
||||
}
|
||||
resultCenterLine.setPoints(arrayList);
|
||||
}
|
||||
}
|
||||
return resultCenterLine;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user