This commit is contained in:
wangcongtao
2021-01-22 16:48:02 +08:00
parent 7d5e8566fd
commit 87607058cb
13 changed files with 362 additions and 84 deletions

View File

@@ -1,13 +1,13 @@
package com.mogo.module.common.drawer;
import android.content.Context;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.commons.debug.DebugConfig;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
@@ -39,7 +39,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
mContext = AbsMogoApplication.getApp();
}
private Map< String, MogoLatLng > mLastPositions = new ConcurrentHashMap<>();
private Map< String, ADASRecognizedListResult > mLastPositions = new ConcurrentHashMap<>();
public static AdasRecognizedResultDrawer getInstance() {
if ( sInstance == null ) {
@@ -94,36 +94,30 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
continue;
}
mAdasRecognizedMarkersCaches.put( uniqueKey, marker );
}
MogoLatLng lastPosition = mLastPositions.get( uniqueKey );
List< MogoLatLng > points = new ArrayList<>();
MogoLatLng endLatLon = null;
if ( recognizedListResult.latLonList != null
&& recognizedListResult.latLonList.size() > 1 ) {
for ( int j = 0; j < recognizedListResult.latLonList.size(); j++ ) {
ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( j );
if ( latLon == null ) {
continue;
mLastPositions.put( uniqueKey, recognizedListResult );
} else {
ADASRecognizedListResult lastPosition = mLastPositions.get( uniqueKey );
mLastPositions.put( uniqueKey, recognizedListResult );
if ( lastPosition != null ) {
List< MogoLatLng > points = new ArrayList<>();
MogoLatLng endLatLon = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
points.add( new MogoLatLng( lastPosition.lat, lastPosition.lon ) );
points.add( endLatLon );
if ( DebugConfig.isNotSmooth() ) {
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
} else {
long interval = recognizedListResult.systemTime - lastPosition.systemTime;
marker.startSmoothInMs( points, interval );
}
points.add( endLatLon = new MogoLatLng( latLon.lat, latLon.lon ) );
} else {
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
}
} else if ( recognizedListResult.latLonList != null
&& recognizedListResult.latLonList.size() == 1 ) {
// 原来的点和新的点做一个数组进行平滑移动
ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( 0 );
if ( latLon == null ) {
continue;
}
points.add( lastPosition );
points.add( endLatLon = new MogoLatLng( latLon.lat, latLon.lon ) );
}
mLastPositions.put( uniqueKey, endLatLon );
if ( points.size() >= 1 ) {
marker.startSmoothInMs( points, 100 );
}
showSelfSpeed( mContext,
marker,
recognizedListResult.speed,
MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()
);
}
}
@@ -177,7 +171,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
.set3DMode( true )
.icon3DRes( getVrModel() )
.rotate( ( float ) recognizedListResult.heading )
.position( new MogoLatLng( recognizedListResult.latLonList.get( 0 ).lat, recognizedListResult.latLonList.get( 0 ).lon ) );
.position( new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon ) );
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );
}
@@ -185,21 +179,4 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
return R.raw.carred;
}
private View inflateView( ADASRecognizedListResult data, boolean machineVision, double curSpeed ) {
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
// SafeType safeType = getSafeType( data.distanceX, data.distanceY, data.speed, curSpeed );
// TextView tv = rootView.findViewById( R.id.module_commons_marker_car_speed );
// tv.setText( safeType.getMsg() );
ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model );
// iv.setImageResource( MarkerResourceManager.getMarkerDrawableResId(
// machineVision ? VisionMode.Machine : VisionMode.User,
// AdasRecognizedType.valueFrom( data.type ),
// getCarModelType(),
// safeType
// ) );
iv.setImageResource( R.drawable.icon_map_marker_car_gray );
return rootView;
}
}