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.3.2'
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.3.3'
|
||||
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-test-3.4'
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import android.view.ViewGroup;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.autonavi.nge.map.LonLat;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.map.IMogoMap;
|
||||
import com.mogo.map.IMogoMapView;
|
||||
@@ -56,6 +57,7 @@ import com.zhidaoauto.map.sdk.open.location.RTKAutopilotLocationBean;
|
||||
import com.zhidaoauto.map.sdk.open.marker.BitmapDescriptorFactory;
|
||||
import com.zhidaoauto.map.sdk.open.marker.Marker;
|
||||
import com.zhidaoauto.map.sdk.open.marker.OnMarkClickListener;
|
||||
import com.zhidaoauto.map.sdk.open.poyline.PolylineOptions;
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
import com.zhidaoauto.map.sdk.open.tools.MapTools;
|
||||
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
|
||||
@@ -65,8 +67,13 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import static java.lang.Math.PI;
|
||||
|
||||
public class AMapViewWrapper implements IMogoMapView,
|
||||
IMogoMapUIController,
|
||||
@@ -731,15 +738,6 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
sysLocation.setBearing(location.getHeading());
|
||||
sysLocation.setSpeed(location.getSpeed());
|
||||
|
||||
if (sysLocation.getSpeed() > 0) {
|
||||
mLastDriveLocationShadow = sysLocation;
|
||||
} else {
|
||||
if ((int) sysLocation.getBearing() == 0
|
||||
&& mLastDriveLocationShadow != null) {
|
||||
// TODO: 2020/12/12 停车时自车图标方向调整
|
||||
}
|
||||
}
|
||||
|
||||
NaviClient.getInstance(getContext()).syncCarLocation(sysLocation);
|
||||
if (checkAMapView() && mMapLoaded) {
|
||||
// 地图初始化完成后,每隔5s自动判断当前地图的模式
|
||||
@@ -1042,42 +1040,68 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
private double[] matchRoad(String id, double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK, boolean usdCache) {
|
||||
double wgs[] = new double[]{lon, lat};
|
||||
long start = System.currentTimeMillis();
|
||||
RoadCacheWrapper roadCache = roadCacheMap.get(id);
|
||||
if (roadCache == null) {
|
||||
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad(((float) wgs[0]), ((float) wgs[1]), ((float) angle), isGpsLocation, isRTK);
|
||||
if (singlePointRoadInfo != null && singlePointRoadInfo.getCoords() != null && !singlePointRoadInfo.getCoords().isEmpty()) {
|
||||
Log.i("timer-matchRoad-4", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + singlePointRoadInfo.getRoadId());
|
||||
roadCache = new RoadCacheWrapper(singlePointRoadInfo.getCoords());
|
||||
}
|
||||
}
|
||||
|
||||
Log.i("timer-matchRoad-1", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
if (roadCache != null
|
||||
&& roadCache.getRoad() != null
|
||||
&& !roadCache.getRoad().isEmpty()) {
|
||||
start = System.currentTimeMillis();
|
||||
double matchedPoint[] = PointInterpolatorUtil.mergeToRoad(wgs[0], wgs[1], roadCache.getRoad());
|
||||
if (matchedPoint[2] > 0 && matchedPoint[2] < 1.5) {
|
||||
// if (roadCache.inCache(matchedPoint[0], matchedPoint[1])) {
|
||||
roadCacheMap.put(id, roadCache);
|
||||
Log.i("timer-matchRoad-3", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
return matchedPoint;
|
||||
// }
|
||||
// roadCacheMap.put(id, null);
|
||||
// Log.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: "+roadCache.getLastLat());
|
||||
// return matchRoad(id, lon, lat, angle, isGpsLocation, isRTK,false);
|
||||
}else{
|
||||
roadCacheMap.put(id, null);
|
||||
Log.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + roadCache.getLastLat());
|
||||
if(usdCache) {
|
||||
return matchRoad(id, lon, lat, angle, isGpsLocation, isRTK, false);
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
//
|
||||
// try {
|
||||
// PolylineOptions options = new PolylineOptions( );
|
||||
// options.setColor( Color.WHITE );
|
||||
// options.setId( "test-line"+new Random( ).nextLong() );
|
||||
// options.setGps( true );
|
||||
// options.setLineWidth( 3 );
|
||||
// List<LonLatPoint> points = singlePointRoadInfo.getCoords();
|
||||
// ArrayList< LonLat > lonLats = new ArrayList<>( );
|
||||
// for ( LonLatPoint point : points ) {
|
||||
// lonLats.add( new LonLat( point.getLongitude(), point.getLatitude() ) );
|
||||
// }
|
||||
// options.setLonLats( lonLats );
|
||||
// mMapView.getMapAutoViewHelper().drawThickLine( options );
|
||||
// } catch( Exception e ){
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad(((float) wgs[0]), ((float) wgs[1]), ((float) angle), isGpsLocation, isRTK);
|
||||
if ( singlePointRoadInfo == null || singlePointRoadInfo.getCoords() == null || singlePointRoadInfo.getCoords().isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
roadCacheMap.put(id, null);
|
||||
return null;
|
||||
double matchedPoint[] = PointInterpolatorUtil.mergeToRoad(wgs[0], wgs[1], singlePointRoadInfo.getCoords());
|
||||
return matchedPoint;
|
||||
|
||||
// RoadCacheWrapper roadCache = roadCacheMap.get(id);
|
||||
// if (roadCache == null) {
|
||||
// SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad(((float) wgs[0]), ((float) wgs[1]), ((float) angle), isGpsLocation, isRTK);
|
||||
// if (singlePointRoadInfo != null && singlePointRoadInfo.getCoords() != null && !singlePointRoadInfo.getCoords().isEmpty()) {
|
||||
// Log.i("timer-matchRoad-4", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + singlePointRoadInfo.getRoadId());
|
||||
// roadCache = new RoadCacheWrapper(singlePointRoadInfo.getCoords());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Log.i("timer-matchRoad-1", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
// if (roadCache != null
|
||||
// && roadCache.getRoad() != null
|
||||
// && !roadCache.getRoad().isEmpty()) {
|
||||
// start = System.currentTimeMillis();
|
||||
// double matchedPoint[] = PointInterpolatorUtil.mergeToRoad(wgs[0], wgs[1], roadCache.getRoad());
|
||||
// if (matchedPoint[2] > 0 && matchedPoint[2] < 1.5) {
|
||||
//// if (roadCache.inCache(matchedPoint[0], matchedPoint[1])) {
|
||||
// roadCacheMap.put(id, roadCache);
|
||||
// Log.i("timer-matchRoad-3", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
// return matchedPoint;
|
||||
//// }
|
||||
//// roadCacheMap.put(id, null);
|
||||
//// Log.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: "+roadCache.getLastLat());
|
||||
//// return matchRoad(id, lon, lat, angle, isGpsLocation, isRTK,false);
|
||||
// }else{
|
||||
// roadCacheMap.put(id, null);
|
||||
// Log.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + roadCache.getLastLat());
|
||||
//// if(usdCache) {
|
||||
//// return matchRoad(id, lon, lat, angle, isGpsLocation, isRTK, false);
|
||||
//// }else{
|
||||
//// return null;
|
||||
//// }
|
||||
// return null;
|
||||
// }
|
||||
// }
|
||||
// roadCacheMap.put(id, null);
|
||||
// return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.map.impl.custom.marker;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Point;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
|
||||
@@ -58,6 +59,9 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
if ( marker != null ) {
|
||||
// 设置自研 marker 的object对象为 IMogoMarker 实例。!!!!
|
||||
marker.setMObject( this );
|
||||
if ( !TextUtils.isEmpty( mogoMarkerOptions.getAnchorColor() ) ) {
|
||||
marker.setAnchorColor( mogoMarkerOptions.getAnchorColor() );
|
||||
}
|
||||
MarkerWrapperClickHelper.getInstance().setMogoMarkerMap( marker.getId(), this );
|
||||
}
|
||||
setObject( mogoMarkerOptions.getObject() );
|
||||
@@ -592,9 +596,9 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDynamicAnchorPosition( MogoLatLng latLng, long duration ) {
|
||||
public void addDynamicAnchorPosition( MogoLatLng latLng, float angle, long duration ) {
|
||||
try {
|
||||
mMarker.addDynamicAnchorPostion( new LonLatPoint( latLng.lon, latLng.lat ), System.currentTimeMillis(), ( int ) duration );
|
||||
mMarker.addDynamicAnchorPostion( new LonLatPoint( latLng.lon, latLng.lat, angle ), System.currentTimeMillis(), ( int ) duration );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ public class ObjectUtils {
|
||||
// }
|
||||
|
||||
MarkerOptions markerOptions = new MarkerOptions()
|
||||
.setGps( opt.isGps() )
|
||||
.position( new LonLatPoint( opt.getLongitude(), opt.getLatitude() ) )
|
||||
.anchor( opt.getU(), opt.getV() )
|
||||
.icons( descriptors )
|
||||
@@ -100,13 +101,17 @@ public class ObjectUtils {
|
||||
.visible( opt.isVisible() )
|
||||
.infoWindowEnable( opt.isInifoWindowEnable() )
|
||||
.alpha( opt.getAlpha() )
|
||||
.setGps( opt.isGps() )
|
||||
// .draggable( opt.isDraggable() )
|
||||
.setInfoWindowOffset( opt.getOffsetX(), opt.getOffsetY() )
|
||||
.zIndex( opt.getzIndex() );
|
||||
try {
|
||||
Color.parseColor( opt.getAnchorColor() );
|
||||
markerOptions.anchorColor( opt.getAnchorColor() );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
markerOptions.vrEnable( opt.is3DMode() );
|
||||
if ( !TextUtils.isEmpty( opt.getResName() ) ) {
|
||||
markerOptions.setMarkerIconName( opt.getResName() );
|
||||
markerOptions.vrEnable( opt.is3DMode() );
|
||||
} else {
|
||||
BitmapDescriptor descriptor = getBitmapDescriptorFromMogo( opt );
|
||||
if ( descriptor != null ) {
|
||||
@@ -114,11 +119,6 @@ public class ObjectUtils {
|
||||
}
|
||||
if ( opt.getIcon3DRes() != 0 ) {
|
||||
markerOptions.marker3DIcon( opt.getIcon3DRes() );
|
||||
try {
|
||||
Color.parseColor( opt.getAnchorColor() );
|
||||
markerOptions.anchorColor( opt.getAnchorColor() );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( !TextUtils.isEmpty( opt.getTitle() ) ) {
|
||||
|
||||
@@ -390,7 +390,7 @@ public interface IMogoMarker {
|
||||
|
||||
}
|
||||
|
||||
default void addDynamicAnchorPosition( MogoLatLng latLng, long duration ) {
|
||||
default void addDynamicAnchorPosition( MogoLatLng latLng, float angle, long duration ) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
@@ -15,6 +16,7 @@ import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.utils.SimpleHandlerThreadPool;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -24,6 +26,8 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import static java.lang.Math.PI;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -167,7 +171,10 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
mAdasRecognizedMarkersCaches = newAdasRecognizedMarkersCaches;
|
||||
}
|
||||
|
||||
private final Map< String, Boolean > mIsMatchStatusCache = new ArrayMap<>();
|
||||
// private final Map< String, Boolean > mIsMatchStatusCache = new ArrayMap<>();
|
||||
|
||||
private String markerRes;
|
||||
private String markerRes2;
|
||||
|
||||
/**
|
||||
* 绘制某个物体的一个数据
|
||||
@@ -177,7 +184,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
*/
|
||||
private void renderAdasOneFrame( ADASRecognizedResult recognizedListResult, Map< String, IMogoMarker > newAdasRecognizedMarkersCaches ) {
|
||||
// 暂时只显示车辆
|
||||
if ( !isCarType( recognizedListResult.type ) ) {
|
||||
if ( !isRenderType( recognizedListResult.type ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -186,6 +193,8 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
return;
|
||||
}
|
||||
|
||||
final double lon = recognizedListResult.lon;
|
||||
final double lat = recognizedListResult.lat;
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( recognizedListResult.uuid, recognizedListResult.lon,
|
||||
@@ -193,31 +202,52 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
recognizedListResult.heading,
|
||||
true
|
||||
);
|
||||
Boolean isMatch = mIsMatchStatusCache.get( uniqueKey );
|
||||
if ( matchedPoint != null ) {
|
||||
if ( ( isMatch == null || !isMatch ) ) {
|
||||
if ( matchedPoint[2] < 0.5 ) {
|
||||
isMatch = true;
|
||||
}
|
||||
} else {
|
||||
if ( matchedPoint[2] > 1 ) {
|
||||
isMatch = false;
|
||||
}
|
||||
}
|
||||
if ( isMatch == null ) {
|
||||
isMatch = false;
|
||||
}
|
||||
mIsMatchStatusCache.put( uniqueKey, isMatch );
|
||||
|
||||
if ( isMatch ) {
|
||||
ADASRecognizedResult lastPosition = mLastPositions.remove( uniqueKey );
|
||||
|
||||
if ( matchedPoint != null ) {
|
||||
Logger.d( TAG, "matchPoint %s distance = %s",lineCounter, matchedPoint[2] );
|
||||
boolean match = matchedPoint[2] < 0.45 && matchedPoint[2] > 0;
|
||||
|
||||
if ( lastPosition != null ) {
|
||||
double _angle = Math.atan2(Math.abs(matchedPoint[0] - lastPosition.lon), Math.abs(matchedPoint[1] - lastPosition.lat)) * (180 / PI);
|
||||
Logger.d( TAG, "matchPoint %s angel = %s", lineCounter,_angle );
|
||||
if ( _angle > 22.5 ) {
|
||||
match = false;
|
||||
}
|
||||
}
|
||||
// mIsMatchStatusCache.put( uniqueKey, match );
|
||||
if ( match ) {
|
||||
recognizedListResult.lon = matchedPoint[0];
|
||||
recognizedListResult.lat = matchedPoint[1];
|
||||
}
|
||||
}
|
||||
mLastPositions.put( uniqueKey, recognizedListResult );
|
||||
|
||||
// Boolean isMatch = mIsMatchStatusCache.get( uniqueKey );
|
||||
// if ( matchedPoint != null ) {
|
||||
// if ( ( isMatch == null || !isMatch ) ) {
|
||||
// if ( matchedPoint[2] < 0.5 ) {
|
||||
// isMatch = true;
|
||||
// }
|
||||
// } else {
|
||||
// if ( matchedPoint[2] > 1 ) {
|
||||
// isMatch = false;
|
||||
// }
|
||||
// }
|
||||
// if ( isMatch == null ) {
|
||||
// isMatch = false;
|
||||
// }
|
||||
// mIsMatchStatusCache.put( uniqueKey, isMatch );
|
||||
//
|
||||
// if ( isMatch ) {
|
||||
// recognizedListResult.lon = matchedPoint[0];
|
||||
// recognizedListResult.lat = matchedPoint[1];
|
||||
// }
|
||||
// }
|
||||
Logger.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
|
||||
|
||||
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );
|
||||
ADASRecognizedResult lastPosition = mLastPositions.put( uniqueKey, recognizedListResult );
|
||||
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawAdasRecognizedDataMarker( recognizedListResult );
|
||||
@@ -247,7 +277,40 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
final IMogoMarker renderRef = marker;
|
||||
final long intervalRef = interval;
|
||||
SimpleHandlerThreadPool.getInstance().postRender( () -> {
|
||||
renderRef.addDynamicAnchorPosition( endPoint.point, intervalRef );
|
||||
renderRef.addDynamicAnchorPosition( endPoint.point, endPoint.angle, intervalRef );
|
||||
//
|
||||
// // 原坐标
|
||||
// MogoMarkerOptions options2 = new MogoMarkerOptions();
|
||||
// options2.gps( true )
|
||||
// .position( new MogoLatLng( lat, lon ) )
|
||||
// .anchor( 0.5f, 0.5f )
|
||||
// .rotate( endPoint.angle );
|
||||
// if ( TextUtils.isEmpty( markerRes2 ) ) {
|
||||
// options2.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.sy ) );
|
||||
// } else {
|
||||
// options2.resName( markerRes2 );
|
||||
// }
|
||||
// IMogoMarker marker2 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( TAG, options2 );
|
||||
// if ( TextUtils.isEmpty( markerRes2 ) ) {
|
||||
// markerRes2 = marker2.getMarkerResName();
|
||||
// }
|
||||
//
|
||||
// // 匹配坐标
|
||||
// MogoMarkerOptions options = new MogoMarkerOptions();
|
||||
// options.gps( true )
|
||||
// .position( endPoint.point )
|
||||
// .anchor( 0.5f, 0.5f )
|
||||
// .rotate( endPoint.angle );
|
||||
// if ( TextUtils.isEmpty( markerRes ) ) {
|
||||
// options.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.sr ) );
|
||||
// } else {
|
||||
// options.resName( markerRes );
|
||||
// }
|
||||
// IMogoMarker marker1 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( TAG, options );
|
||||
// if ( TextUtils.isEmpty( markerRes ) ) {
|
||||
// markerRes = marker1.getMarkerResName();
|
||||
// }
|
||||
|
||||
} );
|
||||
|
||||
// method 2
|
||||
@@ -268,12 +331,14 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
SpeedData obj = new SpeedData();
|
||||
obj.context = mContext;
|
||||
obj.marker = marker;
|
||||
obj.speed = recognizedListResult.speed;
|
||||
obj.speed = recognizedListResult.speed;//;lineCounter++
|
||||
msg.obj = obj;
|
||||
msg.what = MSG_DISPLAY_SPEED;
|
||||
mRenderThreadHandler.sendMessage( msg );
|
||||
}
|
||||
|
||||
int lineCounter = 0;
|
||||
|
||||
/**
|
||||
* 绘制 marker
|
||||
*
|
||||
@@ -286,13 +351,14 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
}
|
||||
|
||||
String resIdVal = null;
|
||||
int resId = getVrModelResId();
|
||||
int resId = getModelRes( recognizedListResult.type );
|
||||
resIdVal = resId + "";
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner( DataTypes.TYPE_MARKER_ADAS )
|
||||
.anchor( 0.5f, 0.5f )
|
||||
.set3DMode( true )
|
||||
.gps( true )
|
||||
.anchorColor( getModelRenderColor( CloudRoadData.FROM_ADAS, recognizedListResult.type ) )
|
||||
.controlAngle( true )
|
||||
.resName( mMarkerCachesResMd5Values.get( resIdVal ) )
|
||||
.icon3DRes( resId )
|
||||
@@ -303,15 +369,6 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
return marker;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 vr 模型资源 id
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private int getVrModelResId() {
|
||||
return R.raw.cargrey;
|
||||
}
|
||||
|
||||
/**
|
||||
* vr 模式切换
|
||||
*/
|
||||
|
||||
@@ -14,7 +14,9 @@ import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -103,14 +105,17 @@ class BaseDrawer {
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否是车辆
|
||||
* 判断是否是绘制内容
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public boolean isCarType( int type ) {
|
||||
public boolean isRenderType( int type ) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
|
||||
if ( recognizedType == AdasRecognizedType.classIdCar
|
||||
|| recognizedType == AdasRecognizedType.classIdMoto
|
||||
|| recognizedType == AdasRecognizedType.classIdBicycle
|
||||
|| recognizedType == AdasRecognizedType.classIdPerson
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficBus
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficTruck ) {
|
||||
return true;
|
||||
@@ -118,6 +123,53 @@ class BaseDrawer {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取3D锚点模型资源
|
||||
*
|
||||
* @param type
|
||||
* @return
|
||||
*/
|
||||
public int getModelRes( int type ) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( type );
|
||||
if ( recognizedType == AdasRecognizedType.classIdCar
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficBus
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficTruck ) {
|
||||
return R.raw.othercar;
|
||||
} else if ( recognizedType == AdasRecognizedType.classIdBicycle
|
||||
|| recognizedType == AdasRecognizedType.classIdMoto ) {
|
||||
return R.raw.motorbike;
|
||||
}
|
||||
return R.raw.people;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fromType {@link com.mogo.realtime.entity.CloudRoadData}
|
||||
* @return
|
||||
*/
|
||||
protected String getModelRenderColor( int fromType, int modelType ) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom( modelType );
|
||||
if ( recognizedType == AdasRecognizedType.classIdCar
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficBus
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficTruck ) {
|
||||
if ( fromType == CloudRoadData.FROM_ADAS ) {
|
||||
// 灰色
|
||||
return "#D8D8D8FF";
|
||||
} else if ( fromType == CloudRoadData.FROM_ROAD_UNIT ) {
|
||||
// 绿色
|
||||
return "#3FE792FF";
|
||||
} else {
|
||||
// 蓝色
|
||||
return "#5A8DFFFF";
|
||||
}
|
||||
} else if ( recognizedType == AdasRecognizedType.classIdBicycle
|
||||
|| recognizedType == AdasRecognizedType.classIdMoto ) {
|
||||
// 灰色
|
||||
return "#D8D8D8FF";
|
||||
}
|
||||
// 灰色
|
||||
return "#D8D8D8FF";
|
||||
}
|
||||
|
||||
private TextView mSpeedView = null;
|
||||
|
||||
/**
|
||||
@@ -215,7 +267,7 @@ class BaseDrawer {
|
||||
.getMapServiceApi()
|
||||
.getMapUIController()
|
||||
.matchRoad( id, lon, lat, angle, true, isRtk );
|
||||
Log.i("timer-matchRoad", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
Log.i( "timer-matchRoad", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
return matchRoad;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ class OnlineCarDrawer {
|
||||
String sn = MarkerDrawer.getInstance().getPrimaryKeyFromEntity( markerOnlineCar );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, false, MarkerDrawer.MARKER_Z_INDEX_LOW, R.raw.taxi, listener );
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, false, MarkerDrawer.MARKER_Z_INDEX_LOW, R.raw.othercar, listener );
|
||||
}
|
||||
if ( mogoMarker != null ) {
|
||||
mogoMarker.setVisible( true );
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -17,9 +16,7 @@ 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.drawer.marker.IMarkerView;
|
||||
import com.mogo.module.common.utils.SimpleHandlerThreadPool;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
@@ -189,7 +186,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
*/
|
||||
private void renderSnapshotOneFrame(CloudRoadData recognizedListResult, Map< String, IMogoMarker > newAdasRecognizedMarkersCaches ) {
|
||||
// 暂时只显示车辆
|
||||
if ( !isCarType( recognizedListResult.getType() ) ) {
|
||||
if ( !isRenderType( recognizedListResult.getType() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -200,33 +197,33 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( recognizedListResult.getUniqueKey(), recognizedListResult.getWgslon(),
|
||||
recognizedListResult.getWgslat(),
|
||||
recognizedListResult.getHeading(),
|
||||
true
|
||||
);
|
||||
Boolean isMatch = mIsMatchStatusCache.get( uniqueKey );
|
||||
if ( matchedPoint != null ) {
|
||||
if ( ( isMatch == null || !isMatch ) ) {
|
||||
if ( matchedPoint[2] < 0.5 ) {
|
||||
isMatch = true;
|
||||
}
|
||||
} else {
|
||||
if ( matchedPoint[2] > 1 ) {
|
||||
isMatch = false;
|
||||
}
|
||||
}
|
||||
if ( isMatch == null ) {
|
||||
isMatch = false;
|
||||
}
|
||||
mIsMatchStatusCache.put( uniqueKey, isMatch );
|
||||
|
||||
if ( isMatch ) {
|
||||
recognizedListResult.setWgslon(matchedPoint[0]);
|
||||
recognizedListResult.setWgslat(matchedPoint[1]);
|
||||
}
|
||||
}
|
||||
Logger.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
|
||||
// double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( recognizedListResult.getUniqueKey(), recognizedListResult.getWgslon(),
|
||||
// recognizedListResult.getWgslat(),
|
||||
// recognizedListResult.getHeading(),
|
||||
// true
|
||||
// );
|
||||
// Boolean isMatch = mIsMatchStatusCache.get( uniqueKey );
|
||||
// if ( matchedPoint != null ) {
|
||||
// if ( ( isMatch == null || !isMatch ) ) {
|
||||
// if ( matchedPoint[2] < 0.5 ) {
|
||||
// isMatch = true;
|
||||
// }
|
||||
// } else {
|
||||
// if ( matchedPoint[2] > 1 ) {
|
||||
// isMatch = false;
|
||||
// }
|
||||
// }
|
||||
// if ( isMatch == null ) {
|
||||
// isMatch = false;
|
||||
// }
|
||||
// mIsMatchStatusCache.put( uniqueKey, isMatch );
|
||||
//
|
||||
// if ( isMatch ) {
|
||||
// recognizedListResult.setWgslon(matchedPoint[0]);
|
||||
// recognizedListResult.setWgslat(matchedPoint[1]);
|
||||
// }
|
||||
// }
|
||||
// Logger.d( "matchRoad", "cost = %s", System.currentTimeMillis() - start );
|
||||
|
||||
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );
|
||||
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, recognizedListResult );
|
||||
@@ -259,7 +256,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
final IMogoMarker renderRef = marker;
|
||||
final long intervalRef = interval;
|
||||
SimpleHandlerThreadPool.getInstance().postRender( () -> {
|
||||
renderRef.addDynamicAnchorPosition( endPoint.point, intervalRef );
|
||||
renderRef.addDynamicAnchorPosition( endPoint.point, endPoint.angle, intervalRef );
|
||||
} );
|
||||
|
||||
// method 2
|
||||
@@ -350,8 +347,8 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
String resIdVal = null;
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
options.set3DMode( true );
|
||||
options.anchorColor( "#00FF00" );
|
||||
int resId = getVrModelResId( data );
|
||||
options.anchorColor( getModelRenderColor( data.getFromType(), data.getType() ) );
|
||||
int resId = getModelRes( data.getType() );
|
||||
resIdVal = resId + "";
|
||||
options.resName( mMarkerCachesResMd5Values.get( resIdVal ) );
|
||||
options.icon3DRes( resId );
|
||||
@@ -370,24 +367,6 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
return mMarkerCachesResMd5Values.get( resIdVal );
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车辆 3d 模型
|
||||
*
|
||||
* @param data 道路数据
|
||||
* @return 3D车辆模型id
|
||||
*/
|
||||
public int getVrModelResId( CloudRoadData data ) {
|
||||
switch ( data.getFromType() ) {
|
||||
case CloudRoadData.FROM_ADAS:
|
||||
return R.raw.cargrey;
|
||||
case CloudRoadData.FROM_ROAD_UNIT:
|
||||
return R.raw.cargreen;
|
||||
case CloudRoadData.FROM_MY_LOCATION:
|
||||
default:
|
||||
return R.raw.carblue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 2d marker 资源
|
||||
*
|
||||
@@ -456,7 +435,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
setChangeCarModeStatus( false );
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
marker.getMogoMarkerOptions().set3DMode( true );
|
||||
int resId = getVrModelResId( cloudRoadData );
|
||||
int resId = getModelRes( cloudRoadData.getType() );
|
||||
String resName = get3DCacheId( resId + "" );
|
||||
if ( TextUtils.isEmpty( resName ) ) {
|
||||
marker.use3DResource( resId );
|
||||
|
||||
@@ -181,7 +181,7 @@ public class SimpleHandlerThreadPool {
|
||||
|
||||
// 暂时只显示车辆
|
||||
if ( TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
|
||||
if ( !SnapshotSetDataDrawer.getInstance().isCarType( cloudRoadData.getType() ) ) {
|
||||
if ( !SnapshotSetDataDrawer.getInstance().isRenderType( cloudRoadData.getType() ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -288,7 +288,7 @@ public class SimpleHandlerThreadPool {
|
||||
renderHandler.post( () -> {
|
||||
// 由于地图现在不支持addDynamicAnchorPosition并发,所以工作线程仅做相关计算,真正绘制发送到另外一条绘制线程中做
|
||||
if ( lastPosition != null && !lastPosition.equals( cloudRoadData ) ) {
|
||||
finalMarker.addDynamicAnchorPosition( new MogoLatLng( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() ), finalInterval );
|
||||
finalMarker.addDynamicAnchorPosition( new MogoLatLng( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() ),(float)cloudRoadData.getHeading(), finalInterval );
|
||||
Logger.d( TAG, "anim duration: %s in thread: %s", finalInterval, Thread.currentThread().getName() );
|
||||
} else {
|
||||
finalMarker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
modules/mogo-module-common/src/main/res/raw/motorbike.n3d
Normal file
BIN
modules/mogo-module-common/src/main/res/raw/motorbike.n3d
Normal file
Binary file not shown.
BIN
modules/mogo-module-common/src/main/res/raw/othercar.n3d
Normal file
BIN
modules/mogo-module-common/src/main/res/raw/othercar.n3d
Normal file
Binary file not shown.
BIN
modules/mogo-module-common/src/main/res/raw/people.n3d
Normal file
BIN
modules/mogo-module-common/src/main/res/raw/people.n3d
Normal file
Binary file not shown.
Binary file not shown.
@@ -35,7 +35,6 @@ import com.mogo.module.common.drawer.SnapshotSetDataDrawer;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.uploadintime.SnapshotLocationController;
|
||||
import com.mogo.realtime.core.SnapshotUploadInTime;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
@@ -55,7 +54,6 @@ import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -574,7 +572,7 @@ public class MockIntentHandler implements IntentHandler {
|
||||
.position( new MogoLatLng( 39.981971055705,116.41150648393 ) )
|
||||
.gps( true )
|
||||
.controlAngle( true )
|
||||
.icon3DRes( R.raw.cargrey )
|
||||
.icon3DRes( R.raw.othercar )
|
||||
.rotate( ( float ) 358.526123 );
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
|
||||
List<MogoLatLng> latLngs = new ArrayList<>( );
|
||||
@@ -894,10 +892,10 @@ public class MockIntentHandler implements IntentHandler {
|
||||
// adasRecognizedResult.lon = coor[0];
|
||||
// adasRecognizedResult.lat = coor[1];
|
||||
allList.add( adasRecognizedResult );
|
||||
ADASRecognizedResult next = handleMockAdasIntent3();
|
||||
if(next != null){
|
||||
allList.add(next);
|
||||
}
|
||||
// ADASRecognizedResult next = handleMockAdasIntent3();
|
||||
// if(next != null){
|
||||
// allList.add(next);
|
||||
// }
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user