add draw 3dmodel
This commit is contained in:
@@ -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 他车识别的社会车辆、路边单元识别的车辆
|
||||
*
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user