Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk
This commit is contained in:
@@ -10,6 +10,7 @@ import android.util.Log;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
@@ -59,7 +60,6 @@ class BaseDrawer {
|
||||
|
||||
// 移除过期的 marker
|
||||
public static final int MSG_REMOVE_DIRTY_MARKERS = 9990;
|
||||
public static final int MSG_REMOVE_ADAS_MARKERS = 9992;
|
||||
|
||||
/**
|
||||
* 显示速度
|
||||
@@ -239,7 +239,7 @@ class BaseDrawer {
|
||||
/**
|
||||
* 根据速度、经纬度计算距离判断车辆颜色
|
||||
*
|
||||
* @param speed 车速
|
||||
* @param speed 车速 TODO 这里很可能是adas的策略
|
||||
* @param lon 经度
|
||||
* @param lat 纬度
|
||||
* @return 实际车辆颜色
|
||||
@@ -251,26 +251,26 @@ class BaseDrawer {
|
||||
return "#D8D8D8FF";
|
||||
}
|
||||
// 距离策略
|
||||
// double coordinates[] = getCurCoordinates();
|
||||
// double distance = CoordinateUtils.calculateLineDistance( lon, lat, coordinates[0], coordinates[1] ) * 100;
|
||||
// if ( distance < 50 ) {
|
||||
// return Car3DModelColor.Dangerous.color;
|
||||
// } else if ( distance < 100 && distance >= 50 ) {
|
||||
// return Car3DModelColor.Warming.color;
|
||||
// }
|
||||
double coordinates[] = getCurCoordinates();
|
||||
double distance = CoordinateUtils.calculateLineDistance( lon, lat, coordinates[0], coordinates[1] ) * 100;
|
||||
if ( distance < 50 ) {
|
||||
return Car3DModelColor.Dangerous.color;
|
||||
} else if ( distance < 100 && distance >= 50 ) {
|
||||
return Car3DModelColor.Warming.color;
|
||||
}
|
||||
|
||||
// 他车车速和自车车速对比速度策略
|
||||
// 自车速度 >= 50% 危险
|
||||
// 10% < 自车速度 < 50% 警告
|
||||
// double curSpeed = getCurSpeed();
|
||||
// if ( curSpeed > 0 && speed > curSpeed ) {
|
||||
// double rate = ( ( speed - curSpeed ) / curSpeed ) * 100;
|
||||
// if ( rate >= 50 ) {
|
||||
// return Car3DModelColor.Dangerous.color;
|
||||
// } else if ( rate > 10 && rate < 50 ) {
|
||||
// return Car3DModelColor.Warming.color;
|
||||
// }
|
||||
// }
|
||||
// 他车车速和自车车速对比速度策略
|
||||
// 自车速度 >= 50% 危险
|
||||
// 10% < 自车速度 < 50% 警告
|
||||
double curSpeed = getCurSpeed();
|
||||
if ( curSpeed > 0 && speed > curSpeed ) {
|
||||
double rate = ( ( speed - curSpeed ) / curSpeed ) * 100;
|
||||
if ( rate >= 50 ) {
|
||||
return Car3DModelColor.Dangerous.color;
|
||||
} else if ( rate > 10 && rate < 50 ) {
|
||||
return Car3DModelColor.Warming.color;
|
||||
}
|
||||
}
|
||||
|
||||
// 默认颜色
|
||||
return Car3DModelColor.Normal.color;
|
||||
|
||||
@@ -58,6 +58,10 @@ class OnlineCarDrawer {
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public void clearMarkers(){
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制在线车辆marker
|
||||
*
|
||||
@@ -72,12 +76,12 @@ class OnlineCarDrawer {
|
||||
IMogoMarkerClickListener listener ) {
|
||||
// 将数据同步给在线车辆,避免每次 perform 的时候去拉取,造成消耗
|
||||
if ( onlineCarList == null || onlineCarList.isEmpty() ) {
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
|
||||
clearMarkers();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( clearOld ) {
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
|
||||
clearMarkers();
|
||||
}
|
||||
|
||||
int size = MarkerDrawer.getInstance().getAppropriateSize( maxAmount, onlineCarList );
|
||||
@@ -191,4 +195,6 @@ class OnlineCarDrawer {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -77,16 +77,22 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
|
||||
private boolean mIsVrMode = false;
|
||||
|
||||
/**
|
||||
* 注册StatusDescriptor.VR_MODE类型,VR_MODE状态改变回调
|
||||
* @param descriptor 状态类型
|
||||
* @param isTrue true - accOn、adas ui show、voice ui show、push ui show、v2x ui show
|
||||
*/
|
||||
@Override
|
||||
public void onStatusChanged( StatusDescriptor descriptor, boolean isTrue ) {
|
||||
Logger.d( TAG, "%s - %s", descriptor, isTrue );
|
||||
mChangeCarModeStatus = true;
|
||||
sendMessage( MSG_REMOVE_ADAS_MARKERS, mMarkersCaches );
|
||||
sendMessage( MSG_REMOVE_DIRTY_MARKERS, mMarkersCaches );
|
||||
mMarkersCaches = new HashMap<>();
|
||||
if ( mLastPositions != null ) {
|
||||
mLastPositions.clear();
|
||||
}
|
||||
AdasRecognizedResultDrawer.getInstance().notifyVrModeChanged();
|
||||
AdasRecognizedResultDrawer.getInstance().notifyVrModeChanged(); //清除ADAS old marker data
|
||||
OnlineCarDrawer.getInstance().clearMarkers(); //清除在线车辆 old marker data
|
||||
}
|
||||
|
||||
public boolean isVrMode() {
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.mogo.module.common.drawer.marker.SimpleWindow3DAdapter;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.common.utils.Trigonometric;
|
||||
import com.mogo.module.common.view.MarkerBaseFloor;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
@@ -86,6 +87,11 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
|
||||
IMogoMarker bottomMarker = drawMarkerWith2Resource(markerShowEntity);
|
||||
|
||||
//2D资源图片位置调整
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(data.getCollisionLat(), data.getCollisionLon());
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 8, 180);
|
||||
|
||||
IMogoMarker marker = drawMarker(markerShowEntity);
|
||||
Log.d("liyz", "renderWarnData marker != null direction = " + data.getDirection());
|
||||
//识别物
|
||||
@@ -94,8 +100,8 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
data.getDirection() == 1 ? data.getStopLines().get(1).lon : data.getCollisionLon()), (float) data.getHeading(), 5000);
|
||||
//识别物下方的红色圆圈
|
||||
bottomMarker.addDynamicAnchorPosition(new MogoLatLng(
|
||||
data.getDirection() == 1 ? data.getStopLines().get(1).lat : data.getCollisionLat(),
|
||||
data.getDirection() == 1 ? data.getStopLines().get(1).lon : data.getCollisionLon()), (float) data.getHeading(), 5000);
|
||||
data.getDirection() == 1 ? data.getStopLines().get(1).lat : newLocation.getLat(),
|
||||
data.getDirection() == 1 ? data.getStopLines().get(1).lon : newLocation.getLon()), (float) data.getHeading(), 5000);
|
||||
//移动完成以后,3s后消失
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
marker.remove();
|
||||
@@ -121,16 +127,30 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
return marker;
|
||||
}
|
||||
|
||||
public void drawerMarkerWithLocation(MarkerShowEntity markerShowEntity, MogoLatLng location){
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.object(markerShowEntity)
|
||||
.latitude(location.getLat())
|
||||
.longitude(location.getLon());
|
||||
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
|
||||
options.icon3DRes(getModelRes(2)); //TODO
|
||||
|
||||
options.anchorColor("#FB3C3CFF"); //红色#FF3036 蓝色:#256BFF
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), options);
|
||||
iMarkerView.setMarker(marker);
|
||||
marker.setToTop();
|
||||
}
|
||||
/*
|
||||
* 2D资源绘制marker
|
||||
* 2D资源绘制marker底部的红色圆圈
|
||||
* */
|
||||
private IMogoMarker drawMarkerWith2Resource(MarkerShowEntity markerShowEntity) {
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(markerShowEntity.getMarkerLocation().getLat(), markerShowEntity.getMarkerLocation().getLon());
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 8, 180);
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
||||
.longitude(markerShowEntity.getMarkerLocation().getLon())
|
||||
.latitude(newLocation.getLat())
|
||||
.longitude(newLocation.getLon())
|
||||
.anchor(1.0f, 1.0f)
|
||||
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
||||
|
||||
optionsRipple
|
||||
.icon(ViewUtils.fromView(new EmptyMarkerView(mContext)));
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), optionsRipple);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.mogo.module.common.utils;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 2021/4/13
|
||||
*/
|
||||
public class Trigonometric {
|
||||
private final static double radius_b = 6378137;//大半径
|
||||
private final static double radius_s = 6356725;//小半径
|
||||
private static double mRadLo;
|
||||
private static double mRadLa;
|
||||
private static double Ec;
|
||||
private static double Ed;
|
||||
|
||||
/**
|
||||
* 计算两点间的角度
|
||||
*/
|
||||
public static double getAngle(double lon1, double lat1, double lon2,
|
||||
double lat2) {
|
||||
double fLat = Math.PI * (lat1) / 180.0;
|
||||
double fLng = Math.PI * (lon1) / 180.0;
|
||||
double tLat = Math.PI * (lat2) / 180.0;
|
||||
double tLng = Math.PI * (lon2) / 180.0;
|
||||
|
||||
double degree = (Math.atan2(Math.sin(tLng - fLng) * Math.cos(tLat), Math.cos(fLat) * Math.sin(tLat) -
|
||||
Math.sin(fLat) * Math.cos(tLat) * Math.cos(tLng - fLng))) * 180.0 / Math.PI;
|
||||
if (degree >= 0) {
|
||||
return degree;
|
||||
} else {
|
||||
return 360 + degree;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角度获取指定距离点的经纬度
|
||||
*/
|
||||
public static MogoLatLng getNewLocation(MogoLatLng st, double distance, double angle) {
|
||||
mRadLo = st.getLon() * Math.PI / 180.;
|
||||
mRadLa = st.getLat() * Math.PI / 180.;
|
||||
Ec = radius_s + (radius_b - radius_s) * (90. - st.lat) / 90;
|
||||
Ed = Ec * Math.cos(mRadLa);
|
||||
|
||||
double dx = distance * Math.sin(Math.toRadians(angle));
|
||||
double dy = distance * Math.cos(Math.toRadians(angle));
|
||||
double lon_new = (dx / Ed + mRadLo) * 180. / Math.PI;
|
||||
double lat_new = (dy / Ec + mRadLa) * 180. / Math.PI;
|
||||
return new MogoLatLng(lat_new, lon_new);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user