[3.4.0-map-sdk] code tyle

This commit is contained in:
zhongchao
2023-09-13 18:31:16 +08:00
parent 1f1a28a975
commit 4932c1d8a7
38 changed files with 657 additions and 822 deletions

View File

@@ -119,7 +119,7 @@ object MapAutoApi {
MapStyleHelper.loadStyleOver.set(true)
}
if (!TextUtils.isEmpty(mapParams.getCachePath())) {
MapDataHelper.updateData(context, mapParams.getCachePath()!!)
MapDataHelper.updateData(context, mapParams.getCachePath())
}else{
MapDataHelper.updateData(context, CommonUtils.getCachePath(context))
}
@@ -194,8 +194,8 @@ object MapAutoApi {
mapAutoView.getClerk()?.setIsRecordLogs(isRecordLogs)
}
private val RULE_MORTON: Double = Math.pow(2.0, 32.0) / 360.0
private val RULE_MORTON_TO_LONLAT: Double = 360.0 / Math.pow(2.0, 32.0)
private val RULE_MORTON: Double = 2.0.pow(32.0) / 360.0
private val RULE_MORTON_TO_LONLAT: Double = 360.0 / 2.0.pow(32.0)
private val NDS_90_DEGREES: Long = 0x3fffffff
private val NDS_180_DEGREES: Long = 0x7fffffff
private val NDS_360_DEGREES: Long = 4294967295
@@ -275,18 +275,18 @@ object MapAutoApi {
// Clerk.add()
// if x > 180 degrees, then subtract 360 degrees
if (result.x > NDS_180_DEGREES) {
result.x -= NDS_360_DEGREES + 1; // add 1 because 0 must be counted as well
result.x -= NDS_360_DEGREES + 1 // add 1 because 0 must be counted as well
} else if (result.x < -NDS_180_DEGREES) // if x < 180 , x += 360
{
result.x += NDS_360_DEGREES + 1; // add 1 because 0 must be counted as well
result.x += NDS_360_DEGREES + 1 // add 1 because 0 must be counted as well
}
// if y > 90 degrees, then subtract 180 degrees
if (result.y > NDS_90_DEGREES) {
result.y -= NDS_180_DEGREES + 1; // add 1 because 0 must be counted as well
result.y -= NDS_180_DEGREES + 1 // add 1 because 0 must be counted as well
} else if (result.y < -NDS_90_DEGREES) // if y < 90, y += 180
{
result.y += NDS_180_DEGREES + 1; // add 1 because 0 must be counted as well
result.y += NDS_180_DEGREES + 1 // add 1 because 0 must be counted as well
}
}
@@ -372,13 +372,13 @@ object MapAutoApi {
}
private fun getLeftBottomOfTile(tileId:Long):Coord {
return getLeftBottomOfTileWithLevel(tileId, getLevelOfTileId(tileId));
return getLeftBottomOfTileWithLevel(tileId, getLevelOfTileId(tileId))
}
fun getLonlatOfTile(tileId: Long):Coord_d{
// Clerk.add("$tileId")
val coord = getLeftBottomOfTile(tileId)
val result = Coord_d();
val result = Coord_d()
val lon = String.format("%.9f", coord.x * RULE_MORTON_TO_LONLAT).toDouble()
val lat = String.format("%.9f", coord.y * RULE_MORTON_TO_LONLAT).toDouble()
result.lon = lon
@@ -394,7 +394,7 @@ object MapAutoApi {
}
private fun getLeftBottomOfTileWithLevel(tileId:Long, level:Int):Coord {
val indexOfTile = getIndexOfTileIdWithLevel(tileId,level).toLong()
val indexOfTile = getIndexOfTileIdWithLevel(tileId,level)
//System.out.println("indexOfTile:level:${level},${indexOfTile}")
val mortonCode = indexOfTile shl (2 * (31 - level))
// val mortonCode1 = tileId*Math.pow(2.0,2.0*(31-level)).toLong()
@@ -404,10 +404,10 @@ object MapAutoApi {
//System.out.println("mortonCodeToCoord:${coord.x},${coord.y}")
normalizeCoord(coord)
// NOTE: 处理边界的偏移问题
coord.x += 1;
coord.y += 1;
coord.x += 1
coord.y += 1
//System.out.println("normalizeCoord:${coord.x},${coord.y}")
return coord;
return coord
}
fun getTileBoundingBox(tileId:Long):Box{
@@ -415,7 +415,7 @@ object MapAutoApi {
val level = getLevelOfTileId(tileId)
// println("level:$level")
val coord = getLeftBottomOfTileWithLevel(tileId, level)
val result = Box();
val result = Box()
val lon = String.format("%.9f", coord.x * RULE_MORTON_TO_LONLAT).toDouble()
val lat = String.format("%.9f", coord.y * RULE_MORTON_TO_LONLAT).toDouble()
result.lbLon = lon
@@ -489,7 +489,7 @@ object MapAutoApi {
val curLon = 112.598977
val curLat = 26.831300
println("---$curLon,$curLat-----")
tileId = getTileID(curLon,curLat,16)
// tileId = getTileID(curLon,curLat,16)
tileId = 5572659558
println("getTileID-16:${tileId}")
var box = getTileBoundingBox(tileId)

View File

@@ -1,25 +0,0 @@
package com.mogo.map;
import android.os.Bundle;
/**
* @author congtaowang
* @since 2019-12-18
* <p>
* 生命周期
*/
public interface ILifeCycle {
void onCreate( Bundle bundle );
void onResume();
void onPause();
void onDestroy();
void onSaveInstanceState( Bundle outState );
// mapview only.
void onLowMemory();
}

View File

@@ -0,0 +1,16 @@
package com.mogo.map
import android.os.Bundle
/**
* 生命周期
*/
interface ILifeCycle {
fun onCreate(bundle: Bundle)
fun onResume()
fun onPause()
fun onDestroy()
fun onSaveInstanceState(outState: Bundle)
// mapview only.
fun onLowMemory()
}

View File

@@ -1,38 +1,34 @@
package com.mogo.map;
package com.mogo.map
/**
* @author congtaowang
* @since 2019-12-18
* <p>
* 图层控制
*/
public interface IMogoUiSettings {
interface IMogoUiSettings {
/**
* 设置比例尺功能是否可用
*/
void setScaleControlsEnabled( boolean enabled );
fun setScaleControlsEnabled(enabled: Boolean)
/**
* 这个方法设置了地图是否允许显示缩放按钮如果允许则在地图上显示
*
* @param enabled
*/
void setZoomControlsEnabled( boolean enabled );
fun setZoomControlsEnabled(enabled: Boolean)
/**
* 这个方法设置了地图是否允许显示指南针
*
* @param enabled
*/
void setCompassEnabled( boolean enabled );
fun setCompassEnabled(enabled: Boolean)
/**
* 设置定位按钮是否显示
*
* @param enabled
*/
void setMyLocationButtonEnabled( boolean enabled );
fun setMyLocationButtonEnabled(enabled: Boolean)
/**
* 这个方法设置了地图是否允许通过手势来移动如果允许则用户可以通过按住地图移动来改变可视区域
@@ -40,7 +36,7 @@ public interface IMogoUiSettings {
*
* @param enabled
*/
void setScrollGesturesEnabled( boolean enabled );
fun setScrollGesturesEnabled(enabled: Boolean)
/**
* 这个方法设置了地图是否允许通过手势来缩放
@@ -49,20 +45,16 @@ public interface IMogoUiSettings {
*
* @param enabled
*/
void setZoomGesturesEnabled( boolean enabled );
void setTiltGesturesEnabled( boolean enabled );
void setRotateGesturesEnabled( boolean enabled );
fun setZoomGesturesEnabled(enabled: Boolean)
fun setTiltGesturesEnabled(enabled: Boolean)
fun setRotateGesturesEnabled(enabled: Boolean)
/**
* 设置当前地图是否支持所有手势这个设置不影响用户在点击屏幕上的按钮如缩放按钮的效果也不影响用户在程序里对地图的操作
*
* @param enabled
*/
void setAllGesturesEnabled( boolean enabled );
void setIndoorSwitchEnabled( boolean enabled );
void setLogoEnable( boolean enabled );
}
fun setAllGesturesEnabled(enabled: Boolean)
fun setIndoorSwitchEnabled(enabled: Boolean)
fun setLogoEnable(enabled: Boolean)
}

View File

@@ -1,37 +0,0 @@
package com.mogo.map.identity;
import java.util.HashMap;
import mogo.telematics.pad.MessagePad;
import mogo.yycp.api.proto.SocketDownData;
/**
* @author congtaowang
* @since 2019-12-25
* <p>
* 地图 marker 管理
*/
public interface IMogoIdentifyManager {
/**
* 要移除的感知数据uuid
*
* @param uuidString
*/
void removeMarker(String uuidString);
/**
* 批量更新锚点位置
*
* @param optionsArrayList 锚点集合
*/
void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList);
/**
* 批量更新锚点位置
*
* @param optionsArrayList 锚点集合
*/
void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList);
}

View File

@@ -0,0 +1,31 @@
package com.mogo.map.identity
import mogo.telematics.pad.MessagePad.TrackedObject
import mogo.yycp.api.proto.SocketDownData
import java.util.HashMap
/**
* 地图 marker 管理
*/
interface IMogoIdentifyManager {
/**
* 要移除的感知数据uuid
*
* @param uuidString
*/
fun removeMarker(uuidString: String?)
/**
* 批量更新锚点位置
*
* @param optionsArrayList 锚点集合
*/
fun updateBatchMarkerPosition(optionsArrayList: HashMap<String, TrackedObject>)
/**
* 批量更新锚点位置
*
* @param optionsArrayList 锚点集合
*/
fun updateBatchAiMarkerPosition(optionsArrayList: HashMap<String, SocketDownData.CloudRoadDataProto>)
}

View File

@@ -22,40 +22,30 @@ public interface IMogoMapListener {
/**
* 地图点击
*
* @param motionEvent
*/
default void onTouch(MotionEvent motionEvent) {
}
/**
* 地图点击
*
* @param latLng
*/
default void onMapClick(MogoLatLng latLng) {
}
/**
* 地图锁定
*
* @param isLock
*/
default void onLockMap(boolean isLock) {
}
/**
* 地图白天黑夜、导航视角切换
*
* @param ui
*/
default void onMapModeChanged(EnumMapUI ui) {
}
/**
* 地图视距切换回调
*
* @param visualAngleMode
*/
default void onMapVisualAngleChanged(VisualAngleMode visualAngleMode) {
}

View File

@@ -1,15 +0,0 @@
package com.mogo.map.location
import com.mogo.eagle.core.data.map.MogoLocation
/**
* 高德定位位置监听
*/
interface IMoGoGDLocationListener {
/**
* 位置信息
*
* @param mogoLocation 位置信息
*/
fun onLocationChanged(mogoLocation: MogoLocation)
}

View File

@@ -18,7 +18,7 @@ interface IMogoMapUIController {
/**
* 修改缩放级别
*/
fun changeZoom(zoom: Float): MapControlResult
fun changeZoom(zoom: Float)
/**
* 修改缩放级别的另一种方式
@@ -271,14 +271,14 @@ interface IMogoMapUIController {
/**
* 更新点云数据
* @param dataStr 点云数据
* @param isTrasformer 是否需要转换坐标
* @param dataArray 点云数据
* @param isTransformer 是否需要转换坐标
* @param isResidual 是否需要差量更新
* @param isStrong 是否加粗显示
* @param isReset 是否加粗显示
* @return 是否执行
*/
fun updatePointCloud(
dataArray: ByteArray?, isTrasformer: Boolean,
dataArray: ByteArray?, isTransformer: Boolean,
isResidual: Boolean, isReset: Boolean
): Boolean

View File

@@ -1,10 +0,0 @@
package com.mogo.map.uicontroller;
public interface IMogoMapVisualAngle {
boolean isLongSight();
boolean isCloseSight();
boolean isMediumSight();
}

View File

@@ -0,0 +1,7 @@
package com.mogo.map.uicontroller
interface IMogoMapVisualAngle {
val isLongSight: Boolean
val isCloseSight: Boolean
val isMediumSight: Boolean
}

View File

@@ -1,30 +0,0 @@
package com.mogo.map.uicontroller;
/**
* @author congtaowang
* @since 2020-04-01
* <p>
* 地图控制结果
*/
public enum MapControlResult {
/**
* 成功
*/
SUCCESS,
/**
* 当前已经为预期结果
*/
TARGET,
/**
* 失败
*/
FAIL,
/**
* 错误,未执行
*/
ERROR
}

View File

@@ -1,74 +0,0 @@
package com.mogo.map.uicontroller;
/**
* 切换视距
*
* @author zhongchao
*/
public enum VisualAngleMode implements IMogoMapVisualAngle {
/**
* 视距近景
*/
MODE_CLOSE_SIGHT(0),
/**
* 视距中景
*/
MODE_MEDIUM_SIGHT(1),
/**
* 视距远景
*/
MODE_LONG_SIGHT(2),
/**
* 后方来车300视角
*/
MAP_STYLE_VR_ANGLE_300(3),
/**
* 顶视角
*/
MAP_STYLE_VR_ANGLE_TOP(4),
/**
* 十字路口视角
*/
MAP_STYLE_VR_ANGLE_CROSS(5),
/**
* 漫游模式
*/
MAP_STYLE_VR_ROMA(7);
private final int code;
VisualAngleMode(int code) {
this.code = code;
}
public int getCode() {
return code;
}
@Override
public boolean isLongSight() {
return code == MODE_LONG_SIGHT.getCode();
}
@Override
public boolean isCloseSight() {
return code == MODE_CLOSE_SIGHT.getCode();
}
@Override
public boolean isMediumSight() {
return code == MODE_MEDIUM_SIGHT.getCode();
}
public boolean isRoma(){
return code == MAP_STYLE_VR_ROMA.getCode();
}
}

View File

@@ -0,0 +1,50 @@
package com.mogo.map.uicontroller
/**
* 切换视距
*/
enum class VisualAngleMode(val code: Int) : IMogoMapVisualAngle {
/**
* 视距近景
*/
MODE_CLOSE_SIGHT(0),
/**
* 视距中景
*/
MODE_MEDIUM_SIGHT(1),
/**
* 视距远景
*/
MODE_LONG_SIGHT(2),
/**
* 后方来车300视角
*/
MAP_STYLE_VR_ANGLE_300(3),
/**
* 顶视角
*/
MAP_STYLE_VR_ANGLE_TOP(4),
/**
* 十字路口视角
*/
MAP_STYLE_VR_ANGLE_CROSS(5),
/**
* 漫游模式
*/
MAP_STYLE_VR_ROMA(7);
override val isLongSight: Boolean
get() = code == code
override val isCloseSight: Boolean
get() = code == code
override val isMediumSight: Boolean
get() = code == code
val isRoma: Boolean
get() = code == code
}

View File

@@ -1,115 +0,0 @@
package com.mogo.map;
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper;
import java.lang.reflect.Method;
/**
* @author congtaowang
* @since 2019-12-18
* <p>
* 代理自研地图UiSettings
*/
public class AMapUiSettingsWrapper implements IMogoUiSettings {
private final MapAutoViewHelper mUiSettings;
public AMapUiSettingsWrapper( MapAutoViewHelper mUiSettings ) {
this.mUiSettings = mUiSettings;
}
@Override
public void setScaleControlsEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
if(enabled){
mUiSettings.showScale();
}else{
mUiSettings.hiddenScale();
}
}
}
@Override
public void setZoomControlsEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setZoomGesturesEnabled( enabled );
}
}
@Override
public void setCompassEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
if(enabled){
mUiSettings.showDirection();
}else{
mUiSettings.hiddenDirection();
}
}
}
@Override
public void setMyLocationButtonEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
if(enabled){
mUiSettings.showLocation();
}else{
mUiSettings.hiddenLocation();
}
}
}
@Override
public void setScrollGesturesEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setScrollGesturesEnabled( enabled );
}
}
@Override
public void setZoomGesturesEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setZoomGesturesEnabled( enabled );
}
}
@Override
public void setTiltGesturesEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setTiltGesturesEnabled( enabled );
}
}
@Override
public void setRotateGesturesEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setRotateGesturesEnabled( enabled );
}
}
@Override
public void setAllGesturesEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
mUiSettings.setAllGesturesEnabled( enabled );
}
}
@Override
public void setIndoorSwitchEnabled( boolean enabled ) {
if ( mUiSettings != null ) {
// mUiSettings.setIndoorSwitchEnabled( enabled );
}
}
@Override
public void setLogoEnable( boolean enabled ) {
if ( mUiSettings != null ) {
try {
Method method = mUiSettings.getClass().getMethod( "setLogoEnable", boolean.class );
method.setAccessible( true );
method.invoke( mUiSettings, enabled );
} catch ( Exception e ) {
e.printStackTrace();
}
}
}
}

View File

@@ -0,0 +1,76 @@
package com.mogo.map
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper
/**
* 代理自研地图UiSettings
*/
class AMapUiSettingsWrapper(private val mUiSettings: MapAutoViewHelper?) : IMogoUiSettings {
override fun setScaleControlsEnabled(enabled: Boolean) {
if (enabled) {
mUiSettings?.showScale()
} else {
mUiSettings?.hiddenScale()
}
}
override fun setZoomControlsEnabled(enabled: Boolean) {
mUiSettings?.setZoomGesturesEnabled(enabled)
}
override fun setCompassEnabled(enabled: Boolean) {
if (enabled) {
mUiSettings?.showDirection()
} else {
mUiSettings?.hiddenDirection()
}
}
override fun setMyLocationButtonEnabled(enabled: Boolean) {
if (enabled) {
mUiSettings?.showLocation()
} else {
mUiSettings?.hiddenLocation()
}
}
override fun setScrollGesturesEnabled(enabled: Boolean) {
mUiSettings?.setScrollGesturesEnabled(enabled)
}
override fun setZoomGesturesEnabled(enabled: Boolean) {
mUiSettings?.setZoomGesturesEnabled(enabled)
}
override fun setTiltGesturesEnabled(enabled: Boolean) {
mUiSettings?.setTiltGesturesEnabled(enabled)
}
override fun setRotateGesturesEnabled(enabled: Boolean) {
mUiSettings?.setRotateGesturesEnabled(enabled)
}
override fun setAllGesturesEnabled(enabled: Boolean) {
mUiSettings?.setAllGesturesEnabled(enabled)
}
override fun setIndoorSwitchEnabled(enabled: Boolean) {
// mUiSettings.setIndoorSwitchEnabled( enabled )
}
override fun setLogoEnable(enabled: Boolean) {
if (mUiSettings != null) {
try {
val method = mUiSettings.javaClass.getMethod(
"setLogoEnable",
Boolean::class.javaPrimitiveType
)
method.isAccessible = true
method.invoke(mUiSettings, enabled)
} catch (e: Exception) {
e.printStackTrace()
}
}
}
}

View File

@@ -122,7 +122,7 @@ class AMapViewWrapper(mMapView: MapAutoView) : IMogoMapView, IMogoMapUIControlle
return mIMap
}
override fun onCreate(bundle: Bundle?) {
override fun onCreate(bundle: Bundle) {
mMapView.onCreate(bundle)
d(SceneConstant.M_MAP + TAG, "map onCreate")
}
@@ -258,11 +258,10 @@ class AMapViewWrapper(mMapView: MapAutoView) : IMogoMapView, IMogoMapUIControlle
return ret
}
override fun changeZoom(zoom: Float): MapControlResult {
override fun changeZoom(zoom: Float) {
if (checkAMapView()) {
mMapView.getMapAutoViewHelper()!!.setZoom(zoom.toInt())
}
return MapControlResult.SUCCESS
}
override fun changeZoom2(zoom: Float) {
@@ -792,10 +791,10 @@ class AMapViewWrapper(mMapView: MapAutoView) : IMogoMapView, IMogoMapUIControlle
//更新点云
override fun updatePointCloud(
dataArray: ByteArray?, isTrasformer: Boolean, isResidual: Boolean, isReset: Boolean
dataArray: ByteArray?, isTransformer: Boolean, isResidual: Boolean, isReset: Boolean
): Boolean {
return updatePointCloudDataByPb(
dataArray, isTrasformer, isResidual, isReset, mMapView.getMapController()
dataArray, isTransformer, isResidual, isReset, mMapView.getMapController()
)
}

View File

@@ -1,199 +0,0 @@
package com.mogo.map;
import android.annotation.SuppressLint;
import androidx.annotation.NonNull;
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.uicontroller.IMogoMapUIController;
import com.mogo.map.utils.ObjectUtils;
import com.zhidaoauto.map.sdk.open.marker.BatchMarkerOptions;
import com.zhidaoauto.map.sdk.open.marker.Marker;
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions;
import com.zhidaoauto.map.sdk.open.marker.MarkerSimpleData;
import com.zhidaoauto.map.sdk.open.poyline.Polyline;
import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions;
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper;
import java.util.ArrayList;
import java.util.HashMap;
import mogo.telematics.pad.MessagePad;
import mogo.yycp.api.proto.SocketDownData;
/**
* @author congtaowang
* @since 2019-12-18
* <p>
* 代理自研AMap
*/
public class AMapWrapper implements IMogoMap {
private static final String TAG = "AMapWrapper";
private final IMogoMapUIController mMapUIController;
private MapAutoViewHelper mAMap;
private final MapAutoView mMapView;
private IMogoUiSettings mUiSettings;
public AMapWrapper(MapAutoViewHelper map, MapAutoView mapView, IMogoMapUIController controller) {
CallerLogger.INSTANCE.i(TAG, "autoop--AMapWrapper: init" + this);
this.mAMap = map;
this.mMapView = mapView;
mMapUIController = controller;
}
@Override
public IMogoUiSettings getUiSettings() {
if (!checkAMap()) {
return null;
}
if (mUiSettings == null) {
mUiSettings = new AMapUiSettingsWrapper(mAMap);
}
return mUiSettings;
}
@Override
public IMogoMapUIController getUiController() {
return mMapUIController;
}
@Override
public IMapPointOverlay addPoint(@NonNull com.mogo.map.overlay.point.Point.Options options) {
if (!checkAMap()) {
return null;
}
MarkerOptions markerOptions = ObjectUtils.fromMogo(options,mMapView);
if (markerOptions == null) {
CallerLogger.INSTANCE.e(TAG, "marker参数为空");
return null;
}
Marker delegate = mAMap.addMarker(markerOptions);
if (delegate == null) {
return null;
}
return new AMapPointWrapper(options.getId(), delegate,mMapView);
}
@Override
public IMapPolylineOverlay addLine(@NonNull com.mogo.map.overlay.line.Polyline.Options options) {
if (!checkAMap()) {
return null;
}
PolylineOptions polylineOptions = ObjectUtils.fromMogo(options,mMapView);
if (polylineOptions == null) {
CallerLogger.INSTANCE.e(TAG, "polyline参数为空");
return null;
}
Polyline delegate = polylineOptions.getLineWidth() > 0 ? mAMap.drawThickLine(polylineOptions) : mAMap.drawLine(polylineOptions);
if (delegate == null) {
return null;
}
return new com.mogo.map.overlay.wrapper.line.AMapPolylineWrapper(options.getId(), delegate,mMapView);
}
BatchMarkerOptions batchMarkerOptions = new BatchMarkerOptions();
@SuppressLint("NewApi")
@Override
public void updateBatchMarkerPosition(HashMap<String, MessagePad.TrackedObject> optionsArrayList) {
if (!checkAMap()) {
return;
}
if(optionsArrayList == null || optionsArrayList.size() == 0){
return;
}
ArrayList<MarkerSimpleData> markerOptionsArrayList = new ArrayList<>();
optionsArrayList.forEach((s, trackedObject) -> {
MarkerSimpleData markerOptions = ObjectUtils.fromTrafficData(trackedObject);
if (markerOptions != null) {
markerOptionsArrayList.add(markerOptions);
}
});
if(markerOptionsArrayList.size() == 0){
return;
}
long time = markerOptionsArrayList.get(0).getTime();
batchMarkerOptions.setList(markerOptionsArrayList);
batchMarkerOptions.setDelayStrategy(false);
batchMarkerOptions.setRuleAngle(8.0f);
batchMarkerOptions.setControlIcon(1);
batchMarkerOptions.setSatelliteTime(time);
batchMarkerOptions.setDeleteRule(0);
if(mMapView.getMarkerController() != null){
mMapView.getMarkerController().updateBatchMarkerPositon(batchMarkerOptions);
}
}
BatchMarkerOptions aiBatchMarkerOptions = new BatchMarkerOptions();
@SuppressLint("NewApi")
@Override
public void updateBatchAiMarkerPosition(HashMap<String, SocketDownData.CloudRoadDataProto> optionsArrayList) {
if (!checkAMap()) {
return;
}
if(optionsArrayList == null || optionsArrayList.size() == 0){
return;
}
ArrayList<MarkerSimpleData> markerOptionsArrayList = new ArrayList<>();
optionsArrayList.forEach((s, trackedObject) -> {
MarkerSimpleData markerOptions = ObjectUtils.fromAiData(trackedObject);
if (markerOptions != null) {
markerOptionsArrayList.add(markerOptions);
}
});
if(markerOptionsArrayList.size() == 0){
return;
}
long time = markerOptionsArrayList.get(0).getTime();
// 最后一个参数,是否管理锚点的删除
aiBatchMarkerOptions.setList(markerOptionsArrayList);
aiBatchMarkerOptions.setDelayStrategy(false);
aiBatchMarkerOptions.setRuleAngle(8.0f);
aiBatchMarkerOptions.setControlIcon(1);
aiBatchMarkerOptions.setSatelliteTime(time);
aiBatchMarkerOptions.setDeleteRule(0);
if(mMapView.getMarkerController() != null) {
mMapView.getMarkerController().updateBatchMarkerPositon(aiBatchMarkerOptions);
}
}
@Override
public String addPreVehicleModel(int type, int modelRes) {
try {
if(mMapView.getMarkerController() != null){
return mMapView.getMarkerController().addPreVehicleModel(type, modelRes);
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
public void removeMarker(String uuidString) {
try {
if(mMapView.getMarkerController() != null){
mMapView.getMarkerController().removeMarker(uuidString);
}
} catch (Exception e) {
e.printStackTrace();
}
}
private boolean checkAMap() {
mAMap = mMapView.getMapAutoViewHelper();
if (mAMap == null) {
CallerLogger.INSTANCE.e(TAG, "自研map实例为空请检查");
return false;
}
return true;
}
}

View File

@@ -0,0 +1,178 @@
package com.mogo.map
import android.annotation.SuppressLint
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.i
import com.mogo.map.overlay.line.Polyline
import com.mogo.map.overlay.point.Point
import com.mogo.map.overlay.proxy.line.IMapPolylineOverlay
import com.mogo.map.overlay.proxy.point.IMapPointOverlay
import com.mogo.map.overlay.wrapper.line.AMapPolylineWrapper
import com.mogo.map.overlay.wrapper.point.AMapPointWrapper
import com.mogo.map.uicontroller.IMogoMapUIController
import com.mogo.map.utils.ObjectUtils
import com.zhidaoauto.map.sdk.open.marker.BatchMarkerOptions
import com.zhidaoauto.map.sdk.open.marker.MarkerSimpleData
import com.zhidaoauto.map.sdk.open.view.MapAutoView
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper
import mogo.telematics.pad.MessagePad.TrackedObject
import mogo.yycp.api.proto.SocketDownData
import java.util.function.BiConsumer
/**
* 代理自研AMap
*/
class AMapWrapper(map: MapAutoViewHelper?, mapView: MapAutoView, controller: IMogoMapUIController) :
IMogoMap {
companion object {
private const val TAG = "AMapWrapper"
}
override val uiController: IMogoMapUIController
private var mAMap: MapAutoViewHelper?
private val mMapView: MapAutoView
private var mUiSettings: IMogoUiSettings? = null
override val uiSettings: IMogoUiSettings?
get() {
if (!checkAMap()) {
return null
}
if (mUiSettings == null) {
mUiSettings = AMapUiSettingsWrapper(mAMap)
}
return mUiSettings
}
override fun addPoint(options: Point.Options): IMapPointOverlay? {
if (!checkAMap()) {
return null
}
val markerOptions = ObjectUtils.fromMogo(options, mMapView)
if (markerOptions == null) {
e(TAG, "marker参数为空")
return null
}
val delegate = mAMap!!.addMarker(markerOptions) ?: return null
return AMapPointWrapper(options.id, delegate, mMapView)
}
override fun addLine(options: Polyline.Options): IMapPolylineOverlay? {
if (!checkAMap()) {
return null
}
val polylineOptions = ObjectUtils.fromMogo(options, mMapView)
if (polylineOptions == null) {
e(TAG, "polyline参数为空")
return null
}
val delegate =
(if (polylineOptions.lineWidth > 0) mAMap!!.drawThickLine(polylineOptions) else mAMap!!.drawLine(
polylineOptions
))
?: return null
return AMapPolylineWrapper(options.id, delegate, mMapView)
}
var batchMarkerOptions = BatchMarkerOptions()
@SuppressLint("NewApi")
override fun updateBatchMarkerPosition(optionsArrayList: HashMap<String, TrackedObject>?) {
if (!checkAMap()) {
return
}
if (optionsArrayList == null || optionsArrayList.size == 0) {
return
}
val markerOptionsArrayList = ArrayList<MarkerSimpleData>()
optionsArrayList.forEach(BiConsumer { s: String?, trackedObject: TrackedObject? ->
val markerOptions = ObjectUtils.fromTrafficData(trackedObject)
if (markerOptions != null) {
markerOptionsArrayList.add(markerOptions)
}
})
if (markerOptionsArrayList.size == 0) {
return
}
val time = markerOptionsArrayList[0].time
batchMarkerOptions.list = markerOptionsArrayList
batchMarkerOptions.delayStrategy = false
batchMarkerOptions.ruleAngle = 8.0f
batchMarkerOptions.controlIcon = 1
batchMarkerOptions.satelliteTime = time
batchMarkerOptions.deleteRule = 0
if (mMapView.getMarkerController() != null) {
mMapView.getMarkerController()!!.updateBatchMarkerPositon(batchMarkerOptions)
}
}
var aiBatchMarkerOptions = BatchMarkerOptions()
init {
i(TAG, "autoop--AMapWrapper: init$this")
mAMap = map
mMapView = mapView
uiController = controller
}
@SuppressLint("NewApi")
override fun updateBatchAiMarkerPosition(optionsArrayList: HashMap<String, SocketDownData.CloudRoadDataProto>?) {
if (!checkAMap()) {
return
}
if (optionsArrayList == null || optionsArrayList.size == 0) {
return
}
val markerOptionsArrayList = ArrayList<MarkerSimpleData>()
optionsArrayList.forEach(BiConsumer { s: String?, trackedObject: SocketDownData.CloudRoadDataProto? ->
val markerOptions = ObjectUtils.fromAiData(trackedObject)
if (markerOptions != null) {
markerOptionsArrayList.add(markerOptions)
}
})
if (markerOptionsArrayList.size == 0) {
return
}
val time = markerOptionsArrayList[0].time
// 最后一个参数,是否管理锚点的删除
aiBatchMarkerOptions.list = markerOptionsArrayList
aiBatchMarkerOptions.delayStrategy = false
aiBatchMarkerOptions.ruleAngle = 8.0f
aiBatchMarkerOptions.controlIcon = 1
aiBatchMarkerOptions.satelliteTime = time
aiBatchMarkerOptions.deleteRule = 0
if (mMapView.getMarkerController() != null) {
mMapView.getMarkerController()!!.updateBatchMarkerPositon(aiBatchMarkerOptions)
}
}
override fun addPreVehicleModel(type: Int, modelRes: Int): String? {
try {
if (mMapView.getMarkerController() != null) {
return mMapView.getMarkerController()!!.addPreVehicleModel(type, modelRes)
}
} catch (e: Exception) {
e.printStackTrace()
}
return null
}
override fun removeMarker(uuidString: String?) {
try {
if (mMapView.getMarkerController() != null) {
mMapView.getMarkerController()!!.removeMarker(uuidString!!)
}
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun checkAMap(): Boolean {
mAMap = mMapView.getMapAutoViewHelper()
if (mAMap == null) {
e(TAG, "自研map实例为空请检查")
return false
}
return true
}
}

View File

@@ -16,7 +16,7 @@ import com.zhidaoauto.map.sdk.open.data.CityInfo
import com.zhidaoauto.map.sdk.open.data.MapDataApi
/**
* 地图数据工具
* 地图数据工具,涉及到数据调用可能会有耗时建议IO操作
*/
object MapDataWrapper : IMogoData {
@@ -68,6 +68,7 @@ object MapDataWrapper : IMogoData {
* @param angle 角度
* @param call 回调
*/
@Synchronized
override fun getCenterLineRangeInfo(
lon: Double,
lat: Double,
@@ -94,6 +95,7 @@ object MapDataWrapper : IMogoData {
* @param angle 角度
* @param call 回调
*/
@Synchronized
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?) {
@@ -109,6 +111,7 @@ object MapDataWrapper : IMogoData {
* @param angle 角度
* @param call 回调
*/
@Synchronized
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?) {
@@ -120,6 +123,7 @@ object MapDataWrapper : IMogoData {
/**
* 获取道路宽度
*/
@Synchronized
override fun getRoadWidth(
lon: Double,
lat: Double,
@@ -137,6 +141,7 @@ object MapDataWrapper : IMogoData {
*
* @return
*/
@Synchronized
override fun getAngle(
startLon: Double,
startLat: Double,
@@ -153,6 +158,7 @@ object MapDataWrapper : IMogoData {
* @param lat 纬度
* @return 瓦片id
*/
@Synchronized
override fun getTileId(lon: Double, lat: Double): Long {
return MapAutoApi.getTileID(lon, lat, 13) // 13为默认获取瓦片层级级别
}
@@ -160,6 +166,7 @@ object MapDataWrapper : IMogoData {
/**
* 通过cityCode获取HDMap对应缓存城市
*/
@Synchronized
override fun cacheHDDataByCity(
progress: (cityId: Int, progress: Double) -> Unit,
result: (cityId: Int, state: Int) -> Unit
@@ -183,6 +190,7 @@ object MapDataWrapper : IMogoData {
/**
* 通过经纬度信息获取HDMap对应缓存城市
*/
@Synchronized
override fun cacheHDDataByCityByLonLat(
location: MogoLocation,
progress: (cityId: Int, progress: Double) -> Unit,
@@ -206,6 +214,7 @@ object MapDataWrapper : IMogoData {
/**
* 当前城市离线数据是否已缓存
*/
@Synchronized
override fun isCityDataCached(cache: ((Boolean) -> Unit)) {
val cityCode = gdLocationClient.lastCityCode
i(M_MAP + TAG, "gdCityCode is:$cityCode")
@@ -228,6 +237,7 @@ object MapDataWrapper : IMogoData {
}
}
@Synchronized
override fun cancelDownloadCacheData() {
MapDataApi.cancelCacheHDData()
}

View File

@@ -1,120 +0,0 @@
package com.mogo.map;
import android.content.Context;
import android.os.Bundle;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.annotation.Nullable;
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.view.MapAutoView;
import com.zhidaoauto.map.sdk.open.view.MapStyleParams;
/**
* @author congtaowang
* @since 2019-12-18
* <p>
* 地图实例
*/
public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
private static final String TAG = "MogoMapView";
public MogoMapView(Context context) {
super(context);
}
public MogoMapView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public MogoMapView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
private MapAutoView mapAutoView;
@Override
protected void addMapView(Context context, AttributeSet attrs) {
if (mapAutoView == null) {
if (getStyleParams() == null) {
mapAutoView = new MapAutoView(context, attrs);
} else {
mapAutoView = new MapAutoView(context, getStyleParams());
}
}
if (mMapView == null) {
mMapView = new AMapViewWrapper(mapAutoView);
final View mapView = mMapView.getMapView();
if (mapView != null) {
addView(mapView, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
} else {
CallerLogger.e(TAG, "create MapView instance failed.");
}
}
}
/**
* 子类实现
* 代码StyleParams和XML初始化设置同时仅支持一种
*
* @return MapStyleParams
*/
protected MapStyleParams getStyleParams() {
return null;
}
protected IMogoMapUIController getUIController(){
return mMapView.getMap().getUiController();
}
@Override
protected String getInstanceTag() {
return MogoMap.DEFAULT;
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
CallerLogger.d(TAG, "onCreate");
}
@Override
public void onResume() {
super.onResume();
CallerLogger.d(TAG, "onResume");
}
@Override
public void onPause() {
super.onPause();
CallerLogger.d(TAG, "onPause");
}
@Override
public void onDestroy() {
super.onDestroy();
CallerLogger.d(TAG, "onDestroy");
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
@Override
public void onLowMemory() {
super.onLowMemory();
}
public void setExtraGPSData(MogoLocation gnssInfo) {
getMap().getUiController().setExtraGPSData(gnssInfo);
}
}

View File

@@ -0,0 +1,103 @@
package com.mogo.map
import android.content.Context
import android.os.Bundle
import android.util.AttributeSet
import android.view.ViewGroup
import com.mogo.eagle.core.data.map.MogoLocation
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.e
import com.zhidaoauto.map.sdk.open.view.MapAutoView
import com.zhidaoauto.map.sdk.open.view.MapStyleParams
/**
* @author congtaowang
* @since 2019-12-18
*
*
* 地图实例
*/
open class MogoMapView : MogoBaseMapView, ILifeCycle {
constructor(context: Context?) : super(context) {}
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs) {}
constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(
context,
attrs,
defStyleAttr) {
}
private var mapAutoView: MapAutoView? = null
override fun addMapView(context: Context, attrs: AttributeSet) {
if (mapAutoView == null) {
mapAutoView = if (styleParams == null) {
MapAutoView(context, attrs)
} else {
MapAutoView(context, styleParams!!)
}
}
if (mMapView == null) {
mMapView = AMapViewWrapper(mapAutoView!!)
val mapView = mMapView.mapView
if (mapView != null) {
addView(
mapView, LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
)
} else {
e(TAG, "create MapView instance failed.")
}
}
}
/**
* 子类实现
* 代码StyleParams和XML初始化设置同时仅支持一种
*
* @return MapStyleParams
*/
protected val styleParams: MapStyleParams?
protected get() = null
override fun getInstanceTag(): String {
return MogoMap.DEFAULT
}
override fun onCreate(bundle: Bundle) {
super.onCreate(bundle)
d(TAG, "onCreate")
}
override fun onResume() {
super.onResume()
d(TAG, "onResume")
}
override fun onPause() {
super.onPause()
d(TAG, "onPause")
}
override fun onDestroy() {
super.onDestroy()
d(TAG, "onDestroy")
}
override fun onSaveInstanceState(outState: Bundle) {
super.onSaveInstanceState(outState)
}
override fun onLowMemory() {
super.onLowMemory()
}
fun setExtraGPSData(gnssInfo: MogoLocation) {
map?.uiController?.setExtraGPSData(gnssInfo)
}
companion object {
private const val TAG = "MogoMapView"
}
}

View File

@@ -64,15 +64,11 @@ class GDLocationClient private constructor() : AMapLocationListener,
} catch (e: Exception) {
e.printStackTrace()
}
if (mLocationClient != null) {
mLocationClient.startLocation()
}
mLocationClient.startLocation()
}
override fun stop() {
if (mLocationClient != null) {
mLocationClient.stopLocation()
}
mLocationClient.stopLocation()
}
override fun onLocationChanged(aMapLocation: AMapLocation) {
@@ -170,7 +166,7 @@ class GDLocationClient private constructor() : AMapLocationListener,
}
companion object {
val gdLocationClient by lazy(LazyThreadSafetyMode.SYNCHRONIZED){
val gdLocationClient by lazy(LazyThreadSafetyMode.SYNCHRONIZED) {
GDLocationClient()
}
}

View File

@@ -15,8 +15,6 @@ import java.util.List;
*/
public class MogoMapUtils {
private static final String TAG = "MogoMapUtils";
public static LatLngBounds getLatLngBounds(MogoLatLng carPosition, List< MogoLatLng > lonLats, boolean lockCarPosition ) throws Exception {
if ( lonLats == null || lonLats.isEmpty() ) {
@@ -42,14 +40,14 @@ public class MogoMapUtils {
return null;
}
double south = 0.0;
double west = 0.0;
double south;
double west;
double east = 0.0;
double north = 0.0;
double east;
double north;
double dLat = 0.0;
double dLon = 0.0;
double dLat;
double dLon;
if ( latLngBounds.getNortheast() == null ) {
dLat = Math.abs( carPosition.lat - latLngBounds.getSouthwest().getLatitude() );