diff --git a/core/mogo-core-data/build.gradle b/core/mogo-core-data/build.gradle index 39b80d4537..9ba5734988 100644 --- a/core/mogo-core-data/build.gradle +++ b/core/mogo-core-data/build.gradle @@ -82,7 +82,7 @@ dependencies { implementation rootProject.ext.dependencies.protobuf_java_util implementation project(':core:mogo-core-res') - api 'com.zhidaoauto.machine:mapdata:1.0.0.2' + api 'com.zhidaoauto.machine:mapdata:1.0.0.3' api project(":libraries:mogo-adas-data") api project(':core:mogo-core-utils') } diff --git a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/road/RoadHelper.kt b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/road/RoadHelper.kt index 97f656abca..aea8481e89 100644 --- a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/road/RoadHelper.kt +++ b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/road/RoadHelper.kt @@ -31,41 +31,45 @@ import java.util.concurrent.CopyOnWriteArrayList import java.util.concurrent.atomic.AtomicBoolean -class RoadHelper { +class RoadHelper private constructor() { - val TAG = javaClass.simpleName + companion object{ + const val TAG = "RoadHelper" + + var sInstance: RoadHelper? = null + + @Synchronized + fun getInstance(): RoadHelper? { + if (sInstance == null) { + sInstance = RoadHelper() + } + return sInstance + } + } + + private var routeInfoProvider: RouteInfoProvider = RouteInfoProvider() + private var hdMapProvider: HDMapProvider = HDMapProvider() + private var mapBox: MapBox = MapBox() - private var routeInfoProvider: RouteInfoProvider - private var hdMapProvider: HDMapProvider - private var mapBox: MapBox //GPS匹配最小距离 - private val minGPSDistance = 15f; + private val minGPSDistance = 15f //GPS匹配最小角度 - private val minGPSAngle = 15f; + private val minGPSAngle = 15f //RTK匹配最小距离 - private val minRTKDistance = 5f; + private val minRTKDistance = 5f //RTK匹配最小角度 - private val minRTKAngle = 5f; + private val minRTKAngle = 5f private val MAX_CACHE_SIZE = 20 // Set the maximum size of the cache //限速相关 var lastSpeed = 60 - private var cacheHdDataProgressJob: Job? = null private var mHdDataDownloadListener: ConcurrentHashMap? = null - private constructor() { - routeInfoProvider = RouteInfoProvider() - hdMapProvider = HDMapProvider() - mapBox = MapBox() - } - fun release(){ - - cacheHdDataProgressJob?.cancel() cacheHdDataProgressJob = null @@ -76,39 +80,23 @@ class RoadHelper { RouteInfoProvider.release() if(CompileConfig.DEBUG){ - Log.w(TAG, "destroyop--:RouteInfoProvider.destory") + Log.w(TAG, "destroyop--:RouteInfoProvider.destroy") } hdMapProvider.release() if(CompileConfig.DEBUG){ - Log.w(TAG, "destroyop--:hdMapProvider.destory") + Log.w(TAG, "destroyop--:hdMapProvider.destroy") } RoadResultController.instance.exit() if(CompileConfig.DEBUG){ - Log.w(TAG, "destroyop--:RoadResultController.destory") + Log.w(TAG, "destroyop--:RoadResultController.destroy") } - mapBox.llaRelease(); + mapBox.llaRelease() if(CompileConfig.DEBUG){ - Log.w(TAG, "destroyop--:mapBox.destory") + Log.w(TAG, "destroyop--:mapBox.destroy") } sInstance = null } -// companion object { -// val instance: RoadHelper by lazy(LazyThreadSafetyMode.SYNCHRONIZED) { RoadHelper() } -// } - - companion object{ - var sInstance: RoadHelper? = null - - @Synchronized - fun getInstance(): RoadHelper? { - if (sInstance == null) { - sInstance = RoadHelper() - } - return sInstance - } - } - /** * 获取道路信息 * coor 坐标系,0 GPS ,1 gcj @@ -124,7 +112,6 @@ class RoadHelper { return routeInfoProvider.getRouteInfo(centerLon, centerLat, coor, roadType); } - /** * 获取行车方向 * @@ -168,7 +155,6 @@ class RoadHelper { return result } - /** * 转换道路信息经纬度 */ @@ -180,31 +166,29 @@ class RoadHelper { return result } - /** * 获取匹配道路 * */ fun getSinglePointMatchRoad(lon: Double, lat: Double, angle: Float, isGPS: Boolean,isRTK:Boolean): SinglePointRoadInfo? { - var result = "" var rulerDistance = minGPSDistance var rulerAngle = minGPSAngle if(isRTK){ rulerDistance = minRTKDistance rulerAngle = minRTKAngle } - if (!isGPS) { - val lonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(LonLatPoint(lon.toDouble(), lat.toDouble())) + val result = if (!isGPS) { + val lonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(LonLatPoint(lon, lat)) if (CompileConfig.DEBUG) { Log.i(TAG, "roadop--gisop getSinglePointMatchRoad:${lonLat.lon},${lonLat.lat},${angle},${isGPS}") } - result = routeInfoProvider.matchHDSinglePointOnRoad(lonLat.lon, lonLat.lat, angle,rulerDistance,rulerAngle,!isRTK) + routeInfoProvider.matchHDSinglePointOnRoad(lonLat.lon, lonLat.lat, angle,rulerDistance,rulerAngle,!isRTK) } else { if (CompileConfig.DEBUG) { Log.i(TAG, "roadop--gisop getSinglePointMatchRoad:${lon},${lat},${angle},${isGPS}") } - result = routeInfoProvider.matchHDSinglePointOnRoad(lon, lat, angle,rulerDistance,rulerAngle,!isRTK) + routeInfoProvider.matchHDSinglePointOnRoad(lon, lat, angle,rulerDistance,rulerAngle,!isRTK) } if (CompileConfig.DEBUG) { Log.i(TAG, "roadop--gisop getSinglePointMatchRoad:result:${result}") @@ -323,15 +307,15 @@ class RoadHelper { roadSign.shape = trafficSign.shape roadSign.tileId = trafficSign.tileId roadSign.type = trafficSign.type - val postion = ArrayList() + val position = ArrayList() for (trafficSignPosition in trafficSign.position){ - val roadSignPostion = RoadSignPostion() - roadSignPostion.lon = trafficSignPosition.lon - roadSignPostion.lat = trafficSignPosition.lat - roadSignPostion.hight = trafficSignPosition.hight - postion.add(roadSignPostion) + val roadSignPosition = RoadSignPostion() + roadSignPosition.lon = trafficSignPosition.lon + roadSignPosition.lat = trafficSignPosition.lat + roadSignPosition.hight = trafficSignPosition.hight + position.add(roadSignPosition) } - roadSign.position = postion + roadSign.position = position roadSignList.add(roadSign) } @@ -366,15 +350,14 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val 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() + roadInfo.tileID = buf.int + roadInfo.id = buf.int + roadInfo.speed = buf.int + roadInfo.roadID = buf.int + roadInfo.laneId = buf.int if(roadInfo.speed>250){ roadInfo.speed = lastSpeed }else{ @@ -383,7 +366,7 @@ class RoadHelper { if (CompileConfig.DEBUG) { LogHelper.info( TAG, - "roadop--getRoadLimitSpeed--roadInfo: ${roadInfo}" + "roadop--getRoadLimitSpeed--roadInfo: $roadInfo" ) } // Add new value to LinkedHashMap @@ -436,7 +419,7 @@ class RoadHelper { * This function returns the center line of a given road segment. * * @param dLon The longitude of the starting point of the road segment. - * @param dlat The latitude of the starting point of the road segment. + * @param dLat The latitude of the starting point of the road segment. * @param fAngle The angle of the road segment. * @return The center line of the road segment. */ @@ -456,26 +439,25 @@ class RoadHelper { override fun result(code: Int, result: ByteArray?) { if (CompileConfig.DEBUG) { - Log.d(TAG, "roadop--getCenterLine--code:${code}, result: ${result}") + Log.d(TAG, "roadop--getCenterLine--code:${code}, result: $result") } if (result?.isEmpty() == true){ call.result(1,null) return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val 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() + val centerLine = CenterLine() + centerLine.id = buf.int.toString() + centerLine.tile_id = buf.int.toString() + centerLine.road_id = buf.int.toString() + centerLine.lane_id = buf.int.toString() + val size = buf.int + val points = ArrayList() for (i in 0 until size step 2) { - var lonLatPoint = LonLatPoint(buf.getLong()/ 1e8, buf.getLong()/ 1e8) + val lonLatPoint = LonLatPoint(buf.long / 1e8, buf.long / 1e8) points.add(lonLatPoint) } centerLine.points = points @@ -488,7 +470,7 @@ class RoadHelper { if (CompileConfig.DEBUG) { Log.d( TAG, - "roadop--getCenterLine--centerLine: ${centerLine}" + "roadop--getCenterLine--centerLine: $centerLine" ) } call.result(0, centerLine) @@ -514,7 +496,7 @@ class RoadHelper { * It also calculates the distance from the current location to the stop line using MapDataApi.getNearstFromPointToSegment function. * * @param dLon The longitude of the point of interest. - * @param dlat The latitude of the point of interest. + * @param dLat The latitude of the point of interest. * @param fAngle The angle in degrees of the vehicle at the point of interest. * @return A StopLine object that contains information about the stop line, or null if no stop line was found. */ @@ -542,41 +524,40 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { - val tile_id = it.getInt() - if(tile_id == 0){ + val tileId = buf.int + if(tileId == 0){ call.result(1,null) return } 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() + stopLine.tile_id = "$tileId" + stopLine.length = buf.int.toDouble() + val roadIdSize = buf.int + val laneIdSize = buf.int + val pointSize = buf.int + val roadIds = ArrayList() for (i in 0 until roadIdSize) { - var roadId = it.getInt().toString() + val roadId = buf.int.toString() roadIds.add(roadId) } stopLine.road_id = roadIds - var laneIds = ArrayList() + val laneIds = ArrayList() for (i in 0 until laneIdSize) { - var laneId = it.getInt().toString() + val laneId = buf.int.toString() laneIds.add(laneId) } stopLine.lane_id = laneIds - var points = ArrayList() + val points = ArrayList() for (i in 0 until pointSize step 2) { - var lonLatPoint = LonLatPoint(buf.getLong()/ 1e8, buf.getLong()/ 1e8) + val lonLatPoint = LonLatPoint(buf.long / 1e8, buf.long / 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}") + Log.d(TAG, "roadop--getStopLine--stopLine: $stopLine") } stopLineCache.put(key,stopLine) call.result(0,stopLine) @@ -624,26 +605,25 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { val roadRectInfos = RoadRectInfos() - roadRectInfos.angle = it.getLong() / 1e8 + roadRectInfos.angle = buf.long / 1e8 val rectList = ArrayList() - val size = it.getInt() + val size = buf.int for (i in 0 until size step 8) { val rect = RoadRect() - 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) + rect.topLeft = LonLatPoint(buf.long / 1e8, buf.long / 1e8) + rect.topRight = LonLatPoint(buf.long / 1e8, buf.long / 1e8) + rect.bottomLeft = LonLatPoint(buf.long / 1e8, buf.long / 1e8) + rect.bottomRight = LonLatPoint(buf.long / 1e8, buf.long / 1e8) rectList.add(rect) } roadRectInfos.roadRects = rectList if (CompileConfig.DEBUG) { Log.d( TAG, - "roadop--getRoadRect--roadRectInfos: ${roadRectInfos}" + "roadop--getRoadRect--roadRectInfos: $roadRectInfos" ) } // Add the result to the cache @@ -693,19 +673,18 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val 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() + val centerLine = CenterLine() + centerLine.id = buf.int.toString() + centerLine.tile_id = buf.int.toString() + centerLine.road_id = buf.int.toString() + centerLine.lane_id = buf.int.toString() + val size = buf.int + val points = ArrayList() for (i in 0 until size step 2) { - var lonLatPoint = LonLatPoint(buf.getLong()/ 1e8, buf.getLong()/ 1e8) + val lonLatPoint = LonLatPoint(buf.long / 1e8, buf.long / 1e8) points.add(lonLatPoint) } centerLine.points = points @@ -718,7 +697,7 @@ class RoadHelper { if (CompileConfig.DEBUG) { LogHelper.info( TAG, - "roadop--getCenterLineRange--centerLine: ${centerLine}" + "roadop--getCenterLineRange--centerLine: $centerLine" ) } call.result(0, centerLine) @@ -771,19 +750,18 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val 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() + val centerLine = CenterLine() + centerLine.id = buf.int.toString() + centerLine.tile_id = buf.int.toString() + centerLine.road_id = buf.int.toString() + centerLine.lane_id = buf.int.toString() + val size = buf.int + val points = ArrayList() for (i in 0 until size step 2) { - var lonLatPoint = LonLatPoint(buf.getLong()/ 1e8, buf.getLong()/ 1e8) + val lonLatPoint = LonLatPoint(buf.long / 1e8, buf.long / 1e8) points.add(lonLatPoint) } centerLine.points = points @@ -802,10 +780,8 @@ class RoadHelper { mapBox.llaGetCenterLineRoadNode(dLon, dLat, fAngle, fDis) } - - - fun getRoadName(dLon: Double, dlat: Double, fAngle: Float,call: IResult){ - RoadResultController.instance.addRoadResultListener("llaGetRoadName_${dLon.toTenDecimalsStr()}_${dlat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}",object :IRoadData{ + fun getRoadName(dLon: Double, dLat: Double, fAngle: Float,call: IResult){ + RoadResultController.instance.addRoadResultListener("llaGetRoadName_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}",object :IRoadData{ override fun result(code: Int, result: ByteArray?) { if (CompileConfig.DEBUG) { Log.d(TAG, "roadop--getRoadName--code:${code},result: $result") @@ -815,13 +791,12 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { val roadNameInfo = RoadNameInfo() - roadNameInfo.tile_id = it.getInt().toString() - roadNameInfo.road_id = it.getInt().toString() + roadNameInfo.tile_id = buf.int.toString() + roadNameInfo.road_id = buf.int.toString() roadNameInfo.road_name = ByteBufferHelper.buf2Str(buf)?:"" if (CompileConfig.DEBUG) { Log.d(TAG, "roadop--getRoadName--roadNameInfo:${roadNameInfo}") @@ -835,7 +810,7 @@ class RoadHelper { } }) - mapBox.llaGetRoadName(dLon,dlat,fAngle) + mapBox.llaGetRoadName(dLon,dLat,fAngle) } @@ -845,8 +820,8 @@ class RoadHelper { * 获取路口信息 */ - fun getCrossRoad(dLon: Double, dlat: Double, fAngle: Float,call: IResult) { - val cacheKey = "llaGetCrossRoad_${dLon.toTenDecimalsStr()}_${dlat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}" + fun getCrossRoad(dLon: Double, dLat: Double, fAngle: Float,call: IResult) { + val cacheKey = "llaGetCrossRoad_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}" // Check if the result is already in the cache crossRoadCache.get(cacheKey)?.let { @@ -865,22 +840,21 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { val roadCross = RoadCross() - roadCross.status = it.getInt() - val tile_id = it.getInt() - if(tile_id == 0){ + roadCross.status = buf.int + val tileId = buf.int + if(tileId == 0){ call.result(1,null) } - roadCross.tile_id = "${tile_id}" - roadCross.cross_id= it.getLong().toString() + roadCross.tile_id = "$tileId" + roadCross.cross_id= buf.long.toString() if(roadCross.status == 0){ - roadCross.tile_id_end = it.getInt().toString() - roadCross.cross_id_end = it.getLong().toString() + roadCross.tile_id_end = buf.int.toString() + roadCross.cross_id_end = buf.long.toString() } if (CompileConfig.DEBUG) { Log.d(TAG, "roadop--getCrossRoad--roadCross:${roadCross}") @@ -896,7 +870,7 @@ class RoadHelper { } }) - mapBox.llaGetCrossRoad(dLon, dlat, fAngle) + mapBox.llaGetCrossRoad(dLon, dLat, fAngle) } @@ -911,14 +885,13 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { val list = ArrayList() - val size = it.getInt() + val size = buf.int for(i in 0 until size step 2){ - val lonLatPoint = LonLatPoint(it.getLong()/1e8, it.getLong()/1e8) + val lonLatPoint = LonLatPoint(buf.long /1e8, buf.long /1e8) list.add(lonLatPoint) } if (CompileConfig.DEBUG) { @@ -955,11 +928,10 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { - call.result(code, it.getInt()) + call.result(code, buf.int) return } } @@ -983,11 +955,10 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { - call.result(code, it.getInt() == 1) + call.result(code, buf.int == 1) return } } @@ -1009,11 +980,10 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { - call.result(code, it.getLong()/1e8) + call.result(code, buf.long /1e8) return } } @@ -1037,11 +1007,10 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { - val cityCode = it.getInt() + val cityCode = buf.int if (CompileConfig.DEBUG) { Log.d(TAG, "roadop--getCityCode-${cityCode}") } @@ -1073,12 +1042,12 @@ class RoadHelper { return } getAllCityCode(object : IResult> { - override fun result(code: Int, cityList: ArrayList?) { - if(cityList == null || cityList.size == 0){ + override fun result(code: Int, result: ArrayList?) { + if(result == null || result.size == 0){ call.result(1,false) return } - for(city in cityList){ + for(city in result){ if(id == city.cityCode){ call.result(code,city.isCache) return @@ -1099,24 +1068,23 @@ class RoadHelper { override fun result(code: Int, result: ByteArray?) { if(CompileConfig.DEBUG){ - Log.d(TAG, "roadop--getAllCityCode--result: ${result}") + Log.d(TAG, "roadop--getAllCityCode--result: $result") } if (result?.isEmpty() == true) { call.result(1, null) return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { val cityList = ArrayList() - val size = it.getInt() + val size = buf.int for(i in 0 until size step 6){ val cityInfo = CityInfo() - cityInfo.cityCode = it.getInt() + cityInfo.cityCode = buf.int cityInfo.chineseCityName = ByteBufferHelper.buf2Str(buf)?:"" cityInfo.englishCityName = ByteBufferHelper.buf2Str(buf)?:"" - cityInfo.isCache = it.getInt() == 1 + cityInfo.isCache = buf.int == 1 cityList.add(cityInfo) } call.result(code,cityList) @@ -1149,10 +1117,9 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { - val version = it.getInt().toString() + val version = buf.int.toString() if (CompileConfig.DEBUG) { Log.d(TAG, "roadop--getHdDataVersionByCity-version:${version}") } @@ -1166,8 +1133,8 @@ class RoadHelper { mapBox.getHdDataVersionByCity(lon,lat) } - fun getZebraLineByDistance(dLon: Double, dlat: Double , fAngle: Float, dis: Float,call: IResult>){ - RoadResultController.instance.addRoadResultListener("llaGetZebraLineByDistance_${dLon.toTenDecimalsStr()}_${dlat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${dis.toTenDecimalsStr()}",object :IRoadData{ + fun getZebraLineByDistance(dLon: Double, dLat: Double , fAngle: Float, dis: Float,call: IResult>){ + RoadResultController.instance.addRoadResultListener("llaGetZebraLineByDistance_${dLon.toTenDecimalsStr()}_${dLat.toTenDecimalsStr()}_${fAngle.toTenDecimalsStr()}_${dis.toTenDecimalsStr()}",object :IRoadData{ override fun result(code: Int, result: ByteArray?) { if (CompileConfig.DEBUG) { Log.d(TAG, "roadop--getZebraLineByDistance--code:${code},result: $result") @@ -1177,20 +1144,19 @@ class RoadHelper { return } result?.let { - var result = it - var buf = ByteBufferHelper.bytes2ByteBuffer(result) + val buf = ByteBufferHelper.bytes2ByteBuffer(result) buf?.let { val list = ArrayList() - val size = it.getInt() + val size = buf.int 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() + zebraLine.dis = buf.long /1e8.toFloat() + zebraLine.tileId = buf.int.toString() + zebraLine.id = buf.int.toString() + val size = buf.int val lonlats = ArrayList() for(i in 0 until size step 2){ - val lonLatPoint = LonLatPoint(it.getLong()/1e8, it.getLong()/1e8) + val lonLatPoint = LonLatPoint(buf.long /1e8, buf.long /1e8) lonlats.add(lonLatPoint) } zebraLine.zebraLineList = lonlats @@ -1210,7 +1176,7 @@ class RoadHelper { } }) - mapBox.llaGetZebraLineByDistance(dLon,dlat,fAngle,dis) + mapBox.llaGetZebraLineByDistance(dLon,dLat,fAngle,dis) } @@ -1279,15 +1245,15 @@ class RoadHelper { return } getInstance()?.getCityCode(lon, lat, object : IResult { - override fun result(code: Int, id: Int?) { - if (id == 0) { + override fun result(code: Int, result: Int?) { + if (result == 0) { return } if (CompileConfig.DEBUG) { - Log.i(TAG, "cacheHDDataByCityLonLat--op--id: ${id}") + Log.i(TAG, "cacheHDDataByCityLonLat--op--id: $result") } - id?.let { - cacheHDDataByCity(id, listener) + result?.let { + cacheHDDataByCity(result, listener) } } diff --git a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/utils/ByteBufferHelper.kt b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/utils/ByteBufferHelper.kt index e4902260dd..1b470211bf 100644 --- a/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/utils/ByteBufferHelper.kt +++ b/libraries/mapmodule/src/main/java/com/zhidaoauto/map/sdk/inner/utils/ByteBufferHelper.kt @@ -12,7 +12,7 @@ object ByteBufferHelper { } fun buf2Str(buf: ByteBuffer): String? { - val l = buf.getInt() + val l = buf.int var ret: String? = null if (l > 0) { val tmp = ByteArray(l)