同步3.1.0修改
This commit is contained in:
@@ -65,7 +65,7 @@ dependencies {
|
||||
|
||||
|
||||
implementation 'com.zhidaoauto.map:net:1.0.1'
|
||||
implementation 'com.zhidaoauto.machine:mapcore:3.0.0.5'
|
||||
implementation 'com.zhidaoauto.machine:mapcore:3.1.0.20'
|
||||
implementation 'com.zhidaoauto.machine:mapdata:1.0.0.2'
|
||||
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ uniform bool isWater; //水系
|
||||
uniform vec4 waterColor;
|
||||
uniform vec3 cameraPos;
|
||||
uniform float shadowResolution;
|
||||
uniform bool isLightWave;
|
||||
in vec4 posInLight;
|
||||
in vec4 _color;
|
||||
in highp vec3 posInEye;
|
||||
@@ -38,12 +39,14 @@ uniform float waveTime;
|
||||
in highp float waveOff;
|
||||
out vec4 fragColor;
|
||||
in float distanceFromCamera;
|
||||
in float guideLineTexY;
|
||||
|
||||
uniform bool isFogEnable;
|
||||
uniform vec3 fogColor;
|
||||
uniform float fogStart;
|
||||
uniform float fogEnd;
|
||||
uniform float fogDensity;
|
||||
uniform bool isGuideLine; //引导线
|
||||
void setSpotLightColor(){ //聚光灯光照效果
|
||||
lowp float r_base= 4.0;
|
||||
lowp float r_max = spotRadius * 32.0;
|
||||
@@ -141,6 +144,11 @@ void setLinearFog()
|
||||
fogAlpha=clamp(fogAlpha,0.0,1.0)*fogDensity;
|
||||
fragColor.rgb = mix(fragColor.rgb,fogColor,fogAlpha);
|
||||
}
|
||||
void setGuideLine(){
|
||||
fragColor = texture(texId,_uv);
|
||||
// if(fragColor.a>0.1)
|
||||
// fragColor.a = clamp(1.0/guideLineTexY,0.0,1.0);
|
||||
}
|
||||
void main()
|
||||
{
|
||||
|
||||
@@ -150,6 +158,8 @@ void main()
|
||||
setSignalLine();
|
||||
else if (isWave)
|
||||
setWave();
|
||||
else if(isGuideLine)
|
||||
setGuideLine();
|
||||
else if (isRenderText)
|
||||
setText();
|
||||
else if (isTex)
|
||||
@@ -165,5 +175,9 @@ void main()
|
||||
fragColor = waterColor*dot(normalize(fragColor.rgb), vec3(0.0, 0.0, 1.0));
|
||||
fragColor.a = 1.0;
|
||||
}
|
||||
if(isLightWave){
|
||||
if(_uv.y>0.9)
|
||||
fragColor.a = 0.0;
|
||||
}
|
||||
setLinearFog();
|
||||
}
|
||||
@@ -5,6 +5,9 @@ in float _alphaFac;
|
||||
layout(location = 0) out vec4 color;
|
||||
void main()
|
||||
{
|
||||
color = texture(tex,gl_PointCoord);
|
||||
vec4 c = texture(tex,gl_PointCoord);
|
||||
if(c.a<0.3)
|
||||
discard;
|
||||
color = c;
|
||||
color.a = color.a * _alphaFac;
|
||||
}
|
||||
@@ -25,6 +25,8 @@ uniform float waterTime; //水系滚动时间
|
||||
uniform bool isRenderDivider;
|
||||
uniform vec3 dividerPos0;
|
||||
uniform vec3 dividerPos1;
|
||||
uniform bool isGuideLine; //引导线
|
||||
uniform float guideLineTime;
|
||||
layout( location = 0 ) in vec4 pos;
|
||||
layout(location = 1) in vec4 color;
|
||||
layout(location = 3) in vec2 uv;
|
||||
@@ -34,6 +36,7 @@ out vec3 posInEye; //片元的view坐标
|
||||
out vec2 _uv;
|
||||
out float signalLineTexY;
|
||||
out float waveOff;
|
||||
out float guideLineTexY;
|
||||
void setZebra(){
|
||||
vec4 pos0 = projMat*viewMat*modelMat * vec4(zebraPos0,1.0);
|
||||
vec4 pos1 = projMat*viewMat*modelMat * vec4(zebraPos1,1.0);
|
||||
@@ -83,6 +86,12 @@ void setSignalLine(){
|
||||
_uv = _uv + vec2(0.0,1.0)*signalLineTime;
|
||||
}
|
||||
}
|
||||
void setGuideLine(){
|
||||
_uv.x = uv.x;
|
||||
_uv.y = -uv.y;
|
||||
_uv = _uv + vec2(0.0,1.0)*guideLineTime;
|
||||
guideLineTexY = uv.y;
|
||||
}
|
||||
void main()
|
||||
{
|
||||
setPosInEye();
|
||||
@@ -112,5 +121,7 @@ void main()
|
||||
setWater();
|
||||
if(isRenderSignalLine)
|
||||
setSignalLine();
|
||||
if(isGuideLine)
|
||||
setGuideLine();
|
||||
gl_Position = projMat*viewMat*modelMat * pos;
|
||||
}
|
||||
BIN
libraries/mapmodule/src/main/assets/style/guideLine.png
Normal file
BIN
libraries/mapmodule/src/main/assets/style/guideLine.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 618 B |
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 261 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 265 KiB |
BIN
libraries/mapmodule/src/main/assets/style/lightWave.png
Normal file
BIN
libraries/mapmodule/src/main/assets/style/lightWave.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
@@ -4,5 +4,5 @@ public class Common {
|
||||
static {
|
||||
System.loadLibrary("common");
|
||||
}
|
||||
public native void setCfgKeyVal(String key, String val);
|
||||
// public native void setCfgKeyVal(String key, String val);
|
||||
}
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.autonavi.nge;
|
||||
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig;
|
||||
import com.zhidaoauto.map.sdk.inner.road.RoadResultController;
|
||||
|
||||
@@ -21,7 +18,7 @@ public class MapBox {
|
||||
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);
|
||||
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);
|
||||
@@ -49,12 +46,14 @@ public class MapBox {
|
||||
|
||||
public native void llaRelease();
|
||||
|
||||
static void resultCallback(String key,String result){
|
||||
static void resultCallbackByteStream(String key,byte[] result){
|
||||
if(CompileConfig.INSTANCE.getDEBUG()){
|
||||
Log.d(TAG, "roadop--resultCallback: " +"key:" + key + " result:" + result);
|
||||
// Log.d(TAG, "roadop--resultCallbackDouble: " +"key:" + key + " + " result:"+ result.length);
|
||||
}
|
||||
if (result == null || result.length < 1) {
|
||||
return;
|
||||
}
|
||||
RoadResultController.getInstance().dispatchRoadResult(0,key,result);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.autonavi.nge.dm;//package com.autonavi.nge.dm;
|
||||
//package com.autonavi.nge.dm;
|
||||
//
|
||||
//import android.os.RemoteException;
|
||||
//import android.util.Log;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.autonavi.nge.guidance;//package com.autonavi.nge.guidance;
|
||||
//package com.autonavi.nge.guidance;
|
||||
//
|
||||
//import android.util.Log;
|
||||
//
|
||||
|
||||
@@ -985,6 +985,12 @@ class MapEngine {
|
||||
}
|
||||
}
|
||||
|
||||
fun setCfgKeyVal(key: String?, value: String?) {
|
||||
if(mObj != 0L){
|
||||
setCfgKeyValJni(mObj,key,value)
|
||||
}
|
||||
}
|
||||
|
||||
fun unload() {
|
||||
Log.i(TAG, "MapEngine: unload")
|
||||
if (mObj != 0L) {
|
||||
@@ -992,7 +998,22 @@ class MapEngine {
|
||||
mObj = 0
|
||||
}
|
||||
}
|
||||
fun setLightWave(da:DoubleArray){
|
||||
if (mObj != 0L) {
|
||||
setLightWaveJni(mObj,da)
|
||||
}
|
||||
}
|
||||
|
||||
fun setGuideLine(da:DoubleArray?){
|
||||
if (mObj != 0L) {
|
||||
setGuideLineJni(mObj,da)
|
||||
}
|
||||
}
|
||||
fun setTexture(name: String,ba:ByteArray?){
|
||||
if (mObj != 0L) {
|
||||
setTextureJni(mObj,name,ba)
|
||||
}
|
||||
}
|
||||
private external fun loadJni(projectDir: String, mapView: MapView?,assetManager: AssetManager?): Long
|
||||
|
||||
private external fun resizeJni(obj:Long,newWidth: Int, newHeight: Int)
|
||||
@@ -1595,9 +1616,14 @@ class MapEngine {
|
||||
color: FloatArray
|
||||
)
|
||||
|
||||
private external fun setCfgKeyValJni(obj: Long,key: String?,value: String?)
|
||||
|
||||
private external fun clearAllPrimitivesJni(obj: Long): Boolean
|
||||
|
||||
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")啥的
|
||||
}
|
||||
@@ -8,7 +8,6 @@ import com.zhidaoauto.map.data.road.RoadCross
|
||||
import com.zhidaoauto.map.data.road.StopLine
|
||||
import com.zhidaoauto.map.sdk.open.abs.MapStatusListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnCameraChangeListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapChangeListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapClickListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnMapLoadedListener
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.autonavi.nge.map.Pixels
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.inner.element.MapCoordinate
|
||||
import com.zhidaoauto.map.sdk.inner.use.Clerk
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.view.IMapStyleParams
|
||||
import com.zhidaoauto.map.sdk.open.circle.CircleController
|
||||
import com.zhidaoauto.map.sdk.open.circle.CircleOptions
|
||||
@@ -26,6 +25,8 @@ interface IMapController {
|
||||
fun getContext():Context?
|
||||
fun setMarkerCall(markerCall:IMarkerCall)
|
||||
fun setLocalView(localView: ILocationView?)
|
||||
|
||||
fun getLocalView(): ILocationView?
|
||||
fun getMarkerCall():IMarkerCall?
|
||||
fun getMapStyleParams(): IMapStyleParams
|
||||
fun getClerk():Clerk?
|
||||
@@ -459,5 +460,15 @@ interface IMapController {
|
||||
|
||||
fun setFogMode(isEnable: Boolean)
|
||||
|
||||
fun setLightWave(list: List<LonLatPoint>, width: Double, duration: Double)
|
||||
|
||||
fun setGuideLine(list: List<LonLatPoint>?)
|
||||
|
||||
fun setRoadTexSize(size: Float)
|
||||
|
||||
fun setRoadUseTexture(isEnable: Boolean)
|
||||
|
||||
fun setPlaneUseTexture(isEnable: Boolean)
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.zhidaoauto.map.sdk.inner.abs
|
||||
|
||||
interface IRoadData {
|
||||
|
||||
fun result(code:Int,result:String?)
|
||||
fun result(code: Int, result: ByteArray?)
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package com.zhidaoauto.map.sdk.inner.common
|
||||
|
||||
import com.autonavi.nge.Common
|
||||
|
||||
class CommonHelper {
|
||||
private var common: Common
|
||||
|
||||
private constructor() {
|
||||
common = Common()
|
||||
|
||||
}
|
||||
|
||||
|
||||
companion object{
|
||||
var sInstance: CommonHelper? = null
|
||||
|
||||
@Synchronized
|
||||
fun getInstance(): CommonHelper? {
|
||||
if (sInstance == null) {
|
||||
sInstance = CommonHelper()
|
||||
}
|
||||
return sInstance
|
||||
}
|
||||
}
|
||||
|
||||
fun setCfgKeyVal(key: String, value: String){
|
||||
common.setCfgKeyVal(key, value)
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,8 @@ object ConstantExt {
|
||||
//漫游距离8公里
|
||||
const val ROAM_DIS_8KM = 8000f
|
||||
|
||||
const val ROAM_DIS_MAX = 1800f
|
||||
|
||||
//漫游速度30m/s
|
||||
const val ROAM_SPEED_30 = 30f
|
||||
//漫游速度40m/s
|
||||
@@ -116,11 +118,11 @@ object ConstantExt {
|
||||
|
||||
|
||||
//漫游模式 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_ROAM = 12.5f
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_ROAM = 17.5f
|
||||
//漫游模式 缩放值
|
||||
const val MAP_STYLE_VR_ZOOM_VAL_ROAM = 0.8f
|
||||
//漫游模式 高度
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_ROAM = 23f
|
||||
const val MAP_STYLE_VR_EYE_HEIGHT_ROAM = 55f
|
||||
|
||||
//过渡模式 角度
|
||||
const val MAP_STYLE_VR_OVER_LOOK_ANGLE_TRANS = 12.5f
|
||||
@@ -166,6 +168,9 @@ object ConstantExt {
|
||||
//设置天空盒
|
||||
const val FOG = "fog"
|
||||
const val SKYBOX = "skybox"
|
||||
const val ROADTEXSIZE = "roadTexSize"
|
||||
const val ROAD = "roadUseTex"
|
||||
const val PLANE = "planeUseTex"
|
||||
|
||||
//地图视角测试
|
||||
//地图测试视角角度
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.zhidaoauto.map.sdk.inner.abs.IMapController
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapView
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMarkerCall
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMarkerController
|
||||
import com.zhidaoauto.map.sdk.inner.common.CommonHelper
|
||||
import com.zhidaoauto.map.sdk.inner.common.ConstantExt
|
||||
import com.zhidaoauto.map.sdk.inner.element.M3DCar
|
||||
import com.zhidaoauto.map.sdk.inner.element.MapCoordinate
|
||||
@@ -206,6 +205,10 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
mILocationView = localView
|
||||
}
|
||||
|
||||
override fun getLocalView(): ILocationView?{
|
||||
return mILocationView
|
||||
}
|
||||
|
||||
override fun getMarkerCall(): IMarkerCall? {
|
||||
return mMarkerCall
|
||||
}
|
||||
@@ -529,6 +532,41 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
return mMapView.getMapEngine().getRulerInfo()
|
||||
}
|
||||
|
||||
|
||||
override fun setLightWave(list: List<LonLatPoint>, width: Double, duration: Double) {
|
||||
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
|
||||
}
|
||||
data[i] = width
|
||||
data[i+1] = duration
|
||||
mMapView.getMapEngine().setLightWave(data)
|
||||
}
|
||||
|
||||
override fun setGuideLine(list: List<LonLatPoint>?) {
|
||||
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
|
||||
}
|
||||
mMapView.getMapEngine().setGuideLine(data)
|
||||
}else{
|
||||
mMapView.getMapEngine().setGuideLine(null)
|
||||
}
|
||||
}
|
||||
|
||||
override fun setShowAllRouteLine(isShowAllRouteLine: Boolean) {
|
||||
// if (isShowAllRouteLine) {
|
||||
// if (!instance.naviAutoView!!.isFirst) {
|
||||
@@ -627,6 +665,9 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
|
||||
|
||||
override fun dispatchZoomChanged() {
|
||||
if(!isSurfaceCreated()) {
|
||||
return
|
||||
}
|
||||
setMarkerScale()
|
||||
val currentZoom = getZoom()
|
||||
if (DEBUG) {
|
||||
@@ -898,7 +939,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
lon: Double,
|
||||
lat: Double,
|
||||
alt: Float,
|
||||
rotateAngle: Float,
|
||||
rotateAngle: Float, //加是逆时针,减是顺时针
|
||||
mDuration: Int
|
||||
) {
|
||||
var arrays = mapAnimate.stepAnimation()
|
||||
@@ -1203,10 +1244,10 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
}
|
||||
}
|
||||
var list = CopyOnWriteArrayList<LonLatPoint>()
|
||||
var mRoamlist = CopyOnWriteArrayList<LonLatPoint>()
|
||||
var remainList = CopyOnWriteArrayList<LonLatPoint>()
|
||||
var lastlonlat = LonLatPoint()
|
||||
var postion = 0
|
||||
var mLastPosition = LonLatPoint()
|
||||
var mRoamPostion = 0
|
||||
override fun setMapViewVisualAngle(type: Int) {
|
||||
mHandler.removeMessages(LOCK_CAR)
|
||||
mHandler.removeMessages(CHANGE_VIEW_ANGLE)
|
||||
@@ -1216,24 +1257,24 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "Roam--op--status: 结束漫游 切换视角:${type}")
|
||||
}
|
||||
isRoam.set(false)
|
||||
mRoamPostion = 0
|
||||
mRoamlist.clear()
|
||||
remainList.clear()
|
||||
roadLineJob?.cancel()
|
||||
roadLeaveLineJob?.cancel()
|
||||
roadLineTimeJob?.cancel()
|
||||
roamJob?.cancel()
|
||||
mEventController?.dispatchRoamStatusListener(3, "切换视角结束漫游:$type")
|
||||
}
|
||||
isRoam.set(false)
|
||||
postion = 0
|
||||
list.clear()
|
||||
remainList.clear()
|
||||
roadLineJob?.cancel()
|
||||
roadLeaveLineJob?.cancel()
|
||||
roadLineTimeJob?.cancel()
|
||||
roamJob?.cancel()
|
||||
transJob?.cancel()
|
||||
//还原漫游模式状态结束
|
||||
if (mLockLocation.getLockCar() == false && type != ConstantExt.MAP_STYLE_VR_ROAM) {
|
||||
mLockLocation.setLockCar(true)
|
||||
}
|
||||
if (type != ConstantExt.MAP_STYLE_VR_SKY_BOX) {
|
||||
CommonHelper.getInstance()?.setCfgKeyVal(ConstantExt.FOG, "disable")
|
||||
CommonHelper.getInstance()?.setCfgKeyVal(ConstantExt.SKYBOX, "disable")
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.FOG, "disable")
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.SKYBOX, "disable")
|
||||
}
|
||||
// mMapView.setIsFarViewAngel(false)
|
||||
when (type) {
|
||||
@@ -1268,8 +1309,9 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
|
||||
ConstantExt.MAP_STYLE_VR_SKY_BOX -> {
|
||||
CommonHelper.getInstance()?.setCfgKeyVal(ConstantExt.FOG, "enable")
|
||||
CommonHelper.getInstance()?.setCfgKeyVal(ConstantExt.SKYBOX, "enable")
|
||||
// mMapView.getMapEngine().setCfgKeyVal("isSkyBoxFastChange", "disable")
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.FOG, "enable")
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.SKYBOX, "enable")
|
||||
}
|
||||
|
||||
ConstantExt.MAP_STYLE_VR_ANGLE_FAR -> {
|
||||
@@ -1397,262 +1439,191 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
|
||||
fun setRoamStyle() {
|
||||
roadLineTimeJob?.cancel()
|
||||
roadLineTimeJob = getScope()?.launch(Dispatchers.Default)
|
||||
{
|
||||
delay(3000)
|
||||
Log.d(TAG, "Roam--op--status:获取数据超时")
|
||||
roadLineJob?.cancel()
|
||||
mEventController?.dispatchRoamStatusListener(
|
||||
1,
|
||||
"进入漫游模式失败:获取数据超时"
|
||||
)
|
||||
}
|
||||
mRoamPostion = 0
|
||||
mRoamlist.clear()
|
||||
roadLineJob?.cancel()
|
||||
roadLineJob = getScope()?.launch(Dispatchers.IO) {
|
||||
var currentLonLat = mLockLocation.getCurrentLonLatPoint()
|
||||
lastlonlat = currentLonLat
|
||||
if (mTravel.isNotEmpty() && isUseTrace == 1) {
|
||||
list = CopyOnWriteArrayList(
|
||||
MathUtils.getSmoothPoints(
|
||||
MathUtils.getSubList(
|
||||
currentLonLat,
|
||||
MathUtils.getPoints(MathUtils.getTravelList(mTravel), mSpeed * 0.1f),
|
||||
mRoamDis
|
||||
)
|
||||
roadLineTimeJob?.cancel()
|
||||
roamJob?.cancel()
|
||||
|
||||
var currentLonLat = mLockLocation.getCurrentLonLatPoint()
|
||||
mLastPosition = currentLonLat
|
||||
if (mTravel.isNotEmpty() && isUseTrace == 1) {
|
||||
mRoamlist = CopyOnWriteArrayList(
|
||||
MathUtils.getSmoothPoints(
|
||||
MathUtils.getSubList(
|
||||
currentLonLat,
|
||||
MathUtils.getPoints(MathUtils.getTravelList(mTravel), mSpeed * 0.1f),
|
||||
mRoamDis
|
||||
)
|
||||
)
|
||||
}
|
||||
if (list.size < 2) {
|
||||
var dis = mRoamDis
|
||||
var leaveDis = 0f
|
||||
if (mRoamDis > DEFAULT_ROAM_DIS) {
|
||||
dis = DEFAULT_ROAM_DIS
|
||||
leaveDis = mRoamDis - dis
|
||||
}
|
||||
)
|
||||
}
|
||||
if(mRoamlist.size >=2) {
|
||||
startRoam()
|
||||
}else {
|
||||
var isCancelTimeJob = AtomicBoolean(false)
|
||||
var isCancelRoadLineJob = AtomicBoolean(false)
|
||||
roadLineJob?.cancel()
|
||||
roadLineJob = getScope()?.launch(Dispatchers.IO) {
|
||||
RoadHelper.getInstance()?.getCenterLineRoadNode(
|
||||
currentLonLat.longitude,
|
||||
currentLonLat.latitude,
|
||||
currentLonLat.angle.toFloat(),
|
||||
dis,
|
||||
mRoamDis,
|
||||
object : IResult<CenterLine> {
|
||||
override fun result(code: Int, rodeCenterLine: CenterLine?) {
|
||||
|
||||
if(isCancelRoadLineJob.get()) {
|
||||
return
|
||||
}
|
||||
roadLineTimeJob?.cancel()
|
||||
isCancelTimeJob.set(true)
|
||||
if (rodeCenterLine != null && rodeCenterLine!!.points != null && rodeCenterLine.points!!.size >= 2) {
|
||||
roadLineTimeJob?.cancel()
|
||||
list = CopyOnWriteArrayList(
|
||||
mRoamlist = CopyOnWriteArrayList(
|
||||
MathUtils.getSmoothPoints(
|
||||
MathUtils.getPoints(
|
||||
ArrayList(rodeCenterLine.points), mSpeed * 0.1f
|
||||
ArrayList(rodeCenterLine.points),
|
||||
mSpeed * 0.1f
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
if (list.size >= 2) {
|
||||
if (mRoamlist.size >= 2) {
|
||||
startRoam()
|
||||
if (leaveDis > 0f) {
|
||||
getLeaveData(leaveDis)
|
||||
}
|
||||
} else {
|
||||
}else{
|
||||
if (DEBUG) {
|
||||
Log.i(
|
||||
TAG,
|
||||
"Roam--op--status: 进入漫游模式失败:获取数据无效:${list.size}"
|
||||
)
|
||||
Log.i(TAG, "Roam--op--status: 进入漫游模式失败:获取数据无效:${mRoamlist.size}")
|
||||
}
|
||||
mEventController?.dispatchRoamStatusListener(
|
||||
1,
|
||||
"进入漫游模式失败:获取数据无效:${list.size}"
|
||||
)
|
||||
mEventController?.dispatchRoamStatusListener(1, "进入漫游模式失败:获取数据无效:${mRoamlist.size}")
|
||||
}
|
||||
} else {
|
||||
roadLineTimeJob?.cancel()
|
||||
if (DEBUG) {
|
||||
Log.i(
|
||||
TAG,
|
||||
"Roam--op--status: 进入漫游模式失败:获取数据无效:${list.size}"
|
||||
"Roam--op--status: 进入漫游模式失败:获取数据无效:${mRoamlist.size}"
|
||||
)
|
||||
}
|
||||
mEventController?.dispatchRoamStatusListener(
|
||||
1,
|
||||
"进入漫游模式失败:获取数据无效:${list.size}"
|
||||
"进入漫游模式失败:获取数据无效:${mRoamlist.size}"
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
} else {
|
||||
roadLineTimeJob?.cancel()
|
||||
startRoam()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun getLeaveData(leaveDis: Float) {
|
||||
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "Roam--op--status: 获取剩余数据,leaveDis:${leaveDis}米")
|
||||
}
|
||||
var size = list.size
|
||||
if (size < 2) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
var startLonLatPoint = list[size - 2]
|
||||
var endLonLatPoint = list[size - 1]
|
||||
var angle = GisGeomTool.GetLineAngle(
|
||||
startLonLatPoint.longitude,
|
||||
startLonLatPoint.latitude,
|
||||
endLonLatPoint.longitude,
|
||||
endLonLatPoint.latitude
|
||||
)
|
||||
RoadHelper.getInstance()?.getCenterLineRoadNode(
|
||||
endLonLatPoint.longitude,
|
||||
endLonLatPoint.latitude,
|
||||
angle.toFloat(),
|
||||
leaveDis,
|
||||
object : IResult<CenterLine> {
|
||||
override fun result(code: Int, rodeCenterLineLeave: CenterLine?) {
|
||||
if (rodeCenterLineLeave != null && rodeCenterLineLeave!!.points != null && rodeCenterLineLeave.points!!.size >= 2) {
|
||||
remainList = CopyOnWriteArrayList(
|
||||
MathUtils.getSmoothPoints(
|
||||
MathUtils.getPoints(
|
||||
ArrayList(rodeCenterLineLeave.points), mSpeed * 0.1f
|
||||
)
|
||||
)
|
||||
)
|
||||
if (remainList.size >= 2) {
|
||||
var disRoam =
|
||||
MathUtils.distance(remainList.first(), remainList.last())
|
||||
if (disRoam < 300) {
|
||||
Log.e(
|
||||
TAG,
|
||||
"Roam--op--status: 获取剩余数据失败,剩余数据距离: ${String.format("%.1f", disRoam)}米"
|
||||
)
|
||||
remainList.clear()
|
||||
} else {
|
||||
if (DEBUG) {
|
||||
Log.i(
|
||||
TAG,
|
||||
"Roam--op--status: 获取剩余数据成功:${remainList.size}"
|
||||
)
|
||||
} else {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Roam--op--status: 获取剩余数据无效:${remainList.size}")
|
||||
}
|
||||
} else {
|
||||
Log.e(TAG, "Roam--op--status: 获取剩余数据无效")
|
||||
}
|
||||
roadLineTimeJob?.cancel()
|
||||
roadLineTimeJob = getScope()?.launch(Dispatchers.Default) {
|
||||
delay(3000)
|
||||
if(!isCancelTimeJob.get()) {
|
||||
Log.d(TAG, "Roam--op--status:获取数据超时")
|
||||
roadLineJob?.cancel()
|
||||
isCancelRoadLineJob.set(true)
|
||||
withContext(Dispatchers.Main) {
|
||||
mEventController?.dispatchRoamStatusListener(1, "进入漫游模式失败:获取数据超时")
|
||||
}
|
||||
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private fun startRoam() {
|
||||
|
||||
|
||||
try {
|
||||
var disRoam = MathUtils.distance(list.first(), list.last())
|
||||
|
||||
|
||||
if (disRoam < 300) {
|
||||
|
||||
Log.e(
|
||||
TAG,
|
||||
"Roam--op--status: 进入漫游模式失败:获取数据距离太短: ${String.format("%.1f", disRoam)}米"
|
||||
)
|
||||
mEventController?.dispatchRoamStatusListener(
|
||||
1,
|
||||
"进入漫游模式失败:获取数据距离太短: ${String.format("%.1f", disRoam)}米"
|
||||
)
|
||||
return
|
||||
|
||||
}
|
||||
roamJob?.cancel()
|
||||
|
||||
roamJob = getDemaningScope()?.launch(Dispatchers.IO) {
|
||||
roamJob?.cancel()
|
||||
roamJob = getDemaningScope()?.launch(Dispatchers.IO) {
|
||||
try {
|
||||
var disRoam = MathUtils.distance(mRoamlist.first(), mRoamlist.last())
|
||||
if (disRoam < 100) {
|
||||
Log.e(TAG, "Roam--op--status: 进入漫游模式失败:获取数据距离太短: ${String.format("%.1f", disRoam)}米")
|
||||
withContext(Dispatchers.Main) {
|
||||
mEventController?.dispatchRoamStatusListener(1, "进入漫游模式失败:获取数据距离太短: ${String.format("%.1f", disRoam)}米")
|
||||
}
|
||||
return@launch
|
||||
}
|
||||
isRoam.set(true)
|
||||
interpolation(
|
||||
ConstantExt.MAP_STYLE_VR_EYE_HEIGHT_ROAM,
|
||||
ConstantExt.MAP_STYLE_VR_OVER_LOOK_ANGLE_ROAM,
|
||||
ConstantExt.MAP_STYLE_VR_ZOOM_VAL_ROAM,
|
||||
ConstantExt.MAP_STYLE_VR_ROAM,
|
||||
100
|
||||
)
|
||||
delay(100)
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "Roam--op--status: 进入漫游模式成功:${mRoamlist.size}")
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
mEventController?.dispatchRoamStatusListener(0, "进入漫游模式成功:${mRoamlist.size}")
|
||||
}
|
||||
if(mRoamlist.size > 10) {
|
||||
mRoamlist = CopyOnWriteArrayList(mRoamlist.subList(10, mRoamlist.size))
|
||||
}
|
||||
|
||||
val location = mRoamlist.get(0)
|
||||
val currentPostion = mLockLocation.getCurrentLonLatPoint()
|
||||
val angle = currentPostion.angle
|
||||
val dis = MathUtils.distance(currentPostion, location)
|
||||
val time = dis / mSpeed * 1000
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "Roam--op--time: ${time}ms")
|
||||
}
|
||||
mMapView.removeTouch()
|
||||
if (mLockLocation.getLockCar()) {
|
||||
mLockLocation.setLockCar(false)
|
||||
}
|
||||
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())
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "Roam--op--status: 进入漫游模式成功:${list.size}")
|
||||
Log.i(TAG, "Roam--op--status: 切换漫游视角成功")
|
||||
}
|
||||
withContext(Dispatchers.Main) {
|
||||
mEventController?.dispatchRoamStatusListener(
|
||||
0,
|
||||
"进入漫游模式成功:${list.size}"
|
||||
)
|
||||
mEventController?.dispatchRoamStatusListener(4, "切换漫游视角成功")
|
||||
}
|
||||
if(mRoamlist.size > 1) {
|
||||
mRoamlist = CopyOnWriteArrayList(mRoamlist.subList(1, mRoamlist.size))
|
||||
}
|
||||
withContext(Dispatchers.IO) {
|
||||
while (isRoam.get()) {
|
||||
dealRoamMode()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}catch (e: NoSuchElementException) {
|
||||
Log.e(
|
||||
TAG,
|
||||
"Roam--op--status: 进入漫游模式失败"
|
||||
)
|
||||
mEventController?.dispatchRoamStatusListener(
|
||||
1,
|
||||
"进入漫游模式失败"
|
||||
)
|
||||
} catch (e: Exception){
|
||||
if(mRoamlist.size > 0) {
|
||||
Log.e(TAG, "Roam--op--status: 进入漫游模式失败")
|
||||
isRoam.set(false)
|
||||
withContext(Dispatchers.Main) {
|
||||
mEventController?.dispatchRoamStatusListener(1, "进入漫游模式失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun dealRoamMode(){
|
||||
if (postion < list.size) {
|
||||
var location = list[postion]
|
||||
if (mRoamPostion < mRoamlist.size) {
|
||||
var location = mRoamlist[mRoamPostion]
|
||||
var angle = GisGeomTool.GetLineAngle(
|
||||
lastlonlat.longitude,
|
||||
lastlonlat.latitude,
|
||||
mLastPosition.longitude,
|
||||
mLastPosition.latitude,
|
||||
location.longitude,
|
||||
location.latitude
|
||||
)
|
||||
|
||||
if(postion == 0){
|
||||
angle = lastlonlat.angle
|
||||
if(mRoamPostion == 0){
|
||||
angle = mLastPosition.angle
|
||||
}
|
||||
if (Math.abs(lastlonlat.angle - angle) < 3.5) {
|
||||
angle = lastlonlat.angle
|
||||
if (Math.abs(mLastPosition.angle - angle) < 3.5) {
|
||||
angle = mLastPosition.angle
|
||||
}
|
||||
|
||||
location.angle = angle
|
||||
animateTo(location.longitude, location.latitude, 0f, -location.angle.toFloat(), 100)
|
||||
lastlonlat = location
|
||||
postion += 1
|
||||
delay(100)
|
||||
mLastPosition = location
|
||||
mRoamPostion += 1
|
||||
}else{
|
||||
postion = 0
|
||||
list.clear()
|
||||
mRoamPostion = 0
|
||||
mRoamlist.clear()
|
||||
if(remainList.size >= 2){
|
||||
list.addAll(remainList)
|
||||
mRoamlist.addAll(remainList)
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "Roam--op--status: 剩余轨迹:${list.size}")
|
||||
Log.i(TAG, "Roam--op--status: 剩余轨迹:${mRoamlist.size}")
|
||||
}
|
||||
remainList.clear()
|
||||
}else {
|
||||
@@ -2050,7 +2021,7 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
}
|
||||
|
||||
override fun setWeatherType(type: String) {
|
||||
CommonHelper.getInstance()?.setCfgKeyVal(ConstantExt.WEATHER, type)
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.WEATHER, type)
|
||||
}
|
||||
|
||||
override fun getWeatherInfo(lon: Double, lat: Double, call: WeatherResult) {
|
||||
@@ -2068,10 +2039,32 @@ class MapController(private var context: Context?, private val mMapView: IMapVie
|
||||
override fun setFogMode(isEnable: Boolean)
|
||||
{
|
||||
if(isEnable){
|
||||
CommonHelper.getInstance()?.setCfgKeyVal(ConstantExt.FOG, "enable")
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.FOG, "enable")
|
||||
}else{
|
||||
CommonHelper.getInstance()?.setCfgKeyVal(ConstantExt.FOG, "disable")
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.FOG, "disable")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun setRoadTexSize(size: Float){
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.ROADTEXSIZE, "${size}")
|
||||
}
|
||||
|
||||
override fun setRoadUseTexture(isEnable: Boolean){
|
||||
if(isEnable){
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.ROAD, "enable")
|
||||
}else{
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.ROAD, "disable")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun setPlaneUseTexture(isEnable: Boolean){
|
||||
if(isEnable){
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.PLANE, "enable")
|
||||
}else{
|
||||
mMapView.getMapEngine().setCfgKeyVal(ConstantExt.PLANE, "disable")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import android.util.Log;
|
||||
import android.view.Menu;
|
||||
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig;
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IMapController;
|
||||
|
||||
public class PanelMap extends Panel{
|
||||
|
||||
@@ -16,7 +17,13 @@ public class PanelMap extends Panel{
|
||||
if (CompileConfig.INSTANCE.getDEBUG()) {
|
||||
Log.i(TAG, "autoop-mapop-PanelMap:init");
|
||||
}
|
||||
// addView((MapView) CommonController.getInstance().getMapView());
|
||||
setMargin(0, 0, 0, 0);
|
||||
}
|
||||
public PanelMap(Context context, IMapController mapController) {
|
||||
super(context,mapController);
|
||||
if (CompileConfig.INSTANCE.getDEBUG()) {
|
||||
Log.i(TAG, "autoop-mapop-PanelMap:init");
|
||||
}
|
||||
setMargin(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,20 +7,21 @@ 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.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.data.CityInfo
|
||||
import com.zhidaoauto.map.sdk.open.data.MapDataApi
|
||||
import com.zhidaoauto.map.data.road.*
|
||||
import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
import com.zhidaoauto.map.sdk.inner.map.MapController
|
||||
import com.zhidaoauto.map.sdk.inner.utils.TransformUtils
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
@@ -344,7 +345,7 @@ class RoadHelper {
|
||||
|
||||
fun getRoadLimitSpeed(dLon: Double, dLat: Double, fAngle: Float,call:IResult<RoadInfo>) {
|
||||
// Use input parameters to create a unique cache key
|
||||
val key = "$dLon,$dLat,$fAngle"
|
||||
val key = "llaGetRoadLimitSpeed_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}"
|
||||
|
||||
// Get cached value from LinkedHashMap
|
||||
val cachedValue = roadLimitSpeedCache.get(key)
|
||||
@@ -355,35 +356,41 @@ class RoadHelper {
|
||||
}
|
||||
|
||||
// If cached value does not exist, call llaGetRoadLimitSpeed method to get new value
|
||||
RoadResultController.instance.addRoadResultListener("llaGetRoadLimitSpeed_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}",object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--getRoadLimitSpeed-code:$code-result: $result")
|
||||
}
|
||||
if (TextUtils.isEmpty(result)){
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
val array = result.split(",")
|
||||
if(array.size < 3){
|
||||
call.result(1,null)
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
buf?.let {
|
||||
val roadInfo = RoadInfo()
|
||||
roadInfo.tileID = it.getInt()
|
||||
roadInfo.id = it.getInt()
|
||||
roadInfo.speed = it.getInt()
|
||||
roadInfo.roadID = it.getInt()
|
||||
roadInfo.laneId = it.getInt()
|
||||
if(roadInfo.speed>250){
|
||||
roadInfo.speed = lastSpeed
|
||||
}else{
|
||||
lastSpeed = roadInfo.speed
|
||||
}
|
||||
if (CompileConfig.DEBUG) {
|
||||
LogHelper.info(
|
||||
TAG,
|
||||
"roadop--getRoadLimitSpeed--roadInfo: ${roadInfo}"
|
||||
)
|
||||
}
|
||||
// Add new value to LinkedHashMap
|
||||
roadLimitSpeedCache.put(key,roadInfo)
|
||||
call.result(0,roadInfo)
|
||||
return
|
||||
}
|
||||
val roadInfo = RoadInfo()
|
||||
roadInfo.tileID = array[0].toLong()
|
||||
roadInfo.roadID = array[1].toLong()
|
||||
roadInfo.speed = array[2].toInt()
|
||||
if(roadInfo.speed>250){
|
||||
roadInfo.speed = lastSpeed
|
||||
}else{
|
||||
lastSpeed = roadInfo.speed
|
||||
}
|
||||
|
||||
// Add new value to LinkedHashMap
|
||||
roadLimitSpeedCache.put(key,roadInfo)
|
||||
call.result(0,roadInfo)
|
||||
return
|
||||
}
|
||||
call.result(1,null)
|
||||
}
|
||||
@@ -394,11 +401,13 @@ class RoadHelper {
|
||||
|
||||
fun getZebraLine(lon: Double,lat: Double,angle: Float,call:IResult<String>){
|
||||
RoadResultController.instance.addRoadResultListener("llaGetZebraLine_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}_${angle.toTenDecimalsStr()}",object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--getZebraLine-code:$code-result: $result")
|
||||
}
|
||||
call.result(code,result)
|
||||
call.result(code,null)
|
||||
}
|
||||
|
||||
})
|
||||
@@ -408,11 +417,12 @@ class RoadHelper {
|
||||
|
||||
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: String?) {
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--getTrafficLight-code:$code-result: $result")
|
||||
}
|
||||
call.result(code,result)
|
||||
call.result(code,null)
|
||||
}
|
||||
|
||||
})
|
||||
@@ -433,7 +443,7 @@ class RoadHelper {
|
||||
|
||||
fun getCenterLine(dLon: Double, dLat: Double, fAngle: Float,call: IResult<CenterLine>) {
|
||||
// Generate a unique key for this request.
|
||||
val cacheKey = "$dLon:$dLat:$fAngle"
|
||||
val cacheKey = "llaGetCenterLine_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}"
|
||||
|
||||
// If the center line for this request is already in the cache, return it.
|
||||
centerLineSingleCache.get(cacheKey)?.let { centerLine ->
|
||||
@@ -442,39 +452,52 @@ class RoadHelper {
|
||||
}
|
||||
|
||||
// If the center line is not in the cache, fetch it from the server.
|
||||
RoadResultController.instance.addRoadResultListener("llaGetCenterLine_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}",object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--getCenterLine-code:$code-result: $result")
|
||||
RoadResultController.instance.addRoadResultListener(cacheKey,object :IRoadData{
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCenterLine--code:${code}, result: ${result}")
|
||||
}
|
||||
if (TextUtils.isEmpty(result)){
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
val array = result.split(",")
|
||||
if (array.size > 5) {
|
||||
val centerLine = CenterLine(
|
||||
array[0], array[1], array[2], array[3],
|
||||
(4..array.size - 1 step 2).map { i ->
|
||||
LonLatPoint(array[i].toDouble(), array[i + 1].toDouble())
|
||||
}.toMutableList()
|
||||
)
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
|
||||
// Calculate the angle of the center line.
|
||||
buf?.let {
|
||||
var centerLine = CenterLine()
|
||||
centerLine.id = buf.getInt().toString()
|
||||
centerLine.tile_id = buf.getInt().toString()
|
||||
centerLine.road_id = buf.getInt().toString()
|
||||
centerLine.lane_id = buf.getInt().toString()
|
||||
var size = buf.getInt()
|
||||
var points = ArrayList<LonLatPoint>()
|
||||
for (i in 0 until size step 2) {
|
||||
var lonLatPoint = LonLatPoint(buf.getLong()/ 1e8, buf.getLong()/ 1e8)
|
||||
points.add(lonLatPoint)
|
||||
}
|
||||
centerLine.points = points
|
||||
val pMatch = LonLatPoint()
|
||||
MapDataApi.GetDisFromPointToLine(LonLatPoint(dLon, dLat), ArrayList(centerLine.points), pMatch, 1)
|
||||
MapDataApi.GetDisFromPointToLine(LonLatPoint(dLon, dLat), points, pMatch, 1)
|
||||
centerLine.angle = pMatch.angle
|
||||
// Add the result to the cache
|
||||
centerLineSingleCache.put(cacheKey, centerLine)
|
||||
|
||||
// Add the center line to the cache.
|
||||
centerLineSingleCache.put(cacheKey,centerLine)
|
||||
// Return the center line.
|
||||
call.result(0,centerLine)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"roadop--getCenterLine--centerLine: ${centerLine}"
|
||||
)
|
||||
}
|
||||
call.result(0, centerLine)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
call.result(0,null)
|
||||
|
||||
call.result(1,null)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
@@ -498,7 +521,7 @@ class RoadHelper {
|
||||
|
||||
fun getStopLine(dLon: Double, dLat: Double , fAngle: Float,call: IResult<StopLine>) {
|
||||
|
||||
val key = "$dLon,$dLat,$fAngle"
|
||||
val key = "llaStopLine_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}"
|
||||
|
||||
// Check if the result is in the cache
|
||||
val cachedResult = stopLineCache.get(key)
|
||||
@@ -508,60 +531,59 @@ class RoadHelper {
|
||||
}
|
||||
|
||||
// Get the stop line information from the MapBox SDK.
|
||||
RoadResultController.instance.addRoadResultListener("llaStopLine_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}",object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--getStopLine-code:$code-result: $result")
|
||||
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getStopLine-code:${code}, result: ${result}")
|
||||
}
|
||||
if (TextUtils.isEmpty(result)){
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
var result = it
|
||||
// Remove the trailing comma if present.
|
||||
if (result.endsWith(",")) {
|
||||
result = result.trim(',')
|
||||
}
|
||||
|
||||
// Parse the result into an array of strings.
|
||||
val array = result.split(",")
|
||||
|
||||
// Create a new StopLine object.
|
||||
val stopLine = StopLine()
|
||||
|
||||
// If the array contains at least six elements, parse them into the StopLine object.
|
||||
if (array != null && array.size > 5) {
|
||||
stopLine.tile_id = array[0]
|
||||
var roadId = array[1]
|
||||
if (array[1].endsWith("*")) {
|
||||
roadId = array[1].trim('*')
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
buf?.let {
|
||||
val tile_id = it.getInt()
|
||||
if(tile_id == 0){
|
||||
call.result(1,null)
|
||||
return
|
||||
}
|
||||
stopLine.road_id = roadId.split("*")
|
||||
var laneId = array[2]
|
||||
if (array[2].endsWith("*")) {
|
||||
laneId = array[2].trim('*')
|
||||
val stopLine = StopLine()
|
||||
stopLine.tile_id = "${tile_id}"
|
||||
stopLine.length = it.getInt().toDouble()
|
||||
val roadIdSize = it.getInt()
|
||||
val laneIdSize = it.getInt()
|
||||
val pointSize = it.getInt()
|
||||
var roadIds = ArrayList<String>()
|
||||
for (i in 0 until roadIdSize) {
|
||||
var roadId = it.getInt().toString()
|
||||
roadIds.add(roadId)
|
||||
}
|
||||
stopLine.lane_id = laneId.split("*")
|
||||
stopLine.length = array[3].toDouble()
|
||||
stopLine.road_id = roadIds
|
||||
var laneIds = ArrayList<String>()
|
||||
for (i in 0 until laneIdSize) {
|
||||
var laneId = it.getInt().toString()
|
||||
laneIds.add(laneId)
|
||||
}
|
||||
stopLine.lane_id = laneIds
|
||||
var points = ArrayList<LonLatPoint>()
|
||||
for (i in 4..array.size - 1 step 2) {
|
||||
val lonLatPoint = LonLatPoint(array[i].toDouble(), array[i + 1].toDouble())
|
||||
for (i in 0 until pointSize step 2) {
|
||||
var lonLatPoint = LonLatPoint(buf.getLong()/ 1e8, buf.getLong()/ 1e8)
|
||||
points.add(lonLatPoint)
|
||||
}
|
||||
stopLine.points = points
|
||||
// Print the stop line object to the log if debugging is enabled.
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getStopLine--stopLine: ${stopLine}")
|
||||
}
|
||||
stopLineCache.put(key,stopLine)
|
||||
call.result(0,stopLine)
|
||||
return
|
||||
}
|
||||
|
||||
// Print the stop line object to the log if debugging is enabled.
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getStopLine--stopLine: ${stopLine}")
|
||||
}
|
||||
stopLineCache.put(key,stopLine)
|
||||
call.result(0,stopLine)
|
||||
return
|
||||
}
|
||||
call.result(1,null)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
@@ -581,7 +603,7 @@ class RoadHelper {
|
||||
*/
|
||||
|
||||
fun getRoadRect(lon: Double, lat: Double, angle: Float,call : IResult<RoadRectInfos>) {
|
||||
val key = "$lon,$lat,$angle"
|
||||
val key = "llaMergedRoadRect_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}_${angle.toTenDecimalsStr()}"
|
||||
|
||||
// Check if the result is in the cache
|
||||
val cachedResult = roadRectCache.get(key)
|
||||
@@ -591,39 +613,46 @@ class RoadHelper {
|
||||
}
|
||||
|
||||
// Compute the result if it's not in the cache
|
||||
RoadResultController.instance.addRoadResultListener("llaMergedRoadRect_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}_${angle.toTenDecimalsStr()}",object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getRoadRect--code:${code},result: $result")
|
||||
}
|
||||
if (TextUtils.isEmpty(result)){
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
val array = result.split(",")
|
||||
val roadRectInfos = RoadRectInfos()
|
||||
val rectList = ArrayList<RoadRect>()
|
||||
if (array != null && array.size >= 9) {
|
||||
roadRectInfos.angle = array[0].toDouble()
|
||||
for (i in 1..array.size - 1 step 8) {
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
buf?.let {
|
||||
val roadRectInfos = RoadRectInfos()
|
||||
roadRectInfos.angle = it.getLong() / 1e8
|
||||
val rectList = ArrayList<RoadRect>()
|
||||
val size = it.getInt()
|
||||
for (i in 0 until size step 8) {
|
||||
val rect = RoadRect()
|
||||
rect.topLeft = LonLatPoint(array[i].toDouble(), array[i + 1].toDouble())
|
||||
rect.topRight = LonLatPoint(array[i + 2].toDouble(), array[i + 3].toDouble())
|
||||
rect.bottomLeft = LonLatPoint(array[i + 4].toDouble(), array[i + 5].toDouble())
|
||||
rect.bottomRight = LonLatPoint(array[i + 6].toDouble(), array[i + 7].toDouble())
|
||||
rect.topLeft = LonLatPoint(it.getLong() / 1e8, it.getLong() / 1e8)
|
||||
rect.topRight = LonLatPoint(it.getLong() / 1e8, it.getLong() / 1e8)
|
||||
rect.bottomLeft = LonLatPoint(it.getLong() / 1e8, it.getLong() / 1e8)
|
||||
rect.bottomRight = LonLatPoint(it.getLong() / 1e8, it.getLong() / 1e8)
|
||||
rectList.add(rect)
|
||||
}
|
||||
roadRectInfos.roadRects = rectList
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(
|
||||
TAG,
|
||||
"roadop--getRoadRect--roadRectInfos: ${roadRectInfos}"
|
||||
)
|
||||
}
|
||||
// Add the result to the cache
|
||||
roadRectCache.put(key, roadRectInfos)
|
||||
call.result(0, roadRectInfos)
|
||||
return
|
||||
}
|
||||
roadRectInfos.roadRects = rectList
|
||||
|
||||
// Add the result to the cache
|
||||
roadRectCache.put(key,roadRectInfos)
|
||||
call.result(0,roadRectInfos)
|
||||
return
|
||||
}
|
||||
call.result(1,null)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
@@ -643,9 +672,9 @@ class RoadHelper {
|
||||
//获取行驶方向一定长度的中心线
|
||||
//dDis:正 行驶方向前方距离 负 行驶方向后方距离
|
||||
|
||||
fun getCenterLineRange(dLon: Double, dlat: Double , fAngle: Float, fDis: Float,call:IResult<CenterLine>){
|
||||
fun getCenterLineRange(dLon: Double, dlat: Double , fAngle: Float, fDis: Float,isSmooth: Boolean,orders:Int, call:IResult<CenterLine>){
|
||||
// Combine the four parameters into a single string as the cache key
|
||||
val cacheKey = "$dLon,$dlat,$fAngle,$fDis"
|
||||
val cacheKey = "llaGetCenterLineRange_${dLon.toTenDecimalsStr()}_${dlat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${fDis.toTenDecimalsStr()}_${isSmooth}_${orders}"
|
||||
|
||||
// Check if the result is already cached
|
||||
// If yes, return the cached result
|
||||
@@ -653,31 +682,30 @@ class RoadHelper {
|
||||
call.result(0,it)
|
||||
return
|
||||
}
|
||||
RoadResultController.instance.addRoadResultListener("llaGetCenterLineRange_${dLon.toTenDecimalsStr()}_${dlat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${fDis.toTenDecimalsStr()}",object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
RoadResultController.instance.addRoadResultListener(cacheKey,object :IRoadData{
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCenterLineRange--code:${code},result: $result")
|
||||
Log.d(TAG, "roadop--getCenterLineRange--code:${code}, result: ${result}")
|
||||
}
|
||||
if (TextUtils.isEmpty(result)){
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
var result = it
|
||||
if(result.endsWith(",")){
|
||||
result = result.trim(',')
|
||||
}
|
||||
val array = result.split(",")
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
|
||||
if(array != null && array.size > 5) {
|
||||
val centerLine = CenterLine()
|
||||
centerLine.id = array[0]
|
||||
centerLine.tile_id = array[1]
|
||||
centerLine.road_id = array[2]
|
||||
centerLine.lane_id = array[3]
|
||||
buf?.let {
|
||||
var centerLine = CenterLine()
|
||||
centerLine.id = buf.getInt().toString()
|
||||
centerLine.tile_id = buf.getInt().toString()
|
||||
centerLine.road_id = buf.getInt().toString()
|
||||
centerLine.lane_id = buf.getInt().toString()
|
||||
var size = buf.getInt()
|
||||
var points = ArrayList<LonLatPoint>()
|
||||
for(i in 4..array.size-1 step 2){
|
||||
var lonLatPoint = LonLatPoint(array[i].toDouble(), array[i+1].toDouble())
|
||||
for (i in 0 until size step 2) {
|
||||
var lonLatPoint = LonLatPoint(buf.getLong()/ 1e8, buf.getLong()/ 1e8)
|
||||
points.add(lonLatPoint)
|
||||
}
|
||||
centerLine.points = points
|
||||
@@ -685,18 +713,25 @@ class RoadHelper {
|
||||
MapDataApi.GetDisFromPointToLine(LonLatPoint(dLon, dlat), points, pMatch, 1)
|
||||
centerLine.angle = pMatch.angle
|
||||
// Add the result to the cache
|
||||
centerLineCache.put(cacheKey,centerLine)
|
||||
call.result(0,centerLine)
|
||||
centerLineCache.put(cacheKey, centerLine)
|
||||
|
||||
if (CompileConfig.DEBUG) {
|
||||
LogHelper.info(
|
||||
TAG,
|
||||
"roadop--getCenterLineRange--centerLine: ${centerLine}"
|
||||
)
|
||||
}
|
||||
call.result(0, centerLine)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
call.result(1,null)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
mapBox.llaGetCenterLineRange(dLon,dlat,fAngle, fDis)
|
||||
mapBox.llaGetCenterLineRange(dLon,dlat,fAngle, fDis,isSmooth,orders)
|
||||
}
|
||||
|
||||
|
||||
@@ -712,7 +747,7 @@ class RoadHelper {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCenterLineRoadNode--: ${dLon}, ${dLat}, ${fAngle}")
|
||||
}
|
||||
val cacheKey = "$dLon,$dLat,$fAngle,$fDis"
|
||||
val cacheKey = "llaGetCenterLineRoadNode_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${fDis.toTenDecimalsStr()}"
|
||||
|
||||
// Check if the result is already cached
|
||||
if (centerLineCache.containsKey(cacheKey)) {
|
||||
@@ -725,40 +760,42 @@ class RoadHelper {
|
||||
}
|
||||
|
||||
// If the result is not cached, calculate it
|
||||
RoadResultController.instance.addRoadResultListener("llaGetCenterLineRoadNode_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${fDis.toTenDecimalsStr()}",object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
RoadResultController.instance.addRoadResultListener(cacheKey,object :IRoadData{
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCenterLineRoadNode--code:${code},result: $result")
|
||||
}
|
||||
if (TextUtils.isEmpty(result)){
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
var result = it
|
||||
if (result.endsWith(",")) {
|
||||
result = result.trim(',')
|
||||
}
|
||||
val array = result.split(",")
|
||||
if (array != null && array.size > 5) {
|
||||
val centerLine = CenterLine()
|
||||
centerLine.id = array[0]
|
||||
centerLine.tile_id = array[1]
|
||||
centerLine.road_id = array[2]
|
||||
centerLine.lane_id = array[3]
|
||||
val points = ArrayList<LonLatPoint>()
|
||||
for (i in 4..array.size - 1 step 2) {
|
||||
val lonLatPoint = LonLatPoint(array[i].toDouble(), array[i + 1].toDouble())
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
|
||||
buf?.let {
|
||||
var centerLine = CenterLine()
|
||||
centerLine.id = buf.getInt().toString()
|
||||
centerLine.tile_id = buf.getInt().toString()
|
||||
centerLine.road_id = buf.getInt().toString()
|
||||
centerLine.lane_id = buf.getInt().toString()
|
||||
var size = buf.getInt()
|
||||
var points = ArrayList<LonLatPoint>()
|
||||
for (i in 0 until size step 2) {
|
||||
var lonLatPoint = LonLatPoint(buf.getLong()/ 1e8, buf.getLong()/ 1e8)
|
||||
points.add(lonLatPoint)
|
||||
}
|
||||
centerLine.points = points
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCenterLineRoadNode--centerLine:${centerLine}")
|
||||
}
|
||||
centerLineCache.put(cacheKey,centerLine)
|
||||
call.result(code,centerLine)
|
||||
return
|
||||
}
|
||||
}
|
||||
call.result(1,null)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
@@ -769,24 +806,30 @@ class RoadHelper {
|
||||
|
||||
fun getRoadName(dLon: Double, dlat: Double, fAngle: Float,call: IResult<RoadNameInfo>){
|
||||
RoadResultController.instance.addRoadResultListener("llaGetRoadName_${dLon.toTenDecimalsStr()}_${dlat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}",object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getRoadName--code:${code},result: $result")
|
||||
}
|
||||
if (TextUtils.isEmpty(result)){
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
val array = result.split(",")
|
||||
val roadNameInfo = RoadNameInfo()
|
||||
if(array != null && array.size > 2) {
|
||||
roadNameInfo.tile_id = array[0]
|
||||
roadNameInfo.road_id = array[1]
|
||||
roadNameInfo.road_name = array[2]
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
|
||||
buf?.let {
|
||||
val roadNameInfo = RoadNameInfo()
|
||||
roadNameInfo.tile_id = it.getInt().toString()
|
||||
roadNameInfo.road_id = it.getInt().toString()
|
||||
roadNameInfo.road_name = ByteBufferHelper.buf2Str(buf)?:""
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getRoadName--roadNameInfo:${roadNameInfo}")
|
||||
}
|
||||
call.result(code,roadNameInfo)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
call.result(1,null)
|
||||
}
|
||||
@@ -803,7 +846,7 @@ class RoadHelper {
|
||||
*/
|
||||
|
||||
fun getCrossRoad(dLon: Double, dlat: Double, fAngle: Float,call: IResult<RoadCross>) {
|
||||
val cacheKey = "$dLon,$dlat,$fAngle"
|
||||
val cacheKey = "llaGetCrossRoad_${dLon.toTenDecimalsStr()}_${dlat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}"
|
||||
|
||||
// Check if the result is already in the cache
|
||||
crossRoadCache.get(cacheKey)?.let {
|
||||
@@ -812,34 +855,44 @@ class RoadHelper {
|
||||
}
|
||||
|
||||
// Otherwise, call the mapBox.llaGetCrossRoad function to get the result
|
||||
RoadResultController.instance.addRoadResultListener("llaGetCrossRoad_${dLon.toTenDecimalsStr()}_${dlat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}",object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
RoadResultController.instance.addRoadResultListener(cacheKey,object :IRoadData{
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCrossRoad--code:${code},result: $result")
|
||||
}
|
||||
if (TextUtils.isEmpty(result)){
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
val array = result.split(",")
|
||||
if (array != null && array.size > 2) {
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
|
||||
buf?.let {
|
||||
val roadCross = RoadCross()
|
||||
roadCross.status = array[0].toInt()
|
||||
roadCross.tile_id = array[1]
|
||||
roadCross.cross_id = array[2]
|
||||
if (array.size > 4) {
|
||||
roadCross.tile_id_end = array[3]
|
||||
roadCross.cross_id_end = array[4]
|
||||
roadCross.status = it.getInt()
|
||||
val tile_id = it.getInt()
|
||||
if(tile_id == 0){
|
||||
call.result(1,null)
|
||||
}
|
||||
roadCross.tile_id = "${tile_id}"
|
||||
roadCross.cross_id= it.getLong().toString()
|
||||
|
||||
if(roadCross.status == 0){
|
||||
roadCross.tile_id_end = it.getInt().toString()
|
||||
roadCross.cross_id_end = it.getLong().toString()
|
||||
}
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCrossRoad--roadCross:${roadCross}")
|
||||
}
|
||||
// Store the result in the cache before returning it
|
||||
crossRoadCache.put(cacheKey,roadCross)
|
||||
call.result(code,roadCross)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
call.result(1,null)
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
@@ -849,22 +902,28 @@ class RoadHelper {
|
||||
|
||||
fun getCrossRoadById(tileId: Int, id: Long,call: IResult<ArrayList<LonLatPoint>>){
|
||||
RoadResultController.instance.addRoadResultListener("llaGetCrossRoadById_${tileId}_${id}",object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCrossRoadById--code:${code},result: $result")
|
||||
}
|
||||
if (TextUtils.isEmpty(result)){
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
val array = result.split(",")
|
||||
if(array != null && array.size >= 2) {
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
|
||||
buf?.let {
|
||||
val list = ArrayList<LonLatPoint>()
|
||||
for(i in 0 until array.size step 2){
|
||||
val lonLatPoint = LonLatPoint(array[i].toDouble(), array[i+1].toDouble())
|
||||
val size = it.getInt()
|
||||
for(i in 0 until size step 2){
|
||||
val lonLatPoint = LonLatPoint(it.getLong()/1e8, it.getLong()/1e8)
|
||||
list.add(lonLatPoint)
|
||||
}
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCrossRoadById--roadCross:${list}")
|
||||
}
|
||||
call.result(code,list)
|
||||
return
|
||||
}
|
||||
@@ -886,11 +945,25 @@ class RoadHelper {
|
||||
fun cacheHDDataByCityLonLat(lon: Double, lat: Double,call: IResult<Int>){
|
||||
val key = "cacheHDDataByCityLonLat_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}"
|
||||
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--${key}--code:${code},result: $result")
|
||||
}
|
||||
call.result(code,result?.toIntOrNull()?:0)
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,0)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
|
||||
buf?.let {
|
||||
call.result(code, it.getInt())
|
||||
return
|
||||
}
|
||||
}
|
||||
call.result(1,0)
|
||||
}
|
||||
|
||||
})
|
||||
@@ -900,11 +973,25 @@ class RoadHelper {
|
||||
fun cacheHDDataByCity(id: Int,call: IResult<Boolean>){
|
||||
val key = "cacheHDDataByCity_${id}"
|
||||
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--cacheHDDataByCity-${key}-code:${code},result: $result")
|
||||
}
|
||||
call.result(code,result?.toBoolean()?:false)
|
||||
if (result?.isEmpty() == true){
|
||||
call.result(1,false)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
|
||||
buf?.let {
|
||||
call.result(code, it.getInt() == 1)
|
||||
return
|
||||
}
|
||||
}
|
||||
call.result(code,false)
|
||||
}
|
||||
})
|
||||
mapBox.cacheHDDataByCity(id)
|
||||
@@ -913,11 +1000,24 @@ class RoadHelper {
|
||||
fun getCacheProgressByCity(id: Int,call: IResult<Double>){
|
||||
val key = "getCacheProgressByCity_${id}"
|
||||
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCacheProgressByCity-${key}-code:${code},result: $result")
|
||||
}
|
||||
call.result(code,result?.toDouble()?:0.0)
|
||||
if (result?.isEmpty() == true) {
|
||||
call.result(1, 0.0)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
|
||||
buf?.let {
|
||||
call.result(code, it.getLong()/1e8)
|
||||
return
|
||||
}
|
||||
}
|
||||
call.result(1, 0.0)
|
||||
}
|
||||
|
||||
})
|
||||
@@ -927,13 +1027,30 @@ class RoadHelper {
|
||||
fun getCityCode(lon: Double, lat: Double, call: IResult<Int>){
|
||||
val key = "getCityCode_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}"
|
||||
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCityCode-${key}-code:${code},result: $result")
|
||||
}
|
||||
val cityCode = result?.toIntOrNull()?:0
|
||||
val code = if(cityCode>0){0}else{1}
|
||||
call.result(code,cityCode)
|
||||
if (result?.isEmpty() == true) {
|
||||
call.result(1, 0)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
|
||||
buf?.let {
|
||||
val cityCode = it.getInt()
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getCityCode-${cityCode}")
|
||||
}
|
||||
call.result(code,cityCode)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
call.result(1,0)
|
||||
}
|
||||
|
||||
})
|
||||
@@ -979,35 +1096,39 @@ class RoadHelper {
|
||||
fun getAllCityCode(call: IResult<ArrayList<CityInfo>>) {
|
||||
val key = "getAllCityCode"
|
||||
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.d(TAG, "roadop--getAllCityCode--result: ${result}")
|
||||
}
|
||||
val cityList = ArrayList<CityInfo>()
|
||||
if (result?.isEmpty() == true) {
|
||||
call.result(1, null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
val array = result.split(";")
|
||||
if(array!= null && array.isNotEmpty()){
|
||||
for(str in array){
|
||||
if(str.isNotEmpty()){
|
||||
val cityInfo = CityInfo()
|
||||
val city = str.trim().split(",")
|
||||
if(city.isNotEmpty() && city.size >= 4){
|
||||
cityInfo.cityCode = city[0].trim().toIntOrNull()?:0
|
||||
cityInfo.chineseCityName = city[1]
|
||||
cityInfo.englishCityName = city[2]
|
||||
cityInfo.isCache = city[3].toIntOrNull()?:0 == 1
|
||||
cityList.add(cityInfo)
|
||||
}
|
||||
|
||||
}
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
buf?.let {
|
||||
val cityList = ArrayList<CityInfo>()
|
||||
val size = it.getInt()
|
||||
for(i in 0 until size step 6){
|
||||
val cityInfo = CityInfo()
|
||||
cityInfo.cityCode = it.getInt()
|
||||
cityInfo.chineseCityName = ByteBufferHelper.buf2Str(buf)?:""
|
||||
cityInfo.englishCityName = ByteBufferHelper.buf2Str(buf)?:""
|
||||
cityInfo.isCache = it.getInt() == 1
|
||||
cityList.add(cityInfo)
|
||||
}
|
||||
|
||||
call.result(code,cityList)
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.d(TAG, "roadop--getAllCityCode--cityList: ${cityList}")
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.d(TAG, "roadop--getAllCityCode--cityList: ${cityList}")
|
||||
}
|
||||
call.result(code,cityList)
|
||||
call.result(1, null)
|
||||
|
||||
|
||||
}
|
||||
|
||||
})
|
||||
@@ -1018,11 +1139,28 @@ class RoadHelper {
|
||||
fun getHdDataVersionByCity(lon: Double,lat: Double,call: IResult<String>){
|
||||
val key = "getHdDataVersionByCity_${lon.toTenDecimalsStr()}_${lat.toTenDecimalsStr()}"
|
||||
RoadResultController.instance.addRoadResultListener(key,object :IRoadData{
|
||||
override fun result(code: Int, result: String?) {
|
||||
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--${key}-code:${code},result: $result")
|
||||
}
|
||||
call.result(0,result?:"")
|
||||
if (result?.isEmpty() == true) {
|
||||
call.result(1, null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
buf?.let {
|
||||
val version = it.getInt().toString()
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getHdDataVersionByCity-version:${version}")
|
||||
}
|
||||
call.result(0,version)
|
||||
return
|
||||
}
|
||||
}
|
||||
call.result(1, null)
|
||||
}
|
||||
})
|
||||
mapBox.getHdDataVersionByCity(lon,lat)
|
||||
@@ -1030,48 +1168,42 @@ class RoadHelper {
|
||||
|
||||
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{
|
||||
override fun result(code: Int, result: String?) {
|
||||
override fun result(code: Int, result: ByteArray?) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getZebraLineByDistance--code:${code},result: $result")
|
||||
}
|
||||
if (TextUtils.isEmpty(result)){
|
||||
call.result(1,null)
|
||||
if (result?.isEmpty() == true) {
|
||||
call.result(1, null)
|
||||
return
|
||||
}
|
||||
result?.let {
|
||||
val list = ArrayList<ZebraLine>()
|
||||
val array = result.split(";")
|
||||
if(!array.isEmpty()) {
|
||||
for(arr in array){
|
||||
if(arr.isEmpty()) {
|
||||
continue
|
||||
var result = it
|
||||
var buf = ByteBufferHelper.bytes2ByteBuffer(result)
|
||||
buf?.let {
|
||||
val list = ArrayList<ZebraLine>()
|
||||
val size = it.getInt()
|
||||
for(i in 0 until size step 11){
|
||||
val zebraLine = ZebraLine()
|
||||
zebraLine.dis = it.getLong()/1e8.toFloat()
|
||||
zebraLine.tileId = it.getInt().toString()
|
||||
zebraLine.id = it.getInt().toString()
|
||||
val size = it.getInt()
|
||||
val lonlats = ArrayList<LonLatPoint>()
|
||||
for(i in 0 until size step 2){
|
||||
val lonLatPoint = LonLatPoint(it.getLong()/1e8, it.getLong()/1e8)
|
||||
lonlats.add(lonLatPoint)
|
||||
}
|
||||
val line = arr.split(",")
|
||||
if (line.isNotEmpty() && line.size > 5) {
|
||||
val zebraLine = ZebraLine()
|
||||
val dis = line[0].toFloatOrNull()
|
||||
dis?.let {
|
||||
zebraLine.dis = it
|
||||
}
|
||||
zebraLine.tileId = line[1]
|
||||
zebraLine.id = line[2]
|
||||
val lonlats = ArrayList<LonLatPoint>()
|
||||
for(i in 3 until line.size step 2){
|
||||
val lonLatPoint = LonLatPoint(line[i].toDouble(), line[i+1].toDouble())
|
||||
lonlats.add(lonLatPoint)
|
||||
}
|
||||
zebraLine.zebraLineList = lonlats
|
||||
list.add(zebraLine)
|
||||
|
||||
}
|
||||
|
||||
zebraLine.zebraLineList = lonlats
|
||||
list.add(zebraLine)
|
||||
}
|
||||
if(list.isNotEmpty()){
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.d(TAG, "roadop--getZebraLineByDistance--list:${list}")
|
||||
}
|
||||
call.result(0,list)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
call.result(1,null)
|
||||
|
||||
|
||||
@@ -7,12 +7,13 @@ import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import java.util.concurrent.CopyOnWriteArrayList
|
||||
|
||||
class RoadResultController {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
private var mRoadResultCallHashMap: ConcurrentHashMap<String,ArrayList<IRoadData>> = ConcurrentHashMap()
|
||||
private var mRoadResultCallHashMap: ConcurrentHashMap<String,CopyOnWriteArrayList<IRoadData>> = ConcurrentHashMap()
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +23,7 @@ class RoadResultController {
|
||||
}
|
||||
var list = mRoadResultCallHashMap.get(key)
|
||||
if(list == null){
|
||||
list = ArrayList<IRoadData>()
|
||||
list = CopyOnWriteArrayList<IRoadData>()
|
||||
}
|
||||
list.add(listener)
|
||||
mRoadResultCallHashMap.put(key,list)
|
||||
@@ -47,9 +48,9 @@ class RoadResultController {
|
||||
|
||||
}
|
||||
|
||||
fun dispatchRoadResult(code:Int,key:String,result:String){
|
||||
fun dispatchRoadResult(code:Int,key:String,result:ByteArray){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "roadop--dispatchRoadResult:$key,result:$result ")
|
||||
Log.i(TAG, "roadop--dispatchRoadResultDouble:$key,strResult:$result")
|
||||
}
|
||||
val list = mRoadResultCallHashMap.get(key)
|
||||
if(list != null && list.isNotEmpty()){
|
||||
|
||||
@@ -19,6 +19,7 @@ class Clerk(private val mMapController: IMapController?) {
|
||||
|
||||
private var saveJob: Job? = null
|
||||
private var uploadJob: Job? = null
|
||||
private var job: Job? = null
|
||||
|
||||
|
||||
private val saveJobList = ConcurrentSet<Job?>()
|
||||
@@ -35,30 +36,36 @@ class Clerk(private val mMapController: IMapController?) {
|
||||
if(!isWork){
|
||||
return
|
||||
}
|
||||
var className:String = ""
|
||||
var methodName:String = ""
|
||||
try{
|
||||
className = Thread.currentThread().stackTrace[3].className
|
||||
methodName = Thread.currentThread().stackTrace[3].methodName
|
||||
}catch (e:Exception){
|
||||
job?.cancel()
|
||||
job = mMapController?.getDemaningScope()?.launch(Dispatchers.IO) {
|
||||
var className: String = ""
|
||||
var methodName: String = ""
|
||||
try {
|
||||
className = Thread.currentThread().stackTrace[3].className
|
||||
methodName = Thread.currentThread().stackTrace[3].methodName
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
add(className, methodName, "")
|
||||
}
|
||||
add(className, methodName, "")
|
||||
}
|
||||
|
||||
fun add(param:String?){
|
||||
if(!isWork){
|
||||
return
|
||||
}
|
||||
var className:String = ""
|
||||
var methodName:String = ""
|
||||
try{
|
||||
className = Thread.currentThread().stackTrace[3].className
|
||||
methodName = Thread.currentThread().stackTrace[3].methodName
|
||||
}catch (e:Exception){
|
||||
job?.cancel()
|
||||
job = mMapController?.getDemaningScope()?.launch(Dispatchers.IO) {
|
||||
var className: String = ""
|
||||
var methodName: String = ""
|
||||
try {
|
||||
className = Thread.currentThread().stackTrace[3].className
|
||||
methodName = Thread.currentThread().stackTrace[3].methodName
|
||||
} catch (e: Exception) {
|
||||
|
||||
}
|
||||
add(className, methodName, param)
|
||||
}
|
||||
add(className, methodName, param)
|
||||
}
|
||||
|
||||
fun add(className:String,methodName:String,param:String?){
|
||||
@@ -188,6 +195,7 @@ class Clerk(private val mMapController: IMapController?) {
|
||||
it.remove()
|
||||
}
|
||||
}
|
||||
job?.cancel()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,7 +12,7 @@ object ByteBufferHelper {
|
||||
}
|
||||
|
||||
fun buf2Str(buf: ByteBuffer): String? {
|
||||
val l = buf.short.toInt()
|
||||
val l = buf.getInt()
|
||||
var ret: String? = null
|
||||
if (l > 0) {
|
||||
val tmp = ByteArray(l)
|
||||
|
||||
@@ -8,23 +8,18 @@ import android.app.ProgressDialog
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.pm.PackageManager
|
||||
import android.graphics.Color
|
||||
import android.location.LocationManager
|
||||
import android.os.Build
|
||||
import android.os.Environment
|
||||
import android.os.RemoteException
|
||||
import android.provider.Settings
|
||||
import android.text.format.Formatter
|
||||
import android.view.Gravity
|
||||
import android.view.KeyEvent
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.RadioGroup
|
||||
import android.widget.TextView
|
||||
import android.widget.Toast
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.autonavi.nge.guidance.RouteBook
|
||||
import com.autonavi.nge.obj.SubCategory
|
||||
import com.autonavi.nge.routing.RoutingProvider
|
||||
import com.zhidaoauto.map.sdk.R
|
||||
|
||||
@@ -9,7 +9,16 @@ import java.text.DateFormat
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Calendar
|
||||
import java.util.TimeZone
|
||||
import kotlin.math.*
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.absoluteValue
|
||||
import kotlin.math.acos
|
||||
import kotlin.math.asin
|
||||
import kotlin.math.atan2
|
||||
import kotlin.math.cos
|
||||
import kotlin.math.pow
|
||||
import kotlin.math.sin
|
||||
import kotlin.math.sqrt
|
||||
import kotlin.math.tan
|
||||
|
||||
object MathUtils {
|
||||
|
||||
@@ -334,7 +343,7 @@ object MathUtils {
|
||||
index = pLine.size - 1 - i
|
||||
Log.d(TAG, "angleooo--distance: ${dis}, index: $index")
|
||||
}
|
||||
if(dis >= MAX_DISTANCE){
|
||||
if(dis >= MAX_DISTANCE){
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -344,7 +353,7 @@ object MathUtils {
|
||||
lonLatPoint.latitude - lastLonLatPoint.latitude
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
if (tempAngle == -400.0) {
|
||||
tempAngle = lonLatPoint.angle
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import com.autonavi.nge.map.MapView
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.abs.IEventController
|
||||
import com.zhidaoauto.map.sdk.inner.common.CommonHelper
|
||||
import com.zhidaoauto.map.sdk.inner.common.ConstantExt
|
||||
import com.zhidaoauto.map.sdk.inner.common.MapHelper
|
||||
import com.zhidaoauto.map.sdk.inner.controller.CommonController
|
||||
@@ -108,7 +107,6 @@ object MapAutoApi {
|
||||
* 初始化
|
||||
*/
|
||||
fun init(context: Context, mapParams: MapParams) {
|
||||
CommonHelper.getInstance()
|
||||
CommonController.instance.init(context)
|
||||
Recorder.i("common","$mapParams")
|
||||
val customPath = context.filesDir.absolutePath
|
||||
@@ -185,7 +183,7 @@ object MapAutoApi {
|
||||
fun setDebugMode(debug: Boolean){
|
||||
MapHelper.setDebugMode(debug)
|
||||
if(debug){
|
||||
setLogLevel(2)
|
||||
setLogLevel(1)
|
||||
}else{
|
||||
setLogLevel(-1)
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@ package com.zhidaoauto.map.sdk.open.abs
|
||||
interface OnMapLoadedListener {
|
||||
fun onMapInit()
|
||||
fun onMapLoaded()
|
||||
fun onRoadLoaded(roadInfo:String?){}
|
||||
fun onRoadLoaded(roadInfo:String?)
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.zhidaoauto.map.sdk.open.data
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
@@ -8,6 +7,14 @@ import android.util.Log
|
||||
import com.autonavi.nge.dm.SharedMemoryService
|
||||
import com.autonavi.nge.map.LonLat
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
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.RoadRectInfos
|
||||
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.proxy.CommonProxy
|
||||
@@ -17,17 +24,16 @@ import com.zhidaoauto.map.sdk.inner.utils.LogHelper
|
||||
import com.zhidaoauto.map.sdk.inner.utils.MathUtils
|
||||
import com.zhidaoauto.map.sdk.inner.utils.Recorder
|
||||
import com.zhidaoauto.map.sdk.open.abs.IResult
|
||||
import com.zhidaoauto.map.data.road.*
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object MapDataApi {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
|
||||
private var mContext:Context? = null
|
||||
|
||||
|
||||
|
||||
fun getContext():Context?{
|
||||
return mContext
|
||||
}
|
||||
@@ -52,6 +58,31 @@ object MapDataApi {
|
||||
mContext = null
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断服务是否开启
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
fun isServiceRunning(context: Context, ServiceName: String): Boolean {
|
||||
if (true) {
|
||||
return false
|
||||
}
|
||||
if (TextUtils.isEmpty(ServiceName)) {
|
||||
return false
|
||||
}
|
||||
val myManager = context
|
||||
.getSystemService(Context.ACTIVITY_SERVICE) as ActivityManager
|
||||
val runningServices = myManager
|
||||
.getRunningServices(50) as ArrayList<ActivityManager.RunningServiceInfo>
|
||||
for (info in runningServices) {
|
||||
if (info.service.className.equals(ServiceName)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
fun getRouteInfo(
|
||||
centerLon: Float,
|
||||
centerLat: Float, coor: Int, type: Int
|
||||
@@ -174,10 +205,16 @@ object MapDataApi {
|
||||
* lat:纬度
|
||||
* angle:航向角
|
||||
* dis:获取车道中心线的长度 正 行驶方向前方距离 负 行驶方向后方距离
|
||||
* isSmooth:是否平滑
|
||||
* orders:贝塞尔阶数
|
||||
*/
|
||||
fun getCenterLineRangeInfo(lon: Double, lat: Double, angle: Float, dis: Float,call: IResult<CenterLine>) {
|
||||
fun getCenterLineRangeInfo(lon: Double, lat: Double, angle: Float, dis: Float,isSmooth: Boolean,orders:Int, call: IResult<CenterLine>) {
|
||||
Recorder.add("roadop-getCenterLineRangeInfo:$lon,$lat,$angle,$dis")
|
||||
RoadHelper.getInstance()?.getCenterLineRange(lon, lat, angle,dis,call)
|
||||
if(isSmooth && orders < 3){
|
||||
call.result(-1,null)
|
||||
return
|
||||
}
|
||||
RoadHelper.getInstance()?.getCenterLineRange(lon, lat, angle,dis,isSmooth,orders, call)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
const val LOCATION_TYPE_FOLLOW = 2//连续定位、且将视角移动到地图中心点,定位蓝点跟随设备移动。(1秒1次定位) 默认执行此种模式
|
||||
const val LOCATION_TYPE_FOLLOW_NO_CENTER = 3 //连续定位、蓝点不会移动到地图中心点,并且蓝点会跟随设备移动。
|
||||
|
||||
const val ANIM_WAIT_FRAME_NIGHT = 150
|
||||
const val ANIM_PERIOD_NIGHT = 20
|
||||
const val ANIM_WAIT_FRAME_NIGHT = 35
|
||||
const val ANIM_PERIOD_NIGHT = 60
|
||||
const val ANIM_WAIT_FRAME_DAY = 60
|
||||
const val ANIM_PERIOD_DAY = 45
|
||||
}
|
||||
@@ -131,6 +131,13 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
return
|
||||
}
|
||||
if((mMapController?.isSurfaceCreated())?:false){
|
||||
if(executeFlag.get()){
|
||||
return
|
||||
}
|
||||
if (mMarker != null){
|
||||
return
|
||||
}
|
||||
executeFlag.set(true)
|
||||
var lon = mLonLat.lon
|
||||
var lat = mLonLat.lat
|
||||
var angle = mAngle
|
||||
@@ -139,12 +146,14 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
.position(LonLatPoint(lon, lat))
|
||||
.markerIcon(bitmap,mMapController).zIndex(1).title("self").rotateAngle(angle.toFloat()).controlAngle(true).anchor(0.5f,0.5f)
|
||||
|
||||
addConstMarker(options)
|
||||
mMarker = mMarkerController?.addSelfCar(options)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "autoop--selfop--markerop--drawCar:${mMarker?.getId()}")
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
mMarker = null
|
||||
}finally {
|
||||
executeFlag.set(false)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,12 +185,21 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
}
|
||||
mMarker?.setMarkerOptions(it)
|
||||
}
|
||||
carId = resId
|
||||
|
||||
return
|
||||
}
|
||||
if((mMapController?.isSurfaceCreated())?:false){
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "markerop---selfop--draw3DCar:start:mapView SurfaceCreated")
|
||||
}
|
||||
if(executeFlag.get()){
|
||||
return
|
||||
}
|
||||
if (mMarker != null){
|
||||
return
|
||||
}
|
||||
executeFlag.set(true)
|
||||
var lon = mLonLat.lon
|
||||
var lat = mLonLat.lat
|
||||
var angle = mAngle
|
||||
@@ -203,7 +221,8 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
if(isDisplayAnim){
|
||||
options?.animMarkerRes(guangquanResId,mMapController)
|
||||
}
|
||||
addConstMarker(options)
|
||||
mMarker = mMarkerController?.addSelfCar(options)
|
||||
carId = resId
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "autoop--selfop--markerop--draw3DCar:${mMarker?.getId()},${resId},${options.getMarkerIconName()}")
|
||||
}
|
||||
@@ -212,6 +231,8 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
Log.e(TAG, "autoop--selfop--markerop--draw3DCar:${mMarker?.getId()}",e)
|
||||
}
|
||||
mMarker = null
|
||||
}finally {
|
||||
executeFlag.set(false)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,8 +344,8 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
}
|
||||
drawCar(it)
|
||||
}
|
||||
carId = carResId
|
||||
}
|
||||
carId = carResId
|
||||
}
|
||||
|
||||
return this
|
||||
@@ -412,17 +433,5 @@ class MyLocationStyle(private var mContext:Context?,private var mMarkerControlle
|
||||
mMarker = null
|
||||
}
|
||||
|
||||
private fun addConstMarker(markerOptions: MarkerOptions){
|
||||
if(executeFlag.get()){
|
||||
return
|
||||
}
|
||||
if(mMarker == null){
|
||||
executeFlag.set(true)
|
||||
mMarker = mMarkerController?.addSelfCar(markerOptions)
|
||||
executeFlag.set(false)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -158,6 +158,5 @@ class Polyline {
|
||||
}
|
||||
|
||||
private fun refreshMap() {
|
||||
//CommonController.getInstance().getMapView().shakeSceneManual();
|
||||
}
|
||||
}
|
||||
@@ -4,15 +4,16 @@ import android.graphics.Point
|
||||
import android.util.Log
|
||||
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.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.absoluteValue
|
||||
|
||||
object MapTools {
|
||||
|
||||
val TAG: String = javaClass.simpleName
|
||||
val TAG = javaClass.simpleName
|
||||
var viewHeight = 1040
|
||||
var viewWidth = 1920
|
||||
|
||||
@@ -20,13 +21,13 @@ object MapTools {
|
||||
* 屏幕坐标转经纬度
|
||||
*/
|
||||
fun fromScreenLocation(paramPoint: Point,mMapController: IMapController?): LonLatPoint {
|
||||
if (DEBUG) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "lonlatop--fromScreenLocation--${paramPoint.toString()}")
|
||||
}
|
||||
val lonLat = mMapController?.pixelsToLonlat(paramPoint.x.toFloat(), paramPoint.y.toFloat())
|
||||
var lonLat = mMapController?.pixelsToLonlat(paramPoint.x.toFloat(), paramPoint.y.toFloat())
|
||||
lonLat?.let {
|
||||
val lonLatPoint = CommonProxy.getInstance().getLonLatProxy().switchLonLat(it)
|
||||
if (DEBUG) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(
|
||||
TAG,
|
||||
"lonlatop-toScreenLocation-toOuter-before:${lonLat},after:${lonLatPoint}"
|
||||
@@ -41,16 +42,16 @@ object MapTools {
|
||||
* 经纬度转屏幕坐标
|
||||
*/
|
||||
fun toScreenLocation(lonLatPoint: LonLatPoint,mMapController: IMapController?): Point {
|
||||
val lonLat: LonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
|
||||
if (DEBUG) {
|
||||
var lonLat: LonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "lonlatop-toScreenLocation-toInner-before:${lonLatPoint},after:${lonLat}")
|
||||
}
|
||||
val point = mMapController?.lonlatToPixels(
|
||||
var point = mMapController?.lonlatToPixels(
|
||||
lonLat.lon,
|
||||
lonLat.lat
|
||||
)
|
||||
point?.let {
|
||||
if (DEBUG) {
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "lonlatop-toScreenLocation-result-${point}")
|
||||
}
|
||||
return Point(point.x.toInt(), point.y.toInt())
|
||||
@@ -78,9 +79,9 @@ object MapTools {
|
||||
* 批量经纬度转屏幕坐标
|
||||
*/
|
||||
fun toScreenLocations(data: List<LonLatPoint>,mMapController: IMapController?): List<Point> {
|
||||
val arrayList: ArrayList<Point> = ArrayList()
|
||||
var arrayList: ArrayList<Point> = ArrayList()
|
||||
for (pp in data) {
|
||||
val point = toScreenLocation(pp,mMapController)
|
||||
var point = toScreenLocation(pp,mMapController)
|
||||
arrayList.add(point)
|
||||
}
|
||||
return arrayList
|
||||
@@ -90,9 +91,9 @@ object MapTools {
|
||||
* 批量屏幕坐标转经纬度
|
||||
*/
|
||||
fun fromScreenLocations(data: List<Point>,mMapController: IMapController?): List<LonLatPoint> {
|
||||
val arrayList: ArrayList<LonLatPoint> = ArrayList()
|
||||
var arrayList: ArrayList<LonLatPoint> = ArrayList()
|
||||
for (pp in data) {
|
||||
val lonLat = fromScreenLocation(pp,mMapController)
|
||||
var lonLat = fromScreenLocation(pp,mMapController)
|
||||
arrayList.add(lonLat)
|
||||
}
|
||||
return arrayList
|
||||
@@ -130,10 +131,10 @@ object MapTools {
|
||||
}
|
||||
|
||||
fun getLonLats(start: LonLatPoint, end: LonLatPoint): List<LonLatPoint> {
|
||||
val lonLatPoints: ArrayList<LonLatPoint> = ArrayList()
|
||||
var lonLatPoints: ArrayList<LonLatPoint> = ArrayList<LonLatPoint>()
|
||||
val x = end.latitude - start.latitude
|
||||
val y = end.longitude - start.longitude
|
||||
val dis = sqrt(x * x + y * y).absoluteValue
|
||||
val dis = Math.sqrt(x * x + y * y).absoluteValue
|
||||
val num = (dis / 0.000001).toInt()
|
||||
val numX = x / num.toDouble()
|
||||
val numY = y / num.toDouble()
|
||||
@@ -142,7 +143,7 @@ object MapTools {
|
||||
val lat = start.latitude + numX * i
|
||||
val lonlatPoint = LonLatPoint(lon, lat)
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "lonlatPoint: $lonlatPoint")
|
||||
Log.d(TAG, "lonlatPoint: ${lonlatPoint}")
|
||||
}
|
||||
lonLatPoints.add(lonlatPoint)
|
||||
|
||||
@@ -155,7 +156,7 @@ object MapTools {
|
||||
}
|
||||
|
||||
fun HaverSin(theta: Double): Double {
|
||||
val v = sin(theta / 2)
|
||||
val v = Math.sin(theta / 2)
|
||||
return v * v
|
||||
}
|
||||
|
||||
@@ -185,12 +186,12 @@ object MapTools {
|
||||
lon2 = ConvertDegreesToRadians(lon2)
|
||||
|
||||
//差值
|
||||
val vLon = abs(lon1 - lon2)
|
||||
val vLat = abs(lat1 - lat2)
|
||||
val vLon = Math.abs(lon1 - lon2)
|
||||
val vLat = Math.abs(lat1 - lat2)
|
||||
|
||||
//h is the great circle distance in radians, great circle就是一个球体上的切面,它的圆心即是球心的一个周长最大的圆。
|
||||
val h = HaverSin(vLat) + cos(lat1) * cos(lat2) * HaverSin(vLon)
|
||||
return 2 * EARTH_RADIUS * asin(sqrt(h))
|
||||
val h = HaverSin(vLat) + Math.cos(lat1) * Math.cos(lat2) * HaverSin(vLon)
|
||||
return 2 * EARTH_RADIUS * Math.asin(Math.sqrt(h))
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -211,25 +212,25 @@ object MapTools {
|
||||
val a = 6378137
|
||||
|
||||
fun getDestinceLonLat(lonlat: LonLat, angle: Double, dist: Float): LonLat {
|
||||
val angleRadHeading = angle / 180 * Math.PI
|
||||
var angleRadHeading = angle / 180 * Math.PI
|
||||
var newLat = 0.0
|
||||
var newLong = 0.0
|
||||
|
||||
val distRatio = dist / EARTH_RADIUS
|
||||
val distRatioSine = sin(distRatio)
|
||||
val distRatioCosine = cos(distRatio)
|
||||
val distRatioSine = Math.sin(distRatio)
|
||||
val distRatioCosine = Math.cos(distRatio)
|
||||
|
||||
val startLatRad = lonlat.lat / 180 * Math.PI
|
||||
val startLonRad = lonlat.lon / 180 * Math.PI
|
||||
|
||||
val startLatCos = cos(startLatRad)
|
||||
val startLatSin = sin(startLatRad)
|
||||
val startLatCos = Math.cos(startLatRad)
|
||||
val startLatSin = Math.sin(startLatRad)
|
||||
|
||||
val endLatRads = asin(startLatSin * distRatioCosine + startLatCos * distRatioSine * cos(angleRadHeading))
|
||||
val endLatRads = Math.asin(startLatSin * distRatioCosine + startLatCos * distRatioSine * Math.cos(angleRadHeading))
|
||||
val endLonRads = (startLonRad
|
||||
+ atan2(
|
||||
sin(angleRadHeading) * distRatioSine * startLatCos,
|
||||
distRatioCosine - startLatSin * sin(endLatRads)
|
||||
+ Math.atan2(
|
||||
Math.sin(angleRadHeading) * distRatioSine * startLatCos,
|
||||
distRatioCosine - startLatSin * Math.sin(endLatRads)
|
||||
))
|
||||
newLat = endLatRads / Math.PI * 180
|
||||
newLong = endLonRads / Math.PI * 180
|
||||
@@ -240,15 +241,15 @@ object MapTools {
|
||||
fun getDistance(lastLonlat: LonLat, lonlat: LonLat): Double {
|
||||
val x = lonlat.lat - lastLonlat.lat
|
||||
val y = lonlat.lon - lastLonlat.lon
|
||||
return sqrt(x * x + y * y).absoluteValue
|
||||
return Math.sqrt(x * x + y * y).absoluteValue
|
||||
}
|
||||
|
||||
fun getNextLonLat(lastLonlat: LonLat, lonlat: LonLat, length: Double): LonLat {
|
||||
val x = lonlat.lat - lastLonlat.lat
|
||||
val y = lonlat.lon - lastLonlat.lon
|
||||
val distance = sqrt(x * x + y * y).absoluteValue
|
||||
val distance = Math.sqrt(x * x + y * y).absoluteValue
|
||||
val scale = length / distance
|
||||
if(DEBUG){
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG,"centerop-mattop:length:${length},distance:${distance},scale:${scale}")
|
||||
}
|
||||
val lon = lastLonlat.lon + y * scale
|
||||
|
||||
@@ -62,6 +62,7 @@ class MonitorPressApi {
|
||||
}
|
||||
|
||||
fun exit() {
|
||||
TaskManager.instance.monitorCancleCacheHdData()
|
||||
mainFlag = false
|
||||
TaskManager.instance.exit()
|
||||
mMainJob?.cancel()
|
||||
@@ -97,7 +98,7 @@ class MonitorPressApi {
|
||||
TaskManager.instance.resetTask()
|
||||
|
||||
|
||||
val rv = (Math.random() * 17).toInt()
|
||||
val rv = (Math.random() * 20).toInt()
|
||||
var trackIndex = (Math.random() * (mFiles!!.size - 1)).toInt()
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.i(TAG, "onClick--randomop: rv:${rv},trackIndex:${trackIndex}")
|
||||
@@ -169,6 +170,14 @@ class MonitorPressApi {
|
||||
mapAutoView.postInvalidate()
|
||||
}
|
||||
}
|
||||
17 -> {
|
||||
val lonLatPoint = mapAutoView.getCurrentLonLatPoint()
|
||||
val isSmooth = Random.nextBoolean()
|
||||
TaskManager.instance.monitorGetCenterLineRange(lonLatPoint,isSmooth,6,mapAutoView)
|
||||
}
|
||||
18->{
|
||||
TaskManager.instance.monitorSetCanScaleVrMode(mapAutoView)
|
||||
}
|
||||
|
||||
else -> {
|
||||
TaskManager.instance.monitor2DMarkerAdd(trackIndex,mapAutoView)
|
||||
|
||||
@@ -8,6 +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.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
|
||||
@@ -32,7 +37,6 @@ 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.data.road.*
|
||||
import com.zhidaoauto.map.sdk.open.view.MapAutoView
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -176,6 +180,20 @@ class TaskManager {
|
||||
}
|
||||
|
||||
fun exit() {
|
||||
if(centerLine != null){
|
||||
centerLine?.remove()
|
||||
centerLine = null
|
||||
}
|
||||
if(stopLine != null){
|
||||
stopLine?.remove()
|
||||
stopLine = null
|
||||
}
|
||||
if(listRect != null && listRect.size > 0){
|
||||
for (line in listRect){
|
||||
line.remove()
|
||||
}
|
||||
listRect.clear()
|
||||
}
|
||||
mMarkerCacheController?.destory()
|
||||
markerMap.clear()
|
||||
resetTask()
|
||||
@@ -908,7 +926,7 @@ class TaskManager {
|
||||
}
|
||||
|
||||
})
|
||||
RoadHelper.getInstance()?.getCenterLineRange(lonlatPoint.longitude,lonlatPoint.latitude,lonlatPoint.angle.toFloat(), 10f,object :IResult<CenterLine>{
|
||||
RoadHelper.getInstance()?.getCenterLineRange(lonlatPoint.longitude,lonlatPoint.latitude,lonlatPoint.angle.toFloat(), 10f,false, 6,object :IResult<CenterLine>{
|
||||
override fun result(code: Int, result: CenterLine?) {
|
||||
|
||||
}
|
||||
@@ -1313,7 +1331,7 @@ class TaskManager {
|
||||
}
|
||||
|
||||
|
||||
fun monitorGetCenterLineRange(lonlatPoint: LonLatPoint, mapAutoView: MapAutoView) {
|
||||
fun monitorGetCenterLineRange(lonlatPoint: LonLatPoint, isSmooth:Boolean,orders:Int,mapAutoView: MapAutoView) {
|
||||
|
||||
val location = MogoLocation()
|
||||
location.provider = "GPS_RTK"
|
||||
@@ -1322,7 +1340,7 @@ class TaskManager {
|
||||
location.heading = lonlatPoint.angle
|
||||
|
||||
|
||||
MapDataApi.getCenterLineRangeInfo(lonlatPoint.longitude, lonlatPoint.latitude,lonlatPoint.angle.toFloat(), 300f,object :IResult<CenterLine>{
|
||||
MapDataApi.getCenterLineRangeInfo(lonlatPoint.longitude, lonlatPoint.latitude,lonlatPoint.angle.toFloat(), 300f,isSmooth, orders,object :IResult<CenterLine>{
|
||||
override fun result(code: Int, line: CenterLine?) {
|
||||
var valuesArr = arrayListOf<Int>()
|
||||
line?.let {
|
||||
@@ -1432,6 +1450,16 @@ class TaskManager {
|
||||
|
||||
}
|
||||
|
||||
fun monitorSetCanScaleVrMode(mapAutoView: MapAutoView){
|
||||
val i = ((Math.random() * 100)%2).toInt()
|
||||
if(i == 1) {
|
||||
mapAutoView.getMapAutoViewHelper()?.setScaleVRMode(true)
|
||||
}else{
|
||||
mapAutoView.getMapAutoViewHelper()?.setScaleVRMode(false)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -11,6 +11,7 @@ import android.widget.FrameLayout
|
||||
import com.autonavi.nge.map.*
|
||||
import com.zhidao.map.net.api.Result
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
import com.zhidaoauto.map.data.road.*
|
||||
import com.zhidaoauto.map.sdk.R
|
||||
import com.zhidaoauto.map.sdk.inner.CompileConfig
|
||||
import com.zhidaoauto.map.sdk.inner.abs.*
|
||||
@@ -37,7 +38,6 @@ 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.data.road.*
|
||||
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,7 +124,7 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
|
||||
private val weatherRepository by lazy { WeatherRepository() }
|
||||
private var isFirstInit = true
|
||||
|
||||
constructor(context: Context) : super(context) {
|
||||
constructor(context: Context) : super(context) {
|
||||
initView()
|
||||
}
|
||||
|
||||
@@ -338,7 +338,6 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
|
||||
|
||||
|
||||
mMapAutoViewHelper = MapAutoViewHelper(this@MapAutoView)
|
||||
mPanelManager?.setPanel(PanelManager.PANEL_WHAT_SET_MODE, PanelManager.PANEL_MODE_SDK_MAIN)
|
||||
mMapController?.setFollowCarMode(true)
|
||||
if (CompileConfig.DEBUG) {
|
||||
Log.i(TAG, "autoop-mapop-initMapView--over")
|
||||
@@ -446,6 +445,7 @@ open class MapAutoView : FrameLayout, LonLatPointListener, ITraffic,ILockLocatio
|
||||
isFirstInit = false
|
||||
updateCacheByCityCode(mogoLocation)
|
||||
}
|
||||
isWeatherEnable = mMapStyleParams?.getIsWeatherEnable()?:true
|
||||
if(isWeatherEnable && isFirstLocation){
|
||||
isFirstLocation = false
|
||||
loopFlag = true
|
||||
|
||||
@@ -4,14 +4,11 @@ import android.util.Log
|
||||
import com.autonavi.nge.map.*
|
||||
import com.zhidaoauto.map.data.point.LonLatPoint
|
||||
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.common.ConstantExt
|
||||
import com.zhidaoauto.map.sdk.inner.panel.PanelManager
|
||||
import com.zhidaoauto.map.sdk.inner.proxy.CommonProxy
|
||||
import com.zhidaoauto.map.sdk.inner.utils.TransformUtils
|
||||
import com.zhidaoauto.map.sdk.open.MapAutoApi
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
import com.zhidaoauto.map.sdk.open.abs.marker.InfoWindowAdapter
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraPosition
|
||||
import com.zhidaoauto.map.sdk.open.camera.CameraUpdate
|
||||
@@ -1237,8 +1234,8 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
|
||||
mMapAutoView.getClerk()?.add("$isUseTrace,$dis,$speed")
|
||||
|
||||
var roamDis = dis
|
||||
if(roamDis > ConstantExt.ROAM_DIS_8KM){
|
||||
roamDis = ConstantExt.ROAM_DIS_8KM
|
||||
if(roamDis > ConstantExt.ROAM_DIS_MAX){
|
||||
roamDis = ConstantExt.ROAM_DIS_MAX
|
||||
} else if(roamDis < ConstantExt.ROAM_DIS_1KM){
|
||||
roamDis = ConstantExt.ROAM_DIS_1KM
|
||||
}
|
||||
@@ -1352,6 +1349,51 @@ class MapAutoViewHelper(mapAutoView: MapAutoView) {
|
||||
mMapAutoView.getMapController()?.setFogMode(isEnable)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置光波
|
||||
* @param start 起点
|
||||
* @param end 终点
|
||||
* @param width 宽度
|
||||
* @param duration 动画时长
|
||||
*/
|
||||
fun setLightWave(list: List<LonLatPoint>, width: Double, duration: Double){
|
||||
mMapAutoView.getMapController()?.setLightWave(list, width, duration)
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置引导线
|
||||
* @param list 引导线轨迹
|
||||
*/
|
||||
fun setGuideLine(list: List<LonLatPoint>?){
|
||||
mMapAutoView.getMapController()?.setGuideLine(list)
|
||||
}
|
||||
|
||||
fun setRoadTexSize(size: Float){
|
||||
mMapAutoView.getClerk()?.add("$size")
|
||||
if (CompileConfig.DEBUG){
|
||||
Log.i(TAG, "setRoadTexSize")
|
||||
}
|
||||
mMapAutoView.getMapController()?.setRoadTexSize(size)
|
||||
}
|
||||
|
||||
fun setRoadUseTexture(isEnable: Boolean){
|
||||
mMapAutoView.getClerk()?.add("$isEnable")
|
||||
if (CompileConfig.DEBUG){
|
||||
Log.i(TAG, "setRoadUseTexture")
|
||||
}
|
||||
mMapAutoView.getMapController()?.setRoadUseTexture(isEnable)
|
||||
}
|
||||
|
||||
fun setPlaneUseTexture(isEnable: Boolean){
|
||||
mMapAutoView.getClerk()?.add("$isEnable")
|
||||
if (CompileConfig.DEBUG){
|
||||
Log.i(TAG, "setPlaneUseTexture")
|
||||
}
|
||||
mMapAutoView.getMapController()?.setPlaneUseTexture(isEnable)
|
||||
}
|
||||
|
||||
|
||||
fun addImagetoImageManager(imageKey: String, imageByteArray: ByteArray, width: Int, height: Int):Int?{
|
||||
return mMapAutoView.getMapController()?.addImage(
|
||||
imageKey,
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user