Merge remote-tracking branch 'origin/dev2_aiSdk' into dev2_aiSdk
This commit is contained in:
@@ -67,7 +67,7 @@ dependencies {
|
||||
implementation project(':foudations:mogo-commons')
|
||||
}
|
||||
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.5.5'
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.5.6'
|
||||
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-test-3.4'
|
||||
}
|
||||
|
||||
|
||||
@@ -499,6 +499,7 @@ object CarCorderController : TakePhotoCallback, TakeVideoCallback {
|
||||
info.type = type //0为图片, 1为视频
|
||||
info.fromType = fromType
|
||||
info.mainInfoId = mainInfoId
|
||||
info.infoType = 1
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
@@ -28,12 +29,12 @@ import java.util.Set;
|
||||
import static java.lang.Math.PI;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/10/30
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
class BaseDrawer {
|
||||
|
||||
/**
|
||||
@@ -47,11 +48,11 @@ class BaseDrawer {
|
||||
|
||||
public void showSpeed() {
|
||||
try {
|
||||
showSelfSpeed( context,
|
||||
showSelfSpeed(context,
|
||||
marker,
|
||||
speed,
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() );
|
||||
} catch ( Exception e ) {
|
||||
MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
/**
|
||||
* 显示速度
|
||||
@@ -79,12 +79,12 @@ class BaseDrawer {
|
||||
/**
|
||||
* 地图内部资源md5缓存,便于资源复用
|
||||
*/
|
||||
protected static final Map< String, String > mMarkerCachesResMd5Values = new HashMap<>();
|
||||
protected static final Map<String, String> mMarkerCachesResMd5Values = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 上一帧数据的缓存
|
||||
*/
|
||||
protected Map< String, IMogoMarker > mMarkersCaches = new HashMap<>();
|
||||
protected Map<String, IMogoMarker> mMarkersCaches = new HashMap<>();
|
||||
|
||||
protected final Context mContext;
|
||||
|
||||
@@ -101,38 +101,38 @@ class BaseDrawer {
|
||||
* 处理 marker 移除的线程
|
||||
*/
|
||||
private static void initWorkThreadHandler() {
|
||||
if ( mWorkThreadHandler == null ) {
|
||||
mWorkThreadHandler = new Handler( WorkThreadHandler.newInstance( "3d-marker-work-thread" ).getLooper() ) {
|
||||
if (mWorkThreadHandler == null) {
|
||||
mWorkThreadHandler = new Handler(WorkThreadHandler.newInstance("3d-marker-work-thread").getLooper()) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.what == MSG_REMOVE_DIRTY_MARKERS ) {
|
||||
if ( msg.obj instanceof Map ) {
|
||||
removeDirtyMarkers( ( ( Map ) msg.obj ) );
|
||||
Set< String > key = ( ( Map ) msg.obj ).keySet();
|
||||
for ( String id : key ) {
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_REMOVE_DIRTY_MARKERS) {
|
||||
if (msg.obj instanceof Map) {
|
||||
removeDirtyMarkers(((Map) msg.obj));
|
||||
Set<String> key = ((Map) msg.obj).keySet();
|
||||
for (String id : key) {
|
||||
// 清除道路缓存
|
||||
clearRoadCacheById( id );
|
||||
clearRoadCacheById(id);
|
||||
}
|
||||
} else if ( msg.obj instanceof String ) {
|
||||
} else if (msg.obj instanceof String) {
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getMapServiceApi()
|
||||
.getMarkerManager( AbsMogoApplication.getApp() )
|
||||
.removeMarkers( ( ( String ) msg.obj ) );
|
||||
.getMarkerManager(AbsMogoApplication.getApp())
|
||||
.removeMarkers(((String) msg.obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if ( mRenderThreadHandler == null ) {
|
||||
mRenderThreadHandler = new Handler( WorkThreadHandler.newInstance( "render-thread-" + new Random().nextLong() ).getLooper() ) {
|
||||
if (mRenderThreadHandler == null) {
|
||||
mRenderThreadHandler = new Handler(WorkThreadHandler.newInstance("render-thread-" + new Random().nextLong()).getLooper()) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.what == MSG_DISPLAY_SPEED ) {
|
||||
if ( msg.obj instanceof SpeedData ) {
|
||||
showSpeed( ( SpeedData ) msg.obj );
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (msg.what == MSG_DISPLAY_SPEED) {
|
||||
if (msg.obj instanceof SpeedData) {
|
||||
showSpeed((SpeedData) msg.obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,10 +143,10 @@ class BaseDrawer {
|
||||
/**
|
||||
* 显示速度
|
||||
*
|
||||
* @param data
|
||||
* @param data {@link SpeedData}
|
||||
*/
|
||||
private static void showSpeed( SpeedData data ) {
|
||||
if ( data == null ) {
|
||||
private static void showSpeed(SpeedData data) {
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
data.showSpeed();
|
||||
@@ -156,13 +156,13 @@ class BaseDrawer {
|
||||
* 清除无效[为 null 或者 已被销毁]的 marker
|
||||
*/
|
||||
protected void removeUselessMarker() {
|
||||
if ( mMarkersCaches == null || mMarkersCaches.isEmpty() ) {
|
||||
if (mMarkersCaches == null || mMarkersCaches.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Iterator< IMogoMarker > iterator = mMarkersCaches.values().iterator();
|
||||
while ( iterator.hasNext() ) {
|
||||
Iterator<IMogoMarker> iterator = mMarkersCaches.values().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
IMogoMarker marker = iterator.next();
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
if (marker == null || marker.isDestroyed()) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
@@ -171,66 +171,60 @@ class BaseDrawer {
|
||||
/**
|
||||
* 发送消息
|
||||
*
|
||||
* @param msg
|
||||
* @param data
|
||||
* @param msg 消息类型
|
||||
* @param data 数据体
|
||||
*/
|
||||
public void sendMessage( int msg, Object data ) {
|
||||
public void sendMessage(int msg, Object data) {
|
||||
Message message = Message.obtain();
|
||||
message.what = msg;
|
||||
message.obj = data;
|
||||
mWorkThreadHandler.sendMessage( message );
|
||||
mWorkThreadHandler.sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是绘制内容
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
* @param type {@link AdasRecognizedType}
|
||||
* @return render
|
||||
*/
|
||||
public boolean isRenderType( int type ) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
|
||||
if ( recognizedType == AdasRecognizedType.classIdCar
|
||||
public boolean isRenderType(int type) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
return recognizedType == AdasRecognizedType.classIdCar
|
||||
|| recognizedType == AdasRecognizedType.classIdMoto
|
||||
|| recognizedType == AdasRecognizedType.classIdBicycle
|
||||
|| recognizedType == AdasRecognizedType.classIdPerson
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficBus
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficTruck ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficTruck;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否展示车速
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
* @param type {@link AdasRecognizedType}
|
||||
* @return showSpeed
|
||||
*/
|
||||
public boolean shouldShowSpeed( int type ) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
|
||||
if ( recognizedType == AdasRecognizedType.classIdBicycle
|
||||
|| recognizedType == AdasRecognizedType.classIdMoto
|
||||
|| recognizedType == AdasRecognizedType.classIdPerson ) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
public boolean shouldShowSpeed(int type) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
return recognizedType != AdasRecognizedType.classIdBicycle
|
||||
&& recognizedType != AdasRecognizedType.classIdMoto
|
||||
&& recognizedType != AdasRecognizedType.classIdPerson;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取3D锚点模型资源
|
||||
*
|
||||
* @param type {@link AdasRecognizedType}
|
||||
* @return
|
||||
* @return modelRes
|
||||
*/
|
||||
public int getModelRes( int type ) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
|
||||
if ( recognizedType == AdasRecognizedType.classIdCar
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficTruck ) {
|
||||
public int getModelRes(int type) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
if (recognizedType == AdasRecognizedType.classIdCar
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficTruck) {
|
||||
return R.raw.othercar;
|
||||
} else if ( recognizedType == AdasRecognizedType.classIdTrafficBus ) {
|
||||
} else if (recognizedType == AdasRecognizedType.classIdTrafficBus) {
|
||||
return R.raw.bus;
|
||||
} else if ( recognizedType == AdasRecognizedType.classIdBicycle
|
||||
|| recognizedType == AdasRecognizedType.classIdMoto ) {
|
||||
} else if (recognizedType == AdasRecognizedType.classIdBicycle
|
||||
|| recognizedType == AdasRecognizedType.classIdMoto) {
|
||||
return R.raw.motorbike;
|
||||
}
|
||||
return R.raw.people;
|
||||
@@ -239,38 +233,38 @@ class BaseDrawer {
|
||||
/**
|
||||
* 根据速度、经纬度计算距离判断车辆颜色
|
||||
*
|
||||
* @param speed 车速
|
||||
* @param speed 车速 TODO 这里很可能是adas的策略
|
||||
* @param lon 经度
|
||||
* @param lat 纬度
|
||||
* @return 实际车辆颜色
|
||||
*/
|
||||
protected String getModelRenderColor( int type, double speed, double lon, double lat, double angle ) {
|
||||
protected String getModelRenderColor(int type, double speed, double lon, double lat, double angle) {
|
||||
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
|
||||
if ( recognizedType == AdasRecognizedType.classIdTrafficBus ) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
if (recognizedType == AdasRecognizedType.classIdTrafficBus) {
|
||||
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;
|
||||
@@ -279,11 +273,11 @@ class BaseDrawer {
|
||||
/**
|
||||
* 返回当前自车速度
|
||||
*
|
||||
* @return
|
||||
* @return isCurSpeed
|
||||
*/
|
||||
private double getCurSpeed() {
|
||||
double speed = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastSpeed();
|
||||
if ( speed <= 0 ) {
|
||||
if (speed <= 0) {
|
||||
speed = SnapshotLocationController.getInstance().getCurSpeed();
|
||||
}
|
||||
return speed;
|
||||
@@ -295,11 +289,11 @@ class BaseDrawer {
|
||||
* @return
|
||||
*/
|
||||
private double[] getCurCoordinates() {
|
||||
double coordinates[] = {
|
||||
double[] coordinates = {
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon(),
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
|
||||
};
|
||||
if ( coordinates[0] <= 0 ) {
|
||||
if (coordinates[0] <= 0) {
|
||||
coordinates[0] = SnapshotLocationController.getInstance().getCurLon();
|
||||
coordinates[1] = SnapshotLocationController.getInstance().getCurLat();
|
||||
}
|
||||
@@ -312,13 +306,13 @@ class BaseDrawer {
|
||||
*/
|
||||
public enum Car3DModelColor {
|
||||
|
||||
Normal( "#D8D8D8FF" ),
|
||||
Warming( "#FFD53EFF" ),
|
||||
Dangerous( "#FF3C45FF" );
|
||||
Normal("#D8D8D8FF"),
|
||||
Warming("#FFD53EFF"),
|
||||
Dangerous("#FF3C45FF");
|
||||
|
||||
private String color;
|
||||
private final String color;
|
||||
|
||||
Car3DModelColor( String color ) {
|
||||
Car3DModelColor(String color) {
|
||||
this.color = color;
|
||||
}
|
||||
}
|
||||
@@ -328,59 +322,59 @@ class BaseDrawer {
|
||||
/**
|
||||
* 展示车辆速度
|
||||
*
|
||||
* @param context
|
||||
* @param mogoMarker
|
||||
* @param speed
|
||||
* @param isVrMode
|
||||
* @param context 上下文
|
||||
* @param mogoMarker {@link IMogoMarker}
|
||||
* @param speed 是否显示速度
|
||||
* @param isVrMode 是否是vrMode
|
||||
*/
|
||||
public void showSelfSpeed( Context context, IMogoMarker mogoMarker, double speed, boolean isVrMode ) {
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
public void showSelfSpeed(Context context, IMogoMarker mogoMarker, double speed, boolean isVrMode) {
|
||||
if (mogoMarker == null || mogoMarker.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
if ( !isVrMode ) {
|
||||
if (!isVrMode) {
|
||||
mogoMarker.hideInfoWindow();
|
||||
return;
|
||||
}
|
||||
int speedIntVal = ( int ) ( speed * 3.6 );
|
||||
if ( speedIntVal <= 0 ) {
|
||||
int speedIntVal = (int) (speed * 3.6);
|
||||
if (speedIntVal <= 0) {
|
||||
mogoMarker.hideInfoWindow();
|
||||
return;
|
||||
}
|
||||
String speedVal = speedIntVal + "";
|
||||
String infoResName = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getMarkerInfoResName( speedVal );
|
||||
mogoMarker.setInfoWindowOffset( 0, 20 );
|
||||
if ( TextUtils.isEmpty( infoResName ) ) {
|
||||
if ( mSpeedView == null ) {
|
||||
mSpeedView = new TextView( context );
|
||||
mSpeedView.setTextColor( Color.WHITE );
|
||||
mSpeedView.setTypeface( Typeface.defaultFromStyle( Typeface.BOLD ) );
|
||||
mSpeedView.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT ) );
|
||||
String infoResName = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getMarkerInfoResName(speedVal);
|
||||
mogoMarker.setInfoWindowOffset(0, 20);
|
||||
if (TextUtils.isEmpty(infoResName)) {
|
||||
if (mSpeedView == null) {
|
||||
mSpeedView = new TextView(context);
|
||||
mSpeedView.setTextColor(Color.WHITE);
|
||||
mSpeedView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
|
||||
mSpeedView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
}
|
||||
mSpeedView.setText( speedVal );
|
||||
mogoMarker.updateInfoWindowView( mSpeedView );
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().setMarkerInfoResName( speedVal, mogoMarker.getMarkerInfoResName() );
|
||||
mSpeedView.setText(speedVal);
|
||||
mogoMarker.updateInfoWindowView(mSpeedView);
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().setMarkerInfoResName(speedVal, mogoMarker.getMarkerInfoResName());
|
||||
} else {
|
||||
mogoMarker.updateInfoWindowView( infoResName );
|
||||
mogoMarker.updateInfoWindowView(infoResName);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除markers
|
||||
*
|
||||
* @param dirtyMarkers
|
||||
* @param dirtyMarkers 缓存marker数据
|
||||
*/
|
||||
protected static void removeDirtyMarkers( Map< String, IMogoMarker > dirtyMarkers ) {
|
||||
if ( dirtyMarkers == null || dirtyMarkers.isEmpty() ) {
|
||||
protected static void removeDirtyMarkers(Map<String, IMogoMarker> dirtyMarkers) {
|
||||
if (dirtyMarkers == null || dirtyMarkers.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
final Collection< IMogoMarker > dirSet = dirtyMarkers.values();
|
||||
for ( IMogoMarker value : dirSet ) {
|
||||
if ( value == null || value.isDestroyed() ) {
|
||||
final Collection<IMogoMarker> dirSet = dirtyMarkers.values();
|
||||
for (IMogoMarker value : dirSet) {
|
||||
if (value == null || value.isDestroyed()) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
value.destroy();
|
||||
} catch ( Exception e ) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -393,15 +387,15 @@ class BaseDrawer {
|
||||
* @param id
|
||||
* @param marker
|
||||
*/
|
||||
protected static void cacheMarkerIconResMd5Val( String id, IMogoMarker marker ) {
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
protected static void cacheMarkerIconResMd5Val(String id, IMogoMarker marker) {
|
||||
if (marker == null || marker.isDestroyed()) {
|
||||
return;
|
||||
}
|
||||
String md5 = marker.getMarkerResName();
|
||||
if ( TextUtils.isEmpty( md5 ) || TextUtils.isEmpty( id ) ) {
|
||||
if (TextUtils.isEmpty(md5) || TextUtils.isEmpty(id)) {
|
||||
return;
|
||||
}
|
||||
mMarkerCachesResMd5Values.put( id, md5 );
|
||||
mMarkerCachesResMd5Values.put(id, md5);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,14 +407,14 @@ class BaseDrawer {
|
||||
* @param isRtk
|
||||
* @return
|
||||
*/
|
||||
public double[] matchRoad( String id, double lon, double lat, double angle, boolean isRtk ) {
|
||||
public double[] matchRoad(String id, double lon, double lat, double angle, boolean isRtk) {
|
||||
final long start = System.currentTimeMillis();
|
||||
double[] matchRoad = MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getMapServiceApi()
|
||||
.getMapUIController()
|
||||
.matchRoad( id, lon, lat, angle, true, isRtk );
|
||||
Log.i( "timer-matchRoad", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
.matchRoad(id, lon, lat, angle, true, isRtk);
|
||||
Log.i("timer-matchRoad", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
return matchRoad;
|
||||
}
|
||||
|
||||
@@ -429,8 +423,8 @@ class BaseDrawer {
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public static void clearRoadCacheById( String id ) {
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().clearRoadCacheById( id );
|
||||
public static void clearRoadCacheById(String id) {
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().clearRoadCacheById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,11 +436,11 @@ class BaseDrawer {
|
||||
* @param curSatelliteTime
|
||||
* @return
|
||||
*/
|
||||
public long computeAnimDuration( long lastSystemTime, long curSystemTime, long lastSatelliteTime, long curSatelliteTime ) {
|
||||
public long computeAnimDuration(long lastSystemTime, long curSystemTime, long lastSatelliteTime, long curSatelliteTime) {
|
||||
long systemTimeInterval = curSystemTime - lastSystemTime;
|
||||
long satelliteTimeInterval = curSatelliteTime - lastSatelliteTime;
|
||||
long interval = systemTimeInterval < satelliteTimeInterval || satelliteTimeInterval == 0 ? systemTimeInterval : satelliteTimeInterval;
|
||||
if ( interval < 45 ) {
|
||||
if (interval < 45) {
|
||||
interval = 45;
|
||||
}
|
||||
return interval;
|
||||
@@ -463,37 +457,37 @@ class BaseDrawer {
|
||||
* @param lastLat
|
||||
* @return
|
||||
*/
|
||||
protected double[] getMatchLonLat( String id, double lon, double lat, double heading, double lastLon, double lastLat ) {
|
||||
double[] matchedPoint = matchRoad( id, lon,
|
||||
protected double[] getMatchLonLat(String id, double lon, double lat, double heading, double lastLon, double lastLat) {
|
||||
double[] matchedPoint = matchRoad(id, lon,
|
||||
lat,
|
||||
heading,
|
||||
true
|
||||
);
|
||||
|
||||
boolean match = false;
|
||||
if ( matchedPoint != null ) {
|
||||
if (matchedPoint != null) {
|
||||
// Logger.d( TAG, "matchPoint %s distance = %s",lineCounter, matchedPoint[2] );
|
||||
match = matchedPoint[2] < 1 && matchedPoint[2] > 0;
|
||||
|
||||
if ( lastLon != -1 ) {
|
||||
if (lastLon != -1) {
|
||||
double clearAngle;
|
||||
if ( heading > 0 && heading <= 90 ) {
|
||||
if (heading > 0 && heading <= 90) {
|
||||
clearAngle = heading;
|
||||
} else if ( heading > 90 && heading <= 180 ) {
|
||||
} else if (heading > 90 && heading <= 180) {
|
||||
clearAngle = 180 - heading;
|
||||
} else if ( heading > 180 && heading <= 270 ) {
|
||||
} else if (heading > 180 && heading <= 270) {
|
||||
clearAngle = heading - 180;
|
||||
} else {
|
||||
clearAngle = 360 - heading;
|
||||
}
|
||||
double _angle = Math.atan2( Math.abs( matchedPoint[0] - lastLon ), Math.abs( matchedPoint[1] - lastLat ) ) * ( 180 / PI );
|
||||
_angle = Math.abs( clearAngle - _angle );
|
||||
double _angle = Math.atan2(Math.abs(matchedPoint[0] - lastLon), Math.abs(matchedPoint[1] - lastLat)) * (180 / PI);
|
||||
_angle = Math.abs(clearAngle - _angle);
|
||||
// Logger.d(TAG, "matchPoint %s angel = %s", lineCounter, _angle);
|
||||
if ( _angle > 22.5 ) {
|
||||
if (_angle > 22.5) {
|
||||
match = false;
|
||||
}
|
||||
}
|
||||
if ( match ) {
|
||||
if (match) {
|
||||
lon = matchedPoint[0];
|
||||
lat = matchedPoint[1];
|
||||
}
|
||||
|
||||
@@ -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,12 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
|
||||
IMogoMarker bottomMarker = drawMarkerWith2Resource(markerShowEntity);
|
||||
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(data.getCollisionLat(), data.getCollisionLon());
|
||||
//2D资源图片位置调整
|
||||
MogoLatLng stopLineNew = Trigonometric.getNewLocation(data.getStopLines().get(1), 8, 180);
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 8, 180);
|
||||
|
||||
IMogoMarker marker = drawMarker(markerShowEntity);
|
||||
Log.d("liyz", "renderWarnData marker != null direction = " + data.getDirection());
|
||||
//识别物
|
||||
@@ -94,8 +101,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 ? stopLineNew.lat : newLocation.getLat(),
|
||||
data.getDirection() == 1 ? stopLineNew.lon : newLocation.getLon()), (float) data.getHeading(), 5000);
|
||||
//移动完成以后,3s后消失
|
||||
UiThreadHandler.postDelayed(() -> {
|
||||
marker.remove();
|
||||
@@ -121,16 +128,31 @@ 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);
|
||||
|
||||
@@ -10,11 +10,11 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public
|
||||
/**
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/12/14
|
||||
*
|
||||
* 实时坐标
|
||||
* 实时坐标数据处理中心
|
||||
*/
|
||||
class SnapshotLocationController {
|
||||
|
||||
@@ -40,16 +40,15 @@ class SnapshotLocationController {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private CloudLocationInfo mLastLocationInfo = null;
|
||||
|
||||
private List< CloudLocationInfo > mLocationList = new ArrayList<>();
|
||||
private int mDataAccuracy = 0;
|
||||
// GPS(1s1次) RTK(OS侧)缓存数据,
|
||||
private final List< CloudLocationInfo > mLocationList = new ArrayList<>();
|
||||
|
||||
// adda 工控机数据缓存
|
||||
private final List< CloudLocationInfo > mMachineCacheList = new ArrayList<>();
|
||||
|
||||
private int mDataAccuracy = 0;
|
||||
private double mCurSpeed;
|
||||
private double mCurLon;
|
||||
private double mCurLat;
|
||||
@@ -57,26 +56,23 @@ class SnapshotLocationController {
|
||||
/**
|
||||
* 同步从定位来的数据(也可能是rtk)
|
||||
*
|
||||
* @param cli
|
||||
* @param cli {@link CloudLocationInfo}
|
||||
*/
|
||||
public void syncLocationInfo( CloudLocationInfo cli ) {
|
||||
if ( cli == null ) {
|
||||
return;
|
||||
}
|
||||
mLastLocationInfo = cli;
|
||||
mCurSpeed = mLastLocationInfo.getSpeed();
|
||||
mCurLon = mLastLocationInfo.getLon();
|
||||
mCurLat = mLastLocationInfo.getLat();
|
||||
mCurSpeed = cli.getSpeed();
|
||||
mCurLon = cli.getLon();
|
||||
mCurLat = cli.getLat();
|
||||
mLocationList.add( cli );
|
||||
}
|
||||
|
||||
// adda 工控机数据缓存
|
||||
private List< CloudLocationInfo > mMachineCacheList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 同步从工控机来的数据
|
||||
*
|
||||
* @param data
|
||||
* @param data JSON结构化数据
|
||||
*/
|
||||
public void syncAdasLocationInfo( JSONObject data ) {
|
||||
if ( data == null ) {
|
||||
@@ -105,15 +101,15 @@ class SnapshotLocationController {
|
||||
mLastLocationInfo = cloudLocationInfo;
|
||||
mMachineCacheList.add( cloudLocationInfo );
|
||||
|
||||
mCurSpeed = mLastLocationInfo.getSpeed();
|
||||
mCurLon = mLastLocationInfo.getLon();
|
||||
mCurLat = mLastLocationInfo.getLat();
|
||||
mCurSpeed = cloudLocationInfo.getSpeed();
|
||||
mCurLon = cloudLocationInfo.getLon();
|
||||
mCurLat = cloudLocationInfo.getLat();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某一段时间内的坐标集合
|
||||
*
|
||||
* @return
|
||||
* @return 坐标合集
|
||||
*/
|
||||
public List< CloudLocationInfo > getSendLocationData() {
|
||||
|
||||
@@ -144,7 +140,7 @@ class SnapshotLocationController {
|
||||
/**
|
||||
* 数据精度类型,目前按照数据来源标志
|
||||
*
|
||||
* @return
|
||||
* @return 精度
|
||||
*/
|
||||
public int getDataAccuracy() {
|
||||
Logger.d( TAG, "upload loc accuracy = %s", mDataAccuracy );
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<ImageView
|
||||
android:layout_marginTop="@dimen/dp_100"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:src="@drawable/common_marker_bottom_floor"/>
|
||||
android:src="@drawable/common_marker_bottom_floor" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -109,11 +109,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static final String TAG = "MogoServices";
|
||||
|
||||
/**
|
||||
@@ -238,7 +233,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
/**
|
||||
* 手动刷新回调
|
||||
*/
|
||||
private RefreshCallback mCustomRefreshCallback = new RefreshCallback< MarkerResponse >() {
|
||||
private final RefreshCallback mCustomRefreshCallback = new RefreshCallback< MarkerResponse >() {
|
||||
@Override
|
||||
public void onSuccess( MarkerResponse o ) {
|
||||
MapMarkerManager.getInstance().onSyncMarkerResponse( o );
|
||||
@@ -616,16 +611,13 @@ public class MogoServices implements IMogoMapListener,
|
||||
private int getQueryRadius() {
|
||||
mCameraSouthWestPosition = mUiController.getCameraSouthWestPosition();
|
||||
mCameraNorthEastPosition = mUiController.getCameraNorthEastPosition();
|
||||
int radius = 0;
|
||||
int radius;
|
||||
if ( mIsVertical ) {
|
||||
radius = ( ( int ) ( getMapCameraFactWidth() / 2 ) );
|
||||
} else {
|
||||
radius = ( ( int ) ( getMapCameraFactHeight() / 2 ) );
|
||||
}
|
||||
if ( radius < 1000 ) {
|
||||
return 1_000;
|
||||
}
|
||||
return radius;
|
||||
return Math.max(radius, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -633,7 +625,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
*/
|
||||
private boolean invokeRefreshWhenTranslationByUser( MogoLatLng latLng ) {
|
||||
try {
|
||||
float factor = 0.0f;
|
||||
float factor;
|
||||
if ( mIsVertical ) {
|
||||
factor = getMapCameraFactWidth();
|
||||
} else {
|
||||
@@ -697,7 +689,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
/**
|
||||
* 首次定位成功后,执行道路事件的刷新
|
||||
*
|
||||
* @param point
|
||||
* @param point {@link MogoLatLng}
|
||||
*/
|
||||
private void startFirstLocationRequest( MogoLatLng point ) {
|
||||
mLastAutoRefreshLocation = point;
|
||||
|
||||
@@ -58,19 +58,21 @@ public class MogoRTKLocation {
|
||||
return criteria;
|
||||
}
|
||||
|
||||
private LocationListener locationListener = new LocationListener() {
|
||||
private final LocationListener locationListener = new LocationListener() {
|
||||
@Override
|
||||
public void onLocationChanged( Location location ) {
|
||||
if ( location != null ) {
|
||||
CloudLocationInfo cloudLocationInfo = new CloudLocationInfo();
|
||||
cloudLocationInfo.setAlt( location.getAltitude() );
|
||||
cloudLocationInfo.setHeading( location.getBearing() );
|
||||
cloudLocationInfo.setLat( location.getLatitude() );
|
||||
cloudLocationInfo.setLon( location.getLongitude() );
|
||||
cloudLocationInfo.setSpeed( location.getSpeed() );
|
||||
cloudLocationInfo.setSatelliteTime( location.getTime() );
|
||||
cloudLocationInfo.setSystemTime( System.currentTimeMillis() );
|
||||
SnapshotLocationController.getInstance().syncLocationInfo( cloudLocationInfo );
|
||||
if(location.getLatitude() != 0.0 && location.getLongitude() != 0.0){
|
||||
cloudLocationInfo.setAlt( location.getAltitude() );
|
||||
cloudLocationInfo.setHeading( location.getBearing() );
|
||||
cloudLocationInfo.setLat( location.getLatitude() );
|
||||
cloudLocationInfo.setLon( location.getLongitude() );
|
||||
cloudLocationInfo.setSpeed( location.getSpeed() );
|
||||
cloudLocationInfo.setSatelliteTime( location.getTime() );
|
||||
cloudLocationInfo.setSystemTime( System.currentTimeMillis() );
|
||||
SnapshotLocationController.getInstance().syncLocationInfo( cloudLocationInfo );
|
||||
}
|
||||
} else {
|
||||
Logger.e( TAG, "location == null" );
|
||||
}
|
||||
|
||||
@@ -100,20 +100,19 @@ public class V2XWaringManager {
|
||||
if (v2XWarnMessageListener != null) {
|
||||
V2XServiceManager
|
||||
.getMoGoSocketManager()
|
||||
.unregisterOnMessageListener(401011, v2XWarnMessageListener);
|
||||
.unregisterOnMessageListener(10116, v2XWarnMessageListener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 道路事件,行人 TODO type
|
||||
* 道路预警 弱势群体事件,行人 TODO type
|
||||
*/
|
||||
private void registerWarnListener() {
|
||||
v2XWarnMessageListener = new V2XWarnMessageListener();
|
||||
// 道路事件,在线车辆绘制
|
||||
V2XServiceManager
|
||||
.getMoGoSocketManager()
|
||||
.registerOnMessageListener(
|
||||
401011,
|
||||
10116,
|
||||
v2XWarnMessageListener );
|
||||
}
|
||||
|
||||
|
||||
@@ -20,12 +20,13 @@ public class V2XWarnMessageListener implements IMogoOnMessageListener<V2XWarning
|
||||
|
||||
@Override
|
||||
public void onMsgReceived(V2XWarningEntity info) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "V2XWarnMessageListener onMsgReceived ---11---> ");
|
||||
//Logger.d(MODULE_NAME, "V2XMessageListener_401011==V2X地图气泡数据刷新:\n" + GsonUtil.jsonFromObject(response));
|
||||
V2XUtils.runOnBackgroundThread(() -> {
|
||||
// 解析不同的Marker类型,然后对应的进行绘制
|
||||
if (info != null) {
|
||||
// 解析存储道路事件 liyz
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "V2XWarnMessageListener onMsgReceived ----> ");
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "V2XWarnMessageListener onMsgReceived --22--> ");
|
||||
V2XServiceManager.getMoGoV2XCloundDataManager().analysisV2XCloundDataEvent(info);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -11,7 +11,9 @@ import com.mogo.map.navi.IMogoCarLocationChangedListener2;
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
|
||||
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.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.v2x.MoGoV2XServicePaths;
|
||||
@@ -19,7 +21,6 @@ import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
import com.mogo.module.v2x.entity.model.DrawLineInfo;
|
||||
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
|
||||
import com.mogo.module.v2x.utils.LocationUtils;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
@@ -39,7 +40,10 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
private boolean isSelfLineClear;
|
||||
private List fillPoints = new ArrayList();//停止线经纬度合集
|
||||
private boolean isFirstLocation = false;
|
||||
private MogoLatLng carLocation;
|
||||
private MogoLatLng carLocation = new MogoLatLng(
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon()
|
||||
);
|
||||
|
||||
private static long showTime = 0;
|
||||
|
||||
@@ -63,7 +67,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
isFirstLocation = false;
|
||||
|
||||
if (cloundWarningInfo.getDirection() == 1) { //前方
|
||||
MogoLatLng newLocation = LocationUtils.getNewLocation((MogoLatLng) fillPoints.get(0), 80, cloundWarningInfo.getAngle());
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation((MogoLatLng) fillPoints.get(0), 80, cloundWarningInfo.getAngle());
|
||||
//停止线前方画线
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
//二轮车和行人的渲染和移动
|
||||
@@ -116,7 +120,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
|
||||
* 车辆行驶正前方绘制红色区域(停止线继续前行的预警区域) TODO 需要实时给行人当前位置
|
||||
*/
|
||||
private void drawStopLine(V2XWarningEntity info, MogoLatLng mogoLatLng) {
|
||||
if (info != null) {
|
||||
@@ -126,7 +130,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine endLatlng lon =" + endLatlng.lon + "--lat =" + endLatlng.lat
|
||||
+ "--startLatlng lon = " + startLatlng.lon + "-lat = " + startLatlng.lat);
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
MogoLatLng addMiddleLoc = LocationUtils.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
if (polyLine != null) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
@@ -150,7 +154,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
|
||||
|
||||
/**
|
||||
* 目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
|
||||
* 侧方目标物与预碰撞点连线,并且更新数据 TODO 需要实时给行人当前位置
|
||||
*/
|
||||
private void drawOtherObjectLine(V2XWarningEntity info) {
|
||||
if (info != null) {
|
||||
@@ -158,7 +162,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());
|
||||
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
MogoLatLng addMiddleLoc = LocationUtils.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
if (polyLine != null) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "polyLine != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
@@ -182,6 +186,21 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
}
|
||||
}
|
||||
|
||||
//侧面目标物与碰撞点之间添加多个小箭头
|
||||
private void addArrows(MogoLatLng startLatLng, MogoLatLng endLatLng) {
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
float distance = CoordinateUtils.calculateLineDistance(
|
||||
startLatLng.lon, startLatLng.lat, endLatLng.lon, endLatLng.lat);
|
||||
if (distance > 5) {
|
||||
int count = (int) (distance / 5);
|
||||
for (int i = 0; i < count; i++) {
|
||||
MogoLatLng newLo = Trigonometric.getNewLocation(
|
||||
startLatLng, 5 * i, mCloundWarningInfo.getAngle());
|
||||
V2XWarnDataDrawer.getInstance().drawerMarkerWithLocation(markerShowEntity, newLo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearALLPOI() {
|
||||
|
||||
@@ -225,7 +244,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? carLocation.lat : mCloundWarningInfo.getCollisionLat(),
|
||||
mCloundWarningInfo.getDirection() == 1 ? carLocation.lon : mCloundWarningInfo.getCollisionLon());
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
addMiddleLoc = LocationUtils.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawSlefCarLine lon = " + carLocation.lon + "---lat = " + carLocation.lat);
|
||||
isFirstLocation = true;
|
||||
}
|
||||
@@ -265,11 +284,11 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
|
||||
float average = distance / 3;
|
||||
//两点间的角度
|
||||
double angle = LocationUtils.getAngle(x.lon, x.lat, y.lon, y.lat);
|
||||
double angle = Trigonometric.getAngle(x.lon, x.lat, y.lon, y.lat);
|
||||
//根据距离和角度获取下个点的经纬度
|
||||
fillPoints.add(x);
|
||||
for (int i = 1; i < 3; i++) {
|
||||
MogoLatLng newLocation = LocationUtils.getNewLocation(x, average * i, angle);
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(x, average * i, angle);
|
||||
fillPoints.add(newLocation);
|
||||
}
|
||||
fillPoints.add(y);
|
||||
@@ -280,7 +299,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
}
|
||||
|
||||
private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
||||
MogoLatLng newLocation = LocationUtils.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getDirection());
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getDirection());
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.v2x.R;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
@@ -99,7 +100,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
carlo = new MogoLatLng(lat, lon);
|
||||
}
|
||||
//自车行驶方向的前方*米的经纬度,该经纬度在停止线上
|
||||
MogoLatLng drawStopLineLon = LocationUtils.getNewLocation(carlo, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
|
||||
MogoLatLng drawStopLineLon = Trigonometric.getNewLocation(carlo, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
|
||||
Log.d(TAG, "2D资源绘" + drawStopLineLon);
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(drawStopLineLon.getLat())
|
||||
|
||||
@@ -27,12 +27,6 @@ import com.mogo.utils.network.utils.GsonUtil;
|
||||
*/
|
||||
public class LocationUtils {
|
||||
private static final String TAG = "LocationUtils";
|
||||
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 void geoCodeSearch(MogoLocation location, IMogoGeoSearchListener listener) {
|
||||
MogoRegeocodeQuery mogoRegeocodeQuery = new MogoRegeocodeQuery();
|
||||
@@ -93,42 +87,6 @@ public class LocationUtils {
|
||||
return latLon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两点间的角度
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取传入的经纬度在车辆的什么位置
|
||||
*
|
||||
|
||||
@@ -138,10 +138,16 @@ public class MogoADASController implements IMogoADASController {
|
||||
super.handleMessage( msg );
|
||||
final long start = System.currentTimeMillis();
|
||||
ADASCarStateInfo stateInfo = GsonUtil.objectFromJson( ( ( String ) msg.obj ), ADASCarStateInfo.class );
|
||||
Logger.d( "ADAS-LOC-timer", "upd 到 aidl 传输耗时:%s", start - Long.valueOf( stateInfo.getValues().getStartReceiverDataTime() ) );
|
||||
if ( stateInfo == null || stateInfo.getValues() == null ) {
|
||||
Logger.d(TAG,"ADAS-LOC-timer","upd 到 aidl 传输数据 stateInfo or stateInfo.getValues() is null");
|
||||
return;
|
||||
}
|
||||
if(stateInfo.getValues().getStartReceiverDataTime() != null){
|
||||
Logger.d( "ADAS-LOC-timer", "upd 到 aidl 传输耗时:%s", start - Long.valueOf( stateInfo.getValues().getStartReceiverDataTime() ) );
|
||||
}else{
|
||||
Logger.d( "ADAS-LOC-timer", "upd 到 aidl 传输耗时时间字段 startReceiverDataTime is null");
|
||||
}
|
||||
|
||||
mLastLon = stateInfo.getValues().getLon();
|
||||
mLastLat = stateInfo.getValues().getLat();
|
||||
if ( mMogoAdasCarDataCallback != null ) {
|
||||
|
||||
Reference in New Issue
Block a user