优化显示逻辑

This commit is contained in:
wangcongtao
2021-03-10 11:37:37 +08:00
parent 36e5356bfe
commit 443cf9b8cb
11 changed files with 118 additions and 70 deletions

View File

@@ -67,7 +67,7 @@ dependencies {
implementation project(':foudations:mogo-commons')
}
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.2.4'
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.2.6'
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-test-3.4'
}

View File

@@ -468,7 +468,7 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
return;
}
List< LonLatPoint > newPoints = new ArrayList<>();
ArrayList< LonLatPoint > newPoints = new ArrayList<>();
for ( int i = 0; i < points.size(); i++ ) {
LonLatPoint point = ObjectUtils.fromMogo( points.get( i ) );
if ( point == null ) {
@@ -480,6 +480,35 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
return;
}
// MarkerTranslateAnimation animation = new MarkerTranslateAnimation( newPoints );
// animation.setDuration( duration );
// animation.setAnimationListener( new MarkerAnimationListener() {
// @Override
// public void onAnimationStart( @NotNull Animation animation ) {
//
// }
//
// @Override
// public void onAnimationEnd( @NotNull Animation animation ) {
//
// }
//
// long lastTime = 0L;
//
// @Override
// public void onAnimationRepeat( @NotNull Animation animation ) {
// if ( lastTime == 0L ) {
// lastTime = System.currentTimeMillis();
// return;
// }
// Logger.d( TAG, "frame cost = %s", System.currentTimeMillis() - lastTime );
// lastTime = System.currentTimeMillis();
// }
// } );
// mMarker.setTranslateAnimation( animation );
// mMarker.startAnimation();
mMarker.startSmooth( newPoints, ( int ) duration );
// mMarker.addDynamicAnchorPostion( newPoints.get( newPoints.size() - 1 ), ( int ) duration );
}

View File

@@ -17,35 +17,6 @@ public class PointInterpolatorUtil {
private static final String TAG = "PointInterpolatorUtil";
private static final int DISTANCE_THRESHOLD = 2;
/**
* 在两点之间插值
*
* @param start
* @param end
* @param frameInterval
* @return
*/
public static List< MogoLatLng > interpolate( MogoLatLng start, MogoLatLng end, long frameInterval ) {
if ( start == null || end == null ) {
return null;
}
long locInterval = end.time - start.time;
int interpolateFrame = ( int ) ( locInterval / frameInterval ) - 1;
List< MogoLatLng > arrayList = new ArrayList<>();
arrayList.add( start );
if ( interpolateFrame > 0 ) {
double lonStep = ( end.lon - start.lon ) / ( interpolateFrame + 1 );
double latStep = ( end.lat - start.lat ) / ( interpolateFrame + 1 );
for ( int i = 0; i < interpolateFrame; i++ ) {
double lon = start.lon + lonStep * ( i + 1 );
double lat = start.lat + latStep * ( i + 1 );
arrayList.add( new MogoLatLng( lon, lat ) );
}
}
arrayList.add( end );
return arrayList;
}
/**
* 在(x1,y1) (x2,y2)中间插入一些点,使每两个点之间距离<={@link #DISTANCE_THRESHOLD},利用如下公式进行计算
* xn = x1 + (x2 - x1)*n/a

View File

@@ -17,7 +17,6 @@ public class MogoLatLng implements Parcelable {
@Deprecated
public final double lng;
public final double lon;
public long time;
public MogoLatLng( double lat, double lon ) {
this.lat = lat;
@@ -43,14 +42,6 @@ public class MogoLatLng implements Parcelable {
return lon;
}
public long getTime() {
return time;
}
public void setTime( long time ) {
this.time = time;
}
@Override
public boolean equals( Object o ) {
if ( this == o ) return true;
@@ -83,14 +74,12 @@ public class MogoLatLng implements Parcelable {
dest.writeDouble( this.lat );
dest.writeDouble( this.lng );
dest.writeDouble( this.lon );
dest.writeLong( this.time );
}
protected MogoLatLng( Parcel in ) {
this.lat = in.readDouble();
this.lng = in.readDouble();
this.lon = in.readDouble();
this.time = in.readLong();
}
public static final Creator< MogoLatLng > CREATOR = new Creator< MogoLatLng >() {