[3.4.0-map-sdk] code style
This commit is contained in:
@@ -52,8 +52,8 @@ public class SharedMemoryService {
|
||||
|
||||
HDMapProvider.setDataFileSource(MapHelper.INSTANCE.getMMapParams().getDataFileSource());
|
||||
HDMapProvider.setDataRedisSource(MapHelper.INSTANCE.getMMapParams().getDataRedisFileSource());
|
||||
if (!TextUtils.isEmpty(MapHelper.INSTANCE.getMMapParams().getHdmapPath())) {
|
||||
HDMapProvider.setDataDir(MapHelper.INSTANCE.getMMapParams().getHdmapPath());
|
||||
if (!TextUtils.isEmpty(MapHelper.INSTANCE.getMMapParams().getHdMapPath())) {
|
||||
HDMapProvider.setDataDir(MapHelper.INSTANCE.getMMapParams().getHdMapPath());
|
||||
}
|
||||
|
||||
String dir = Constant.getNDSDataPath();
|
||||
@@ -64,7 +64,7 @@ public class SharedMemoryService {
|
||||
if (CompileConfig.INSTANCE.getDEBUG()) {
|
||||
Log.i(TAG, "autoop-dir:" + dir+",SharedMemory--cachePath:"+cachePath);
|
||||
}
|
||||
initSharedMemory_Native(dir, cachePath,MapHelper.INSTANCE.getMMapParams().getQzoneFilterArray());
|
||||
initSharedMemory_Native(dir, cachePath,MapHelper.INSTANCE.getMMapParams().getQZoneFilterArray());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,12 +8,12 @@ import android.graphics.Canvas
|
||||
object CommonUtils {
|
||||
|
||||
fun getScreenWidth(context: Context): Int {
|
||||
val displayMetrics = context.resources.getDisplayMetrics()
|
||||
val displayMetrics = context.resources.displayMetrics
|
||||
return displayMetrics.widthPixels
|
||||
}
|
||||
|
||||
fun getScreenHeight(context: Context): Int {
|
||||
val displayMetrics = context.resources.getDisplayMetrics()
|
||||
val displayMetrics = context.resources.displayMetrics
|
||||
return displayMetrics.heightPixels
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ object CommonUtils {
|
||||
val bgHeight = background.height
|
||||
val fgWidth = foreground.width
|
||||
val fgHeight = foreground.height
|
||||
val newmap = Bitmap.createBitmap(bgWidth, bgHeight, Bitmap.Config.ARGB_8888)
|
||||
val canvas = Canvas(newmap)
|
||||
val newMap = Bitmap.createBitmap(bgWidth, bgHeight, Bitmap.Config.ARGB_8888)
|
||||
val canvas = Canvas(newMap)
|
||||
canvas.drawBitmap(background, 0f, 0f, null)
|
||||
canvas.drawBitmap(
|
||||
foreground, (bgWidth - fgWidth) / 2f,
|
||||
@@ -40,12 +40,11 @@ object CommonUtils {
|
||||
)
|
||||
canvas.save()
|
||||
canvas.restore()
|
||||
return newmap
|
||||
return newMap
|
||||
}
|
||||
|
||||
fun getCachePath(context: Context?): String{
|
||||
var cachePath = ""
|
||||
cachePath = if (context != null) {
|
||||
val cachePath = if (context != null) {
|
||||
context.filesDir.absolutePath + "/vr_tiles"
|
||||
} else {
|
||||
"sdcard/vr_tiles"
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.zhidaoauto.map.sdk.open.view.MapAutoView
|
||||
import io.netty.buffer.Unpooled
|
||||
import java.math.BigDecimal
|
||||
import java.nio.charset.Charset
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.pow
|
||||
|
||||
|
||||
@@ -127,8 +128,8 @@ object MapAutoApi {
|
||||
// VR
|
||||
if(mapParams.getDataFileSource() == 0){
|
||||
MapHdDataHelper.initDataMgr(context)
|
||||
}else if (TextUtils.isEmpty(mapParams.getHdmapPath())) {
|
||||
mapParams.setHdmapPath("${customPath}/shmdata")
|
||||
}else if (TextUtils.isEmpty(mapParams.getHdMapPath())) {
|
||||
mapParams.setHdMapPath("${customPath}/shmdata")
|
||||
MapHdDataHelper.copyAssetsToSdcard(context, "hdmapData", "${customPath}/shmdata/hdmapData")
|
||||
}else{
|
||||
MapHdDataHelper.loadDataOver.set(true)
|
||||
@@ -240,11 +241,11 @@ object MapAutoApi {
|
||||
* 莫顿码转换为经纬度
|
||||
*/
|
||||
private fun fromMortonCode(mortonCode: Long): LonLat {
|
||||
var coord: Coord = mortonCodeToCoord(mortonCode)
|
||||
val coord: Coord = mortonCodeToCoord(mortonCode)
|
||||
|
||||
normalizeCoord(coord)
|
||||
var lon = String.format("%.8f", coord.x * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
var lat = String.format("%.8f", coord.y * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
val lon = String.format("%.8f", coord.x * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
val lat = String.format("%.8f", coord.y * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
return LonLat(lon, lat)
|
||||
}
|
||||
|
||||
@@ -252,7 +253,7 @@ object MapAutoApi {
|
||||
* 莫顿码转换为莫顿坐标
|
||||
*/
|
||||
private fun mortonCodeToCoord(mortonCodeParam: Long):Coord {
|
||||
var coord: Coord = Coord()
|
||||
val coord = Coord()
|
||||
var mortonCode = mortonCodeParam
|
||||
var bit: Long = 1
|
||||
coord.x = 0
|
||||
@@ -314,8 +315,7 @@ object MapAutoApi {
|
||||
}
|
||||
|
||||
//lng>73.66 && lng < 135.05 && lat > 3.86 && lat < 53.55
|
||||
fun randomLonlat(): LonLatPoint {
|
||||
|
||||
fun randomLonLat(): LonLatPoint {
|
||||
// return randomLonLatArea(73.66, 135.05, 3.86, 53.55)
|
||||
return randomLonLatArea(100.01, 118.02, 21.36, 43.55)
|
||||
}
|
||||
@@ -343,15 +343,15 @@ object MapAutoApi {
|
||||
|
||||
fun angleDiff(a:Double,b:Double):Double{
|
||||
val d1: Double = a - b
|
||||
var d2: Double = 360 - Math.abs(d1)
|
||||
var d2: Double = 360 - abs(d1)
|
||||
//d1>0,那么相当于从b顺时针旋转d1能到a,那么当这个旋转角度大于180度时,不如从b逆时针旋d2转到a(取反那一步就代表逆时针旋转)
|
||||
if (d1 > 0){
|
||||
d2 *= -1.0
|
||||
}
|
||||
if (Math.abs(d1) < Math.abs(d2)){
|
||||
return d1
|
||||
return if (abs(d1) < abs(d2)){
|
||||
d1
|
||||
} else{
|
||||
return d2
|
||||
d2
|
||||
}
|
||||
|
||||
}
|
||||
@@ -379,8 +379,8 @@ object MapAutoApi {
|
||||
// Clerk.add("$tileId")
|
||||
val coord = getLeftBottomOfTile(tileId)
|
||||
val result = Coord_d();
|
||||
var lon = String.format("%.9f", coord.x * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
var lat = String.format("%.9f", coord.y * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
val lon = String.format("%.9f", coord.x * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
val lat = String.format("%.9f", coord.y * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
result.lon = lon
|
||||
result.lat = lat
|
||||
// System.out.println("getLonlatOfTile:${lon},${lat}")
|
||||
@@ -399,7 +399,7 @@ object MapAutoApi {
|
||||
val mortonCode = indexOfTile shl (2 * (31 - level))
|
||||
// val mortonCode1 = tileId*Math.pow(2.0,2.0*(31-level)).toLong()
|
||||
//System.out.println("mortonCode:${mortonCode}")
|
||||
var coord = mortonCodeToCoord(mortonCode)
|
||||
val coord = mortonCodeToCoord(mortonCode)
|
||||
|
||||
//System.out.println("mortonCodeToCoord:${coord.x},${coord.y}")
|
||||
normalizeCoord(coord)
|
||||
@@ -416,8 +416,8 @@ object MapAutoApi {
|
||||
// println("level:$level")
|
||||
val coord = getLeftBottomOfTileWithLevel(tileId, level)
|
||||
val result = Box();
|
||||
var lon = String.format("%.9f", coord.x * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
var lat = String.format("%.9f", coord.y * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
val lon = String.format("%.9f", coord.x * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
val lat = String.format("%.9f", coord.y * RULE_MORTON_TO_LONLAT).toDouble()
|
||||
result.lbLon = lon
|
||||
result.lbLat = lat
|
||||
val c: Int = getTileSize(level) - 1
|
||||
@@ -471,32 +471,32 @@ object MapAutoApi {
|
||||
|
||||
//112.59231238564,26.83079549695
|
||||
|
||||
var array1 = TransformUtils.transformGcj02toWgs84(26.875038,112.538527)
|
||||
System.out.println("GPS:${array1!![0]},${array1!![1]}")
|
||||
var array = TransformUtils.transformGcj02toWgs84(26.83079549695, 112.59231238564)
|
||||
System.out.println("GPS:${array!![0]},${array!![1]}")
|
||||
val code = toMortonCode(array!![0], array!![1])
|
||||
System.out.println("code:${code}")
|
||||
val array1 = TransformUtils.transformGcj02toWgs84(26.875038,112.538527)
|
||||
println("GPS:${array1[0]},${array1[1]}")
|
||||
val array = TransformUtils.transformGcj02toWgs84(26.83079549695, 112.59231238564)
|
||||
println("GPS:${array[0]},${array[1]}")
|
||||
val code = toMortonCode(array[0], array[1])
|
||||
println("code:${code}")
|
||||
var tileId = getTileIdByMortonCode(code,13)
|
||||
System.out.println("tileId:${tileId}")
|
||||
println("tileId:${tileId}")
|
||||
val lonLat = fromMortonCode(code)
|
||||
System.out.println("LonLat--GPS:${lonLat}")
|
||||
System.out.println("getTileID-13:${getTileID(100.14754525, 25.76392892,13)}")
|
||||
System.out.println("getTileID-13:${getTileID(112.577272,26.828447,13)}")
|
||||
System.out.println("getTileID-14:${getTileID(112.5719037958,26.8208054862,14)}")
|
||||
System.out.println("getTileID-15:${getTileID(112.5719037958,26.8208054862,15)}")
|
||||
System.out.println("getTileID-16:${getTileID(112.5719037958,26.8208054862,16)}")
|
||||
println("LonLat--GPS:${lonLat}")
|
||||
println("getTileID-13:${getTileID(100.14754525, 25.76392892,13)}")
|
||||
println("getTileID-13:${getTileID(112.577272,26.828447,13)}")
|
||||
println("getTileID-14:${getTileID(112.5719037958,26.8208054862,14)}")
|
||||
println("getTileID-15:${getTileID(112.5719037958,26.8208054862,15)}")
|
||||
println("getTileID-16:${getTileID(112.5719037958,26.8208054862,16)}")
|
||||
val curLon = 112.598977
|
||||
val curLat = 26.831300
|
||||
println("---$curLon,$curLat-----")
|
||||
tileId = getTileID(curLon,curLat,16)
|
||||
tileId = 5572659558
|
||||
System.out.println("getTileID-16:${tileId}")
|
||||
println("getTileID-16:${tileId}")
|
||||
var box = getTileBoundingBox(tileId)
|
||||
System.out.println("getTileBoundingBox:${box.lbLon},${box.lbLat},${box.rtLon},${box.rtLat}")
|
||||
println("getTileBoundingBox:${box.lbLon},${box.lbLat},${box.rtLon},${box.rtLat}")
|
||||
|
||||
var unitLon = (box.rtLon-box.lbLon)/1250.0
|
||||
var unitLat = (box.rtLon-box.lbLon)/1250.0
|
||||
val unitLon = (box.rtLon-box.lbLon)/1250.0
|
||||
val unitLat = (box.rtLon-box.lbLon)/1250.0
|
||||
val upX = (box.rtLon-curLon)
|
||||
val upY = (box.rtLat-curLat)
|
||||
val downX = (box.rtLon-box.lbLon)
|
||||
@@ -511,11 +511,11 @@ object MapAutoApi {
|
||||
// System.out.println("getLeftBottomOfTile:${coord.x},${coord.y}")
|
||||
|
||||
val coord_d = getLonlatOfTile(5613151104)
|
||||
System.out.println("getLonlatOfTile:${coord_d.lon},${coord_d.lat}")
|
||||
println("getLonlatOfTile:${coord_d.lon},${coord_d.lat}")
|
||||
box = getTileBoundingBox(5613151104)
|
||||
System.out.println("getTileBoundingBox:${box.lbLon},${box.lbLat},${box.rtLon},${box.rtLat}")
|
||||
println("getTileBoundingBox:${box.lbLon},${box.lbLat},${box.rtLon},${box.rtLat}")
|
||||
box = getTileBoundingBox(5572660368)
|
||||
System.out.println("-getTileBoundingBox:${box.lbLon},${box.lbLat},${box.rtLon},${box.rtLat}")
|
||||
println("-getTileBoundingBox:${box.lbLon},${box.lbLat},${box.rtLon},${box.rtLat}")
|
||||
println("--------")
|
||||
val byteBuffer = Unpooled.buffer()
|
||||
val str = "1111112345678sjkfdhdkb"
|
||||
@@ -525,18 +525,18 @@ object MapAutoApi {
|
||||
byteBuffer.writeInt(999)
|
||||
byteBuffer.writeInt(12)
|
||||
val length = byteBuffer.readInt()
|
||||
System.out.println("${length}")
|
||||
System.out.println("${byteBuffer.readCharSequence(length, Charset.forName("utf-8"))}")
|
||||
System.out.println("${byteBuffer.readBoolean()}")
|
||||
System.out.println("${byteBuffer.readInt()}")
|
||||
println("$length")
|
||||
println("${byteBuffer.readCharSequence(length, Charset.forName("utf-8"))}")
|
||||
println("${byteBuffer.readBoolean()}")
|
||||
println("${byteBuffer.readInt()}")
|
||||
|
||||
val lon = 116.410669178793
|
||||
val lat = 39.9908766892266
|
||||
val angle = 179.9999991082
|
||||
val res = MathUtils.convertAngle(angle,lon, lat)
|
||||
System.out.println("$res")
|
||||
System.out.println("${Math.toDegrees(3.62347793579102)}")
|
||||
System.out.println("${Math.toDegrees(1.13428950309753)}")
|
||||
println("$res")
|
||||
println("${Math.toDegrees(3.62347793579102)}")
|
||||
println("${Math.toDegrees(1.13428950309753)}")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -3,11 +3,11 @@ package com.zhidaoauto.map.sdk.open
|
||||
import com.zhidaoauto.map.sdk.inner.common.MapHelper
|
||||
import com.zhidaoauto.map.sdk.inner.map.MapController
|
||||
|
||||
class MapParams {
|
||||
class MapParams private constructor() {
|
||||
|
||||
private var debugMode: Boolean = MapHelper.debug
|
||||
|
||||
// GPS(WGS84) 0 ;GCJ-02(高德) 1; BD09(百度) 2;
|
||||
// GPS(WGS84) 0 GCJ-02(高德) 1 BD09(百度) 2
|
||||
private var coordinateType: Int = COORDINATETYPE_GCJ02
|
||||
|
||||
// 样式
|
||||
@@ -17,19 +17,16 @@ class MapParams {
|
||||
private var cachePath: String = ""
|
||||
|
||||
// 高精数据目录
|
||||
private var hdmapPath: String = ""
|
||||
private var hdMapPath: String = ""
|
||||
|
||||
private var dataFileSource = 0 // 1,本地文件。非1,redis获取
|
||||
private var dataRedisSource = 0 // 1,测试redis(42)。2 长期测试redis 3 演示redis 0正式redis(根据域名访问的)
|
||||
|
||||
private var qzoneFilterArray = IntArray(0)
|
||||
private var qZoneFilterArray = IntArray(0)
|
||||
|
||||
//开启日志
|
||||
private var isRecordLogs = true
|
||||
|
||||
private constructor()
|
||||
|
||||
|
||||
companion object {
|
||||
// 地图坐标系统GPS(WGS84)
|
||||
const val COORDINATETYPE_WGS84 = 1
|
||||
@@ -48,12 +45,10 @@ class MapParams {
|
||||
const val STYLE_ERHAI = "erhai"
|
||||
const val STYLE_NORMAL = "normal"
|
||||
|
||||
|
||||
fun init(): MapParams {
|
||||
return MapParams()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -62,7 +57,7 @@ class MapParams {
|
||||
*/
|
||||
fun setCoordinateType(coordinateType: Int): MapParams {
|
||||
this.coordinateType = coordinateType
|
||||
return this;
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -71,7 +66,7 @@ class MapParams {
|
||||
*/
|
||||
fun setDebugMode(debug: Boolean): MapParams {
|
||||
this.debugMode = debug
|
||||
return this;
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -80,7 +75,7 @@ class MapParams {
|
||||
*/
|
||||
fun setStyleDir(stylePath: String): MapParams {
|
||||
this.stylePath = stylePath
|
||||
return this;
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,45 +84,44 @@ class MapParams {
|
||||
*/
|
||||
fun setCachePath(cachePath: String): MapParams {
|
||||
this.cachePath = cachePath
|
||||
return this;
|
||||
return this
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据路径
|
||||
* @param hdmapPath 路径
|
||||
* @param hdMapPath 路径
|
||||
*/
|
||||
fun setHdmapPath(hdmapPath: String): MapParams {
|
||||
this.hdmapPath = hdmapPath
|
||||
return this;
|
||||
fun setHdMapPath(hdMapPath: String): MapParams {
|
||||
this.hdMapPath = hdMapPath
|
||||
return this
|
||||
}
|
||||
|
||||
fun getCoordinateType(): Int {
|
||||
return coordinateType
|
||||
}
|
||||
|
||||
fun getQzoneFilterArray(): IntArray {
|
||||
return qzoneFilterArray
|
||||
fun getQZoneFilterArray(): IntArray {
|
||||
return qZoneFilterArray
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据区域
|
||||
* @param filter 区域数组
|
||||
*/
|
||||
fun setQzoneFilterArray(filter: IntArray): MapParams {
|
||||
this.qzoneFilterArray = filter
|
||||
return this;
|
||||
fun setQZoneFilterArray(filter: IntArray): MapParams {
|
||||
this.qZoneFilterArray = filter
|
||||
return this
|
||||
}
|
||||
|
||||
fun getCachePath(): String? {
|
||||
fun getCachePath(): String {
|
||||
return cachePath
|
||||
}
|
||||
|
||||
|
||||
fun getHdmapPath(): String? {
|
||||
return hdmapPath
|
||||
fun getHdMapPath(): String {
|
||||
return hdMapPath
|
||||
}
|
||||
|
||||
fun getStyleDir(): String? {
|
||||
fun getStyleDir(): String {
|
||||
return stylePath
|
||||
}
|
||||
|
||||
@@ -176,7 +170,7 @@ class MapParams {
|
||||
}
|
||||
|
||||
override fun toString(): String {
|
||||
return "MapParams(debugMode=$debugMode, stylePath='$stylePath', cachePath='$cachePath', hdmapPath='$hdmapPath', dataFileSource=$dataFileSource, dataRedisSource=$dataRedisSource, qzoneFilterArray=${qzoneFilterArray.contentToString()}, isRecordLogs=$isRecordLogs)"
|
||||
return "MapParams(debugMode=$debugMode, stylePath='$stylePath', cachePath='$cachePath', hdmapPath='$hdMapPath', dataFileSource=$dataFileSource, dataRedisSource=$dataRedisSource, qzoneFilterArray=${qZoneFilterArray.contentToString()}, isRecordLogs=$isRecordLogs)"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.zhidaoauto.map.sdk.open.data
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.ActivityManager
|
||||
import android.content.Context
|
||||
import android.text.TextUtils
|
||||
@@ -26,14 +27,13 @@ import com.zhidaoauto.map.sdk.inner.utils.Recorder
|
||||
import com.zhidaoauto.map.sdk.open.abs.IResult
|
||||
import com.zhidaoauto.map.sdk.open.abs.OnHdDataDownByCityListener
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object MapDataApi {
|
||||
|
||||
private val TAG = javaClass.simpleName
|
||||
private const val TAG = "MapDataApi"
|
||||
|
||||
private var mContext:Context? = null
|
||||
|
||||
|
||||
|
||||
fun getContext():Context?{
|
||||
return mContext
|
||||
}
|
||||
@@ -49,11 +49,11 @@ object MapDataApi {
|
||||
fun destroy(){
|
||||
RoadHelper.getInstance()?.release()
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.w(TAG, "destroyop--:RoadHelper.destory")
|
||||
Log.w(TAG, "destroyop--:RoadHelper.destroy")
|
||||
}
|
||||
SharedMemoryService.getInstance(mContext).exit()
|
||||
if(CompileConfig.DEBUG){
|
||||
Log.w(TAG, "destroyop--:SharedMemoryService.destory")
|
||||
Log.w(TAG, "destroyop--:SharedMemoryService.destroy")
|
||||
}
|
||||
mContext = null
|
||||
}
|
||||
@@ -75,7 +75,7 @@ object MapDataApi {
|
||||
val runningServices = myManager
|
||||
.getRunningServices(50) as ArrayList<ActivityManager.RunningServiceInfo>
|
||||
for (info in runningServices) {
|
||||
if (info.service.className.equals(ServiceName)) {
|
||||
if (info.service.className == ServiceName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
@@ -239,9 +239,9 @@ object MapDataApi {
|
||||
/**
|
||||
* 获取道路路口信息
|
||||
*/
|
||||
fun getCrossRoad(dLon: Double, dlat: Double , fAngle: Float,call: IResult<RoadCross>){
|
||||
Recorder.add("roadop-getCrossRoad:$dLon,$dlat,$fAngle")
|
||||
RoadHelper.getInstance()?.getCrossRoad(dLon, dlat, fAngle,call)
|
||||
fun getCrossRoad(dLon: Double, dLat: Double , fAngle: Float,call: IResult<RoadCross>){
|
||||
Recorder.add("roadop-getCrossRoad:$dLon,$dLat,$fAngle")
|
||||
RoadHelper.getInstance()?.getCrossRoad(dLon, dLat, fAngle,call)
|
||||
}
|
||||
/**
|
||||
* 根据路口id获取道路信息
|
||||
|
||||
@@ -4,12 +4,11 @@ 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.absoluteValue
|
||||
import kotlin.math.*
|
||||
|
||||
object MapTools {
|
||||
|
||||
@@ -21,13 +20,13 @@ object MapTools {
|
||||
* 屏幕坐标转经纬度
|
||||
*/
|
||||
fun fromScreenLocation(paramPoint: Point,mMapController: IMapController?): LonLatPoint {
|
||||
if (CompileConfig.DEBUG) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "lonlatop--fromScreenLocation--${paramPoint.toString()}")
|
||||
}
|
||||
var lonLat = mMapController?.pixelsToLonlat(paramPoint.x.toFloat(), paramPoint.y.toFloat())
|
||||
val lonLat = mMapController?.pixelsToLonlat(paramPoint.x.toFloat(), paramPoint.y.toFloat())
|
||||
lonLat?.let {
|
||||
val lonLatPoint = CommonProxy.getInstance().getLonLatProxy().switchLonLat(it)
|
||||
if (CompileConfig.DEBUG) {
|
||||
if (DEBUG) {
|
||||
Log.i(
|
||||
TAG,
|
||||
"lonlatop-toScreenLocation-toOuter-before:${lonLat},after:${lonLatPoint}"
|
||||
@@ -42,16 +41,16 @@ object MapTools {
|
||||
* 经纬度转屏幕坐标
|
||||
*/
|
||||
fun toScreenLocation(lonLatPoint: LonLatPoint,mMapController: IMapController?): Point {
|
||||
var lonLat: LonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
|
||||
if (CompileConfig.DEBUG) {
|
||||
val lonLat: LonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "lonlatop-toScreenLocation-toInner-before:${lonLatPoint},after:${lonLat}")
|
||||
}
|
||||
var point = mMapController?.lonlatToPixels(
|
||||
val point = mMapController?.lonlatToPixels(
|
||||
lonLat.lon,
|
||||
lonLat.lat
|
||||
)
|
||||
point?.let {
|
||||
if (CompileConfig.DEBUG) {
|
||||
if (DEBUG) {
|
||||
Log.i(TAG, "lonlatop-toScreenLocation-result-${point}")
|
||||
}
|
||||
return Point(point.x.toInt(), point.y.toInt())
|
||||
@@ -79,9 +78,9 @@ object MapTools {
|
||||
* 批量经纬度转屏幕坐标
|
||||
*/
|
||||
fun toScreenLocations(data: List<LonLatPoint>,mMapController: IMapController?): List<Point> {
|
||||
var arrayList: ArrayList<Point> = ArrayList()
|
||||
val arrayList: ArrayList<Point> = ArrayList()
|
||||
for (pp in data) {
|
||||
var point = toScreenLocation(pp,mMapController)
|
||||
val point = toScreenLocation(pp,mMapController)
|
||||
arrayList.add(point)
|
||||
}
|
||||
return arrayList
|
||||
@@ -91,9 +90,9 @@ object MapTools {
|
||||
* 批量屏幕坐标转经纬度
|
||||
*/
|
||||
fun fromScreenLocations(data: List<Point>,mMapController: IMapController?): List<LonLatPoint> {
|
||||
var arrayList: ArrayList<LonLatPoint> = ArrayList()
|
||||
val arrayList: ArrayList<LonLatPoint> = ArrayList()
|
||||
for (pp in data) {
|
||||
var lonLat = fromScreenLocation(pp,mMapController)
|
||||
val lonLat = fromScreenLocation(pp,mMapController)
|
||||
arrayList.add(lonLat)
|
||||
}
|
||||
return arrayList
|
||||
@@ -131,21 +130,21 @@ object MapTools {
|
||||
}
|
||||
|
||||
fun getLonLats(start: LonLatPoint, end: LonLatPoint): List<LonLatPoint> {
|
||||
var lonLatPoints: ArrayList<LonLatPoint> = ArrayList<LonLatPoint>()
|
||||
val lonLatPoints: ArrayList<LonLatPoint> = ArrayList<LonLatPoint>()
|
||||
val x = end.latitude - start.latitude
|
||||
val y = end.longitude - start.longitude
|
||||
val dis = Math.sqrt(x * x + y * y).absoluteValue
|
||||
val dis = sqrt(x * x + y * y).absoluteValue
|
||||
val num = (dis / 0.000001).toInt()
|
||||
val numX = x / num.toDouble()
|
||||
val numY = y / num.toDouble()
|
||||
for (i in 1..num) {
|
||||
val lon = start.longitude + numY * i
|
||||
val lat = start.latitude + numX * i
|
||||
val lonlatPoint = LonLatPoint(lon, lat)
|
||||
val lonLatPoint = LonLatPoint(lon, lat)
|
||||
if (DEBUG) {
|
||||
Log.d(TAG, "lonlatPoint: ${lonlatPoint}")
|
||||
Log.d(TAG, "lonlatPoint: $lonLatPoint")
|
||||
}
|
||||
lonLatPoints.add(lonlatPoint)
|
||||
lonLatPoints.add(lonLatPoint)
|
||||
|
||||
}
|
||||
if (DEBUG) {
|
||||
@@ -155,8 +154,8 @@ object MapTools {
|
||||
|
||||
}
|
||||
|
||||
fun HaverSin(theta: Double): Double {
|
||||
val v = Math.sin(theta / 2)
|
||||
fun haverSin(theta: Double): Double {
|
||||
val v = sin(theta / 2)
|
||||
return v * v
|
||||
}
|
||||
|
||||
@@ -180,18 +179,18 @@ object MapTools {
|
||||
var lon1 = lon1
|
||||
var lat2 = lat2
|
||||
var lon2 = lon2
|
||||
lat1 = ConvertDegreesToRadians(lat1)
|
||||
lon1 = ConvertDegreesToRadians(lon1)
|
||||
lat2 = ConvertDegreesToRadians(lat2)
|
||||
lon2 = ConvertDegreesToRadians(lon2)
|
||||
lat1 = convertDegreesToRadians(lat1)
|
||||
lon1 = convertDegreesToRadians(lon1)
|
||||
lat2 = convertDegreesToRadians(lat2)
|
||||
lon2 = convertDegreesToRadians(lon2)
|
||||
|
||||
//差值
|
||||
val vLon = Math.abs(lon1 - lon2)
|
||||
val vLat = Math.abs(lat1 - lat2)
|
||||
val vLon = abs(lon1 - lon2)
|
||||
val vLat = abs(lat1 - lat2)
|
||||
|
||||
//h is the great circle distance in radians, great circle就是一个球体上的切面,它的圆心即是球心的一个周长最大的圆。
|
||||
val h = HaverSin(vLat) + Math.cos(lat1) * Math.cos(lat2) * HaverSin(vLon)
|
||||
return 2 * EARTH_RADIUS * Math.asin(Math.sqrt(h))
|
||||
val h = haverSin(vLat) + cos(lat1) * cos(lat2) * haverSin(vLon)
|
||||
return 2 * EARTH_RADIUS * asin(sqrt(h))
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -199,38 +198,38 @@ object MapTools {
|
||||
/// </summary>
|
||||
/// <param name="degrees">角度</param>
|
||||
/// <returns>弧度</returns>
|
||||
fun ConvertDegreesToRadians(degrees: Double): Double {
|
||||
fun convertDegreesToRadians(degrees: Double): Double {
|
||||
return degrees * Math.PI / 180
|
||||
}
|
||||
|
||||
fun ConvertRadiansToDegrees(radian: Double): Double {
|
||||
fun convertRadiansToDegrees(radian: Double): Double {
|
||||
return radian * 180.0 / Math.PI
|
||||
}
|
||||
|
||||
val f = 1 / 298.257223563
|
||||
val b = 6356752.3142
|
||||
val a = 6378137
|
||||
const val f = 1 / 298.257223563
|
||||
const val b = 6356752.3142
|
||||
const val a = 6378137
|
||||
|
||||
fun getDestinceLonLat(lonlat: LonLat, angle: Double, dist: Float): LonLat {
|
||||
var angleRadHeading = angle / 180 * Math.PI
|
||||
fun getDestinceLonLat(lonLat: LonLat, angle: Double, dist: Float): LonLat {
|
||||
val angleRadHeading = angle / 180 * Math.PI
|
||||
var newLat = 0.0
|
||||
var newLong = 0.0
|
||||
|
||||
val distRatio = dist / EARTH_RADIUS
|
||||
val distRatioSine = Math.sin(distRatio)
|
||||
val distRatioCosine = Math.cos(distRatio)
|
||||
val distRatioSine = sin(distRatio)
|
||||
val distRatioCosine = cos(distRatio)
|
||||
|
||||
val startLatRad = lonlat.lat / 180 * Math.PI
|
||||
val startLonRad = lonlat.lon / 180 * Math.PI
|
||||
val startLatRad = lonLat.lat / 180 * Math.PI
|
||||
val startLonRad = lonLat.lon / 180 * Math.PI
|
||||
|
||||
val startLatCos = Math.cos(startLatRad)
|
||||
val startLatSin = Math.sin(startLatRad)
|
||||
val startLatCos = cos(startLatRad)
|
||||
val startLatSin = sin(startLatRad)
|
||||
|
||||
val endLatRads = Math.asin(startLatSin * distRatioCosine + startLatCos * distRatioSine * Math.cos(angleRadHeading))
|
||||
val endLatRads = asin(startLatSin * distRatioCosine + startLatCos * distRatioSine * cos(angleRadHeading))
|
||||
val endLonRads = (startLonRad
|
||||
+ Math.atan2(
|
||||
Math.sin(angleRadHeading) * distRatioSine * startLatCos,
|
||||
distRatioCosine - startLatSin * Math.sin(endLatRads)
|
||||
+ atan2(
|
||||
sin(angleRadHeading) * distRatioSine * startLatCos,
|
||||
distRatioCosine - startLatSin * sin(endLatRads)
|
||||
))
|
||||
newLat = endLatRads / Math.PI * 180
|
||||
newLong = endLonRads / Math.PI * 180
|
||||
@@ -238,22 +237,22 @@ object MapTools {
|
||||
return LonLat(newLong, newLat)
|
||||
}
|
||||
|
||||
fun getDistance(lastLonlat: LonLat, lonlat: LonLat): Double {
|
||||
val x = lonlat.lat - lastLonlat.lat
|
||||
val y = lonlat.lon - lastLonlat.lon
|
||||
return Math.sqrt(x * x + y * y).absoluteValue
|
||||
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
|
||||
}
|
||||
|
||||
fun getNextLonLat(lastLonlat: LonLat, lonlat: LonLat, length: Double): LonLat {
|
||||
val x = lonlat.lat - lastLonlat.lat
|
||||
val y = lonlat.lon - lastLonlat.lon
|
||||
val distance = 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 scale = length / distance
|
||||
if(CompileConfig.DEBUG){
|
||||
if(DEBUG){
|
||||
Log.i(TAG,"centerop-mattop:length:${length},distance:${distance},scale:${scale}")
|
||||
}
|
||||
val lon = lastLonlat.lon + y * scale
|
||||
val lat = lastLonlat.lat + x * scale
|
||||
val lon = lastLonLat.lon + y * scale
|
||||
val lat = lastLonLat.lat + x * scale
|
||||
return LonLat(lon, lat)
|
||||
}
|
||||
|
||||
@@ -266,16 +265,15 @@ object MapTools {
|
||||
}
|
||||
|
||||
//转换WGS_84坐标
|
||||
fun switchLonLatWGS84(lonLatPoint: LonLatPoint): LonLatPoint{
|
||||
val lonlat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
|
||||
val lonLatPoint_WGS84 = LonLatPoint(lonlat.lon, lonlat.lat)
|
||||
return lonLatPoint_WGS84
|
||||
fun switchLonLatWGS84(lonLatPoint: LonLatPoint): LonLatPoint {
|
||||
val lonLat = CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLatPoint)
|
||||
return LonLatPoint(lonLat.lon, lonLat.lat)
|
||||
}
|
||||
|
||||
//转换高德坐标
|
||||
fun switchLonLat(lonLatPoint: LonLatPoint): LonLatPoint{
|
||||
val lonlat = LonLat(lonLatPoint.longitude, lonLatPoint.latitude)
|
||||
val lonLatPoint = CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonlat)
|
||||
return lonLatPoint
|
||||
fun switchLonLat(lonLatPoint: LonLatPoint): LonLatPoint {
|
||||
val lonLat = LonLat(lonLatPoint.longitude, lonLatPoint.latitude)
|
||||
return CommonProxy.getInstance().getLonLatProxy().switchLonLat(lonLat)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,7 +62,7 @@ class MonitorPressApi {
|
||||
}
|
||||
|
||||
fun exit() {
|
||||
TaskManager.instance.monitorCancleCacheHdData()
|
||||
TaskManager.instance.monitorCancelCacheHdData()
|
||||
mainFlag = false
|
||||
TaskManager.instance.exit()
|
||||
mMainJob?.cancel()
|
||||
@@ -91,7 +91,7 @@ class MonitorPressApi {
|
||||
} catch (e1: IOException) {
|
||||
Log.e(TAG, "memoryop-e1", e1)
|
||||
}
|
||||
TaskManager.instance.LoadOtherCarsToMemory(mOtherCarPath)
|
||||
TaskManager.instance.loadOtherCarsToMemory(mOtherCarPath)
|
||||
var i = 0;
|
||||
var randomsq = 10
|
||||
while (mainFlag) {
|
||||
@@ -154,7 +154,7 @@ class MonitorPressApi {
|
||||
}
|
||||
15 -> {
|
||||
// TaskManager.instance.monitorMarkerAdd(trackIndex,mapAutoView)
|
||||
TaskManager.instance.monitorCancleCacheHdData()
|
||||
TaskManager.instance.monitorCancelCacheHdData()
|
||||
}
|
||||
16 -> {
|
||||
withContext(Dispatchers.Main){
|
||||
|
||||
@@ -19,10 +19,10 @@ object RecorderUtils {
|
||||
|
||||
//读取指定目录下的所有TXT文件的文件名
|
||||
fun getFileName(files: Array<File>?, end: String): ArrayList<String>? {
|
||||
var list = ArrayList<String>()
|
||||
val list = ArrayList<String>()
|
||||
if (files != null) { // 先判断目录是否为空,否则会报空指针
|
||||
for (file in files) {
|
||||
val fileName: String = file.getName()
|
||||
val fileName: String = file.name
|
||||
if (fileName.endsWith(end)) {
|
||||
list.add(fileName)
|
||||
}
|
||||
@@ -93,7 +93,7 @@ object RecorderUtils {
|
||||
val dir = dealLogFile(name)
|
||||
if (dir != null) {
|
||||
try {
|
||||
val fw = FileWriter("${dir}", true)
|
||||
val fw = FileWriter("$dir", true)
|
||||
// fw.write("${DateUtils.getCurrentTime()} $content\r\n")
|
||||
fw.write("$content\r\n")
|
||||
fw.close()
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user