修复了当前车辆位置没有拿到的时候距离计算的问题

This commit is contained in:
董宏宇
2020-08-06 17:10:03 +08:00
parent 78d4d1d58f
commit e50a3cc973

View File

@@ -52,10 +52,15 @@ public class V2XMessageListener_401012 implements IMogoOnMessageListener<MarkerC
v2XRoadEventEntity.setPoiType(markerExploreWay.getPoiType());
// 当前车辆数据
MogoLocation currentLocation = V2XServiceManager.getV2XStatusManager().getLocation();
float calculateDistance = Utils.calculateLineDistance(
new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()),
new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude())
);
float calculateDistance;
if (currentLocation.getLatitude() == 0 || currentLocation.getLongitude() == 0) {
calculateDistance = Utils.calculateLineDistance(
new MogoLatLng(markerLocation.getLat(), markerLocation.getLon()),
new MogoLatLng(currentLocation.getLatitude(), currentLocation.getLongitude())
);
} else {
calculateDistance = markerExploreWay.getDirection();
}
v2XRoadEventEntity.setDistance(calculateDistance);
v2XRoadEventEntity.setNoveltyInfo(markerExploreWay);
v2XRoadEventEntity.setExpireTime(20000);