[base_3.4.0-map-sdk]

This commit is contained in:
zhongchao
2023-08-18 18:42:12 +08:00
parent 10b5933c03
commit fc25630dc4
43 changed files with 644 additions and 790 deletions

View File

@@ -1,28 +1,93 @@
package com.mogo.map
import com.mogo.map.center.CenterLine
import com.mogo.eagle.core.data.map.MogoLocation
import com.zhidaoauto.map.data.road.CenterLine
interface IMogoData {
fun setDebugMode(debugMode: Boolean)
/**
* 获取行驶方向一定长度的中心线
*
* @param lon 经
* @param lat 纬
* @param angle 航向角
* @param distance 获取车道中心线的长度,> 0: 行驶方向前方距离, <0 行驶方向后方距离
* @return 中心线相关数据
* 获取车道中心线数据
* @param lon 经度
* @param lat 纬
* @param angle 角
* @param call 回调
*/
fun getCenterLineRangeInfo(lon: Double, lat: Double, angle: Float, distance: Float): CenterLine?
fun getCenterLineInfo(lon: Double, lat: Double, angle: Float, call: ((CenterLine?) -> Unit))
/**
* 按距离获取道路数据
* @param lon 经度
* @param lat 纬度
* @param angle 角度
* @param call 回调
*/
fun getCenterLineRangeInfo(
lon: Double,
lat: Double,
angle: Float,
distance: Float,
call: ((Int, com.mogo.map.center.CenterLine?) -> Unit)
call: ((CenterLine?) -> Unit)
)
/**
* 获取车道限速
* @param lon 经度
* @param lat 纬度
* @param angle 角度
* @param call 回调
*/
fun getLimitSpeed(lon: Double, lat: Double, angle: Float, call: ((Int) -> Unit))
/**
* 获取道路角度
* @param lon 经度
* @param lat 纬度
* @param angle 角度
* @param call 回调
*/
fun getRoadAngle(lon: Double, lat: Double, angle: Float, call: ((Double) -> Unit))
/**
* 获取道路宽度
*/
fun getRoadWidth(lon: Double, lat: Double, angle: Float, isGpsLocation: Boolean, isRTK: Boolean): Float
/**
* 获取行车方向
*
* @return
*/
fun getAngle(startLon: Double, startLat: Double, endLon: Double, endLat: Double): Float
/**
* 获取瓦片id
*
* @param lon 经度
* @param lat 纬度
* @return 瓦片id
*/
fun getTileId(lon: Double, lat: Double): Long
/**
* 通过cityCode,缓存城市HDMap
*/
fun cacheHDDataByCity(progress:((cityId: Int, progress: Double) -> Unit), result:((cityId: Int, state: Int) -> Unit))
/**
* 通过经纬度信息缓存城市HDMap
*/
fun cacheHDDataByCityByLonLat(location: MogoLocation, progress:((cityId: Int, progress: Double) -> Unit), result:((cityId: Int, state: Int) -> Unit))
/**
* 当前城市离线数据是否已缓存
*/
fun isCityDataCached(cache:((Boolean) -> Unit))
/**
* 取消下载 城市HDMap
*/
fun cancelDownloadCacheData()
}

View File

@@ -100,7 +100,6 @@ public interface IMogoMap {
*/
void changeZoom(float zoom);
/**
* 改变地图缩放级别的别一种方式
*
@@ -115,32 +114,4 @@ public interface IMogoMap {
*/
float getZoomLevel();
/**
* 获取道路的宽度
*/
float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK);
/**
* 获取行驶方向一定长度的中心线
*
* @param lon 经度
* @param lat 纬度
* @param angle 航向角
* @param distance 获取车道中心线的长度,> 0: 行驶方向前方距离, <0 行驶方向后方距离
* @return 中心线相关数据
*/
CenterLine getCenterLineRangeInfo(double lon, double lat, float angle, float distance);
/**
* 根据自车经纬度和航向角,获取道路名称
*
* @param lon 经度
* @param lat 纬度
* @param angle 航向角
* @return 道路名称等相关信息
*/
RoadNameInfo getRoadName(double lon, double lat, float angle);
}

View File

@@ -1,13 +0,0 @@
package com.mogo.map;
public
/**
* @author congtaowang
* @since 2020/12/9
*
* 描述
*/
class MapApiPath {
public static final String PATH = "/mogomap/api";
}

View File

@@ -16,8 +16,6 @@ import androidx.annotation.Nullable;
*/
public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle {
private static final String TAG = "MogoBaseMapView";
protected IMogoMapView mMapView;
public MogoBaseMapView( Context context ) {
@@ -36,12 +34,14 @@ public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle
private void init( Context context ) {
addMapView( context );
if (mMapView != null){
MogoMap.getInstance().init( getContext(), mMapView.getMap() );
MogoMap.Companion.getMapInstance().initInstance( mMapView.getMap() , getInstanceTag());
}
}
protected abstract void addMapView( Context context );
protected abstract String getInstanceTag();
@Override
public void onCreate( Bundle bundle ) {
if ( mMapView != null ) {
@@ -68,7 +68,7 @@ public abstract class MogoBaseMapView extends FrameLayout implements ILifeCycle
if ( mMapView != null ) {
mMapView.onDestroy();
}
MogoMap.getInstance().clear();
MogoMap.Companion.getMapInstance().clear(getInstanceTag());
}
@Override

View File

@@ -1,13 +1,23 @@
package com.mogo.map
class MogoData {
class MogoData private constructor() {
companion object{
companion object {
val mogoData by lazy(LazyThreadSafetyMode.SYNCHRONIZED){
val mogoMapData by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
MogoData()
}
}
private lateinit var iMogoData: IMogoData
fun init(iMogoData: IMogoData) {
this.iMogoData = iMogoData
}
fun get():IMogoData{
return iMogoData
}
}

View File

@@ -1,52 +0,0 @@
package com.mogo.map;
import android.content.Context;
/**
* @author congtaowang
* @since 2019-12-20
* <p>
* 描述
*/
public class MogoMap {
private static final String TAG = "MogoMap";
private IMogoMap mMap;
private Context mContext;
private static volatile MogoMap sInstance;
private MogoMap() {
}
public static MogoMap getInstance() {
if ( sInstance == null ) {
synchronized ( MogoMap.class ) {
if ( sInstance == null ) {
sInstance = new MogoMap();
}
}
}
return sInstance;
}
//todo 多实例
public void init( Context context, IMogoMap map ) {
this.mContext = context;
this.mMap = map;
}
public Context getContext() {
return mContext;
}
public IMogoMap getMogoMap() {
return mMap;
}
public void clear(){
mContext = null;
mMap = null;
}
}

View File

@@ -0,0 +1,58 @@
package com.mogo.map
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.Companion.M_MAP
import java.util.concurrent.ConcurrentHashMap
class MogoMap private constructor() {
companion object {
private const val TAG = "MogoMap"
const val DEFAULT = "Default"
val mapInstance by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
MogoMap()
}
}
private val mapCache = ConcurrentHashMap<String, IMogoMap>()
/**
* 缓存多实例对象
*/
fun initInstance(map: IMogoMap, instanceTag: String = DEFAULT) {
if (mapCache.contains(instanceTag)) {
CallerLogger.e(
"$M_MAP$TAG",
" already has map instance with tag :$instanceTag , please check"
)
return
}
mapCache[instanceTag] = map
}
/**
* 业务使用时根据地图是否加载来判定 是否获取IMogoMap实例
*/
fun getMogoMap(instance: String = DEFAULT): IMogoMap {
return if (mapCache[instance] == null) {
CallerLogger.e("$M_MAP$TAG", "getMogoMap func has error with no instance in mapCache")
mapCache[DEFAULT]!!
} else {
mapCache[instance]!!
}
}
fun clear(instance: String = DEFAULT) {
if (mapCache.containsKey(instance)) {
mapCache.remove(instance)
} else {
CallerLogger.e(
"$M_MAP$TAG",
"Map instance invoke destroy in clear func has no instance key"
)
}
}
}

View File

@@ -1,11 +1,13 @@
package com.mogo.map.location;
import android.content.Context;
public interface IMogoGDLocationClient {
/**
* 开始定位
*/
void start();
void start(Context context);
/**
* 停止定位

View File

@@ -7,11 +7,7 @@ import android.view.View;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;
import com.mogo.eagle.core.data.map.CenterLine;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.map.hdcache.IHdCacheListener;
import org.json.JSONObject;
import com.mogo.eagle.core.data.map.MogoLocation;
import java.util.List;
@@ -112,11 +108,6 @@ public interface IMogoMapUIController {
*/
float getZoomLevel();
/**
* 获取道路的宽度
*/
float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK);
/**
* 获取视图东北角坐标
*/
@@ -213,21 +204,6 @@ public interface IMogoMapUIController {
*/
void changeBearing(float bearing);
/**
* 修改地图中心
* MapAutoApi.CAR_CENTER_100 = 1
* MapAutoApi.CAR_QUARTER_100 = 2
* MapAutoApi.CAR_TWO_FIFTHS_100 = 3
* MapAutoApi.CAR_TWO_FIFTHS_80= 4
* MapAutoApi.CAR_AFTER_30_FRONT_80 = 5
* MapAutoApi.CAR_AFTER_30_FRONT_100 = 6
* MapAutoApi.CAR_AFTER_30_FRONT_120 = 7
* MapAutoApi.CAR_AFTER_40_FRONT_80= 8
* MapAutoApi.CAR_AFTER_40_FRONT_100 = 9
* MapAutoApi.CAR_AFTER_40_FRONT_120 = 10
*/
void changeMapViewAngle(int type);
/**
* 修改高精地图自车图标
* 传入资源ID
@@ -314,17 +290,6 @@ public interface IMogoMapUIController {
* @param color // color:"#RRGGBB*
*/
void setPointCloudColor(String color);
void cacheHDDataByCity(IHdCacheListener listener);
void cacheHDDataByCity(IHdCacheListener listener, MogoLocation location);
/**
* 当前城市离线数据是否已缓存
* @return
*/
boolean isCityDataCached();
void cancelDownloadCacheData();
String getCityCode();