[fix]
[小地图算法修改]
This commit is contained in:
yangyakun
2024-07-24 12:18:44 +08:00
parent 8fce3e45be
commit e0c62ca773
2 changed files with 16 additions and 2 deletions

View File

@@ -578,6 +578,20 @@ object CoordinateCalculateRouteUtil {
return 360-bearing
}
fun getHeadingAngleTemp(locationLongitude: Double, locationLatitude: Double,
nextPointLongitude: Double, nextPointLatitude: Double): Double {
val lat1Rad = Math.toRadians(locationLatitude)
val lat2Rad = Math.toRadians(nextPointLatitude)
val lon1Rad = Math.toRadians(locationLongitude)
val lon2Rad = Math.toRadians(nextPointLongitude)
val y = sin(lon2Rad - lon1Rad) * cos(lat2Rad)
val x = cos(lat1Rad) * sin(lat2Rad) - sin(lat1Rad) * cos(lat2Rad) * cos(lon2Rad - lon1Rad)
val bearing = Math.toDegrees(atan2(y, x))
return (bearing + 360) % 360
}
/**

View File

@@ -420,7 +420,7 @@ class SimpleMapView : View, SimpleMapViewModel.SimpleMapCallback {
val nextPointList = mutableListOf<NearPointView>()
nextLineData.clear()
nextList.forEachIndexed { index, currentPoint ->
val headingAngle = CoordinateCalculateRouteUtil.getHeadingAngle(
val headingAngle = CoordinateCalculateRouteUtil.getHeadingAngleTemp(
carLocation.longitude,
carLocation.latitude,
currentPoint.location.longitude,
@@ -492,7 +492,7 @@ class SimpleMapView : View, SimpleMapViewModel.SimpleMapCallback {
val prePointList = mutableListOf<NearPointView>()
preLineData.clear()
preList.forEachIndexed { index, currentPoint ->
val headingAngle = CoordinateCalculateRouteUtil.getHeadingAngle(
val headingAngle = CoordinateCalculateRouteUtil.getHeadingAngleTemp(
carLocation.longitude,
carLocation.latitude,
currentPoint.location.longitude,