[map-sdk]同步地图3.2.0修改 1.增加聚焦自车周边车辆 2.车道中心线数据平滑处理

This commit is contained in:
jiaguofeng
2023-09-19 10:59:09 +08:00
parent c467a8a50d
commit f29829751c
45 changed files with 777 additions and 609 deletions

View File

@@ -1,59 +0,0 @@
package com.autonavi.nge;
import com.zhidaoauto.map.sdk.inner.CompileConfig;
import com.zhidaoauto.map.sdk.inner.road.RoadResultController;
public class MapBox {
private static final String TAG = "MapBox";
static {
System.loadLibrary("map");
}
public MapBox(){
llaInit(this);
}
public native void llaInit(MapBox mapBox);
public native void llaGetCenterLine(double dLon, double dLat, float fAngle);
public native void llaStopLine(double dLon, double dLat, float fAngle);
public native void llaGetZebraLine(double dLon, double dLat, float fAngle);
public native void llaGetTrafficLight(double dLon, double dLat, float fAngle);
public native void llaMergedRoadRect(double dLon, double dLat, float fAngle);
public native void llaGetRoadLimitSpeed(double dLon, double dLat, float fAngle);
public native void llaGetCenterLineRange(double dLon, double dLat, float fAngle,float fDis,boolean isSmooth,int orders);
public native void llaGetRoadName(double dLon, double dLat, float fAngle);
public native void llaGetCenterLineRoadNode(double dLon, double dLat, float fAngle,float fDis);
public native void llaGetCrossRoad(double dLon, double dLat, float fAngle);
public native void llaGetCrossRoadById(int tileId, long id);
public native void llaIsInZebraLine(double dLon, double dLat, float fAngle);
public native void llaGetZebraLineByDistance(double dLon, double dLat, float fAngle,float dis);
public native void updateCacheFile();
public native void modifyRedisFileVersion(int version);
/*@return value format: cityCode1,chineseCityName1,englishCityName1,isCache1;cityCode2,chineseCityName2,englishCityName2,isCache2;...;*/
public native void getAllCityCode();
public native void cacheHDDataByCity(int id);
public native void getCityCode(double lon, double lat);
public native void getCacheProgressByCity(int id);
public native void cacheHDDataByCityLonLat(double lon,double lat);
public native void cancelCacheHDData();
public native void initFileCacheByCity(double lon, double lat);
public native void getHdDataVersionByCity(double lon,double lat);
public native void llaRelease();
static void resultCallbackByteStream(String key,byte[] result){
if(CompileConfig.INSTANCE.getDEBUG()){
// Log.d(TAG, "roadop--resultCallbackDouble: " +"key:" + key + " + " result:"+ result.length);
}
if (result == null || result.length < 1) {
return;
}
RoadResultController.getInstance().dispatchRoadResult(0,key,result);
}
}

View File

@@ -41,7 +41,7 @@ public class SharedMemoryService {
unload();
}
private native static int initSharedMemory_Native(String dir, String tilesDir,int[] tileFilter);
private native static int initSharedMemory_Native(String dir, String mogoStyleDir,String tilesDir,int[] tileFilter);
private native static boolean testRoutingTile(int i, int j, int k);
@@ -64,7 +64,7 @@ public class SharedMemoryService {
if (CompileConfig.INSTANCE.getDEBUG()) {
Log.i(TAG, "autoop-dir:" + dir+",SharedMemory--cachePath:"+cachePath);
}
initSharedMemory_Native(dir, cachePath,MapHelper.INSTANCE.getMMapParams().getQZoneFilterArray());
initSharedMemory_Native(dir,MapHelper.INSTANCE.getMMapParams().getStyleDir(),cachePath,MapHelper.INSTANCE.getMMapParams().getQZoneFilterArray());
}

View File

@@ -4,8 +4,8 @@ import android.os.Parcel;
import android.os.Parcelable;
public class LonLat implements Parcelable {
private double lon;
private double lat;
private double lon = - 1.0;
private double lat = - 1.0;
private double alt;

View File

@@ -998,15 +998,15 @@ class MapEngine {
mObj = 0
}
}
fun setLightWave(da:DoubleArray){
fun setLightWave(cmd:String){
if (mObj != 0L) {
setLightWaveJni(mObj,da)
setPainterCmdJni(mObj,"lightwave",cmd)
}
}
fun setGuideLine(da:DoubleArray?){
fun setGuideLine(cmd:String?){
if (mObj != 0L) {
setGuideLineJni(mObj,da)
setPainterCmdJni(mObj,"guideline",cmd)
}
}
fun setTexture(name: String,ba:ByteArray?){
@@ -1623,7 +1623,6 @@ class MapEngine {
private external fun drawDeadZoneJni(obj: Long,strJsonOption: String?)
private external fun setDeadZoneVisiableJni(obj:Long,b: Boolean)
private external fun setLightWaveJni(obj: Long,da:DoubleArray) //光波移动lon1,lat1,lon2,lat2...width,duration
private external fun setGuideLineJni(obj: Long,da:DoubleArray?) //带纹理的引导线
private external fun setTextureJni(obj: Long,name:String,ba:ByteArray?) //设置一些元素的纹理,比如路面("road"),地面("plane")啥的
private external fun setPainterCmdJni(obj: Long,name:String?,cmd:String?)
}

View File

@@ -18,7 +18,6 @@ import android.view.SurfaceHolder
import android.view.View
import com.alibaba.fastjson.JSON
import com.zhidaoauto.map.data.point.LonLatPoint
import com.zhidaoauto.map.sdk.inner.CompileConfig
import com.zhidaoauto.map.sdk.inner.CompileConfig.DEBUG
import com.zhidaoauto.map.sdk.inner.abs.IEventController
import com.zhidaoauto.map.sdk.inner.abs.ILockLocation
@@ -86,7 +85,6 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
private var m_fLastAverageDistanceFromCenter = -1f
private var m_iMultiTouchCnt = 0
private var m_FPS = 60
private var lastUpdateTime: Long = 0
private val mGestureDetector: GestureDetector
//The controller of map
private var mMapController: IMapController? = null
@@ -98,16 +96,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
// down事件时间
private var lastDownTime = 0L
// 上次ScaleBy事件时间
private var lastScaleByTime = 0L
// 上次时间
private var lastTime = 0L
// 事件间隔
private final val eventScaleInterval = 30L // 事件间隔
private final val eventInterval = 30L
private val eventInterval = 30L
//已初始化Surface
private var mSurfaceCreated: AtomicBoolean = AtomicBoolean(false)
@@ -119,7 +108,6 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
private var mPoiTouchEnable = true
private var mViewWidth = 1920
private var mViewHeight = 1040
var mLonLat: LonLat? = null
private val ZOOM_CHANGE = 0x7F
private val FOCUS_CHANGE = 0x9F
private val ROTATE_CHANGE = 0x11F
@@ -128,25 +116,23 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
private val LOAD_COMPLETE = 0x17F
private val RENDER_CHANGE = 0x19F
private val INIT_COMPLETE = 0x21F
private val LISTENER_TYPE_SCREEN = 0x5F
private val DELAY_TIME: Long = 500
private val VELOCITY_MEASURE: Float = 3000f
private val SCALE_SMALL_DISTANCE: Float = 0.5f
private var mOnMarkerDragListener: OnMarkerDragListener? = null
var mITraffic: ITraffic? = null
var mLockCarJob: Job? = null
var mAnimJob: Job? = null
var mMarkerJob: Job? = null
var mLongPressJob: Job? = null
var mLockCar: Job? = null
private var mLockCarJob: Job? = null
private var mAnimJob: Job? = null
private var mMarkerJob: Job? = null
private var mLongPressJob: Job? = null
private var mLockCar: Job? = null
//是否第一次加载完成
private var isFirst = true
//是否已回收
private var isDestory = false
private var isDestroy = false
private var lastClickMarker: Marker? = null
private var dragMarker: Marker? = null
private var mDragMarker: Marker? = null
private var renderDataCall: IRenderData? = null
private var enableSync = false
@@ -155,9 +141,9 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
private var isAutoLockCar = true
// 协程
lateinit var mScope: CoroutineScope
private val mScope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
// 耗时专用协程
lateinit var mDemaningScope: CoroutineScope
private val mDemaningScope: CoroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
private val mHandler: Handler = object : Handler(Looper.getMainLooper()) {
@@ -183,10 +169,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
if (DEBUG) {
Log.i(TAG, "mapop--load complete-start")
}
// setAnchorScale(1.01f,2.5f)
mEventController?.dispatchMapLoadedListener()
// CommonController.instance.naviAutoView?.mNaviViewListener?.onNaviViewLoaded()
}
INIT_COMPLETE -> {
@@ -195,8 +178,6 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
}
mEventController?.dispatchMapLoadedInitListener()
}
else -> {
}
}
}
}
@@ -243,7 +224,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
}
isFirst = true
loaded = false
isDestory = true
isDestroy = true
mHandler.removeCallbacksAndMessages(null)
mMapController = null
mITraffic = null
@@ -285,30 +266,17 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
}
override fun onPause() {
super.onPause()
}
override fun onResume() {
super.onResume()
}
open fun loadOverCallbak() {
// if (DEBUG) {
// Log.i(TAG, "mapop---renderop-loadOverCallbak- isFirst:${isFirst}")
// }
fun loadOverCallbak() {
if (isFirst) {
loaded = true
isFirst = false
// setAnchorScale(1.01f,2.5f)
mHandler.sendEmptyMessage(LOAD_COMPLETE)
}
}
//渲染完成回调
open fun renderOverCallbak() {
fun renderOverCallbak() {
if (DEBUG) {
Log.i(TAG, "mapop---renderop-renderOverCallbak: ")
}
@@ -320,7 +288,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
this.renderDataCall = renderDataCall
}
open fun clipedRouteLineCbk(
fun clipedRouteLineCbk(
tileId: Int, leftTopLon: Double, leftTopLat: Double, leftBottomLon: Double, leftBottomLat: Double,
rightTopLon: Double, rightTopLat: Double, rightBottomLon: Double, rightBottomLat: Double, clipedRouteInfo: String?
) {
@@ -331,9 +299,11 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
mEventController?.dispatchRoadLoadedListener(clipedRouteInfo)
}
//type==2 代表的缩放结束
//type==1 代表平移结束
//type== 0 代表所有动画结束
/**
* 锚点动画事件回调
* @param markerId
* @param type 0 代表所有动画结束 1 代表平移结束 2 代表的缩放结束
*/
fun AnimateFinishCallback(markerId: String, type: Int) {
if (DEBUG) {
Log.d("AnimateFinishCallback", "markerop-AnimateFinishCallback:${markerId},type =${type}")
@@ -341,12 +311,17 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
val animationListener = mMarkerCall?.getAnimationListener(markerId)
animationListener?.let {
mAnimJob?.cancel()
mAnimJob = mScope.launch(Dispatchers.IO){
mAnimJob = mDemaningScope.launch(){
it.onAnimationFinish(markerId, type)
}
}
}
/**
* 锚点批量更新数据回调,锚点所有属性
*
* @param dataStr
*/
private fun markerBatchCallback(dataStr: String) {
mMarkerCall?.updateMarkerResource(dataStr)
if(DEBUG) {
@@ -365,15 +340,17 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
return JSON.parseObject(json, MarkerInfo::class.java)
}
var isTouchingFlag = false
private var isTouchingFlag = false
var lonlat: LonLat? = null
override fun onTouchEvent(ev: MotionEvent): Boolean {
if (ev.action == MotionEvent.ACTION_MOVE && dragMarker != null) {
dragMarker?.let {
Log.i(TAG, "markerop--dragMarker:ev.getX().toInt()${ev.getX().toInt()} ev.getY().toInt()${ev.getY().toInt()}")
if (ev.action == MotionEvent.ACTION_MOVE && mDragMarker != null) {
mDragMarker?.let {
if(DEBUG){
Log.i(TAG, "markerop--dragMarker:ev.getX().toInt()${ev.getX().toInt()} ev.getY().toInt()${ev.getY().toInt()}")
}
mMapEngine.setSomeDrawModelPointScreenPosition(ev.getX().toInt(), ev.getY().toInt())
mOnMarkerDragListener?.onMarkerDrag(dragMarker)
mOnMarkerDragListener?.onMarkerDrag(mDragMarker)
return true
}
@@ -390,12 +367,12 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
if (ev.action == MotionEvent.ACTION_UP || ev.action == MotionEvent.ACTION_CANCEL) {
mDealScale = true
isTouchingFlag = false
dragMarker?.let {
dragMarker?.getId()?.let {
mDragMarker?.let {
mDragMarker?.getId()?.let {
mMapEngine.setSomeAnchorDrawModel(it, false)
mOnMarkerDragListener?.onMarkerDragEnd(dragMarker)
mOnMarkerDragListener?.onMarkerDragEnd(mDragMarker)
}
dragMarker = null
mDragMarker = null
mOnMarkerDragListener = null
}
}
@@ -410,7 +387,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
mILockLocation.setLockCar(false)
if(isAutoLockCar) {
mLockCarJob?.cancel()
mLockCarJob = mDemaningScope.launch(Dispatchers.IO) {
mLockCarJob = mDemaningScope.launch {
if (DEBUG) {
Log.i(TAG, "lockop--onTouchEvent:mLockCarJob start: ${mMapStyleParams.getVrAngleMode()}")
}
@@ -438,22 +415,18 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
var angle = 0
// 两指切换3D效果
if (m_bLastMultiple && !m_bRotating) {
if (m_bLastMultiple && !m_bRotating && isFling) {
//跳到3d效果
val dy0 = m_iLastY0 - ev.getY(0)
val dy1 = m_iLastY1 - ev.getY(1)
if (abs(dy0) > 1 || abs(dy1) > 1) {
if (dy1 * dy0 > 1 && dy1 / dy0 < 3 && dy0 / dy1 < 3) {
if (isFling) {
m_bBending = true
val value = (dy0 + dy1) / 8f
if (DEBUG && mShowTouchInfo) {
Log.i(TAG, "touchop--lookUpDown:${value}")
}
tilt(value)
}
if ((abs(dy0) > 1 || abs(dy1) > 1)
&& (dy1 * dy0 > 1 && dy1 / dy0 < 3 && dy0 / dy1 < 3)){
m_bBending = true
val value = (dy0 + dy1) / 8f
if (DEBUG && mShowTouchInfo) {
Log.i(TAG, "touchop--lookUpDown:${value}")
}
tilt(value)
}
}
//旋转效果
@@ -507,12 +480,9 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
if (DEBUG && mShowTouchInfo) {
Log.i(TAG, "touchop--scaleop--lastDownTime:${lastDownTime},${ev.eventTime}")
}
// 增加两次事件执行间隔
// if (lastScaleByTime == 0L || ev.eventTime - lastDownTime > eventScaleInterval) {
if (DEBUG && mShowTouchInfo) {
Log.i(TAG, "touchop--scaleop--zoomFactor-scaleBy2:${zoomFactor},${mScaleCenterX},${mScaleCenterY}")
}
// lastScaleByTime = SystemClock.uptimeMillis()
if(isVr && (mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_NIGHT_VR || mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_DAY_VR)){
if(DEBUG) {
Log.d(TAG, "getZoomVal(): ${mMapEngine.getZoomValue()}, $zoomFactor")
@@ -520,8 +490,6 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
//zoomFactor 缩放比例 > 1 放大 < 1 缩小 getZoomVal() / zoomFactor 缩放到的值
if(mMapEngine.getZoomValue() / zoomFactor < 3.0) {
mMapEngine.scaleByCenter(mScaleCenterX, mScaleCenterY, zoomFactor)
}else{
}
}else {
mMapEngine.scaleByCenter(mScaleCenterX, mScaleCenterY, zoomFactor)
@@ -530,7 +498,6 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
Log.i(TAG, "touchop--scaleop:over")
}
requestRender()
// }
}
}
@@ -609,17 +576,8 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
}
}
var snapshotBitmap: Bitmap? = null
var isScreen:AtomicBoolean = AtomicBoolean()
private var doubles = doubleArrayOf()
open fun getDoubles(): DoubleArray {
return doubles
}
open override fun setDoubles(doubles: DoubleArray) {
this.doubles = doubles
}
private var snapshotBitmap: Bitmap? = null
private var isScreen:AtomicBoolean = AtomicBoolean()
private var time: Long = 0
@@ -627,7 +585,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
override fun onDrawFrame(gl: GL10) {
if (isDestory) {
if (isDestroy) {
return
}
time = System.currentTimeMillis()
@@ -638,7 +596,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
if (isRenderFirst) {
isRenderFirst = false
if(mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_NIGHT_VR || mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_DAY_VR) {
mMapController?.setMapViewVisualAngle(mMapStyleParams.getDefaultPerspective())
mMapController?.setMapViewVisualAngle(mMapStyleParams.getVrAngleDefaultMode())
}
mHandler.sendEmptyMessage(INIT_COMPLETE)
if(DEBUG){
@@ -648,7 +606,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
if(enableSync){
// 2ms是每次耗时补充
val sTime = renderTimePer-(System.currentTimeMillis()-time)-2
if(sTime > 0 && sTime < 100){
if(sTime in 1..99){
try {
Thread.sleep(sTime)
} catch (e:Exception) {
@@ -718,7 +676,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
override fun onAttachedToWindow() {
super.onAttachedToWindow()
isRenderFirst = true
isDestory = false
isDestroy = false
isFirst = true
if (DEBUG) {
Log.i(TAG, "mapop-surfaceop----onAttachedToWindow:")
@@ -766,11 +724,9 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
//默认锁车模式
mMapEngine.setLockSelfCar(true)
mMapController?.setMapStyle(styleMode)
val param = mMapStyleParams.getCarPosition()
// if(param>0f)
// {
mMapEngine.setScreenToOriginDis(param)
// }
mMapEngine.setScreenToOriginDis(mMapStyleParams.getCarPosition())
if (mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_NIGHT_VR || mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_DAY_VR) {
if (DEBUG) {
Log.i(TAG, "mapop-surfaceop----onSurfaceCreated,Vr")
@@ -790,7 +746,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
if(mMapStyleParams.getPerspectiveMode()>2){
mMapEngine.setSelfLocaionControl(mMapStyleParams.getPerspectiveMode())
}
if(mMapStyleParams.getIsSkyBoxEnable()) {
if(mMapStyleParams.isSkyBoxEnable()) {
mMapController?.setSkyBoxMode()
}
isFling = false
@@ -825,13 +781,13 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
}
if (isCanZoom) {
if(mMapStyleParams.isSwitchViewAngle() && (mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_NIGHT_VR || mMapStyleParams.getStyleMode() == MapAutoApi.MAP_STYLE_DAY_VR)){
var type = mMapStyleParams.getDefaultPerspective()
var type = mMapStyleParams.getVrAngleDefaultMode()
when(mMapStyleParams.getVrAngleMode()){
mMapStyleParams.getDefaultPerspective()->{
mMapStyleParams.getVrAngleDefaultMode()->{
type = ConstantExt.MAP_STYLE_VR_ANGLE_FAR
}
ConstantExt.MAP_STYLE_VR_ANGLE_FAR->{
type = mMapStyleParams.getDefaultPerspective()
type = mMapStyleParams.getVrAngleDefaultMode()
}
}
setMapViewVisualAngle(type)
@@ -885,7 +841,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
val x = e.x.toInt()
val y = e.y.toInt()
mMarkerJob?.cancel()
mMarkerJob = mDemaningScope.launch(Dispatchers.IO) {
mMarkerJob = mDemaningScope.launch {
if (DEBUG) {
Log.i(TAG, "markerop--findAnchorAtScreenPoint:start")
}
@@ -897,6 +853,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
Log.i(TAG, "markerop--findAnchorAtScreenPoint:${resultInfo}")
}
if (TextUtils.isEmpty(resultInfo) || resultInfo == "unableBeTouch") {
return@launch
} else {
val markerInfo = jsonToObj(resultInfo)
@@ -921,7 +878,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
mILockLocation.setLockCar(false)
it.onMarkClick(marker)
mLockCarJob?.cancel()
mLockCarJob = mDemaningScope.launch(Dispatchers.IO) {
mLockCarJob = mDemaningScope.launch {
delay(waitTime)
mILockLocation.setLockCar(true)
}
@@ -935,7 +892,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
for (rect in it.keys) {
if (rect.contains(markerInfo.hitx, markerInfo.hity)) {
withContext(Dispatchers.Main) {
it.get(rect)?.click()
it[rect]?.click()
}
clickFlag = true
break
@@ -960,11 +917,11 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
inner class TouchGestureDetecter : GestureDetector.OnGestureListener {
override fun onLongPress(e: MotionEvent) {
if (dragMarker != null) {
if (mDragMarker != null) {
return
}
mLongPressJob?.cancel()
mLongPressJob = mScope.launch(Dispatchers.IO) {
mLongPressJob = mScope.launch {
if(!mSurfaceCreated.get()){
return@launch
}
@@ -973,20 +930,21 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
Log.i(TAG, "markerop--touch--findAnchorAtScreenPoint:${resultInfo}")
}
if (TextUtils.isEmpty(resultInfo) || resultInfo == "unableBeTouch") {
return@launch
} else {
val markerInfo = jsonToObj(resultInfo)
if (markerInfo != null) {
val isDraggable = mMapEngine.getAnchorProperty(markerInfo.id, "draggable").toBoolean()
if (isDraggable) {
dragMarker = Marker(MarkerOptions(markerInfo.id,null).lonLatPoint(LonLat(markerInfo.lon, markerInfo.lat)),mMapController,mMarkerCall)
mDragMarker = Marker(MarkerOptions(markerInfo.id,null).lonLatPoint(LonLat(markerInfo.lon, markerInfo.lat)),mMapController,mMarkerCall)
markerInfo.id?.let { infoId->
mOnMarkerDragListener = mMarkerCall?.getMarkDragListener(infoId)
mOnMarkerDragListener?.let {
withContext(Dispatchers.Main) {
dragMarker?.getId()?.let { id->
mDragMarker?.getId()?.let { id->
mMapEngine.setSomeAnchorDrawModel(id, true)
Log.i(TAG, "markerop--markerDragStart")
it.onMarkerDragStart(dragMarker)
it.onMarkerDragStart(mDragMarker)
}
}
@@ -1330,8 +1288,6 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
companion object {
private const val TAG = "MapView"
private const val SECOND = 1000
private const val FRAME_TIME = 16
private const val NOT_A_ANGLE = -2147483648
const val LISTENER_TYPE_SCROLL = 0x11111
@@ -1374,8 +1330,7 @@ class MapView(context: Context, private val mMapStyleParams: IMapStyleParams, pr
mGestureDetector = GestureDetector(context, TouchGestureDetecter())
mGestureDetector.setOnDoubleTapListener(DoubleClickDetecter())
m_iLastAngle = NOT_A_ANGLE
mScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
mDemaningScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
}
}

View File

@@ -1,39 +0,0 @@
package com.autonavi.nge.routeinfo;
import android.os.Environment;
import android.util.Log;
import com.zhidaoauto.map.sdk.inner.CompileConfig;
public class RouteInfoProvider {
{
System.loadLibrary("map");
}
private static final String TAG = "RouteInfoProvider";
public RouteInfoProvider() {
if (CompileConfig.INSTANCE.getDEBUG()) {
Log.i(TAG, "roadop load database");
}
String shmdataDir = Environment.getExternalStorageDirectory().getAbsolutePath() + "/shmdata/";
RouteInfoProvider.init(shmdataDir);
}
private native static boolean init(String dir);
@Deprecated
public native String getRouteInfo(float centerLon, float centerLat,int type, int nFuncClass);
@Deprecated
public native float getRouteAngle(float startLon, float startLat,float endLon, float endLat);
@Deprecated
public native double [] matchPointOnRoad(double[] allPoint, boolean bGetAllPoints);
@Deprecated
public native String matchSinglePointOnRoad(float fLon, float fLat, float fAngle);
public native String matchHDSinglePointOnRoad(double fLon, double fLat, float fAngle, float fDistance, float fDetaAngle, boolean isZeroNo);
public native double getOffRoadDistance(double dLon, double dLat, double dAngle);
public native static void release();
}

View File

@@ -31,17 +31,10 @@ public class RoutingProvider {
public RoutingProvider() {
String dir = Constant.getNDSDataPath();
load(dir, "autonavi", null);
//setloglevel(1, 4);
}
{
// System.loadLibrary("datascript");
// System.loadLibrary("ndssqlite");
// System.loadLibrary("ndssystem");
// System.loadLibrary("ndsprovider");
// System.loadLibrary("datamgr");
System.loadLibrary("routing");
// System.loadLibrary("pbjni");
}
public void destroyProvider() { unload(); }

View File

@@ -38,6 +38,8 @@ interface IEventController {
fun addMapClickListener(mapClickListener: OnMapClickListener)
fun removeMapClickListener(mapClickListener: OnMapClickListener)
fun dispatchMapClickListener(lonLatPoint: LonLatPoint)
fun isMapClickListenerListEmpty():Boolean
fun addMapLoadedListener(mapLoadedListener: OnMapLoadedListener)
fun removeMapLoadedListener(mapLoadedListener: OnMapLoadedListener)
fun dispatchMapLoadedInitListener()

View File

@@ -112,7 +112,7 @@ interface IMapController {
fun resetChangeAngleTime()
fun setNearViewAnglePosition(lonLat: LonLat)
fun setRoamStyle(isUseTrace: Int, dis: Float, speed: Float)
fun setRoamTrajectory(travel: String)
fun setRoamTrajectory(travelList: ArrayList<LonLatPoint>?)
fun getIsRoam(): Boolean
fun testMapViewAngle(type: Int)
@@ -462,7 +462,7 @@ interface IMapController {
fun setLightWave(list: List<LonLatPoint>, width: Double, duration: Double)
fun setGuideLine(list: List<LonLatPoint>?)
fun setGuideLine(list: List<LonLatPoint>?, drawEleLength: Float)
fun setRoadTexSize(size: Float)
@@ -470,5 +470,8 @@ interface IMapController {
fun setPlaneUseTexture(isEnable: Boolean)
//地图中心点周围模糊属性[是否开启;颜色;起始距离;结束距离;密度;]
fun setMapCenterBlur(isEnable: Boolean, color: String?, starDis: Float?, endDis: Float?, density: Float?)
fun setStreetLightEffectIsEnable(isEnable: Boolean)
}

View File

@@ -37,16 +37,15 @@ interface IMapView {
fun rotateByP(r: Float)
fun setCanZoom(boolean: Boolean)
fun setScroll(boolean: Boolean)
fun setFling(boolean: Boolean)
fun setRotate(boolean: Boolean)
fun setCanZoom(isCanZoom: Boolean)
fun setScroll(scroll: Boolean)
fun setFling(isFling: Boolean)
fun setRotate(isRotate: Boolean)
fun isCanZoom(): Boolean
fun isScroll(): Boolean
fun isFling(): Boolean
fun isRotate(): Boolean
fun setOnTouchListener(listener: View.OnTouchListener)
fun setDoubles(doubleArray: DoubleArray)
fun destory()
//设置刷新帧率

View File

@@ -171,6 +171,8 @@ object ConstantExt {
const val ROADTEXSIZE = "roadTexSize"
const val ROAD = "roadUseTex"
const val PLANE = "planeUseTex"
const val BLUR = "blur"
const val STREET_LIGHT = "isStreetLightEffectEnable"
//地图视角测试
//地图测试视角角度

View File

@@ -166,6 +166,10 @@ class MapEventController(): IEventController {
}
}
override fun isMapClickListenerListEmpty():Boolean{
return mMapClickListenerList?.isEmpty()?:true
}
override fun addMapLoadedListener(mapLoadedListener: OnMapLoadedListener){
if(mMapLoadedListenerList == null){
mMapLoadedListenerList = ArrayList()

View File

@@ -35,12 +35,15 @@ class MapAnimate(private val mMapController: IMapController) {
fun setStartFrame(zoomVal: Float, lookAngle: Float, eyeHeight: Float){
if(zoomVal != -1f){
startZoomVal = zoomVal
endZoomVal = startZoomVal
}
if(lookAngle != -1f){
startLookAngle = lookAngle
endLookAngle = startLookAngle
}
if(eyeHeight != -1f){
startEyeHeight = eyeHeight
endEyeHeight = startEyeHeight
}
}
@@ -116,7 +119,7 @@ class MapAnimate(private val mMapController: IMapController) {
}
if(CompileConfig.DEBUG){
Log.d(TAG, "angle: ${angle}, height: ${eyeHeight}, zoomVal: $zoomVal")
Log.d(TAG, "angle: ${angle}, height: ${eyeHeight}, zoomVal: ${zoomVal}")
}
return floatArrayOf(zoomVal,angle,eyeHeight)
}

View File

@@ -44,6 +44,7 @@ import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions
import com.zhidaoauto.map.sdk.open.tools.MapTools
import com.zhidaoauto.map.sdk.open.weather.WeatherModel
import com.zhidaoauto.map.sdk.open.weather.WeatherResult
import io.netty.util.internal.StringUtil
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
@@ -72,7 +73,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
private var mSpeed = ConstantExt.ROAM_SPEED_30
private val DEFAULT_ROAM_DIS = 1800f
private var isRoam:AtomicBoolean = AtomicBoolean(false)
private var mTravel = ""
private var mTravelList = CopyOnWriteArrayList<LonLatPoint>()
private var isUseTrace = 1// 0 不使用轨迹 1 使用轨迹
private lateinit var mapAnimate: MapAnimate
private var roadLineJob: Job? = null
@@ -148,23 +149,39 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
}
override fun getCenter(): MapCoordinate {
override fun getCenter(): MapCoordinate? {
val mCenter = DoubleArray(2)
mMapView.getMapEngine().getCenter(mCenter)
return MapCoordinate((mCenter[0] * ConstantExt.RULE_INT).toInt(), (mCenter[1] * ConstantExt.RULE_INT).toInt())
try {
mMapView.getMapEngine().getCenter(mCenter)
return MapCoordinate((mCenter[0] * ConstantExt.RULE_INT).toInt(), (mCenter[1] * ConstantExt.RULE_INT).toInt())
}catch (e: Exception){
e.printStackTrace()
}
return null
}
override fun getCenter(point: DoubleArray) {
mMapView.getMapEngine().getCenter(point)
try {
mMapView.getMapEngine().getCenter(point)
}catch (e: Exception){
e.printStackTrace()
}
}
//获取车辆的位置
override fun getCarPosition(pos: MapCoordinate?): Int {
val mCenter = IntArray(2)
val res = mMapView.getMapEngine().getCarPosition(mCenter)
pos?.x = mCenter[0]
pos?.y = mCenter[1]
return res
try {
val res = mMapView.getMapEngine().getCarPosition(mCenter)
pos?.x = mCenter[0]
pos?.y = mCenter[1]
return res
}catch (e: Exception){
e.printStackTrace()
}
return 0
}
fun displayRoute(): Boolean {
@@ -281,7 +298,12 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
override fun setTmcData(tmcData: ByteArray?) {
mMapView.getMapEngine().setTmcData(tmcData)
try {
mMapView.getMapEngine().setTmcData(tmcData)
}catch (e: Exception){
e.printStackTrace()
}
}
override fun draw3DPolygon(id: String, lonlatArr: DoubleArray, height: Float, width: Float, count: Int, color: FloatArray) {
@@ -370,11 +392,21 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
override fun addDynamicAnchorPostion(anchorId: String, points: DoubleArray, angle: Float, current: Long, duration: Int) {
mMapView.getMapEngine().addDynamicAnchorPostion(anchorId, points, angle, current, duration)
try{
mMapView.getMapEngine().addDynamicAnchorPostion(anchorId, points, angle, current, duration)
}catch (e: Exception){
e.printStackTrace()
}
}
override fun addTranslateAnimationToAnchor(anchorId: String, points: DoubleArray, duration: Int) {
mMapView.getMapEngine().addTranslateAnimationToAnchor(anchorId, points, duration)
try {
mMapView.getMapEngine().addTranslateAnimationToAnchor(anchorId, points, duration)
}catch (e: Exception){
e.printStackTrace()
}
}
override fun addScaleAnimationToAnchor(anchorId: String, min: Float, max: Float, duration: Int) {
@@ -538,31 +570,25 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
if(list.size < 2){
return
}
val data = DoubleArray((list.size * 2)+2)
var i = 0
for (lonlatPoint in list) {
data[i] = lonlatPoint.longitude
data[i + 1] = lonlatPoint.latitude
i += 2
var str = StringBuffer()
for(i in 0..list.size-1){
str.append(list[i].longitude).append(",").append(list[i].latitude).append(",")
}
data[i] = width
data[i+1] = duration
mMapView.getMapEngine().setLightWave(data)
str.append(width).append(",").append(duration)
mMapView.getMapEngine().setLightWave(str.toString())
}
override fun setGuideLine(list: List<LonLatPoint>?) {
override fun setGuideLine(list: List<LonLatPoint>?, drawEleLength: Float) {
if(list != null) {
if(list.size < 2){
return
}
val data = DoubleArray(list.size * 2)
var i = 0
for (lonlatPoint in list) {
data[i] = lonlatPoint.longitude
data[i + 1] = lonlatPoint.latitude
i += 2
var str = StringBuffer()
for(i in 0..list.size-1){
str.append(list[i].longitude).append(",").append(list[i].latitude).append(",")
}
mMapView.getMapEngine().setGuideLine(data)
str.append(drawEleLength)
mMapView.getMapEngine().setGuideLine(str.toString())
}else{
mMapView.getMapEngine().setGuideLine(null)
}
@@ -616,7 +642,12 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
fun initCar(lon: Long, lat: Long, z: Int, r: Int, carResId: Int) {
if (null == mCar) {
mCar = M3DCar(context, carResId)
mMapView.getMapEngine().drawCar(lon, lat, z.toShort(), r.toShort(), 65536, 1f, mCar!!.totBuffer, mCar!!.totSize)
try {
mMapView.getMapEngine().drawCar(lon, lat, z.toShort(), r.toShort(), 65536, 1f, mCar!!.totBuffer, mCar!!.totSize);
}catch (e: Exception){
e.printStackTrace()
}
}
}
@@ -771,7 +802,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
interpolation(ConstantExt.MAP_STYLE_2D_EYE_HEIGHT, ConstantExt.MAP_STYLE_2D_OVER_LOOK_ANGLE, ConstantExt.MAP_STYLE_2D_ZOOM.toFloat(), -1, -1)
MAP_PERSPECTIVE_3D -> {
//mMapView.setDAngle(45)
setMapViewVisualAngle(mMapStyleParams.getDefaultPerspective())
setMapViewVisualAngle(mMapStyleParams.getVrAngleDefaultMode())
mMapView.getMapEngine().lookUpDown(-1f)
lookUpDown()
}
@@ -827,7 +858,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
mMapView.getMapEngine().setOffset(0, 0)
//
if (mMapStyleParams.getDefaultPerspective() == ConstantExt.MAP_STYLE_VR_ANGLE_MIDDLE) {
if (mMapStyleParams.getVrAngleDefaultMode() == ConstantExt.MAP_STYLE_VR_ANGLE_MIDDLE) {
interpolation(
ConstantExt.MAP_STYLE_VR_EYE_HEIGHT_MIDDLE,
ConstantExt.MAP_STYLE_VR_OVER_LOOK_ANGLE_MIDDLE,
@@ -994,7 +1025,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
val data = polylineOptions.lonLats
var polyline: Polyline? = null
try {
if (data.size <= 1) {
if (data == null || data.size <= 1) {
throw RuntimeException("传入的坐标数必须大于1")
}
val strOptionsJson = JSON.toJSONString(polylineOptions)
@@ -1023,7 +1054,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
val colorSize = colorValues?.size ?: 0
var polyline: Polyline? = null
try {
if (data.size <= 1) {
if (data == null || data.size <= 1) {
throw RuntimeException("传入的坐标数必须大于1")
}
if (polylineOptions.getIsGradient() && colorSize > data.size) {
@@ -1059,7 +1090,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
val data = deadZoneOptions.getPosition()
var deadZone: DeadZone? = null
try {
if (data.size <= 1) {
if (data == null || data.size <= 1) {
throw RuntimeException("传入的坐标数必须大于1")
}
val strOptionsJson = JSON.toJSONString(deadZoneOptions)
@@ -1132,7 +1163,9 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
val green = (paintColor shr 8 and 0xff).toChar()
val blue = (paintColor and 0xff).toChar()
//native实现
mMapView.getMapEngine().drawEllipse(id, doubles, red, green, blue, alpha)
if (id != null) {
mMapView.getMapEngine().drawEllipse(id, doubles, red, green, blue, alpha)
}
//mMapView.shakeSceneManual()
polyline = Polyline(polylineOptions, this)
} catch (e: Exception) {
@@ -1165,7 +1198,9 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
val green = (paintColor shr 8 and 0xff).toChar()
val blue = (paintColor and 0xff).toChar()
//native实现
mMapView.getMapEngine().drawPolygon(id, doubles, red, green, blue, alpha)
if (id != null) {
mMapView.getMapEngine().drawPolygon(id, doubles, red, green, blue, alpha)
}
//mMapView.shakeSceneManual()
polyline = Polyline(polylineOptions, this)
} catch (e: Exception) {
@@ -1233,7 +1268,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
CHANGE_VIEW_ANGLE -> {
setMapViewVisualAngle(mMapStyleParams.getDefaultPerspective())
setMapViewVisualAngle(mMapStyleParams.getVrAngleDefaultMode())
}
}
}
@@ -1253,6 +1288,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
Log.i(TAG, "Roam--op--status: 结束漫游 切换视角:${type}")
}
isRoam.set(false)
roamDis = 0.0
mRoamPostion = 0
mRoamlist.clear()
remainList.clear()
@@ -1420,7 +1456,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
}
withContext(Dispatchers.Main) {
setMapViewVisualAngle(mMapStyleParams.getDefaultPerspective())
setMapViewVisualAngle(mMapStyleParams.getVrAngleDefaultMode())
}
}
@@ -1435,6 +1471,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
fun setRoamStyle() {
mRoamPostion = 0
roamDis = 0.0
mRoamlist.clear()
roadLineJob?.cancel()
roadLineTimeJob?.cancel()
@@ -1442,12 +1479,12 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
val currentLonLat = mLockLocation.getCurrentLonLatPoint()
mLastPosition = currentLonLat
if (mTravel.isNotEmpty() && isUseTrace == 1) {
if (mTravelList.isNotEmpty() && isUseTrace == 1) {
mRoamlist = CopyOnWriteArrayList(
MathUtils.getSmoothPoints(
MathUtils.getSubList(
currentLonLat,
MathUtils.getPoints(MathUtils.getTravelList(mTravel), mSpeed * 0.1f),
MathUtils.getPoints(mTravelList, mSpeed * 0.1f),
mRoamDis
)
)
@@ -1465,18 +1502,19 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
currentLonLat.latitude,
currentLonLat.angle.toFloat(),
mRoamDis,
true,
object : IResult<CenterLine> {
override fun result(code: Int, result: CenterLine?) {
override fun result(code: Int, rodeCenterLine: CenterLine?) {
if(isCancelRoadLineJob.get()) {
return
}
roadLineTimeJob?.cancel()
isCancelTimeJob.set(true)
if (result != null && result.points.size >= 2) {
if (rodeCenterLine != null && rodeCenterLine!!.points != null && rodeCenterLine.points!!.size >= 2) {
mRoamlist = CopyOnWriteArrayList(
MathUtils.getSmoothPoints(
MathUtils.getPoints(
ArrayList(result.points),
CopyOnWriteArrayList(rodeCenterLine.points),
mSpeed * 0.1f
)
)
@@ -1553,14 +1591,18 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
val currentPostion = mLockLocation.getCurrentLonLatPoint()
val angle = currentPostion.angle
val dis = MathUtils.distance(currentPostion, location)
val time = dis / mSpeed * 1000
var time = dis / mSpeed * 1000
if(time > 3000){
time = 3000.0
}
if (DEBUG) {
Log.i(TAG, "Roam--op--time: ${time}ms")
Log.i(TAG, "Roam--op--time: ${time}ms, ${dis}")
}
mMapView.removeTouch()
if (mLockLocation.getLockCar()) {
mLockLocation.setLockCar(false)
}
mMapStyleParams.setVrAngleMode(ConstantExt.MAP_STYLE_VR_ROAM)
setStartFrame(ConstantExt.MAP_STYLE_VR_ZOOM_VAL_ROAM, ConstantExt.MAP_STYLE_VR_OVER_LOOK_ANGLE_ROAM, ConstantExt.MAP_STYLE_VR_EYE_HEIGHT_ROAM)
animateTo(location.longitude, location.latitude, 0f, -angle.toFloat(), time.toInt())
delay(time.toLong())
@@ -1582,6 +1624,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
if(mRoamlist.size > 0) {
Log.e(TAG, "Roam--op--status: 进入漫游模式失败")
isRoam.set(false)
roamDis = 0.0
withContext(Dispatchers.Main) {
mEventController?.dispatchRoamStatusListener(1, "进入漫游模式失败")
}
@@ -1589,7 +1632,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
}
}
private var roamDis = 0.0
suspend fun dealRoamMode(){
if (mRoamPostion < mRoamlist.size) {
val location = mRoamlist[mRoamPostion]
@@ -1609,6 +1652,15 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
location.angle = angle
animateTo(location.longitude, location.latitude, 0f, -location.angle.toFloat(), 100)
roamDis += MathUtils.distance(mLastPosition, location)
if (DEBUG) {
Log.i(TAG, "Roam--op--dis: ${roamDis}")
}
withContext(Dispatchers.Main) {
mEventController?.dispatchRoamStatusListener(5, "${String.format("%.1f", roamDis)}")
}
delay(100)
mLastPosition = location
mRoamPostion += 1
@@ -1623,12 +1675,13 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
remainList.clear()
}else {
isRoam.set(false)
roamDis = 0.0
withContext(Dispatchers.Main) {
if (DEBUG) {
Log.i(TAG, "Roam--op--status: 漫游轨迹已完成,结束漫游")
}
mEventController?.dispatchRoamStatusListener(2, "漫游轨迹已完成,结束漫游")
setMapViewVisualAngle(mMapStyleParams.getDefaultPerspective())
setMapViewVisualAngle(mMapStyleParams.getVrAngleDefaultMode())
}
}
}
@@ -1650,8 +1703,14 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
override fun setRoamTrajectory(travel: String){
this.mTravel = travel
override fun setRoamTrajectory(travelList: ArrayList<LonLatPoint>?){
if(travelList != null && travelList.isNotEmpty()){
this.mTravelList.clear()
this.mTravelList.addAll(travelList)
}else{
this.mTravelList.clear()
}
}
@@ -1778,7 +1837,13 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
override fun addImage(imageKey: String, imageData: ByteArray, width: Int, height: Int): Int {
return mMapView.getMapEngine().addImage(imageKey, imageData, width, height)
try{
return mMapView.getMapEngine().addImage(imageKey, imageData, width, height)
}catch (e: Exception){
e.printStackTrace()
}
return 10001
}
override fun clearAllTmcLines() {
@@ -1822,7 +1887,12 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
override fun updatePointCloudDataByPb(dataArray: ByteArray?, isTrasformer: Boolean, isResidual: Boolean, isReset: Boolean): Boolean {
return mMapView.getMapEngine().updatePointCloudDataByPb(dataArray, isTrasformer, isResidual, isReset)
try {
return mMapView.getMapEngine().updatePointCloudDataByPb(dataArray, isTrasformer, isResidual, isReset)
}catch (e: Exception){
e.printStackTrace()
}
return false
}
override fun setIsDrawPointCloud(isDrawPointCloud: Boolean) {
@@ -1910,6 +1980,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
zoomJob = null
isRoam.set(false)
roamDis = 0.0
mRecyClerController.clear()
}
@@ -2045,6 +2116,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.ROADTEXSIZE, "${size}")
}
//设置路面纹理
override fun setRoadUseTexture(isEnable: Boolean){
if(isEnable){
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.ROAD, "enable")
@@ -2054,6 +2126,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
//设置地面纹理
override fun setPlaneUseTexture(isEnable: Boolean){
if(isEnable){
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.PLANE, "enable")
@@ -2062,4 +2135,39 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
}
}
override fun setMapCenterBlur(isEnable: Boolean, color: String?, starDis: Float?, endDis: Float?, density: Float?) {
var blurColor = color
var start_dis = starDis
var end_dis = endDis
var blurDensity = density
if(StringUtil.isNullOrEmpty(blurColor)){
blurColor = "cccccc"
}
if(start_dis == null){
start_dis = 0f
}
if(end_dis == null){
end_dis = 20f
}
if(blurDensity == null){
blurDensity = 0.6f
}
if(isEnable){
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.BLUR, "enable;${blurColor};${start_dis};${end_dis};${blurDensity}")
}else{
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.BLUR, "disable;${blurColor};${start_dis};${end_dis};${blurDensity}")
}
}
override fun setStreetLightEffectIsEnable(isEnable: Boolean){
if(isEnable){
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.STREET_LIGHT, "enable")
}else{
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.STREET_LIGHT, "disable")
}
}
}

View File

@@ -27,7 +27,8 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
private val infoWindowClickListenerMap: MutableMap<String, OnInfoWindowClickListener> = HashMap<String, OnInfoWindowClickListener>()
private val animationListenerMap: MutableMap<String, OnAnimationListener> = HashMap<String, OnAnimationListener>()
private val markDragListenerMap: MutableMap<String, OnMarkerDragListener> = HashMap()
private val markerIconCacheMap = ConcurrentHashMap<Int,String>()
//根据资源ID存储的资源数据的MD5值
private val markerIconResourceCacheMap = ConcurrentHashMap<Int,String>()
private val markerInfoCacheMap = ConcurrentHashMap<String,String>()
//点击infoview区域
@@ -42,7 +43,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
infoWindowClickListenerMap.clear()
animationListenerMap.clear()
markDragListenerMap.clear()
markerIconCacheMap.clear()
markerIconResourceCacheMap.clear()
markerInfoCacheMap.clear()
infoViewClickMap.clear()
}
@@ -73,19 +74,19 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
}
override fun containMarkerIconCache(id: Int): Boolean {
return markerIconCacheMap.containsKey(id)
return markerIconResourceCacheMap.containsKey(id)
}
override fun removeMarkerIconCache(id: Int) {
markerIconCacheMap.remove(id)
markerIconResourceCacheMap.remove(id)
}
override fun addMarkerIconCache(id: Int, icon: String) {
markerIconCacheMap[id] = icon
markerIconResourceCacheMap.put(id,icon)
}
override fun getMarkerIconCache(id:Int):String?{
return markerIconCacheMap[id]
return markerIconResourceCacheMap.get(id)
}
@Synchronized
@@ -249,9 +250,7 @@ class MarkerNativeInterface(private val mMapController: IMapController): IMarker
fun getPosition(id: String?): LonLat {
val lonlstStr = getMarkerProperty(id!!, "lonLatPoint")
val lonlat = lonlstStr.split(",").toTypedArray()
lonlat.let{
return LonLat(lonlat[0].toDouble(), lonlat[1].toDouble())
}
return LonLat(lonlat[0].toDouble(), lonlat[1].toDouble())
}
/**

View File

@@ -9,12 +9,10 @@ import android.database.MatrixCursor
import android.net.Uri
import android.text.TextUtils
import android.util.Log
import androidx.annotation.NonNull
import com.zhidaoauto.map.sdk.inner.CompileConfig
import com.zhidaoauto.map.sdk.inner.common.ConstantExt
import com.zhidaoauto.map.sdk.inner.road.RoadHelper
import com.zhidaoauto.map.sdk.open.data.MapDataApi
import org.jetbrains.annotations.Nullable
class MapDataProvider : ContentProvider() {

View File

@@ -1,25 +1,34 @@
package com.zhidaoauto.map.sdk.inner.road
import android.text.TextUtils
import android.util.Log
import com.autonavi.nge.MapBox
import com.autonavi.nge.hdmap.HDMapProvider
import com.autonavi.nge.map.LonLat
import com.autonavi.nge.routeinfo.RouteInfoProvider
import com.zhidaoauto.map.data.point.LonLatPoint
import com.zhidaoauto.map.data.road.*
import com.zhidaoauto.map.data.road.CenterLine
import com.zhidaoauto.map.data.road.Lane
import com.zhidaoauto.map.data.road.RoadCross
import com.zhidaoauto.map.data.road.RoadNameInfo
import com.zhidaoauto.map.data.road.RoadRect
import com.zhidaoauto.map.data.road.RoadRectInfos
import com.zhidaoauto.map.data.road.RoadSign
import com.zhidaoauto.map.data.road.RoadSignPostion
import com.zhidaoauto.map.data.road.SinglePointRoadInfo
import com.zhidaoauto.map.data.road.StopLine
import com.zhidaoauto.map.data.road.ZebraLine
import com.zhidaoauto.map.data.routeinfo.RoadInfo
import com.zhidaoauto.map.sdk.inner.CompileConfig
import com.zhidaoauto.map.sdk.inner.abs.IRoadData
import com.zhidaoauto.map.sdk.inner.aspect.KotlinExtern.toTenDecimalsStr
import com.zhidaoauto.map.sdk.inner.controller.CommonController
import com.zhidaoauto.map.sdk.inner.proxy.CommonProxy
import com.zhidaoauto.map.sdk.inner.utils.ByteBufferHelper
import com.zhidaoauto.map.sdk.inner.utils.ConcurrentLRUCache
import com.zhidaoauto.map.sdk.inner.utils.LogHelper
import com.zhidaoauto.map.sdk.inner.utils.TransformUtils
import com.zhidaoauto.map.sdk.open.abs.IResult
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
import com.zhidaoauto.map.sdk.open.city.CityCodeInfo
import com.zhidaoauto.map.sdk.open.city.CityCodeModel
import com.zhidaoauto.map.sdk.open.city.CityCodeResult
import com.zhidaoauto.map.sdk.open.data.CityInfo
import com.zhidaoauto.map.sdk.open.data.MapDataApi
import kotlinx.coroutines.Dispatchers
@@ -47,7 +56,6 @@ class RoadHelper private constructor() {
}
}
private var routeInfoProvider: RouteInfoProvider = RouteInfoProvider()
private var hdMapProvider: HDMapProvider = HDMapProvider()
private var mapBox: MapBox = MapBox()
@@ -78,10 +86,6 @@ class RoadHelper private constructor() {
cancelCacheHDData()
RouteInfoProvider.release()
if(CompileConfig.DEBUG){
Log.w(TAG, "destroyop--:RouteInfoProvider.destroy")
}
hdMapProvider.release()
if(CompileConfig.DEBUG){
Log.w(TAG, "destroyop--:hdMapProvider.destroy")
@@ -109,7 +113,7 @@ class RoadHelper private constructor() {
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop getRoadInfo")
}
return routeInfoProvider.getRouteInfo(centerLon, centerLat, coor, roadType);
return ""
}
/**
@@ -121,7 +125,7 @@ class RoadHelper private constructor() {
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop getRouteAngle")
}
return routeInfoProvider.getRouteAngle(startLon, startLat, endLon, endLat)
return 0f
}
/**
@@ -130,137 +134,25 @@ class RoadHelper private constructor() {
*/
@Deprecated(message = "replace getLaneInfo")
fun getMatchRoadInfo(allPoint: DoubleArray, bGetAllPoints: Boolean): DoubleArray? {
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop getMatchRoadInfo")
}
val result = routeInfoProvider.matchPointOnRoad(allPoint, bGetAllPoints)
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop getMatchRoadInfo-result:${result}")
}
return result
return null
}
/**
* 获取点与道路边界的距离
*
*/
@Deprecated(message = "unused")
fun getOffRoadDistance(lon: Double, lat: Double, angle: Float): Double {
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop getOffRoadDistance")
}
val result = routeInfoProvider.getOffRoadDistance(lon,lat,angle.toDouble())
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop getOffRoadDistance-result:${result}")
}
return result
}
/**
* 转换道路信息经纬度
*/
private fun dealLonLatList(data: ArrayList<LonLat>): ArrayList<LonLatPoint> {
val result = ArrayList<LonLatPoint>()
for (lonLat in data) {
result.add(CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLat))
}
return result
return 0.0
}
/**
* 获取匹配道路
*
*/
@Deprecated(message = "unused")
fun getSinglePointMatchRoad(lon: Double, lat: Double, angle: Float, isGPS: Boolean,isRTK:Boolean): SinglePointRoadInfo? {
var rulerDistance = minGPSDistance
var rulerAngle = minGPSAngle
if(isRTK){
rulerDistance = minRTKDistance
rulerAngle = minRTKAngle
}
val result = if (!isGPS) {
val lonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(LonLatPoint(lon, lat))
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop--gisop getSinglePointMatchRoad:${lonLat.lon},${lonLat.lat},${angle},${isGPS}")
}
routeInfoProvider.matchHDSinglePointOnRoad(lonLat.lon, lonLat.lat, angle,rulerDistance,rulerAngle,!isRTK)
} else {
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop--gisop getSinglePointMatchRoad:${lon},${lat},${angle},${isGPS}")
}
routeInfoProvider.matchHDSinglePointOnRoad(lon, lat, angle,rulerDistance,rulerAngle,!isRTK)
}
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop--gisop getSinglePointMatchRoad:result:${result}")
}
var singlePointRoadInfo: SinglePointRoadInfo? = null
if (!TextUtils.isEmpty(result)) {
val array = result.split(":")
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop--gisop getSinglePointMatchRoad:array:${array.size}")
}
if (array.size >= 14) {
singlePointRoadInfo = SinglePointRoadInfo()
singlePointRoadInfo.tileId = array[1].toLong()
singlePointRoadInfo.roadId = array[3].toLong()
singlePointRoadInfo.laneNo = array[5].toInt()
singlePointRoadInfo.laneWidth = array[7].toFloat()
val coordsStr = array[9]
val coordsList: ArrayList<LonLatPoint> = parseLonLatPointNoAngleStr(coordsStr)
singlePointRoadInfo.coords = coordsList
val leftCoordsStr = array[11]
val leftCoordsList: ArrayList<LonLatPoint> = parseLonLatPointStr(leftCoordsStr)
singlePointRoadInfo.leftCoords = leftCoordsList
singlePointRoadInfo.leftLen = array[13].toFloat()
}
}
if (CompileConfig.DEBUG) {
Log.i(TAG, "roadop--gisop getSinglePointMatchRoad--:${result}")
}
return singlePointRoadInfo
}
/**
* 解析经纬度方向字符串
*/
private fun parseLonLatPointStr(coordsStr: String): ArrayList<LonLatPoint> {
val array = coordsStr.split(",")
val list = ArrayList<LonLatPoint>()
var lonLatPoint: LonLatPoint
if (array.size % 3 != 0) {
return list
}
for (i in 0..array.size - 1 step 3) {
lonLatPoint = LonLatPoint()
lonLatPoint.longitude = array[i].toDouble()
lonLatPoint.latitude = array[i + 1].toDouble()
if (array[i + 2].equals("nan")) {
lonLatPoint.angle = Double.NaN
} else {
lonLatPoint.angle = array[i + 2].toDouble()
}
list.add(lonLatPoint)
}
return list
}
/**
* 解析经纬度字符串
*/
private fun parseLonLatPointNoAngleStr(coordsStr: String): ArrayList<LonLatPoint> {
val array = coordsStr.split(",")
val list = ArrayList<LonLatPoint>()
var lonLatPoint: LonLatPoint
if (array.size % 2 != 0) {
return list
}
for (i in 0..array.size - 1 step 2) {
lonLatPoint = LonLatPoint()
lonLatPoint.longitude = array[i].toDouble()
lonLatPoint.latitude = array[i + 1].toDouble()
list.add(lonLatPoint)
}
return list
return null
}
fun getLaneInfo(tileId: Long, routeId: Int): ArrayList<Lane> {
@@ -327,9 +219,9 @@ class RoadHelper private constructor() {
private val roadLimitSpeedCache = ConcurrentLRUCache<String, RoadInfo>(MAX_CACHE_SIZE)
fun getRoadLimitSpeed(dLon: Double, dLat: Double, fAngle: Float,call:IResult<RoadInfo>) {
fun getRoadLimitSpeed(dLon: Double, dLat: Double, fAngle: Float, isCanCancel: Boolean, call:IResult<RoadInfo>) {
// Use input parameters to create a unique cache key
val key = "llaGetRoadLimitSpeed_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}"
val key = "llaGetRoadLimitSpeed_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}$isCanCancel"
// Get cached value from LinkedHashMap
val cachedValue = roadLimitSpeedCache.get(key)
@@ -379,7 +271,7 @@ class RoadHelper private constructor() {
}
})
mapBox.llaGetRoadLimitSpeed(dLon, dLat, fAngle)
mapBox.llaGetRoadLimitSpeed(dLon, dLat, fAngle,isCanCancel)
}
fun getZebraLine(lon: Double,lat: Double,angle: Float,call:IResult<String>){
@@ -398,7 +290,7 @@ class RoadHelper private constructor() {
}
fun getTrafficLight(lon: Double,lat: Double,angle: Float,call:IResult<String>){
fun getTrafficLight(lon: Double,lat: Double,angle: Float, call:IResult<String>){
RoadResultController.instance.addRoadResultListener("llaGetTrafficLight_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}_${angle.toTenDecimalsStr()}",object :IRoadData{
override fun result(code: Int, result: ByteArray?) {
@@ -424,9 +316,9 @@ class RoadHelper private constructor() {
* @return The center line of the road segment.
*/
fun getCenterLine(dLon: Double, dLat: Double, fAngle: Float,call: IResult<CenterLine>) {
fun getCenterLine(dLon: Double, dLat: Double, fAngle: Float,isCanCancel: Boolean, call: IResult<CenterLine>) {
// Generate a unique key for this request.
val cacheKey = "llaGetCenterLine_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}"
val cacheKey = "llaGetCenterLine_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}$isCanCancel"
// If the center line for this request is already in the cache, return it.
centerLineSingleCache.get(cacheKey)?.let { centerLine ->
@@ -483,7 +375,7 @@ class RoadHelper private constructor() {
}
})
mapBox.llaGetCenterLine(dLon, dLat, fAngle)
mapBox.llaGetCenterLine(dLon, dLat, fAngle,isCanCancel)
}
@@ -501,9 +393,8 @@ class RoadHelper private constructor() {
* @return A StopLine object that contains information about the stop line, or null if no stop line was found.
*/
fun getStopLine(dLon: Double, dLat: Double , fAngle: Float,call: IResult<StopLine>) {
val key = "llaStopLine_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}"
fun getStopLine(dLon: Double, dLat: Double , fAngle: Float,isCanCancel: Boolean, call: IResult<StopLine>) {
val key = "llaStopLine_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}$isCanCancel"
// Check if the result is in the cache
val cachedResult = stopLineCache.get(key)
@@ -555,9 +446,11 @@ class RoadHelper private constructor() {
points.add(lonLatPoint)
}
stopLine.points = points
stopLine.points?.let {
stopLine.distance = MapDataApi.getNearstFromPointToSegment(dLon, dLat, it[0].longitude, it[0].latitude, it[it.size-1].longitude, it[it.size-1].latitude) * 1e5
if(stopLine.points.size > 1) {
stopLine.distance = MapDataApi.getNearstFromPointToSegment(dLon, dLat, stopLine.points[0].longitude, stopLine.points[0].latitude, stopLine.points[stopLine.points.size-1].longitude, stopLine.points[stopLine.points.size-1].latitude) * 100000
}
// Print the stop line object to the log if debugging is enabled.
if (CompileConfig.DEBUG) {
Log.d(TAG, "roadop--getStopLine--stopLine: $stopLine")
@@ -571,7 +464,7 @@ class RoadHelper private constructor() {
}
})
mapBox.llaStopLine(dLon, dLat, fAngle)
mapBox.llaStopLine(dLon, dLat, fAngle,isCanCancel)
}
@@ -587,7 +480,7 @@ class RoadHelper private constructor() {
*/
fun getRoadRect(lon: Double, lat: Double, angle: Float,call : IResult<RoadRectInfos>) {
val key = "llaMergedRoadRect_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}_${angle.toTenDecimalsStr()}"
val key = "llaMergedRoadRect_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}_${angle.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}false"
// Check if the result is in the cache
val cachedResult = roadRectCache.get(key)
@@ -639,25 +532,25 @@ class RoadHelper private constructor() {
}
})
mapBox.llaMergedRoadRect(lon, lat, angle)
mapBox.llaMergedRoadRect(lon, lat, angle,false)
}
fun modifyRedisFileVersion(version:Int){
mapBox.modifyRedisFileVersion(version)
mapBox.modifyRedisFileVersion(version,true)
}
fun updateCacheFile(){
mapBox.updateCacheFile()
mapBox.updateCacheFile(true)
}
//获取行驶方向一定长度的中心线
//dDis:正 行驶方向前方距离 负 行驶方向后方距离
fun getCenterLineRange(dLon: Double, dlat: Double , fAngle: Float, fDis: Float,isSmooth: Boolean,orders:Int, call:IResult<CenterLine>){
fun getCenterLineRange(dLon: Double, dlat: Double , fAngle: Float, fDis: Float,isSmooth: Boolean,orders:Int, isCanCancel: Boolean, call:IResult<CenterLine>){
// Combine the four parameters into a single string as the cache key
val cacheKey = "llaGetCenterLineRange_${dLon.toTenDecimalsStr()}_${dlat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${fDis.toTenDecimalsStr()}_${isSmooth}_${orders}"
val cacheKey = "llaGetCenterLineRange_${dLon.toTenDecimalsStr()}_${dlat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${fDis.toTenDecimalsStr()}_${isSmooth}_${orders}_${RoadResultController.CANCELTAG}$isCanCancel"
// Check if the result is already cached
// If yes, return the cached result
@@ -713,7 +606,7 @@ class RoadHelper private constructor() {
}
})
mapBox.llaGetCenterLineRange(dLon,dlat,fAngle, fDis,isSmooth,orders)
mapBox.llaGetCenterLineRange(dLon,dlat,fAngle, fDis,isSmooth,orders,isCanCancel)
}
@@ -723,13 +616,13 @@ class RoadHelper private constructor() {
//获取行驶方向一定长度的中心线
//dDis:正 行驶方向前方距离 负 行驶方向后方距离
fun getCenterLineRoadNode(dLon: Double, dLat: Double, fAngle: Float, fDis: Float,call: IResult<CenterLine>) {
fun getCenterLineRoadNode(dLon: Double, dLat: Double, fAngle: Float, fDis: Float,isCanCancel: Boolean, call: IResult<CenterLine>) {
// Combine the four parameters into a single string as the cache key
val start = System.currentTimeMillis()
if (CompileConfig.DEBUG) {
Log.d(TAG, "roadop--getCenterLineRoadNode--: ${dLon}, ${dLat}, ${fAngle}")
}
val cacheKey = "llaGetCenterLineRoadNode_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${fDis.toTenDecimalsStr()}"
val cacheKey = "llaGetCenterLineRoadNode_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${fDis.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}$isCanCancel"
// Check if the result is already cached
if (centerLineCache.containsKey(cacheKey)) {
@@ -780,11 +673,11 @@ class RoadHelper private constructor() {
}
})
mapBox.llaGetCenterLineRoadNode(dLon, dLat, fAngle, fDis)
mapBox.llaGetCenterLineRoadNode(dLon, dLat, fAngle, fDis,isCanCancel)
}
fun getRoadName(dLon: Double, dLat: Double, fAngle: Float,call: IResult<RoadNameInfo>){
RoadResultController.instance.addRoadResultListener("llaGetRoadName_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}",object :IRoadData{
RoadResultController.instance.addRoadResultListener("llaGetRoadName_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}false",object :IRoadData{
override fun result(code: Int, result: ByteArray?) {
if (CompileConfig.DEBUG) {
Log.d(TAG, "roadop--getRoadName--code:${code},result: $result")
@@ -813,7 +706,7 @@ class RoadHelper private constructor() {
}
})
mapBox.llaGetRoadName(dLon,dLat,fAngle)
mapBox.llaGetRoadName(dLon,dLat,fAngle,false)
}
@@ -823,8 +716,8 @@ class RoadHelper private constructor() {
* 获取路口信息
*/
fun getCrossRoad(dLon: Double, dLat: Double, fAngle: Float,call: IResult<RoadCross>) {
val cacheKey = "llaGetCrossRoad_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}"
fun getCrossRoad(dLon: Double, dLat: Double, fAngle: Float,isCanCancel: Boolean, call: IResult<RoadCross>) {
val cacheKey = "llaGetCrossRoad_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}$isCanCancel"
// Check if the result is already in the cache
crossRoadCache.get(cacheKey)?.let {
@@ -873,12 +766,12 @@ class RoadHelper private constructor() {
}
})
mapBox.llaGetCrossRoad(dLon, dLat, fAngle)
mapBox.llaGetCrossRoad(dLon, dLat, fAngle,isCanCancel)
}
fun getCrossRoadById(tileId: Int, id: Long,call: IResult<ArrayList<LonLatPoint>>){
RoadResultController.instance.addRoadResultListener("llaGetCrossRoadById_${tileId}_${id}",object :IRoadData{
RoadResultController.instance.addRoadResultListener("llaGetCrossRoadById_${tileId}_${id}_${RoadResultController.CANCELTAG}false",object :IRoadData{
override fun result(code: Int, result: ByteArray?) {
if (CompileConfig.DEBUG) {
Log.d(TAG, "roadop--getCrossRoadById--code:${code},result: $result")
@@ -919,7 +812,7 @@ class RoadHelper private constructor() {
}
fun cacheHDDataByCityLonLat(lon: Double, lat: Double,call: IResult<Int>){
val key = "cacheHDDataByCityLonLat_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}"
val key = "cacheHDDataByCityLonLat_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}false"
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
override fun result(code: Int, result: ByteArray?) {
@@ -945,8 +838,8 @@ class RoadHelper private constructor() {
mapBox.cacheHDDataByCityLonLat(lon, lat)
}
fun cacheHDDataByCity(id: Int,call: IResult<Boolean>){
val key = "cacheHDDataByCity_${id}"
fun cacheHDDataByCity(id: Int,isCanCancel: Boolean, call: IResult<Boolean>){
val key = "cacheHDDataByCity_${id}_${RoadResultController.CANCELTAG}$isCanCancel"
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
override fun result(code: Int, result: ByteArray?) {
@@ -968,7 +861,7 @@ class RoadHelper private constructor() {
call.result(code,false)
}
})
mapBox.cacheHDDataByCity(id)
mapBox.cacheHDDataByCity(id,isCanCancel)
}
fun getCacheProgressByCity(id: Int,call: IResult<Double>){
@@ -998,7 +891,7 @@ class RoadHelper private constructor() {
}
fun getCityCode(lon: Double, lat: Double, call: IResult<Int>){
val key = "getCityCode_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}"
val key = "getCityCode_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}false"
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
override fun result(code: Int, result: ByteArray?) {
@@ -1006,14 +899,40 @@ class RoadHelper private constructor() {
Log.d(TAG, "roadop--getCityCode-${key}-code:${code},result: $result")
}
if (result?.isEmpty() == true) {
call.result(1, 0)
CityCodeModel.getCityCodeByLonLat(lon, lat, object : CityCodeResult{
override fun result(code: Int, data: CityCodeInfo, message: String?) {
if (CompileConfig.DEBUG) {
Log.d(TAG, "roadop--getCityCode--code:${code},data: $data")
}
if(code == 0){
call.result(code,data.cityNameId)
}else{
call.result(code,0)
}
}
})
return
}
result?.let {
val buf = ByteBufferHelper.bytes2ByteBuffer(result)
buf?.let {
val cityCode = buf.int
if(cityCode == 0){
CityCodeModel.getCityCodeByLonLat(lon, lat, object : CityCodeResult{
override fun result(code: Int, data: CityCodeInfo, message: String?) {
if(code == 0){
if (CompileConfig.DEBUG) {
Log.d(TAG, "roadop--getCityCode--code:${code},data: $data")
}
call.result(code,data.cityNameId)
}else{
call.result(code,0)
}
}
})
return
}
if (CompileConfig.DEBUG) {
Log.d(TAG, "roadop--getCityCode-${cityCode}")
}
@@ -1066,7 +985,7 @@ class RoadHelper private constructor() {
}
fun getAllCityCode(call: IResult<ArrayList<CityInfo>>) {
val key = "getAllCityCode"
val key = "getAllCityCode_${RoadResultController.CANCELTAG}false"
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
override fun result(code: Int, result: ByteArray?) {
@@ -1081,7 +1000,10 @@ class RoadHelper private constructor() {
val buf = ByteBufferHelper.bytes2ByteBuffer(result)
buf?.let {
val cityList = ArrayList<CityInfo>()
val size = buf.int
val size = it.int
if(CompileConfig.DEBUG) {
Log.d(TAG, "roadop--getAllCityCode--cityList--size: ${size}")
}
for(i in 0 until size){
val cityInfo = CityInfo()
cityInfo.cityCode = buf.int
@@ -1104,11 +1026,10 @@ class RoadHelper private constructor() {
})
mapBox.getAllCityCode()
}
fun getHdDataVersionByCity(lon: Double,lat: Double,call: IResult<String>){
val key = "getHdDataVersionByCity_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}"
val key = "getHdDataVersionByCity_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}false"
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
override fun result(code: Int, result: ByteArray?) {
@@ -1137,7 +1058,7 @@ class RoadHelper private constructor() {
}
fun getZebraLineByDistance(dLon: Double, dLat: Double , fAngle: Float, dis: Float,call: IResult<MutableList<ZebraLine>>){
RoadResultController.instance.addRoadResultListener("llaGetZebraLineByDistance_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${dis.toTenDecimalsStr()}",object :IRoadData{
RoadResultController.instance.addRoadResultListener("llaGetZebraLineByDistance_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${dis.toTenDecimalsStr()}_${RoadResultController.CANCELTAG}false",object :IRoadData{
override fun result(code: Int, result: ByteArray?) {
if (CompileConfig.DEBUG) {
Log.d(TAG, "roadop--getZebraLineByDistance--code:${code},result: $result")
@@ -1156,9 +1077,9 @@ class RoadHelper private constructor() {
zebraLine.dis = buf.long /1e8.toFloat()
zebraLine.tileId = buf.int.toString()
zebraLine.id = buf.int.toString()
val size = buf.int
val lonLatSize = buf.int
val lonlats = ArrayList<LonLatPoint>()
for(i in 0 until size step 2){
for(j in 0 until lonLatSize step 2){
val lonLatPoint = LonLatPoint(buf.long /1e8, buf.long /1e8)
lonlats.add(lonLatPoint)
}
@@ -1197,7 +1118,7 @@ class RoadHelper private constructor() {
cancelCacheHDData()
cacheList.add(id)
getInstance()?.cacheHDDataByCity(id,object : IResult<Boolean> {
cacheHDDataByCity(id,false,object : IResult<Boolean> {
override fun result(code: Int, result: Boolean?) {
mIsExecute.set(result?:false)
if (CompileConfig.DEBUG) {
@@ -1247,7 +1168,7 @@ class RoadHelper private constructor() {
if (TransformUtils.outOfChina(lat, lon)) {
return
}
getInstance()?.getCityCode(lon, lat, object : IResult<Int> {
getCityCode(lon, lat, object : IResult<Int> {
override fun result(code: Int, result: Int?) {
if (result == 0) {
return
@@ -1264,6 +1185,17 @@ class RoadHelper private constructor() {
}
/**
* 取消可取消的任务
*/
fun cancelTask(){
if(CompileConfig.DEBUG){
Log.i(TAG, "roadop--cancelTask")
}
RoadResultController.instance.removeRoadResultListenerByCanCancel()
mapBox.cancelTask()
}
fun addHdDataDownListener(id: Int, onHdDataDownByCityListener: OnHdDataDownByCityListener){
if(mHdDataDownloadListener == null){
mHdDataDownloadListener = ConcurrentHashMap()

View File

@@ -13,7 +13,7 @@ class RoadResultController {
private val TAG = javaClass.simpleName
private var mRoadResultCallHashMap: ConcurrentHashMap<String,CopyOnWriteArrayList<IRoadData>> = ConcurrentHashMap()
private val mRoadResultCallHashMap: ConcurrentHashMap<String,CopyOnWriteArrayList<IRoadData>> = ConcurrentHashMap()
fun addRoadResultListener(key:String,listener:IRoadData){
if(CompileConfig.DEBUG){
@@ -44,6 +44,24 @@ class RoadResultController {
mRoadResultCallHashMap.remove(key)
}
}
fun removeRoadResultListenerByCanCancel(){
if(CompileConfig.DEBUG){
Log.i(TAG, "roadop--removeRoadResultListenerByCanCancel: ")
}
val keysToRemove = mutableListOf<String>()
mRoadResultCallHashMap.forEach { (key, _) ->
if (key.contains("${CANCELTAG}true")) {
keysToRemove.add(key)
}
}
keysToRemove.forEach { key ->
if(CompileConfig.DEBUG){
Log.i(TAG, "roadop--removeRoadResultListenerByCanCancel::--remove:$key ")
}
mRoadResultCallHashMap.remove(key)
}
}
fun dispatchRoadResult(code:Int,key:String,result:ByteArray){
@@ -66,6 +84,8 @@ class RoadResultController {
}
companion object {
const val CANCELTAG = "cancelTask:"
//单例
@JvmStatic val instance: RoadResultController by lazy((LazyThreadSafetyMode.SYNCHRONIZED)) {
RoadResultController()

View File

@@ -23,7 +23,7 @@ object BitmapUtils {
return null;
}
try{
val result = bitmap.copy(bitmap.config, true);
val result = bitmap.copy(bitmap.config, true)
// val canvasBmp2 = Canvas( result );
// canvasBmp2.drawBitmap(bitmap,null, Paint())
return result

View File

@@ -213,7 +213,7 @@ object Constant {
for (i in c.indices) {
if (c[i] == '\u3000') {
c[i] = ' '
} else if (c[i] in ''..'') {
} else if (c[i] > '\uFF00' && c[i] < '\uFF5F') { // in ''..''
c[i] = (c[i] - 65248)
}
}

View File

@@ -1,6 +1,13 @@
package com.zhidaoauto.map.sdk.inner.utils
import kotlin.math.*
import kotlin.math.abs
import kotlin.math.asin
import kotlin.math.atan
import kotlin.math.cos
import kotlin.math.pow
import kotlin.math.sin
import kotlin.math.sqrt
import kotlin.math.tan
class DistanceHelper {
private val EARTH_RADIUS = 6378137.0
@@ -31,7 +38,7 @@ class DistanceHelper {
// MaxLat = maxlat,
// MinLng = minlng,
// MaxLng = maxlng
// }
// }
// }
/// <summary>
/// 计算两点位置的距离,返回两点的距离,单位:公里或千米

View File

@@ -9,6 +9,7 @@ import java.text.DateFormat
import java.text.SimpleDateFormat
import java.util.Calendar
import java.util.TimeZone
import java.util.concurrent.CopyOnWriteArrayList
import kotlin.math.abs
import kotlin.math.absoluteValue
import kotlin.math.acos
@@ -428,7 +429,7 @@ object MathUtils {
return list
}
fun getPoints(line: ArrayList<LonLatPoint> , factor: Float): ArrayList<LonLatPoint> {
fun getPoints(line: CopyOnWriteArrayList<LonLatPoint>, factor: Float): ArrayList<LonLatPoint> {
if (DEBUG) {
Log.i(TAG, "getPoints: 插值原始数据:${line.size}")
}
@@ -506,13 +507,16 @@ object MathUtils {
sIndex = i
}
if(eIndex == list.size && nowDis > maxDis){
eIndex = i
}
}
if(sIndex > eIndex){
eIndex = list.size
var sumDis = 0.0
if(sIndex < list.size-1){
for(i in sIndex until list.size){
sumDis += distance(list[i], list[i + 1])
if(sumDis > maxDis){
eIndex = i-1
break
}
}
}
val subList = ArrayList(list.subList(sIndex, eIndex))
if(DEBUG) {

View File

@@ -3,7 +3,11 @@ package com.zhidaoauto.map.sdk.inner.utils
import android.content.Context
import com.zhidaoauto.map.sdk.inner.abs.IMapController
import java.math.BigDecimal
import kotlin.math.*
import kotlin.math.abs
import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
object TransformUtils {

View File

@@ -109,7 +109,7 @@ object MapAutoApi {
*/
fun init(context: Context, mapParams: MapParams) {
CommonController.instance.init(context)
Recorder.i("common","$mapParams")
addLog("$mapParams")
val customPath = context.filesDir.absolutePath
if (TextUtils.isEmpty(mapParams.getStyleDir())) {
val stylePath = "${customPath}/shmdata/mogo_style"

View File

@@ -93,17 +93,17 @@ interface IMapStyleParams {
fun getStyleName(): String
fun getDefaultPerspective(): Int
fun getVrAngleDefaultMode(): Int
fun setDefaultPerspective(type: Int): MapStyleParams
fun setVrAngleDefaultMode(type: Int): MapStyleParams
fun setIsSkyBoxEnable(isEnable: Boolean): MapStyleParams
fun setSkyBoxEnable(isEnable: Boolean): MapStyleParams
fun getIsSkyBoxEnable(): Boolean
fun isSkyBoxEnable(): Boolean
fun setIsWeatherEnable(isEnable: Boolean): MapStyleParams
fun setWeatherEnable(isEnable: Boolean): MapStyleParams
fun getIsWeatherEnable(): Boolean
fun isWeatherEnable(): Boolean
fun setLocationIcon3DRes(resId: Int): MapStyleParams
@@ -113,4 +113,7 @@ interface IMapStyleParams {
fun getLocationIconRes(): Int
fun setIsDisplayAnim(isEnable: Boolean): MapStyleParams
fun isDisplayAnim(): Boolean
}

View File

@@ -27,9 +27,9 @@ object DeadZoneHelper {
Log.i(TAG, "dealParam: ${System.currentTimeMillis()},$time,$lon,$lat,$angle,${MapTools.convertAngle((450-angle)%360, lon, lat)}")
}
angle = MapTools.convertAngle((450-angle)%360, lon, lat)
val circleAngleInterval = lines[dataLineIndex++].trim().toFloat()
var circleAngleInterval = lines[dataLineIndex++].trim().toFloat()
val count = (360 / circleAngleInterval).toInt()
var count = (360 / circleAngleInterval).toInt()
var countIndex = 1
val list = ArrayList<LonLatPoint>()
while (countIndex <= count && dataLineIndex + countIndex < lines.size) {

View File

@@ -179,7 +179,7 @@ object MapDataApi {
//获取限速接口
fun getLimitSpeed(lon: Double,lat: Double,angle: Float,call: IResult<RoadInfo>){
Recorder.add("roadop-getLimitSpeed:$lon,$lat,$angle")
RoadHelper.getInstance()?.getRoadLimitSpeed(lon,lat,angle,call)
RoadHelper.getInstance()?.getRoadLimitSpeed(lon,lat,angle,true,call)
}
/**
@@ -196,7 +196,7 @@ object MapDataApi {
*/
fun getStopLineInfo(lon: Double, lat: Double, angle: Float,call: IResult<StopLine>) {
Recorder.add("roadop-getStopLineInfo:$lon,$lat,$angle")
RoadHelper.getInstance()?.getStopLine(lon, lat, angle,call)
RoadHelper.getInstance()?.getStopLine(lon, lat, angle,false,call)
}
/**
@@ -214,7 +214,7 @@ object MapDataApi {
call.result(-1,null)
return
}
RoadHelper.getInstance()?.getCenterLineRange(lon, lat, angle,dis,isSmooth,orders, call)
RoadHelper.getInstance()?.getCenterLineRange(lon, lat, angle,dis,isSmooth,orders,false, call)
}
@@ -227,7 +227,7 @@ object MapDataApi {
*/
fun getCenterLineRoadNode(lon: Double, lat: Double, angle: Float, dis: Float,call: IResult<CenterLine>){
Recorder.add("roadop-getCenterLineRoadNode:$lon,$lat,$angle,$dis")
RoadHelper.getInstance()?.getCenterLineRoadNode(lon, lat, angle,dis,call)
RoadHelper.getInstance()?.getCenterLineRoadNode(lon, lat, angle,dis,false,call)
}
@@ -241,7 +241,7 @@ 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)
RoadHelper.getInstance()?.getCrossRoad(dLon, dLat, fAngle,false,call)
}
/**
* 根据路口id获取道路信息
@@ -264,7 +264,7 @@ object MapDataApi {
*/
fun getCenterLineInfo(lon: Double, lat: Double, angle: Float,call: IResult<CenterLine>) {
Recorder.add("roadop-getCenterLineInfo:$lon,$lat,$angle")
RoadHelper.getInstance()?.getCenterLine(lon, lat, angle,call)
RoadHelper.getInstance()?.getCenterLine(lon, lat, angle,false,call)
}
/**
* 是否合法的经纬度
@@ -365,6 +365,13 @@ object MapDataApi {
RoadHelper.getInstance()?.cacheHDDataByCity(id, listener)
}
/**
* 取消过去时间段里的道路相关的任务
*/
fun cancelRoadTask(){
RoadHelper.getInstance()?.cancelTask()
}
/**
* 按照经纬度缓存城市数据
*/

View File

@@ -12,7 +12,6 @@ import com.zhidaoauto.map.sdk.inner.CompileConfig
import com.zhidaoauto.map.sdk.inner.abs.IMapController
import com.zhidaoauto.map.sdk.inner.abs.IMarkerController
import com.zhidaoauto.map.sdk.inner.utils.BitmapUtils
import com.zhidaoauto.map.sdk.inner.utils.Constants
import com.zhidaoauto.map.sdk.inner.utils.TransformUtils
import com.zhidaoauto.map.sdk.open.abs.view.IMapStyleParams
import com.zhidaoauto.map.sdk.open.marker.Marker
@@ -40,12 +39,12 @@ class MyLocationStyle(
}
private var mLonLat: LonLat = LonLat(Constants.BEIJING.lon, Constants.BEIJING.lat)
private var mLonLat: LonLat = LonLat()
private var mAngle: Float = 0.0f
private var locationCount = 0
private var is3D: Boolean = false
private var carId: Int = 0
private var isDisplayAnim: Boolean = true
private var isDisplayAnim: Boolean = false
private var mMarker: Marker? = null
private var lastExecuteTime = -1L
@@ -77,6 +76,7 @@ class MyLocationStyle(
init {
car3DResId = mMapStyleParams?.getLocationIcon3DRes() ?: R.raw.car
carResId = mMapStyleParams?.getLocationIconRes() ?: R.mipmap.map_custom_self_car_night
isDisplayAnim = mMapStyleParams?.isDisplayAnim()?: false
}
fun getSelfMarker(): Marker? {

View File

@@ -27,6 +27,8 @@ class BatchMarkerOptions {
//平均速度标记
var averageFlag: Int = 1
//回调标记
var callbackFlag: Int = 0
constructor(list:ArrayList<MarkerSimpleData>?){

View File

@@ -547,13 +547,14 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
if (CompileConfig.DEBUG) {
Log.i(TAG, "markerop--bitmap:${bitmapDescriptor.getBytes().size},${id}")
}
markerOptions.setInfoWindowShown(true)
markerOptions.infoWindowEnable(true)
markerOptions?.updateInfowindowBitmap(bitmapDescriptor,mMapController)
markerOptions?.setInfoWindowShown(true)
markerOptions?.infoWindowEnable(true)
mMapController?.updateAnchorProperty(id, "infoWindowEnabled", "true")
mMapController?.updateAnchorProperty(id, "isInfoWindowShown", "true")
markerOptions.updateInfowindowBitmap(bitmapDescriptor,mMapController)
if (CompileConfig.DEBUG) {
Log.i(TAG, "markerop--matt--showInfoWindow--bitmapDescriptor:${bitmapDescriptor.width},${bitmapDescriptor.height}")
}
@@ -582,14 +583,16 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
if (CompileConfig.DEBUG) {
Log.i(TAG, "markerop--bitmap:${bitmapDescriptor.getBytes().size},${id}")
}
markerOptions.setInfoWindowShown(true)
markerOptions.infoWindowEnable(true)
markerOptions?.updateInfowindowBitmap(bitmapDescriptor,mMapController)
markerOptions?.setInfoWindowShown(true)
markerOptions?.infoWindowEnable(true)
mMapController?.updateAnchorProperty(id, "infoWindowEnabled", "true")
mMapController?.updateAnchorProperty(id, "isInfoWindowShown", "true")
markerOptions.updateInfowindowBitmap(bitmapDescriptor,mMapController)
if (CompileConfig.DEBUG) {
Log.i(TAG, "markerop--matt--showInfoWindow--bitmapDescriptor:${bitmapDescriptor.width},${bitmapDescriptor.height}")
}
@@ -602,6 +605,8 @@ public class Marker(private var markerOptions: MarkerOptions,private var mMapCon
}
private fun dealInfoWindowViewClick(view: View) {
if (CompileConfig.DEBUG) {
Log.i(TAG, "markerop--matt--dealInfoWindowViewClick-start")

View File

@@ -201,6 +201,7 @@ class MarkerController(mapController: IMapController) : IMarkerController {
buffer.append(batchMarkerOptions.showInfo).append(",")
buffer.append(batchMarkerOptions.isReplaceDuration).append(",")
buffer.append(batchMarkerOptions.averageFlag).append(",")
buffer.append(batchMarkerOptions.callbackFlag).append(",")
buffer.append(otherStr)
if(CompileConfig.DEBUG){

View File

@@ -31,7 +31,7 @@ class MarkerOptions {
var status: Int = 0
@JSONField(name = "lonLatPoint")
private var lonLatPoint: LonLat? = null
private var lonLatPoint: LonLat = LonLat()
@JSONField(serialize = false)
private var originLonLatPoint: LonLatPoint? = null
@@ -140,7 +140,7 @@ class MarkerOptions {
anchorColor = ""
rotateAngle = 0f
visible = true
lonLatPoint = null
lonLatPoint = LonLat()
originLonLatPoint = null
markerIconName =""
markerInfoName =""

View File

@@ -8,7 +8,13 @@ import com.zhidaoauto.map.sdk.inner.CompileConfig.DEBUG
import com.zhidaoauto.map.sdk.inner.abs.IMapController
import com.zhidaoauto.map.sdk.inner.proxy.CommonProxy
import com.zhidaoauto.map.sdk.inner.utils.MathUtils
import kotlin.math.*
import kotlin.math.abs
import kotlin.math.absoluteValue
import kotlin.math.asin
import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.sin
import kotlin.math.sqrt
object MapTools {
@@ -167,10 +173,10 @@ object MapTools {
/// <summary>
/// 给定的经度1纬度1经度2纬度2. 计算2个经纬度之间的距离。
/// </summary>
/// <param name="lat1">度1</param>
/// <param name="lon1">度1</param>
/// <param name="lat2">度2</param>
/// <param name="lon2">度2</param>
/// <param name="lat1">度1</param>
/// <param name="lon1">度1</param>
/// <param name="lat2">度2</param>
/// <param name="lon2">度2</param>
/// <returns>距离(米)</returns>
fun getDistance(lat1: Double, lon1: Double, lat2: Double, lon2: Double): Double {
//用haversine公式计算球面两点间的距离。
@@ -179,10 +185,10 @@ object MapTools {
var lon1 = lon1
var lat2 = lat2
var lon2 = lon2
lat1 = convertDegreesToRadians(lat1)
lon1 = convertDegreesToRadians(lon1)
lat2 = convertDegreesToRadians(lat2)
lon2 = convertDegreesToRadians(lon2)
lat1 = Math.toRadians(lat1)
lon1 = Math.toRadians(lon1)
lat2 = Math.toRadians(lat2)
lon2 = Math.toRadians(lon2)
//差值
val vLon = abs(lon1 - lon2)

View File

@@ -8,7 +8,11 @@ import android.util.Log
import android.widget.TextView
import com.autonavi.nge.NLog
import com.zhidaoauto.map.data.point.LonLatPoint
import com.zhidaoauto.map.data.road.*
import com.zhidaoauto.map.data.road.CenterLine
import com.zhidaoauto.map.data.road.RoadCross
import com.zhidaoauto.map.data.road.RoadRectInfos
import com.zhidaoauto.map.data.road.StopLine
import com.zhidaoauto.map.data.road.ZebraLine
import com.zhidaoauto.map.data.routeinfo.RoadInfo
import com.zhidaoauto.map.sdk.R
import com.zhidaoauto.map.sdk.inner.common.ConstantExt
@@ -22,16 +26,38 @@ import com.zhidaoauto.map.sdk.open.circle.CircleOptions
import com.zhidaoauto.map.sdk.open.data.CityInfo
import com.zhidaoauto.map.sdk.open.data.MapDataApi
import com.zhidaoauto.map.sdk.open.location.MogoLocation
import com.zhidaoauto.map.sdk.open.marker.*
import com.zhidaoauto.map.sdk.open.marker.Marker
import com.zhidaoauto.map.sdk.open.marker.MarkerBatchData
import com.zhidaoauto.map.sdk.open.marker.MarkerCacheController
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions
import com.zhidaoauto.map.sdk.open.marker.MarkerSimpleData
import com.zhidaoauto.map.sdk.open.marker.MarkerSimpleOptions
import com.zhidaoauto.map.sdk.open.polygon.Polygon3D
import com.zhidaoauto.map.sdk.open.polygon.Polygon3DHelper
import com.zhidaoauto.map.sdk.open.polygon.Polygon3DOption
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 kotlinx.coroutines.*
import java.io.*
import java.util.concurrent.*
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.Job
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.Runnable
import kotlinx.coroutines.cancel
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import java.io.BufferedReader
import java.io.FileInputStream
import java.io.FileNotFoundException
import java.io.IOException
import java.io.InputStream
import java.io.InputStreamReader
import java.util.concurrent.ConcurrentHashMap
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.Executors
import java.util.concurrent.LinkedBlockingDeque
import java.util.concurrent.ThreadPoolExecutor
import java.util.concurrent.TimeUnit
import kotlin.math.roundToInt
@@ -427,8 +453,13 @@ class TaskManager private constructor() {
?.setRoamStyle(0, ConstantExt.ROAM_DIS_1KM, ConstantExt.ROAM_SPEED_80)
}
fun setRoamPath(mapAutoView: MapAutoView) {
mapAutoView.getMapAutoViewHelper()?.setRoamTrajectory(trackStr + trackStr1)
fun setRoamPath(mapAutoView: MapAutoView){
val array = (trackStr + trackStr1).split(",")
val list = ArrayList<LonLatPoint>()
for( i in 0 until array.size step 2){
list.add(LonLatPoint(array[i].toDouble(),array[i+1].toDouble()))
}
mapAutoView.getMapAutoViewHelper()?.setRoamTrajectory(list)
}
fun monitorTransStyle(mapAutoView: MapAutoView) {
@@ -642,6 +673,7 @@ class TaskManager private constructor() {
RoadHelper.getInstance()?.getCrossRoad(lonlatPoint.longitude,
lonlatPoint.latitude,
lonlatPoint.angle.toFloat(),
true,
object : IResult<RoadCross> {
override fun result(code: Int, result: RoadCross?) {
result?.let {
@@ -830,7 +862,7 @@ class TaskManager private constructor() {
try {
//分行读取
while (buffReader != null && buffReader.readLine().also { line = it } != null) {
val lines = line!!.split("")
val lines = line!!.split(";")
val count = lines.size
val batchData = MarkerBatchData()
val centerMarkerOptions = MarkerSimpleOptions()
@@ -869,7 +901,7 @@ class TaskManager private constructor() {
simpleData.lat = lat
simpleData.rotateAngle = angle.toFloat()
simpleData.markerType = type
simpleData.color = instance.getRandomColorStr()
simpleData.color = getRandomColorStr()
if (idList.contains(id)) {
continue
}
@@ -961,6 +993,7 @@ class TaskManager private constructor() {
10f,
false,
6,
true,
object : IResult<CenterLine> {
override fun result(code: Int, result: CenterLine?) {
@@ -972,6 +1005,7 @@ class TaskManager private constructor() {
lonlatPoint.latitude,
lonlatPoint.angle.toFloat(),
300f,
true,
object : IResult<CenterLine> {
override fun result(code: Int, result: CenterLine?) {

View File

@@ -38,6 +38,7 @@ import com.zhidaoauto.map.sdk.open.location.LonLatPointListener
import com.zhidaoauto.map.sdk.open.location.MogoLocation
import com.zhidaoauto.map.sdk.open.marker.MarkerController
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener
import com.zhidaoauto.map.sdk.open.tools.MapTools
import com.zhidaoauto.map.sdk.open.view.MapStyleParams.Companion.MAP_PERSPECTIVE_3D
import com.zhidaoauto.map.sdk.open.weather.WeatherRepository
import com.zhidaoauto.map.sdk.open.weather.WeatherType
@@ -124,6 +125,9 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
private val weatherRepository by lazy { WeatherRepository() }
private var isFirstInit = true
//The location information of the last loaded road data
private var mLastRoadLonLatPoint:LonLatPoint? = null
constructor(context: Context) : super(context) {
initView()
}
@@ -155,7 +159,7 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
// 获取自定义属性值
val typedArray = context.obtainStyledAttributes(attrs, R.styleable.MapAutoView)
var zoom = typedArray.getInt(R.styleable.MapAutoView_zoom, 20)
if(zoom in 24 downTo 8){
if(zoom < 9 || zoom > 23){
zoom = 20
}
val carPosition = typedArray.getFloat(R.styleable.MapAutoView_carPosition, ConstantExt.MAP_STYLE_VR_POSITION_MIDDLE)
@@ -176,6 +180,7 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
val isWeatherEnable = typedArray.getBoolean(R.styleable.MapAutoView_isWeatherEnable, true)
val locationIcon3DRes = typedArray.getResourceId(R.styleable.MapAutoView_locationIcon3DRes, R.raw.car)
val locationIconRes = typedArray.getResourceId(R.styleable.MapAutoView_locationIconRes, R.mipmap.map_custom_self_car_night)
val isDisplayAnim = typedArray.getBoolean(R.styleable.MapAutoView_isDisplayAnim, false)
typedArray.recycle()
val mapStyleParams = MapStyleParams()
mapStyleParams.setZoom(zoom)
@@ -192,11 +197,12 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
mapStyleParams.setMinDistanceForPosition(minDistanceForPosition)
mapStyleParams.setShadowEnable(isShadowEnable)
mapStyleParams.setStyleName(styleName)
mapStyleParams.setDefaultPerspective(defaultPerspective)
mapStyleParams.setIsSkyBoxEnable(isSkyBoxEnable)
mapStyleParams.setIsWeatherEnable(isWeatherEnable)
mapStyleParams.setVrAngleDefaultMode(defaultPerspective)
mapStyleParams.setSkyBoxEnable(isSkyBoxEnable)
mapStyleParams.setWeatherEnable(isWeatherEnable)
mapStyleParams.setLocationIconRes(locationIconRes)
mapStyleParams.setLocationIcon3DRes(locationIcon3DRes)
mapStyleParams.setIsDisplayAnim(isDisplayAnim)
this.mMapStyleParams = mapStyleParams
}
@@ -220,7 +226,7 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
locationClient?.start()
}
}
isWeatherEnable = mMapStyleParams?.getIsWeatherEnable()?:true
isWeatherEnable = mMapStyleParams?.isWeatherEnable()?:true
// mTrafficHelper = TrafficHelper()
@@ -433,7 +439,7 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
isFirstInit = false
updateCacheByCityCode(mogoLocation)
}
isWeatherEnable = mMapStyleParams?.getIsWeatherEnable()?:true
isWeatherEnable = mMapStyleParams?.isWeatherEnable()?:true
if(isWeatherEnable && isFirstLocation){
isFirstLocation = false
loopFlag = true
@@ -925,14 +931,31 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
private fun getRoadInfo(mogoLocation: MogoLocation) {
if (System.currentTimeMillis() - mLastTimeRoadInfo > mIntervalTimeRoadInfo) {
mLastTimeRoadInfo = System.currentTimeMillis()
mLastRoadLonLatPoint?.let {
if(CompileConfig.DEBUG){
Log.i(TAG, "roadop--cancelTask last: $mLastRoadLonLatPoint")
}
//发现有任务堆积时100米为超参按照常识5秒内未返回数据取消之前道路相关任务
if(MapTools.getDistance(it.latitude,it.longitude,mogoLocation.lat,mogoLocation.lon) > 100.0){
if(CompileConfig.DEBUG){
Log.i(TAG, "roadop--cancelTask:distance>200 : $mLastRoadLonLatPoint")
}
// 取消任务
RoadHelper.getInstance()?.cancelTask()
}
}
// mLastRoadLonLatPoint = LonLatPoint(mogoLocation.lon,mogoLocation.lat)
// 获取车道中心线数据
RoadHelper.getInstance()?.getCenterLine(
mogoLocation.lon,
mogoLocation.lat,
mogoLocation.heading.toFloat(),
true,
object :
IResult<CenterLine> {
override fun result(code: Int, result: CenterLine?) {
mLastRoadLonLatPoint = LonLatPoint(mogoLocation.lon,mogoLocation.lat)
mEventController?.dispatchRoadIdInfo(
result?.road_id,
result?.lane_id
@@ -943,6 +966,7 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
mogoLocation.lon,
mogoLocation.lat,
mogoLocation.heading.toFloat(),
true,
object : IResult<StopLine> {
override fun result(code: Int, result: StopLine?) {
mEventController?.dispatchStopLineInfo(result)
@@ -953,6 +977,7 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
mogoLocation.lon,
mogoLocation.lat,
mogoLocation.heading.toFloat(),
true,
object : IResult<RoadCross> {
override fun result(code: Int, result: RoadCross?) {
mEventController?.dispatchRoadCrossInfo(result)
@@ -969,7 +994,7 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
fun setWeatherEnable(isEnable: Boolean){
isWeatherEnable = isEnable
mMapStyleParams?.setIsWeatherEnable(isEnable)
mMapStyleParams?.setWeatherEnable(isEnable)
}

View File

@@ -1,7 +1,7 @@
package com.zhidaoauto.map.sdk.open.view
import android.util.Log
import com.autonavi.nge.map.*
import com.autonavi.nge.map.LonLat
import com.zhidaoauto.map.data.point.LonLatPoint
import com.zhidaoauto.map.sdk.inner.CompileConfig
import com.zhidaoauto.map.sdk.inner.common.ConstantExt
@@ -20,7 +20,8 @@ import com.zhidaoauto.map.sdk.open.deadzone.DeadZoneOptions
import com.zhidaoauto.map.sdk.open.exception.NotImplementException
import com.zhidaoauto.map.sdk.open.location.MogoLocation
import com.zhidaoauto.map.sdk.open.location.MyLocationStyle
import com.zhidaoauto.map.sdk.open.marker.*
import com.zhidaoauto.map.sdk.open.marker.Marker
import com.zhidaoauto.map.sdk.open.marker.MarkerOptions
import com.zhidaoauto.map.sdk.open.poyline.Polyline
import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions
import com.zhidaoauto.map.sdk.open.tools.MapTools
@@ -50,12 +51,12 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
/**
* 设置在车在屏幕的相对位置
* param defult = 4 range (1..6) 设置自车位置 offset 1.0-6.0 <4.0车向上,>4.0车向下
* @param param defult = 4 range (1..6) 设置自车位置 offset 1.0-6.0 <4.0车向上,>4.0车向下
*/
fun setSelfCarPosition(param:Float){
mMapAutoView.getClerk()?.add("$param")
var overAngle = (getMapDAngle())?:6.5f
mMapAutoView.getMapController()?.setScreenToOriginDis(param);
mMapAutoView.getMapController()?.setScreenToOriginDis(param)
overAngle += 0.01f
setMapDAngle(overAngle)
overAngle -= 0.01f
@@ -65,14 +66,14 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
/**
* 设置视点位置
* eyeToOrigin defult = 33
* screenToOrigin defult = 4
* @param eyeToOrigin defult = 33
* @param screenToOrigin defult = 4
*/
@Deprecated(message = "dead")
fun setEyePosition(eyeToOrigin:Float,screenToOrigin:Float){
mMapAutoView.getClerk()?.add("$eyeToOrigin,$screenToOrigin")
mMapAutoView.getMapController()?.setEyeToOriginDis(eyeToOrigin);
mMapAutoView.getMapController()?.setScreenToOriginDis(screenToOrigin);
mMapAutoView.getMapController()?.setEyeToOriginDis(eyeToOrigin)
mMapAutoView.getMapController()?.setScreenToOriginDis(screenToOrigin)
}
@@ -222,16 +223,13 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
Log.i(TAG, "autoop-setMapViewAngle${angle}")
}
mMapAutoView.getClerk()?.add()
// mMapAutoView.getMapController()?.setDAngle(angle)
val center = getCenter()
val lonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(center)
mMapAutoView.getMapController()?.interpolation(-1f, angle, -1f, -1, -1)
}
/**
* 设置地图视
* 设置地图视点高度
*
* @param angle 视角
* @param eyeHeight 高度
*/
fun setVrEyeHeight(eyeHeight: Float) {
mMapAutoView.getClerk()?.add()
@@ -327,7 +325,7 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
/**
* 设置地图旋转角度
*
* @param angle
* @param rotateAngle 角
*/
fun setMapViewRotateAngle(rotateAngle: Float) {
if (CompileConfig.DEBUG) {
@@ -1001,7 +999,7 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
if (CompileConfig.DEBUG) {
Log.i(TAG, "autoop-lockop--custommap-setLockMode:${enabled}")
}
if (mMapAutoView.getMapController()?.isTouching() ?: false) {
if (mMapAutoView.getMapController()?.isTouching() == true) {
return
}
mMapAutoView.getClerk()?.add()
@@ -1010,7 +1008,7 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
fun getLockMode(): Boolean {
mMapAutoView.getClerk()?.add()
val result = mMapAutoView.getLockCar() ?: true
val result = mMapAutoView.getLockCar()
if (CompileConfig.DEBUG) {
Log.i(TAG, "mapop-custommap--getLockMode:${result}")
}
@@ -1073,16 +1071,16 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
mMapAutoView.getClerk()?.add()
val centerArray = DoubleArray(2)
mMapAutoView.getMapController()?.getCenter(centerArray)
val centerLonLatPoint = CommonProxy.getInstance().getLonLatProxy().switchLonLat(LonLat(centerArray[0], centerArray[1]))
val zoom = mMapAutoView.getMapController()?.getZoom() ?: 16
val centerLonLatPoint = CommonProxy.getInstance().getLonLatProxy()
.switchLonLat(LonLat(centerArray[0], centerArray[1]))
val zoom = mMapAutoView.getMapController()?.getZoom() ?: 16
val tilt = mMapAutoView.getMapController()?.getTilt() ?: 0f
val heading = mMapAutoView.getLocationClient()?.lastKnownMogoLocation?.heading
var bearing = 0.0
if (heading != null) {
bearing = heading
}
val cameraPosition = CameraPosition(centerLonLatPoint, zoom.toFloat(), tilt, bearing.toFloat())
return cameraPosition
return CameraPosition(centerLonLatPoint, zoom.toFloat(), tilt, bearing.toFloat())
}
/**
@@ -1181,16 +1179,24 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
}
/**
* 设置是否只在高精地图缩放
* @param isScaleVr
*/
fun setScaleVRMode(isScaleVr: Boolean){
mMapAutoView.getClerk()?.add("$isScaleVr")
mMapAutoView.getMapController()?.setVrMode(isScaleVr)
}
/**
* 设置近视角位置
* @param lonLatPoint
* @param isGps
*/
fun setNearViewAnglePosition(lonLatPoint: LonLatPoint, isGps: Boolean){
mMapAutoView.getClerk()?.add("$lonLatPoint,$isGps")
var lonLat: LonLat? = null
val lonLat: LonLat
if(!isGps) {
lonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
}else{
@@ -1238,7 +1244,7 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
var roamDis = dis
if(roamDis > ConstantExt.ROAM_DIS_MAX){
roamDis = ConstantExt.ROAM_DIS_MAX
} else if(roamDis < ConstantExt.ROAM_DIS_1KM){
} else if(roamDis < 0){
roamDis = ConstantExt.ROAM_DIS_1KM
}
var roamSpeed = speed
@@ -1252,11 +1258,11 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
}
/**
* @param travel 轨迹路径 格式 112.5775862,26.82019681,112.5775592,26.82018045,......
* @param travelList 轨迹路径
*/
fun setRoamTrajectory(travel: String){
fun setRoamTrajectory(travelList: ArrayList<LonLatPoint>?){
mMapAutoView.getClerk()?.add()
mMapAutoView.getMapController()?.setRoamTrajectory(travel)
mMapAutoView.getMapController()?.setRoamTrajectory(travelList)
}
@@ -1323,6 +1329,10 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
mMapAutoView.getMapController()?.setWeatherType(type)
}
/**
* 设置是否启用天气渲染
* @param isEnable
*/
fun setWeatherEnable(isEnable: Boolean){
if (CompileConfig.DEBUG){
Log.i(TAG, "setWeatherEnable:${isEnable}")
@@ -1330,6 +1340,12 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
mMapAutoView.setWeatherEnable(isEnable)
}
/**
* 获取天气信息
* @param lon 经度
* @param lat 纬度
* @param call 回调
*/
fun getWeatherInfo(lon: Double, lat: Double, call: WeatherResult){
if (CompileConfig.DEBUG){
Log.i(TAG, "getWeatherInfo:${lon},$lat")
@@ -1337,13 +1353,19 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
mMapAutoView.getMapController()?.getWeatherInfo(lon,lat,call)
}
/**
* 设置启用天空盒模式
*/
fun setSkyBoxMode(){
if (CompileConfig.DEBUG){
Log.i(TAG, "setSkyBoxMode")
}
mMapAutoView.getMapController()?.setSkyBoxMode()
}
/**
* 设置是否启用大雾
* @param isEnable
*/
fun setFogMode(isEnable: Boolean){
if (CompileConfig.DEBUG){
Log.i(TAG, "setFogMode")
@@ -1354,8 +1376,7 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
/**
* 设置光波
* @param start 起点
* @param end 终点
* @param list 点集
* @param width 宽度
* @param duration 动画时长
*/
@@ -1367,10 +1388,14 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
* 设置引导线
* @param list 引导线轨迹
*/
fun setGuideLine(list: List<LonLatPoint>?){
mMapAutoView.getMapController()?.setGuideLine(list)
fun setGuideLine(list: List<LonLatPoint>?, drawEleLength:Float){
mMapAutoView.getMapController()?.setGuideLine(list, drawEleLength)
}
/**
* 设置道路纹理带下
* @param size 纹理大小 取值范围?
*/
fun setRoadTexSize(size: Float){
mMapAutoView.getClerk()?.add("$size")
if (CompileConfig.DEBUG){
@@ -1379,6 +1404,10 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
mMapAutoView.getMapController()?.setRoadTexSize(size)
}
/**
* 设置是否启用纹理绘制路面
* @param isEnable
*/
fun setRoadUseTexture(isEnable: Boolean){
mMapAutoView.getClerk()?.add("$isEnable")
if (CompileConfig.DEBUG){
@@ -1387,6 +1416,10 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
mMapAutoView.getMapController()?.setRoadUseTexture(isEnable)
}
/**
* 设置是否启用纹理绘制地面
* @param isEnable
*/
fun setPlaneUseTexture(isEnable: Boolean){
mMapAutoView.getClerk()?.add("$isEnable")
if (CompileConfig.DEBUG){
@@ -1404,5 +1437,26 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
height
)
}
/**
* 地图中心点周围模糊属性
* @param isEnable 是否开启
* @param color 颜色
* @param starDis 起始距离
* @param endDis 结束距离
* @param density 密度
*/
fun setMapCenterBlur(isEnable: Boolean, color: String?, starDis: Float?, endDis: Float?, density: Float?) {
mMapAutoView.getClerk()?.add("$isEnable,$color,$starDis,$endDis,$density")
mMapAutoView.getMapController()?.setMapCenterBlur(isEnable, color, starDis, endDis, density)
}
/**
* 设置是否启用夜间路灯效果
* @param isEnable
*/
fun setStreetLightNightEffectIsEnable(isEnable: Boolean){
mMapAutoView.getClerk()?.add("$isEnable")
mMapAutoView.getMapController()?.setStreetLightEffectIsEnable(isEnable)
}
}

View File

@@ -15,11 +15,13 @@ class MapStyleParams: IMapStyleParams {
// 小车位置 设置自车位置 offset 1.0-6.0 <4.0车向上,>4.0车向下
private var carPosition: Float = ConstantExt.MAP_STYLE_VR_POSITION_MIDDLE
// 是否自动切换模式
private var isAutoSwitch: Boolean = false
// 是否启动默认定位
private var isAutoLocation = true
// 默认自车2D图标
private var mLocationIconRes = R.mipmap.map_custom_self_car
// 默认自车3D图标
private var mLocationIcon3DRes = R.raw.car
//显示高精地图元素
@@ -63,30 +65,43 @@ class MapStyleParams: IMapStyleParams {
*/
private var perspectiveMode: Int = MAP_PERSPECTIVE_3D
private var vrPerspectiveMode: Float = ConstantExt.MAP_STYLE_VR_OVER_LOOK_ANGLE_MIDDLE
// 视角角度
private var vrPerspectiveModeAngle: Float = ConstantExt.MAP_STYLE_VR_OVER_LOOK_ANGLE_MIDDLE
// 视角模式
private var vrAngleMode: Int = ConstantExt.MAP_STYLE_VR_ANGLE_MIDDLE
private var isSwitchViewAngle = false
// 视点高度
private var vrEyeHeight : Float = ConstantExt.MAP_STYLE_VR_EYE_HEIGHT_MIDDLE
// zoom级别
private var zoomVal = ConstantExt.MAP_STYLE_VR_ZOOM_VAL_MIDDLE
// 更换坐标的最小距离
private var minDistanceForPosition = 0.02f
//开启阴影
// 开启阴影
private var isShadowEnable = true
// 特殊样式目录
private var styleName = ""
private var default_perspective = ConstantExt.MAP_STYLE_VR_ANGLE_MIDDLE
// 是否双击屏幕切换视角
private var isSwitchViewAngle = false
// vr模式下的默认视角模式
private var vrAngleDefaultMode = ConstantExt.MAP_STYLE_VR_ANGLE_MIDDLE
// 是否开启天空盒
private var isSkyBoxEnable = false
// 是否开启天气
private var isWeatherEnable = true
//是否使用光圈
private var isDisplayAnim = false
companion object {
@@ -199,11 +214,11 @@ class MapStyleParams: IMapStyleParams {
}
override fun getVrPerspectiveMode(): Float{
return vrPerspectiveMode
return vrPerspectiveModeAngle
}
override fun setVrPerspectiveMode(vrPerspectiveMode: Float): MapStyleParams{
this.vrPerspectiveMode = vrPerspectiveMode
override fun setVrPerspectiveMode(vrPerspectiveModeAngle: Float): MapStyleParams{
this.vrPerspectiveModeAngle = vrPerspectiveModeAngle
return this
}
@@ -285,34 +300,34 @@ class MapStyleParams: IMapStyleParams {
return this
}
override fun getDefaultPerspective(): Int{
return default_perspective
override fun getVrAngleDefaultMode(): Int{
return vrAngleDefaultMode
}
override fun setDefaultPerspective(type: Int): MapStyleParams{
default_perspective = type
override fun setVrAngleDefaultMode(type: Int): MapStyleParams{
vrAngleDefaultMode = type
return this
}
override fun setIsSkyBoxEnable(isEnable: Boolean): MapStyleParams{
override fun setSkyBoxEnable(isEnable: Boolean): MapStyleParams{
isSkyBoxEnable = isEnable
return this
}
override fun getIsSkyBoxEnable(): Boolean{
override fun isSkyBoxEnable(): Boolean{
return isSkyBoxEnable
}
override fun setIsWeatherEnable(isEnable: Boolean): MapStyleParams{
override fun setWeatherEnable(isEnable: Boolean): MapStyleParams{
isWeatherEnable = isEnable
return this
}
override fun getIsWeatherEnable(): Boolean{
override fun isWeatherEnable(): Boolean{
return isWeatherEnable
}
@@ -334,9 +349,18 @@ class MapStyleParams: IMapStyleParams {
return mLocationIconRes
}
override fun setIsDisplayAnim(isEnable: Boolean): MapStyleParams {
isDisplayAnim = isEnable
return this
}
override fun isDisplayAnim(): Boolean {
return isDisplayAnim
}
override fun toString(): String {
return "MapStyleParams( zoom=$zoom, carPosition=$carPosition, isAutoSwitch=$isAutoSwitch, isAutoLocation=$isAutoLocation, hdVisibileArray=${hdVisibleArray.contentToString()}, styleMode=$styleMode, perspectiveMode=$perspectiveMode, vrPerspectiveMode=$vrPerspectiveMode, vrAngleMode=$vrAngleMode, isSwitchViewAngle=$isSwitchViewAngle, vrEyeHeight=$vrEyeHeight, zoomVal=$zoomVal, minDistanceForPosition=$minDistanceForPosition, isShadowEnable=$isShadowEnable, styleName='$styleName')"
return "MapStyleParams( zoom=$zoom, carPosition=$carPosition, isAutoSwitch=$isAutoSwitch, isAutoLocation=$isAutoLocation, hdVisibileArray=${hdVisibleArray.contentToString()}, styleMode=$styleMode, perspectiveMode=$perspectiveMode, vrPerspectiveModeAngle=$vrPerspectiveModeAngle, vrAngleMode=$vrAngleMode, isSwitchViewAngle=$isSwitchViewAngle, vrEyeHeight=$vrEyeHeight, zoomVal=$zoomVal, minDistanceForPosition=$minDistanceForPosition, isShadowEnable=$isShadowEnable, styleName='$styleName')"
}