[charter]

[3.2.0]
[路距计算、点去错了]
This commit is contained in:
yangyakun
2023-05-24 11:26:16 +08:00
parent eaa34b6dc1
commit 627b37f544

View File

@@ -135,7 +135,7 @@ public class CoordinateCalculateRouteUtil {
// region 当前位置和 对应轨迹点的坐标距离
// 需要加距离 和下一个轨迹点成钝角
if (currentRouteIndex + 1 < stationPointInRouteIndex) {
MogoLocation currentPointsNext = mRoutePoints.get(stationPointInRouteIndex + 1);
MogoLocation currentPointsNext = mRoutePoints.get(currentRouteIndex + 1);
double degree = getDegree(
location.getLongitude(),location.getLatitude(),
currentPoint.getLongitude(), currentPoint.getLatitude(),
@@ -147,7 +147,7 @@ public class CoordinateCalculateRouteUtil {
// 需要减距离 和上一个轨迹点成钝角
if (currentRouteIndex - 1 >= 0) {
MogoLocation lastPointsPre = mRoutePoints.get(stationPointInRouteIndex - 1);
MogoLocation lastPointsPre = mRoutePoints.get(currentRouteIndex - 1);
double degree = getDegree(
location.getLongitude(),location.getLatitude(),
currentPoint.getLongitude(), currentPoint.getLatitude(),
@@ -426,6 +426,16 @@ public class CoordinateCalculateRouteUtil {
return currentIndex;
}
/**
* https://blog.csdn.net/Jeanne_0523/article/details/106056255
* @param vertexPointX
* @param vertexPointY
* @param point0X 角
* @param point0Y 角
* @param point1X
* @param point1Y
* @return
*/
public static int getDegree(double vertexPointX, double vertexPointY, double point0X, double point0Y, double point1X, double point1Y) {
//向量的点乘
double vector = (point0X - vertexPointX) * (point1X - vertexPointX) + (point0Y - vertexPointY) * (point1Y - vertexPointY);