增加了观察者模式,后面会将V2X中的所有场景采用观察者的模式进行重构
完成了最优路线推荐的逻辑,差接口连调
This commit is contained in:
@@ -54,7 +54,7 @@ public class V2XStatusManager {
|
||||
if (mLocation == null) {
|
||||
mLocation = new MogoLocation();
|
||||
}
|
||||
//Logger.d(V2XConst.MODULE_NAME, "当前车辆位置:" + mLocation.toString());
|
||||
Logger.d(V2XConst.MODULE_NAME, "当前车辆位置:" + mLocation.toString());
|
||||
return mLocation;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.v2x.entity.net;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 4/8/21 4:52 PM
|
||||
* 最优路线推荐
|
||||
*/
|
||||
public class V2XRouteRes {
|
||||
private String sn;//车机SN
|
||||
private String roadId;//当前道路唯一标识
|
||||
private int laneNum;//当前车道唯一标识
|
||||
private int mostLaneNum;//最优车道号
|
||||
private double mostSpeed;//最优车道平均速度
|
||||
private List locusList;//线性经纬度轨迹列表
|
||||
private double locusLat;
|
||||
private double locusLon;
|
||||
|
||||
private double heading;// 车头朝向
|
||||
private long satelliteTime;//定位卫星时间
|
||||
private long showTime;//展示时间
|
||||
|
||||
private int warningType;// 1-最优车道,2-安全距离,3-交通预警
|
||||
|
||||
|
||||
}
|
||||
@@ -23,6 +23,8 @@ import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.alarm.V2XAlarmServer;
|
||||
import com.mogo.module.v2x.network.V2XRefreshCallback;
|
||||
import com.mogo.module.v2x.observer.CarLocationSubject;
|
||||
import com.mogo.module.v2x.observer.V2XOptimalRouteObserver;
|
||||
import com.mogo.module.v2x.scenario.impl.V2XScenarioManager;
|
||||
import com.mogo.module.v2x.scenario.scene.obu.V2XObuEventScenario;
|
||||
import com.mogo.module.v2x.utils.ADASUtils;
|
||||
@@ -50,7 +52,10 @@ import static com.mogo.module.v2x.V2XConst.MODULE_NAME;
|
||||
* desc : V2X中用到的位置监听。处理刷新频率,以及位置改变是否触发道路事件警报
|
||||
* version: 1.0
|
||||
*/
|
||||
public class V2XLocationListener implements IMogoLocationListener, CarStatusListener, IMogoCarLocationChangedListener2 {
|
||||
public class V2XLocationListener
|
||||
implements IMogoLocationListener,
|
||||
CarStatusListener,
|
||||
IMogoCarLocationChangedListener2 {
|
||||
private String TAG = "V2XLocationListener";
|
||||
|
||||
private MogoLocation mLastCarLocation;
|
||||
@@ -61,7 +66,14 @@ public class V2XLocationListener implements IMogoLocationListener, CarStatusList
|
||||
|
||||
private static V2XLocationListener mV2XLocationListener;
|
||||
|
||||
private CarLocationSubject mCarLocationSubject;
|
||||
|
||||
private V2XLocationListener() {
|
||||
mCarLocationSubject = new CarLocationSubject();
|
||||
// 注册最优路线的推荐观察者
|
||||
mCarLocationSubject.registerObserver(
|
||||
V2XOptimalRouteObserver.TYPE,
|
||||
V2XOptimalRouteObserver.getInstance());
|
||||
}
|
||||
|
||||
public synchronized static V2XLocationListener getInstance() {
|
||||
@@ -74,22 +86,22 @@ public class V2XLocationListener implements IMogoLocationListener, CarStatusList
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged( MogoLatLng latLng ) {
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
// do not impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2( Location location ) {
|
||||
public void onCarLocationChanged2(Location location) {
|
||||
MogoLocation loc = new MogoLocation();
|
||||
loc.setTime( loc.getTime());
|
||||
loc.setAccuracy( location.getAccuracy() );
|
||||
loc.setSpeed( location.getSpeed());
|
||||
loc.setLongitude( location.getLongitude() );
|
||||
loc.setLatitude( location.getLatitude() );
|
||||
loc.setAltitude( location.getAltitude() );
|
||||
loc.setBearing( location.getBearing() );
|
||||
loc.setProvider( location.getProvider() );
|
||||
onLocationChangedImpl( loc );
|
||||
loc.setTime(loc.getTime());
|
||||
loc.setAccuracy(location.getAccuracy());
|
||||
loc.setSpeed(location.getSpeed());
|
||||
loc.setLongitude(location.getLongitude());
|
||||
loc.setLatitude(location.getLatitude());
|
||||
loc.setAltitude(location.getAltitude());
|
||||
loc.setBearing(location.getBearing());
|
||||
loc.setProvider(location.getProvider());
|
||||
onLocationChangedImpl(loc);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -97,8 +109,9 @@ public class V2XLocationListener implements IMogoLocationListener, CarStatusList
|
||||
// onLocationChangedImpl(location);
|
||||
}
|
||||
|
||||
private void onLocationChangedImpl(MogoLocation location){
|
||||
private void onLocationChangedImpl(MogoLocation location) {
|
||||
try {
|
||||
mCarLocationSubject.setCarLocation(location);
|
||||
//Logger.d(V2XConst.MODULE_NAME, "V2X预警--onLocationChanged: " + GsonUtil.jsonFromObject(location));
|
||||
// 刷新角度
|
||||
getCurrentCarAngle(location);
|
||||
@@ -143,8 +156,12 @@ public class V2XLocationListener implements IMogoLocationListener, CarStatusList
|
||||
if (mMogoPolyline != null && (V2XServiceManager.getMoGoV2XStatusManager().isRoadEventPOIShow()
|
||||
|| V2XServiceManager.getMoGoV2XStatusManager().isOtherSeekHelpPOIShow())
|
||||
&& V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng() != null) {
|
||||
mMogoPolyline.setPoints(Arrays.asList(new MogoLatLng(location.getLatitude(), location.getLongitude()),
|
||||
V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng()));
|
||||
|
||||
// 取出原有的绘制线的经纬度点
|
||||
List<MogoLatLng> pointsOdl = mMogoPolyline.getPoints();
|
||||
// 重新设置第一个坐标,也就是当前车辆位置
|
||||
pointsOdl.set(0, new MogoLatLng(location.getLatitude(), location.getLongitude()));
|
||||
mMogoPolyline.setPoints(pointsOdl);
|
||||
|
||||
float zoomLevel = V2XServiceManager.getMapUIController().getZoomLevel();
|
||||
//Logger.d(V2XConst.MODULE_NAME, "当前地图的缩放比例为:" + zoomLevel);
|
||||
|
||||
@@ -6,6 +6,8 @@ import com.alibaba.android.arouter.facade.template.IProvider;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
|
||||
@@ -6,10 +6,10 @@ import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.v2x.MoGoV2XServicePaths;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.common.entity.V2XPoiTypeEnum;
|
||||
import com.mogo.module.common.entity.V2XRoadEventEntity;
|
||||
import com.mogo.module.v2x.MoGoV2XServicePaths;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XPolylineManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -66,7 +66,7 @@ public class MoGoV2XPolylineManager implements IMoGoV2XPolylineManager {
|
||||
} else {
|
||||
options.add(V2XServiceManager.getV2XStatusManager().getLocation());
|
||||
}
|
||||
// 目标车辆位置
|
||||
// 目标车辆、道路事件位置
|
||||
options.add(V2XServiceManager.getV2XStatusManager().getTargetMoGoLatLng());
|
||||
|
||||
// 绘制线的对象
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.mogo.module.v2x.observer;
|
||||
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 4/9/21 2:14 PM
|
||||
* 当前车辆位置观察者接口
|
||||
*/
|
||||
public abstract class CarLocationObserver {
|
||||
// 更新状态
|
||||
public abstract void update(MogoLocation carLocation);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.mogo.module.v2x.observer;
|
||||
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 4/9/21 2:12 PM
|
||||
* 当前车辆订阅
|
||||
*/
|
||||
public class CarLocationSubject {
|
||||
|
||||
// 车辆位置
|
||||
public MogoLocation carLocation;
|
||||
// 观察者集合
|
||||
private HashMap<String, CarLocationObserver> observers = new HashMap<String, CarLocationObserver>();
|
||||
|
||||
|
||||
/**
|
||||
* 设置新的车辆位置
|
||||
*
|
||||
* @param carLocation 车辆位置
|
||||
*/
|
||||
public void setCarLocation(MogoLocation carLocation) {
|
||||
this.carLocation = carLocation;
|
||||
notifyAllObservers();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加观察者
|
||||
*
|
||||
* @param observerType 观察者类型
|
||||
* @param observer 新的观察者
|
||||
*/
|
||||
public void registerObserver(String observerType, CarLocationObserver observer) {
|
||||
observers.put(observerType, observer);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除指定类型的观察者
|
||||
*
|
||||
* @param observerType 观察者类型
|
||||
*/
|
||||
public void removeObserver(String observerType) {
|
||||
observers.remove(observerType);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知所有观察者更新
|
||||
*/
|
||||
private void notifyAllObservers() {
|
||||
Set<String> keySet = observers.keySet();
|
||||
for (String s : keySet) {
|
||||
CarLocationObserver observer = observers.get(s);
|
||||
if (observer != null) {
|
||||
observer.update(carLocation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.mogo.module.v2x.observer;
|
||||
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.module.v2x.overlay.V2XOptimalRouteOverlay;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @date 4/9/21 2:38 PM
|
||||
* 最优路线推荐
|
||||
*/
|
||||
public class V2XOptimalRouteObserver extends CarLocationObserver {
|
||||
public static String TYPE = "V2XOptimalRouteObserver";
|
||||
|
||||
private static V2XOptimalRouteObserver v2XOptimalRouteObserver;
|
||||
//最优路线覆盖物绘制
|
||||
private V2XOptimalRouteOverlay mV2XOptimalRouteOverlay;
|
||||
// 要绘制的数据
|
||||
private List<double[]> polylinePoint;
|
||||
|
||||
public static V2XOptimalRouteObserver getInstance() {
|
||||
if (v2XOptimalRouteObserver == null) {
|
||||
synchronized (V2XOptimalRouteObserver.class) {
|
||||
if (v2XOptimalRouteObserver == null) {
|
||||
v2XOptimalRouteObserver = new V2XOptimalRouteObserver();
|
||||
}
|
||||
}
|
||||
}
|
||||
return v2XOptimalRouteObserver;
|
||||
}
|
||||
|
||||
private V2XOptimalRouteObserver() {
|
||||
mV2XOptimalRouteOverlay = new V2XOptimalRouteOverlay();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置推荐路线
|
||||
*
|
||||
* @param polylinePoint 推荐的路线
|
||||
*/
|
||||
public void setPolylinePoint(List<double[]> polylinePoint) {
|
||||
this.polylinePoint = polylinePoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(MogoLocation carLocation) {
|
||||
mV2XOptimalRouteOverlay.draw(carLocation, polylinePoint);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mogo.module.v2x.overlay;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.utils.LocationUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 最优路线推荐的图覆盖物
|
||||
*
|
||||
* @author donghongyu
|
||||
* @date 4/8/21 6:06 PM
|
||||
*/
|
||||
public class V2XOptimalRouteOverlay {
|
||||
private IMogoPolyline mMoGoPolyline;
|
||||
// 连接线参数
|
||||
private MogoPolylineOptions mPolylineOptions;
|
||||
// 线路径集合
|
||||
private List<MogoLatLng> mPolylinePointList;
|
||||
|
||||
public V2XOptimalRouteOverlay() {
|
||||
mPolylineOptions = new MogoPolylineOptions();
|
||||
// 渐变色
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
colors.add(0xFFF95959);
|
||||
// 线条粗细,渐变,渐变色值
|
||||
mPolylineOptions.width(25).useGradient(true).colorValues(colors);
|
||||
// 绘制路径集合
|
||||
mPolylinePointList = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制最优路线
|
||||
*
|
||||
* @param polylinePoint 要绘制的经纬度度集合
|
||||
*/
|
||||
public IMogoPolyline draw(MogoLocation carLocal, List<double[]> polylinePoint) {
|
||||
if (mMoGoPolyline != null) {
|
||||
mMoGoPolyline.remove();
|
||||
mPolylinePointList.clear();
|
||||
}
|
||||
if (polylinePoint != null) {
|
||||
// 将当前车辆位置放进去
|
||||
mPolylinePointList.add(new MogoLatLng(carLocal.getLatitude(), carLocal.getLongitude()));
|
||||
// 过滤后台推送的推荐路线集合
|
||||
for (double[] polyline : polylinePoint) {
|
||||
MogoLatLng pointMoGoLatLng = new MogoLatLng(polyline[1], polyline[0]);
|
||||
//需要剔除已经行驶过的经纬度,这里需要比对推荐路线集合中的点是否在当前车辆行驶方向前面如果不在则抛弃
|
||||
if (LocationUtils.isPointOnCarFront(carLocal, pointMoGoLatLng)) {
|
||||
mPolylinePointList.add(pointMoGoLatLng);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 替换路径集合
|
||||
mPolylineOptions.points(mPolylinePointList);
|
||||
// 绘制线
|
||||
mMoGoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(mPolylineOptions);
|
||||
return mMoGoPolyline;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -104,11 +104,12 @@ public class V2XScenarioManager implements IV2XScenarioManager {
|
||||
mV2XScenario = new V2XRecommendRouteScenario();
|
||||
break;
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_PUSH_VR_SHOW:
|
||||
if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
|
||||
mV2XScenario = new V2XOptimalRouteVREventScenario();
|
||||
} else {
|
||||
mV2XScenario = null;
|
||||
}
|
||||
// if (V2XServiceManager.getMoGoStatusManager().isVrMode()) {
|
||||
//
|
||||
// } else {
|
||||
// mV2XScenario = null;
|
||||
// }
|
||||
mV2XScenario = new V2XOptimalRouteVREventScenario();
|
||||
break;
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_TOP:
|
||||
case V2XMessageEntity.V2XTypeEnum.ALERT_THE_FRONT_CRASH_WARNING_LEFT:
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
package com.mogo.module.v2x.scenario.scene.route;
|
||||
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.map.overlay.MogoPolylineOptions;
|
||||
import com.mogo.module.common.entity.V2XPushMessageEntity;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.observer.V2XOptimalRouteObserver;
|
||||
import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
||||
import com.mogo.module.v2x.utils.MarkerUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
@@ -22,8 +18,6 @@ import java.util.List;
|
||||
public class V2XOptimalRouteVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
|
||||
private final String TAG = "V2XPushVREventMarker";
|
||||
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
|
||||
@Override
|
||||
public void drawPOI(V2XPushMessageEntity entity) {
|
||||
Logger.w(V2XConst.MODULE_NAME + "_" + TAG, "drawPOI 绘制VR Marker");
|
||||
@@ -32,10 +26,6 @@ public class V2XOptimalRouteVREventMarker implements IV2XMarker<V2XPushMessageEn
|
||||
// 清除道路事件
|
||||
V2XServiceManager
|
||||
.getMoGoV2XMarkerManager().clearALLPOI();
|
||||
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
}
|
||||
// 绘制引导线
|
||||
drawableRecommendPolyline(entity);
|
||||
} catch (Exception e) {
|
||||
@@ -49,23 +39,7 @@ public class V2XOptimalRouteVREventMarker implements IV2XMarker<V2XPushMessageEn
|
||||
* @param entity
|
||||
*/
|
||||
void drawableRecommendPolyline(V2XPushMessageEntity entity) {
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
|
||||
// 渐变色
|
||||
List<Integer> colors = new ArrayList<>();
|
||||
|
||||
colors.add(0xFFF95959);
|
||||
|
||||
// 线条粗细,渐变,渐变色值
|
||||
options.width(20).useGradient(true).colorValues(colors);
|
||||
|
||||
for (double[] doubles : entity.getRecommendPolyline()) {
|
||||
options.add(doubles[0], doubles[1]);
|
||||
}
|
||||
|
||||
// 绘制线的对象
|
||||
mMogoPolyline = V2XServiceManager.getMogoOverlayManager().addPolyline(options);
|
||||
V2XOptimalRouteObserver.getInstance().setPolylinePoint(entity.getRecommendPolyline());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,10 +53,6 @@ public class V2XOptimalRouteVREventMarker implements IV2XMarker<V2XPushMessageEn
|
||||
}
|
||||
|
||||
public void clearLine() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
V2XServiceManager.getV2XStatusManager().setAlarmInfo(null);
|
||||
}
|
||||
V2XOptimalRouteObserver.getInstance().setPolylinePoint(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.mogo.module.v2x.utils;
|
||||
|
||||
import android.location.Location;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.location.MogoLocation;
|
||||
import com.mogo.map.search.geo.IMogoGeoSearchListener;
|
||||
import com.mogo.map.search.geo.MogoGeocodeResult;
|
||||
import com.mogo.map.search.geo.MogoPoiItem;
|
||||
import com.mogo.map.search.geo.MogoRegeocodeResult;
|
||||
import com.mogo.map.search.geo.query.MogoRegeocodeQuery;
|
||||
import com.mogo.map.search.poisearch.IMogoPoiSearch;
|
||||
import com.mogo.map.search.poisearch.IMogoPoiSearchListener;
|
||||
@@ -69,6 +68,11 @@ public class LocationUtils {
|
||||
poiSearch.searchPOIAsyn();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前位置
|
||||
*
|
||||
* @return 当前位置
|
||||
*/
|
||||
public static MogoLatLng getCurrentLatLon() {
|
||||
MogoLatLng latLon = V2XServiceManager.getNavi().getCarLocation();
|
||||
if (latLon == null) {
|
||||
@@ -89,9 +93,9 @@ public class LocationUtils {
|
||||
return latLon;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* 计算两点间的角度
|
||||
* */
|
||||
*/
|
||||
public static double getAngle(double lon1, double lat1, double lon2,
|
||||
double lat2) {
|
||||
double fLat = Math.PI * (lat1) / 180.0;
|
||||
@@ -108,9 +112,9 @@ public class LocationUtils {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* 根据角度获取指定距离点的经纬度
|
||||
* */
|
||||
*/
|
||||
public static MogoLatLng getNewLocation(MogoLatLng st, double distance, double angle) {
|
||||
mRadLo = st.getLon() * Math.PI / 180.;
|
||||
mRadLa = st.getLat() * Math.PI / 180.;
|
||||
@@ -124,4 +128,31 @@ public class LocationUtils {
|
||||
return new MogoLatLng(lat_new, lon_new);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取传入的经纬度在车辆的什么位置
|
||||
*
|
||||
* @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) {
|
||||
Log.i(TAG, "目标点在车辆--前方");
|
||||
return true;
|
||||
} else {
|
||||
Log.i(TAG, "目标点在车辆--后方");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user