add draw 3dmodel

This commit is contained in:
lixiaopeng
2021-04-01 19:50:09 +08:00
parent 54feb71b4e
commit 618597d2bf
7 changed files with 133 additions and 80 deletions

View File

@@ -280,7 +280,7 @@ public class AMapWrapper implements IMogoMap {
public float getRoadWidth(double lon, double lat, float angle, boolean isGpsLocation, boolean isRTK) {
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad(lon, lat, angle, isGpsLocation, isRTK);
return singlePointRoadInfo.getLaneWidth();
return singlePointRoadInfo != null ? singlePointRoadInfo.getLaneWidth() : 0;
}
private Context getContext() {

View File

@@ -2,7 +2,6 @@ package com.mogo.module.common.drawer;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
@@ -16,7 +15,6 @@ import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.R;
import com.mogo.module.common.api.CallChatApi;
import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.common.utils.SimpleHandlerThreadPool;
import com.mogo.realtime.entity.CloudRoadData;
import com.mogo.realtime.entity.MogoSnapshotSetData;
@@ -138,68 +136,6 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
return false;
}
/**
* 绘制 marker
*
* @param data 道路数据
* @return {@link IMogoMarker}
*/
public IMogoMarker drawWarnDataMarker( V2XWarningEntity data ) {
if ( data == null ) {
return null;
}
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_CLOUD_WARN_DATA )
.anchor( 0.5f, 0.5f )
.rotate( ( float ) data.getHeading() )
.object( data )
.gps( true )
.controlAngle( true )
.position( new MogoLatLng( data.getLat(), data.getLon()));
String resIdVal = null;
IMogoMarker marker = null;
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
options.set3DMode( true );
options.anchorColor(data.color);
int resId = getModelRes( data.getType() );
resIdVal = resId + "";
// options.resName( mMarkerCachesResMd5Values.get( resIdVal ) );
options.icon3DRes( resId );
marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_WARN_DATA, options );
} else {
// options.set3DMode( false );
// View view = inflateView( data );
// options.icon( view );
// resIdVal = view.getId() + "";
}
// cacheMarkerIconResMd5Val( resIdVal, marker );
return marker;
}
/**
* 绘制行人和二轮车
* @param data
*/
public void renderWarnData(V2XWarningEntity data ) {
IMogoMarker marker = drawWarnDataMarker(data);
if ( marker != null ) {
marker.addDynamicAnchorPosition( new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), ( float ) data.getHeading(), 2000);
} else {
Log.e("liyz", "renderWarnData marker == null ");
}
}
/**
* mogo 他车、mogo 他车识别的社会车辆、路边单元识别的车辆
*

View File

@@ -0,0 +1,116 @@
package com.mogo.module.common.drawer;
import android.util.Log;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.marker.IMarkerView;
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
import com.mogo.service.statusmanager.StatusDescriptor;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.WorkThreadHandler;
import com.mogo.utils.logger.Logger;
import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_DATA;
/**
* 云端 预警数据绘制
*/
public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedListener {
private static final String TAG = "V2XWarnDataDrawer";
private static volatile V2XWarnDataDrawer sInstance;
private boolean mChangeCarModeStatus;
private V2XWarnDataDrawer() {
super();
MogoApisHandler.getInstance().getApis()
.getStatusManagerApi()
.registerStatusChangedListener(TAG, StatusDescriptor.VR_MODE, this);
}
public static V2XWarnDataDrawer getInstance() {
if (sInstance == null) {
synchronized (V2XWarnDataDrawer.class) {
if (sInstance == null) {
sInstance = new V2XWarnDataDrawer();
}
}
}
return sInstance;
}
public synchronized void release() {
sInstance = null;
}
private boolean mIsVrMode = false;
@Override
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
Logger.d(TAG, "%s - %s", descriptor, isTrue);
mChangeCarModeStatus = true;
AdasRecognizedResultDrawer.getInstance().notifyVrModeChanged();
}
public boolean isVrMode() {
return mIsVrMode;
}
/**
* 绘制行人和二轮车
*
* @param data
*/
public void renderWarnData(V2XWarningEntity data) {
MarkerLocation location = new MarkerLocation();
location.setLat(data.getLat());
location.setLon(data.getLon());
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setMarkerLocation(location);
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA);
WorkThreadHandler.getInstance().postDelayed(() -> {
IMogoMarker marker = drawMarker(markerShowEntity);
Log.d("liyz", "renderWarnData marker != null ");
marker.addDynamicAnchorPosition(new MogoLatLng(data.getCollisionLat(), data.getCollisionLon()), (float) data.getHeading(), 4000);
//移动完成以后3s后消失
UiThreadHandler.postDelayed( () -> {
marker.remove();
}, 3000 );
}, 0);
}
public IMogoMarker drawMarker(MarkerShowEntity markerShowEntity) {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
.latitude(markerShowEntity.getMarkerLocation().getLat())
.longitude(markerShowEntity.getMarkerLocation().getLon());
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
options.icon3DRes(getModelRes(2)); //TODO
options.anchorColor("#FF4040");
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), options);
iMarkerView.setMarker(marker);
marker.setToTop();
return marker;
}
}

View File

@@ -86,7 +86,7 @@ public class V2XWaringManager {
// 加载数据源
V2XWarningEntity warningEntity = GsonUtil.objectFromJson(baos.toString(), V2XWarningEntity.class);
V2XServiceManager.getMoGoV2XCloundDataManager().analysisV2XCloundDataEvent(warningEntity);
Logger.d(V2XConst.LOG_NAME_WARN, "testData -----> ");
} catch (Exception e) {
e.printStackTrace();
}
@@ -140,11 +140,14 @@ public class V2XWaringManager {
// info1.setStartLocation(startLatlng1);
// info1.setEndLocation(endLatlng1);
//
// //只有在3d模型下才有值
// //只有在3d模型下高精数据才有值 TODO
// if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
// float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(116.411198243370,
// 39.9809517154582, (float) 3.13919341919472 , true, true);
// Log.d(V2XConst.LOG_NAME_WARN, "roadWidth = " + roadWidth);
// float pixel = V2XServiceManager.getMapUIController().getScalePerPixel();
// float width = roadWidth / pixel;
// Log.d(V2XConst.LOG_NAME_WARN, "width = " + width + "---pixel = " + pixel);
// info1.setWidth(roadWidth);
// }
//
@@ -156,7 +159,7 @@ public class V2XWaringManager {
// }, 3000 );
// adas 每隔一秒传递的他车或行人数据 TODO
// adas 每隔一秒传递的他车或行人数据
// V2XServiceManager.getmIMogoADASController().addAdasRecognizedDataCallback(resultList -> {
// // 绘制近景识别到的车辆,行人和二轮车
// AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );

View File

@@ -9,7 +9,7 @@ import com.mogo.map.MogoLatLng;
import com.mogo.map.navi.IMogoCarLocationChangedListener2;
import com.mogo.map.overlay.IMogoPolyline;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.MoGoV2XServicePaths;
import com.mogo.module.v2x.V2XConst;
@@ -17,6 +17,7 @@ import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.manager.IMoGoV2XCloundDataManager;
import com.mogo.utils.UiThreadHandler;
import com.mogo.utils.logger.Logger;
import java.util.Arrays;
@@ -37,12 +38,11 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
public void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo) {
mCloundWarningInfo = cloundWarningInfo;
//TODO 根据判断条件,决定是否画线或者删除线
//绘制识别物与交汇点连线,并且更新连线数据 TODO VR模式无法获取道路宽度
// drawOtherObjectLine(cloundWarningInfo);
//二轮车和行人的移动和渲染
SnapshotSetDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
drawOtherObjectLine(cloundWarningInfo);
Logger.d(V2XConst.LOG_NAME_WARN, "analysisV2XCloundDataEvent -----> ");
//二轮车和行人的渲染和移动
V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo);
}
/**
@@ -67,7 +67,9 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
float roadWidth = V2XServiceManager.getMapUIController().getRoadWidth(info.getLon(),
info.getLat(), (float) info.heading, true, true);
Log.d(V2XConst.LOG_NAME_WARN, "roadWidth = " + roadWidth);
lineInfo.setWidth(roadWidth);
float pixel = V2XServiceManager.getMapUIController().getScalePerPixel();
float width = roadWidth / pixel;
lineInfo.setWidth(width);
}
V2XServiceManager.getMoGoPersonWarnPolylineManager().drawPersonWarnPolyline(getContext(), lineInfo);
}
@@ -81,7 +83,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
Log.e(V2XConst.LOG_NAME_WARN, "info == null");
V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine();
}
}
@Override

View File

@@ -23,11 +23,8 @@ public class AdasDataBroadcastReceiver extends BroadcastReceiver {
// Logger.d(V2XConst.LOG_NAME_WARN, "AdasDataBroadcastReceiver -->" + GsonUtil.jsonFromObject(adasResult));
String adasResult = (String) intent.getSerializableExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY);
Log.d(V2XConst.LOG_NAME_WARN, "AdasDataBroadcastReceiver -----> ");
// V2XWaringManager.getInstance().registerAdasSocketMessage(context);
V2XWaringManager.getInstance().handleAdasData();
} catch (Exception e) {
e.printStackTrace();
}

View File

@@ -1,5 +1,5 @@
{
"type": 0,
"type": 2,
"lat": 39.977148,
"lon": 116.417478,
"distance": 2.22,