[2.13.0-arch-opt] locationUtil move
This commit is contained in:
@@ -76,7 +76,7 @@ class PncActionsView @JvmOverloads constructor(
|
||||
if (it.state == STATUS_AUTOPILOT_RUNNING) {
|
||||
UiThreadHandler.post {
|
||||
var actions: String? = null
|
||||
planningActionMsg.actionMsg?.let {
|
||||
planningActionMsg.actionMsg?.let { it ->
|
||||
actions = PncActionsHelper.getAction(it.drivingState.number, it.drivingAction.number)
|
||||
|
||||
//如果是存在云端红绿灯数据条件下,设置云端数据
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.function.v2x.events.utils.LocationUtils;
|
||||
import com.mogo.commons.utils.LocationUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ColorUtils;
|
||||
import com.mogo.map.overlay.IMogoOverlayManager;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.mogo.eagle.core.function.v2x.events.utils;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant.M_V2X;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
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;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/5/15 10:31 AM
|
||||
* desc : 基于位置工具类
|
||||
* version: 1.0
|
||||
*/
|
||||
public class LocationUtils {
|
||||
private static final String TAG = "LocationUtils";
|
||||
|
||||
/**
|
||||
* 获取传入的经纬度在车辆的什么位置
|
||||
*
|
||||
* @return 顺时针,true-前,false-后
|
||||
*/
|
||||
public static boolean isPointOnCarFront(MogoLocation carLocal, MogoLatLng pointLocal) {
|
||||
double carLon = carLocal.getLongitude();
|
||||
double carLat = carLocal.getLatitude();
|
||||
double poiLon = pointLocal.getLon();
|
||||
double poiLat = pointLocal.getLat();
|
||||
float carAngle = carLocal.getBearing();
|
||||
|
||||
// 计算车辆与点之间的夹角
|
||||
int diffAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
carLon, carLat, poiLon, poiLat, (int) carAngle);
|
||||
|
||||
if (diffAngle <= 90) {
|
||||
CallerLogger.INSTANCE.i(M_V2X + TAG, "目标点在车辆--前方");
|
||||
return true;
|
||||
} else {
|
||||
CallerLogger.INSTANCE.i(M_V2X + TAG, "目标点在车辆--后方");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
package com.mogo.eagle.core.function.v2x.redlightwarning;
|
||||
|
||||
public class LocationUtils {
|
||||
/**
|
||||
* 地球半径
|
||||
*/
|
||||
private static double EARTH_RADIUS = 6378.137;
|
||||
|
||||
private static double rad( double d ) {
|
||||
return d * Math.PI / 180.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两点间距离( 单位:米 )
|
||||
* @param lat1
|
||||
* @param lng1
|
||||
* @param lat2
|
||||
* @param lng2
|
||||
* @return
|
||||
*/
|
||||
public static double getDistance( double lat1, double lng1, double lat2, double lng2 ) {
|
||||
double radLat1 = rad( lat1 );
|
||||
double radLat2 = rad(lat2);
|
||||
double a = radLat1 - radLat2;
|
||||
double b = rad(lng1) - rad(lng2);
|
||||
double s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2)
|
||||
+ Math.cos(radLat1) * Math.cos(radLat2)
|
||||
* Math.pow(Math.sin(b / 2), 2)));
|
||||
s = s * EARTH_RADIUS;
|
||||
s = Math.round(s * 10000d) / 10000d;
|
||||
s = s * 1000;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 点到直线的最短距离的判断 点(x0,y0) 到由两点组成的线段(x1,y1) ,( x2,y2 ) <br>
|
||||
* ( 单位:米 )
|
||||
* @param x1
|
||||
* @param y1
|
||||
* @param x2
|
||||
* @param y2
|
||||
* @param x0
|
||||
* @param y0
|
||||
* @return
|
||||
*/
|
||||
public static double pointToLine( double x1, double y1, double x2, double y2, double x0, double y0 ) {
|
||||
double space;
|
||||
double a, b, c;
|
||||
a = getDistance(y1, x1, y2, x2);// 线段的长度
|
||||
b = getDistance(y1, x1, y0, x0);// (x1,y1)到点的距离
|
||||
c = getDistance(y2, x2, y0, x0);// (x2,y2)到点的距离
|
||||
if (c <= 0.000001 || b <= 0.000001) {
|
||||
space = 0;
|
||||
return space;
|
||||
}
|
||||
if (a <= 0.000001) {
|
||||
space = b;
|
||||
return space;
|
||||
}
|
||||
if (c * c >= a * a + b * b) {
|
||||
space = b;
|
||||
return space;
|
||||
}
|
||||
if (b * b >= a * a + c * c) {
|
||||
space = c;
|
||||
return space;
|
||||
}
|
||||
double p = (a + b + c) / 2;// 半周长
|
||||
double s = Math.sqrt(p * (p - a) * (p - b) * (p - c));// 海伦公式求面积
|
||||
space = 2 * s / a;// 返回点到线的距离(利用三角形面积公式求高)
|
||||
return space;
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import com.mogo.eagle.core.data.msgbox.MsgBoxBean
|
||||
import com.mogo.eagle.core.data.msgbox.MsgBoxType
|
||||
import com.mogo.eagle.core.data.msgbox.V2XMsg
|
||||
import com.mogo.eagle.core.function.call.msgbox.CallerMsgBoxManager
|
||||
import com.mogo.eagle.core.utilcode.util.LocationUtils
|
||||
import com.zhjt.service_biz.BizConfig
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.ceil
|
||||
|
||||
Reference in New Issue
Block a user