[base_3.4.0-map-sdk]

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

View File

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

View File

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