[base_3.4.0-map-sdk]

This commit is contained in:
zhongchao
2023-08-16 14:01:53 +08:00
parent 73a2dfdc95
commit f7a1ebc51b
5 changed files with 46 additions and 137 deletions

View File

@@ -135,6 +135,7 @@ object ConfigStartUp {
mapParams.setDebugMode(false) // 1-使用本地地图数据0-使用在线地图数据
//.setDataFileSource(1)
.setIsRecordLogs(false)
.setIsWeatherEnable(false)
.setCoordinateType(MapParams.COORDINATETYPE_GCJ02)
.setPerspectiveMode(MapParams.MAP_PERSPECTIVE_UP_CAR)
.setHDVisibileArray(

View File

@@ -441,7 +441,7 @@ class RoadHelper {
// Calculate the angle of the center line.
val pMatch = LonLatPoint()
MapDataApi.GetDisFromPointToLine(LonLatPoint(dLon, dLat), ArrayList(centerLine.points), pMatch, 1)
MapDataApi.getDisFromPointToLine(LonLatPoint(dLon, dLat), ArrayList(centerLine.points), pMatch, 1)
centerLine.angle = pMatch.angle
// Add the center line to the cache.
@@ -506,7 +506,7 @@ class RoadHelper {
val array = result.split(",")
// Create a new StopLine object.
var stopLine = StopLine()
val stopLine = StopLine()
// If the array contains at least six elements, parse them into the StopLine object.
if (array != null && array.size > 5) {
@@ -522,7 +522,7 @@ class RoadHelper {
}
stopLine.lane_id = laneId.split("*")
stopLine.length = array[3].toDouble()
var points = ArrayList<LonLatPoint>()
val points = ArrayList<LonLatPoint>()
for (i in 4..array.size - 1 step 2) {
var lonLatPoint = LonLatPoint(array[i].toDouble(), array[i + 1].toDouble())
points.add(lonLatPoint)
@@ -660,7 +660,7 @@ class RoadHelper {
}
centerLine.points = points
var pMatch = LonLatPoint()
MapDataApi.GetDisFromPointToLine(LonLatPoint(dLon, dlat), points, pMatch, 1)
MapDataApi.getDisFromPointToLine(LonLatPoint(dLon, dlat), points, pMatch, 1)
centerLine.angle = pMatch.angle
// Add the result to the cache
centerLineCache.put(cacheKey,centerLine)
@@ -802,7 +802,7 @@ class RoadHelper {
result?.let {
val array = result.split(",")
if (array != null && array.size > 2) {
var roadCross = RoadCross()
val roadCross = RoadCross()
roadCross.status = array[0].toInt()
roadCross.tile_id = array[1]
roadCross.cross_id = array[2]

View File

@@ -1,17 +1,13 @@
package com.zhidaoauto.map.sdk.open.data
import android.annotation.SuppressLint
import android.app.ActivityManager
import android.content.Context
import android.text.TextUtils
import android.util.Log
import com.autonavi.nge.dm.SharedMemoryService
import com.autonavi.nge.map.LonLat
import com.zhidaoauto.map.sdk.inner.CompileConfig
import com.zhidaoauto.map.sdk.inner.proxy.CommonProxy
import com.zhidaoauto.map.sdk.inner.road.RoadHelper
import com.zhidaoauto.map.sdk.inner.utils.GisGeomTool
import com.zhidaoauto.map.sdk.inner.utils.LogHelper
import com.zhidaoauto.map.sdk.inner.utils.MathUtils
import com.zhidaoauto.map.sdk.inner.utils.Recorder
import com.zhidaoauto.map.sdk.open.abs.IResult
@@ -56,31 +52,6 @@ object MapDataApi {
mContext = null
}
/**
* 判断服务是否开启
*
* @return
*/
fun isServiceRunning(context: Context, ServiceName: String): Boolean {
if (true) {
return false
}
if (TextUtils.isEmpty(ServiceName)) {
return false
}
val myManager = context
.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
val runningServices = myManager
.getRunningServices(50) as ArrayList<ActivityManager.RunningServiceInfo>
for (info in runningServices) {
if (info.service.className.equals(ServiceName)) {
return true
}
}
return false
}
fun getRouteInfo(
centerLon: Float,
centerLat: Float, coor: Int, type: Int
@@ -89,49 +60,6 @@ object MapDataApi {
return RoadHelper.getInstance()?.getRoadInfo(centerLon, centerLat, coor, type)?:""
}
/**
* 获取道路关键点数据
*
*/
fun getMatchRoadInfo(
lonLatPoints: List<LonLatPoint>,
bGetAllPoints: Boolean
): List<LonLatPoint>? {
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop getMatchRoadInfo")
}
val originArray = DoubleArray(lonLatPoints.size * 2)
var lonLat: LonLat?
for ((index, lonLatPoint) in lonLatPoints.withIndex()) {
lonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
originArray[index * 2] = lonLat.lon
originArray[index * 2 + 1] = lonLat.lat
}
if (CompileConfig.DEBUG) {
LogHelper.info(TAG, "roadop getMatchRoadInfo--param:${originArray.joinToString()}")
// Recorder.i("${originArray.joinToString()}")
}
val resultArray = RoadHelper.getInstance()?.getMatchRoadInfo(originArray, bGetAllPoints)
if (CompileConfig.DEBUG) {
LogHelper.info(TAG, "roadop getMatchRoadInfo--resultArray:${resultArray?.joinToString()}")
}
resultArray?.let { array ->
if (resultArray.isEmpty()) {
return null
}
var lonLatPoint: LonLatPoint?
val resultList = ArrayList<LonLatPoint>(resultArray.size / 2)
for (index in 0..array.size - 1 step 2) {
lonLatPoint = CommonProxy.getInstance().getLonLatProxy()
.switchLonLat(LonLat(array[index], array[index + 1]))
resultList.add(lonLatPoint)
}
return resultList
}
return null
}
/**
* 获取行车方向
*
@@ -140,15 +68,15 @@ object MapDataApi {
if (CompileConfig.DEBUG) {
Log.i(TAG, "queryop getRouteAngle")
}
val startLonLat =
val sLonLat =
CommonProxy.getInstance().getLonLatProxy().switchLonLat(startLonLat)
val endLonLat =
val eLonLat =
CommonProxy.getInstance().getLonLatProxy().switchLonLat(endLonLat)
return RoadHelper.getInstance()?.getRouteAngle(
startLonLat.lon.toFloat(),
startLonLat.lat.toFloat(),
endLonLat.lon.toFloat(),
endLonLat.lat.toFloat()
sLonLat.lon.toFloat(),
sLonLat.lat.toFloat(),
eLonLat.lon.toFloat(),
eLonLat.lat.toFloat()
)?:0f
}
@@ -166,12 +94,12 @@ object MapDataApi {
}
// 获取点到线段的距离
fun GetDisFromPointToLine( ptOrg:LonLatPoint, pLine:ArrayList<LonLatPoint>, ptMatch:LonLatPoint, nSegmentOrder:Int):Double {
fun getDisFromPointToLine(ptOrg:LonLatPoint, pLine:ArrayList<LonLatPoint>, ptMatch:LonLatPoint, nSegmentOrder:Int):Double {
return GisGeomTool.GetDisFromPointToLine(ptOrg, pLine, ptMatch, nSegmentOrder)
}
// 获取点到线段的最近距离
fun getNearstFromPointToSegment(x: Double, y: Double, x1: Double, y1: Double, x2: Double, y2: Double): Double {
fun getClosestFromPointToSegment(x: Double, y: Double, x1: Double, y1: Double, x2: Double, y2: Double): Double {
return MathUtils.minDistance(x, y, x1, y1, x2, y2)
}
@@ -232,9 +160,9 @@ object MapDataApi {
/**
* 获取道路路口信息
*/
fun getCrossRoad(dLon: Double, dlat: Double , fAngle: Float,call: IResult<RoadCross>){
Recorder.add("roadop-getCrossRoad:$dLon,$dlat,$fAngle")
RoadHelper.getInstance()?.getCrossRoad(dLon, dlat, fAngle,call)
fun getCrossRoad(dLon: Double, dLat: Double, fAngle: Float, call: IResult<RoadCross>){
Recorder.add("roadop-getCrossRoad:$dLon,$dLat,$fAngle")
RoadHelper.getInstance()?.getCrossRoad(dLon, dLat, fAngle,call)
}
/**
* 根据路口id获取道路信息
@@ -284,9 +212,9 @@ object MapDataApi {
}
fun getZebraLineByDistance(dLon: Double, dlat: Double , fAngle: Float, dis: Float,call: IResult<MutableList<ZebraLine>>){
Recorder.add("$dLon,$dlat,$fAngle,$dis")
RoadHelper.getInstance()?.getZebraLineByDistance(dLon, dlat, fAngle, dis,call)
fun getZebraLineByDistance(dLon: Double, dLat: Double, fAngle: Float, dis: Float, call: IResult<MutableList<ZebraLine>>){
Recorder.add("$dLon,$dLat,$fAngle,$dis")
RoadHelper.getInstance()?.getZebraLineByDistance(dLon, dLat, fAngle, dis,call)
}
//计算两线交点

View File

@@ -30,10 +30,8 @@ import android.view.View;
import androidx.annotation.NonNull;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
import com.mogo.eagle.core.data.enums.TrafficTypeEnum;
import com.mogo.eagle.core.data.map.CenterLine;
import com.mogo.eagle.core.data.map.MapRoadInfo;
import com.mogo.eagle.core.data.map.MogoLatLng;
import com.mogo.eagle.core.data.map.MogoLocation;
@@ -44,7 +42,6 @@ import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager;
import com.mogo.eagle.core.function.call.map.CallerMapRomaListener;
import com.mogo.eagle.core.function.call.map.CallerMapStyleListenerManager;
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
import com.mogo.map.hdcache.IHdCacheListener;
@@ -87,9 +84,7 @@ import com.zhidaoauto.map.sdk.open.marker.Marker;
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener;
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
import com.zhidaoauto.map.sdk.open.road.RoadCross;
import com.zhidaoauto.map.sdk.open.road.RoadRectInfos;
import com.zhidaoauto.map.sdk.open.road.StopLine;
import com.zhidaoauto.map.sdk.open.routeinfo.RoadInfo;
import com.zhidaoauto.map.sdk.open.tools.MapTools;
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
import com.zhidaoauto.map.sdk.open.view.MapAutoViewHelper;
@@ -102,10 +97,9 @@ import java.util.ArrayList;
import java.util.List;
public class AMapViewWrapper implements IMogoMapView,
public class AMapViewWrapper implements IMogoMapView, //地图实例和接口操作对象
IMogoMapUIController,
OnMapLoadedListener,
MapStatusListener,
OnCameraChangeListener,
OnMapClickListener,
OnMapTouchListener,
@@ -170,16 +164,17 @@ public class AMapViewWrapper implements IMogoMapView,
return;
}
MapAutoViewHelper options = mMapView.getMapAutoViewHelper();
if (options != null) {
options.setScaleVRMode(true);
}
//todo configStartUp配置
ThreadUtils.getIoPool().submit(() -> {
if (options != null) {
//设置手势是否可以缩放 isCanZoom true 可缩放 false 不可缩放
options.setZoomGesturesEnabled(true);
options.setScaleVRMode(true);
options.setWeatherEnable(false);
// options.setAllGesturesEnabled(false); //禁止全部手势
if (options.getMyLocationStyle() != null) {
options.getMyLocationStyle().setDisplayAnimEnable(true);
}
// if (options.getMyLocationStyle() != null) {
// //是否显示光圈,耗时
// options.getMyLocationStyle().setDisplayAnimEnable(true);
// }
//修改自车模型,未来需区分车的类型
options.setMyLocationStyle(options.getMyLocationStyle().myLocationIcon(HdMapBuildConfig.currentCarVrIconRes, true));
}
@@ -199,7 +194,7 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnRoamStatusListener(this);
mMapView.setOnMapViewVisualAngleChangeListener(this);
mMapView.setOnRoadInfoListener(this, 1);
MapAutoApi.INSTANCE.registerLogListener(this,mMapView.getEventController());
MapAutoApi.INSTANCE.registerLogListener(this, mMapView.getEventController());
CallerLogger.INSTANCE.d(M_MAP + TAG, "styleop - initListeners - setOnMapStyleListener - view " + mMapView);
}
@@ -234,7 +229,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.getNearstFromPointToSegment(carLoc.getLongitude(), carLoc.getLatitude(), p1.getLongitude(), p1.getLatitude(), p2.getLongitude(), p2.getLatitude()) * 10_0000;
double distanceOfCarToStopLine = MapDataApi.INSTANCE.getClosestFromPointToSegment(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);
@@ -318,7 +313,7 @@ public class AMapViewWrapper implements IMogoMapView,
mMapView.setOnMapTouchListener(null);
mMapView.setOnMapClickListener(null);
mMapView.setOnCameraChangeListener(null);
MapAutoApi.INSTANCE.unregisterLogListener(this,mMapView.getEventController());
MapAutoApi.INSTANCE.unregisterLogListener(this, mMapView.getEventController());
CallerLogger.INSTANCE.d(M_MAP + TAG, "map onDestroy");
}
@@ -485,15 +480,6 @@ public class AMapViewWrapper implements IMogoMapView,
}
}
public void initMyLocation() {
if (checkAMapView()) {
mMapView.getMarkerController().addPreModel(R.raw.guangquan);
// MarkerHelper.addPreModel(R.raw.guangquan_day)
mMapView.getMapAutoViewHelper().setMyLocationEnabled(true);
}
}
@Override
public float getScalePerPixel() {
return getMap().getScalePerPixel();
@@ -551,7 +537,7 @@ public class AMapViewWrapper implements IMogoMapView,
public Point getLocationPointInScreen(MogoLatLng latLng) {
if (checkAMapView()) {
try {
return MapTools.INSTANCE.toScreenLocation(ObjectUtils.fromMogo(latLng),mMapView.getMapController());
return MapTools.INSTANCE.toScreenLocation(ObjectUtils.fromMogo(latLng), mMapView.getMapController());
} catch (Exception e) {
e.printStackTrace();
return null;
@@ -565,7 +551,7 @@ public class AMapViewWrapper implements IMogoMapView,
if (checkAMapView()) {
try {
return ObjectUtils.fromAMap(
MapTools.INSTANCE.fromScreenLocation(point,mMapView.getMapController()));
MapTools.INSTANCE.fromScreenLocation(point, mMapView.getMapController()));
} catch (Exception e) {
e.printStackTrace();
return null;
@@ -703,20 +689,17 @@ public class AMapViewWrapper implements IMogoMapView,
return getMap().getUIController().getTileId(lon, lat);
}
@Override
public void result(@NonNull String filePath) {
CallerMapDevaListenerManager.INSTANCE.invokeUploadLogFile(filePath);
}
@Override
public void onMapClick(@Nullable LonLatPoint lonLatPoint) {
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapClick(ObjectUtils.fromAMap(lonLatPoint));
}
//渲染第一帧
@ChainLog(
linkChainLog = CHAIN_TYPE_INIT_STATUS,
linkCode = CHAIN_SOURCE_INIT,
@@ -729,6 +712,7 @@ public class AMapViewWrapper implements IMogoMapView,
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onMapLoaded();
}
//地图视图准备
@ChainLog(
linkChainLog = CHAIN_TYPE_INIT_STATUS,
linkCode = CHAIN_SOURCE_INIT,
@@ -745,11 +729,14 @@ public class AMapViewWrapper implements IMogoMapView,
cameraPosition.getTilt(),
cameraPosition.getBearing());
initMapView();
initMyLocation();
loadPreVehicleModel();
}
}
@Override
public void onRoadLoaded(@Nullable String s) {
}
@Override
public boolean onTouch(@Nullable MotionEvent motionEvent) {
MogoMapListenerHandler.Companion.getMogoMapListenerHandler().onTouch(motionEvent);
@@ -761,14 +748,6 @@ public class AMapViewWrapper implements IMogoMapView,
// mMarkerClickHandler.handleMarkerClicked(markerInfo);
}
@Override
public void onRoadLoaded(@Nullable String s) {
}
@Override
public void onMapStatusChanged(int type, int value) {
}
@Override
public void onRoamStatus(int status, @NonNull String msg) {
CallerMapRomaListener.INSTANCE.invokeMapRomaStatus(status, msg);
@@ -968,7 +947,7 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void setLockMode(boolean isLock) {
if (checkAMapView()) {
Log.d("TTTTT", "setLockMode:" +isLock);
Log.d("TTTTT", "setLockMode:" + isLock);
mMapView.getMapAutoViewHelper().setLockMode(isLock);
}
}
@@ -1013,7 +992,7 @@ public class AMapViewWrapper implements IMogoMapView,
public void setIsDrawPointCloud(Boolean isDrawPointCloud) {
try {
// 是否绘制点云
PointCloudHelper.INSTANCE.setIsDrawPointCloud(isDrawPointCloud,mMapView.getMapController());
PointCloudHelper.INSTANCE.setIsDrawPointCloud(isDrawPointCloud, mMapView.getMapController());
} catch (Exception e) {
e.printStackTrace();
}
@@ -1022,13 +1001,13 @@ public class AMapViewWrapper implements IMogoMapView,
@Override
public void setPointCloudSize(Float pointCloudSize) {
//设置点云大小
PointCloudHelper.INSTANCE.setPointCloudSize(pointCloudSize,mMapView.getMapController());
PointCloudHelper.INSTANCE.setPointCloudSize(pointCloudSize, mMapView.getMapController());
}
@Override
public void setPointCloudColor(String color) {
// 设置点云颜色
PointCloudHelper.INSTANCE.setPointCloudColor(color,mMapView.getMapController());
PointCloudHelper.INSTANCE.setPointCloudColor(color, mMapView.getMapController());
}
@Override

View File

@@ -21,6 +21,7 @@ object MapDataWrapper {
* @param angle 角度
* @param call 回调
*/
@Synchronized
fun getCenterLineInfo(lon: Double, lat: Double, angle: Float,call:IResult<CenterLine>){
MapDataApi.getCenterLineInfo(
lon,