[opt3.0]下沉工具类到mogo-core-utils模块
This commit is contained in:
@@ -3,8 +3,9 @@ package com.mogo.eagle.core.function.v2x.events.alarm;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.MarkerLocation;
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity;
|
||||
import com.mogo.eagle.core.function.v2x.events.utils.DrivingDirectionUtils;
|
||||
import com.mogo.eagle.core.data.enums.EventTypeEnum;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import io.netty.util.internal.ConcurrentSet;
|
||||
|
||||
@@ -10,7 +10,6 @@ import androidx.lifecycle.*
|
||||
import androidx.lifecycle.Lifecycle.Event
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_CREATE
|
||||
import androidx.lifecycle.Lifecycle.Event.ON_DESTROY
|
||||
import com.mogo.commons.utils.DrivingDirectionUtils
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.map.MapRoadInfo.StopLine
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
@@ -23,6 +22,7 @@ import com.mogo.eagle.core.function.v2x.events.consts.V2XConst.V2X_EVENT_ALARM_P
|
||||
import com.mogo.eagle.core.function.v2x.events.scenario.scene.road.*
|
||||
import com.mogo.eagle.core.utilcode.kotlin.*
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.*
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.overlay.*
|
||||
import io.netty.util.internal.*
|
||||
|
||||
@@ -3,11 +3,11 @@ package com.mogo.eagle.core.function.v2x.events.scenario.scene.road
|
||||
import android.graphics.*
|
||||
import android.util.*
|
||||
import com.mogo.cloud.commons.utils.*
|
||||
import com.mogo.commons.utils.DrivingDirectionUtils
|
||||
import com.mogo.eagle.core.data.map.*
|
||||
import com.mogo.eagle.core.data.map.entity.V2XRoadEventEntity
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.context
|
||||
import com.mogo.eagle.core.function.v2x.events.bridge.BridgeApi.v2xMarker
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils
|
||||
import com.mogo.map.*
|
||||
import com.mogo.map.R.raw
|
||||
import com.mogo.map.marker.*
|
||||
|
||||
@@ -1,120 +0,0 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.utils;
|
||||
|
||||
import static java.lang.Math.PI;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/4/14 1:02 PM
|
||||
* desc : 计算车辆驾驶方向的工具类
|
||||
* version: 1.0
|
||||
*/
|
||||
public class DrivingDirectionUtils {
|
||||
|
||||
/**
|
||||
* 计算车辆行驶方向 与 poi点到车辆的连线 间的夹角
|
||||
*
|
||||
* @param carLon 车辆位置 lon
|
||||
* @param carLat 车辆位置 lat
|
||||
* @param poiLon poi 位置 lon
|
||||
* @param poiLat poi 位置 lat
|
||||
* @param carAngle 车辆行驶方向
|
||||
* @return
|
||||
*/
|
||||
public static int getDegreeOfCar2Poi(double carLon, double carLat, double poiLon, double poiLat, int carAngle) {
|
||||
int poiAngle = 0;
|
||||
// 以子午线作为y轴 计算两点的余切 再将余切值转化为角度
|
||||
double _angle = Math.atan2(Math.abs(carLon - poiLon), Math.abs(carLat - poiLat)) * (180 / PI);
|
||||
if (poiLon > carLon) {
|
||||
// poi 在 车辆位置的第1象限
|
||||
if (poiLat > carLat) {
|
||||
poiAngle = (int) _angle;
|
||||
}
|
||||
// poi 在 车辆位置的第2象限
|
||||
else {
|
||||
poiAngle = 180 - (int) _angle;
|
||||
}
|
||||
} else {
|
||||
// poi 在 车辆位置的第3象限
|
||||
if (poiLat < carLat) {
|
||||
poiAngle = (int) _angle + 180;
|
||||
}
|
||||
// poi 在 车辆位置的第4象限
|
||||
else {
|
||||
poiAngle = 360 - (int) _angle;
|
||||
}
|
||||
}
|
||||
return calculationAngle(poiAngle, carAngle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两个行驶方向间的夹角 计算结果小于180度
|
||||
*
|
||||
* @param angle0
|
||||
* @param angle1
|
||||
* @return
|
||||
*/
|
||||
public static int calculationAngle(int angle0, int angle1) {
|
||||
// 获取两方向间夹角
|
||||
int angle = Math.abs(angle0 - angle1);
|
||||
if (angle > 180) {
|
||||
int minAngle = Math.min(angle0, angle1);
|
||||
int maxAngle = Math.max(angle0, angle1);
|
||||
return 180 - Math.abs(minAngle + 180 - maxAngle);
|
||||
} else {
|
||||
return angle;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算车辆行驶方向角度,起点&终点经纬度
|
||||
*
|
||||
* @param carLat 车辆位置 lat
|
||||
* @param carLon 车辆位置 lon
|
||||
* @param poiLat poi 位置 lat
|
||||
* @param poiLon poi 位置 lon
|
||||
*/
|
||||
public static int getCarAngle(double carLat, double carLon, double poiLat, double poiLon) {
|
||||
int poiAngle = 0;
|
||||
// 以子午线作为y轴 计算两点的余切 再将余切值转化为角度
|
||||
double _angle = Math.atan2(Math.abs(carLon - poiLon), Math.abs(carLat - poiLat)) * (180 / PI);
|
||||
|
||||
if (poiLon > carLon) {
|
||||
// poi 在 车辆位置的第1象限
|
||||
if (poiLat > carLat) {
|
||||
poiAngle = (int) _angle;
|
||||
}
|
||||
// poi 在 车辆位置的第2象限
|
||||
else {
|
||||
poiAngle = 180 - (int) _angle;
|
||||
}
|
||||
} else {
|
||||
// poi 在 车辆位置的第3象限
|
||||
if (poiLat < carLat) {
|
||||
poiAngle = (int) _angle + 180;
|
||||
}
|
||||
// poi 在 车辆位置的第4象限
|
||||
else {
|
||||
poiAngle = 360 - (int) _angle;
|
||||
}
|
||||
}
|
||||
|
||||
if (poiAngle >= 355) {
|
||||
poiAngle = 0;
|
||||
}
|
||||
return poiAngle;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算连两个角度差值
|
||||
*
|
||||
* @param angle1 角度1
|
||||
* @param angle2 角度2
|
||||
* @return 差值
|
||||
*/
|
||||
public static double getAngleDiff(double angle1, double angle2) {
|
||||
// 两个角度差值较小
|
||||
return 180 - Math.abs(Math.abs(angle1 - angle2) - 180);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger;
|
||||
import com.mogo.eagle.core.utilcode.util.DrivingDirectionUtils;
|
||||
import com.mogo.map.location.IMogoLocationClient;
|
||||
import com.mogo.map.uicontroller.IMogoMapUIController;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user