优化显示逻辑
This commit is contained in:
@@ -1024,17 +1024,17 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
private float lastRoadId;
|
||||
@Override
|
||||
public double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
|
||||
double wgs[] = CoordinateUtils.transformGcj02toWgs84( lat, lon );
|
||||
double wgs[] = new double[]{lon, lat};//CoordinateUtils.transformGcj02toWgs84( lat, lon );
|
||||
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad( ( ( float ) wgs[0] ), ( ( float ) wgs[1] ), ( ( float ) angle ), isGpsLocation, isRTK );
|
||||
if ( singlePointRoadInfo != null
|
||||
&& singlePointRoadInfo.getCoords() != null
|
||||
&& !singlePointRoadInfo.getCoords().isEmpty() ) {
|
||||
double matchedPoint[] = PointInterpolatorUtil.mergeToRoad( wgs[0], wgs[1], singlePointRoadInfo.getCoords() );
|
||||
// return CoordinateUtils.transformWgsToGcj( matchedPoint[1], matchedPoint[0] );
|
||||
double[] trans = CoordinateUtils.transformWgsToGcj(matchedPoint[1], matchedPoint[0]);
|
||||
// double[] trans = CoordinateUtils.transformWgsToGcj(matchedPoint[1], matchedPoint[0]);
|
||||
|
||||
matchedPoint[0] = trans[0];
|
||||
matchedPoint[1] = trans[1];
|
||||
// matchedPoint[0] = trans[0];
|
||||
// matchedPoint[1] = trans[1];
|
||||
// MarkerOptions options
|
||||
// = new MarkerOptions();
|
||||
// options.markerIcon( R.drawable.red )
|
||||
|
||||
@@ -509,6 +509,26 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use3DResource( String resName ) {
|
||||
try {
|
||||
mMarker.getMarkeOptions().setVrIcon( true );
|
||||
mMarker.setMarkerOptions( mMarker.getMarkeOptions().setMarkerIconName( resName ) );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "use3DResource" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void use2DResource( String resName ) {
|
||||
try {
|
||||
mMarker.getMarkeOptions().setVrIcon( false );
|
||||
mMarker.setMarkerOptions( mMarker.getMarkeOptions().setMarkerIconName( resName ) );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "use3DResource" );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnchorColor( String anchorColor ) {
|
||||
mMarker.setMarkerOptions( mMarker.getMarkeOptions().anchorColor( anchorColor ) );
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidaoauto.map.sdk.open.query.LonLatPoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -16,6 +17,35 @@ 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
|
||||
@@ -31,22 +61,22 @@ public class PointInterpolatorUtil {
|
||||
* @deprecated 这个方法有问题,并不能算出来想要的值
|
||||
*/
|
||||
@Deprecated
|
||||
public static void interpolate(List<MogoLatLng> points) {
|
||||
if (points.size() >= 2) {
|
||||
public static void interpolate( List< MogoLatLng > points ) {
|
||||
if ( points.size() >= 2 ) {
|
||||
// 插值
|
||||
for (int i = 0; i < points.size() - 1; i++) {
|
||||
MogoLatLng current = points.get(i);
|
||||
MogoLatLng next = points.get(i + 1);
|
||||
float distance = CoordinateUtils.calculateLineDistance(current.lon, current.lat, next.lon, next.lat);
|
||||
Logger.d(TAG, i + ": " + distance);
|
||||
if (distance > DISTANCE_THRESHOLD) {
|
||||
int inter = (int) (distance / DISTANCE_THRESHOLD) + 1;
|
||||
for (int j = 1; j < inter; j++) {
|
||||
double newLat = current.lat + (next.lat - current.lat) * j / inter;
|
||||
double newLon = current.lon + (next.lon - current.lon) * j / inter;
|
||||
Logger.d(TAG, "distance: " + distance + ", j: " + j + ", nextLat: " + next.lat + ", nextLon: " + next.lon + ", newLat: " + newLat + ", newLon: " + newLon);
|
||||
points.add(i + 1, new MogoLatLng(newLat, newLon));
|
||||
current = points.get(++i);
|
||||
for ( int i = 0; i < points.size() - 1; i++ ) {
|
||||
MogoLatLng current = points.get( i );
|
||||
MogoLatLng next = points.get( i + 1 );
|
||||
float distance = CoordinateUtils.calculateLineDistance( current.lon, current.lat, next.lon, next.lat );
|
||||
Logger.d( TAG, i + ": " + distance );
|
||||
if ( distance > DISTANCE_THRESHOLD ) {
|
||||
int inter = ( int ) ( distance / DISTANCE_THRESHOLD ) + 1;
|
||||
for ( int j = 1; j < inter; j++ ) {
|
||||
double newLat = current.lat + ( next.lat - current.lat ) * j / inter;
|
||||
double newLon = current.lon + ( next.lon - current.lon ) * j / inter;
|
||||
Logger.d( TAG, "distance: " + distance + ", j: " + j + ", nextLat: " + next.lat + ", nextLon: " + next.lon + ", newLat: " + newLat + ", newLon: " + newLon );
|
||||
points.add( i + 1, new MogoLatLng( newLat, newLon ) );
|
||||
current = points.get( ++i );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,51 +84,51 @@ public class PointInterpolatorUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static double[] mergeToRoad(double lon, double lat, List<LonLatPoint> road) {
|
||||
public static double[] mergeToRoad( double lon, double lat, List< LonLatPoint > road ) {
|
||||
closeStart = 0;
|
||||
closeEnd = road.size() - 1;
|
||||
getCloseTwoPoint(lon, lat, road);
|
||||
LonLatPoint start = road.get(closeStart);
|
||||
LonLatPoint end = road.get(closeEnd);
|
||||
Logger.d(TAG, "mergeToRoad start: " + closeStart + " end: " + closeEnd);
|
||||
getCloseTwoPoint( lon, lat, road );
|
||||
LonLatPoint start = road.get( closeStart );
|
||||
LonLatPoint end = road.get( closeEnd );
|
||||
Logger.d( TAG, "mergeToRoad start: " + closeStart + " end: " + closeEnd );
|
||||
// return getMid(start, end);
|
||||
double[] foot = getFoot(lon, lat, start, end);
|
||||
double[] foot = getFoot( lon, lat, start, end );
|
||||
|
||||
float d = CoordinateUtils.calculateLineDistance(foot[0], foot[1], lon, lat);
|
||||
Logger.d(TAG, "distance to mid line==" + d);
|
||||
float d = CoordinateUtils.calculateLineDistance( foot[0], foot[1], lon, lat );
|
||||
Logger.d( TAG, "distance to mid line==" + d );
|
||||
return new double[]{foot[0], foot[1], d};
|
||||
}
|
||||
|
||||
private static int closeStart = 0;
|
||||
private static int closeEnd = 0;
|
||||
|
||||
private static void getCloseTwoPoint(double lon, double lat, List<LonLatPoint> road) {
|
||||
if (closeEnd - closeStart == 1) {
|
||||
private static void getCloseTwoPoint( double lon, double lat, List< LonLatPoint > road ) {
|
||||
if ( closeEnd - closeStart == 1 ) {
|
||||
return;
|
||||
}
|
||||
LonLatPoint start = road.get(closeStart);
|
||||
LonLatPoint end = road.get(closeEnd);
|
||||
float startDistance = CoordinateUtils.calculateLineDistance(start.getLongitude(), start.getLatitude(), lon, lat);
|
||||
float endDistance = CoordinateUtils.calculateLineDistance(end.getLongitude(), end.getLatitude(), lon, lat);
|
||||
if (startDistance > endDistance) {
|
||||
closeStart += (closeEnd - closeStart) / 2;
|
||||
LonLatPoint start = road.get( closeStart );
|
||||
LonLatPoint end = road.get( closeEnd );
|
||||
float startDistance = CoordinateUtils.calculateLineDistance( start.getLongitude(), start.getLatitude(), lon, lat );
|
||||
float endDistance = CoordinateUtils.calculateLineDistance( end.getLongitude(), end.getLatitude(), lon, lat );
|
||||
if ( startDistance > endDistance ) {
|
||||
closeStart += ( closeEnd - closeStart ) / 2;
|
||||
} else {
|
||||
closeEnd -= (closeEnd - closeStart) / 2;
|
||||
closeEnd -= ( closeEnd - closeStart ) / 2;
|
||||
}
|
||||
getCloseTwoPoint(lon, lat, road);
|
||||
getCloseTwoPoint( lon, lat, road );
|
||||
}
|
||||
|
||||
private static double[] getFoot(double lon, double lat, LonLatPoint beginPt, LonLatPoint endPt) {
|
||||
private static double[] getFoot( double lon, double lat, LonLatPoint beginPt, LonLatPoint endPt ) {
|
||||
double dx = beginPt.getLatitude() - endPt.getLatitude();
|
||||
double dy = beginPt.getLongitude() - endPt.getLongitude();
|
||||
|
||||
double u = (lat - beginPt.getLatitude()) * (beginPt.getLatitude() - endPt.getLatitude()) +
|
||||
(lon - beginPt.getLongitude()) * (beginPt.getLongitude() - endPt.getLongitude());
|
||||
u = u / (dx * dx + dy * dy);
|
||||
double u = ( lat - beginPt.getLatitude() ) * ( beginPt.getLatitude() - endPt.getLatitude() ) +
|
||||
( lon - beginPt.getLongitude() ) * ( beginPt.getLongitude() - endPt.getLongitude() );
|
||||
u = u / ( dx * dx + dy * dy );
|
||||
return new double[]{beginPt.getLongitude() + u * dy, beginPt.getLatitude() + u * dx};
|
||||
}
|
||||
|
||||
private static double[] getMid(LonLatPoint start, LonLatPoint end) {
|
||||
return new double[]{(start.getLongitude() + end.getLongitude()) / 2, (start.getLatitude() + end.getLatitude()) / 2};
|
||||
private static double[] getMid( LonLatPoint start, LonLatPoint end ) {
|
||||
return new double[]{( start.getLongitude() + end.getLongitude() ) / 2, ( start.getLatitude() + end.getLatitude() ) / 2};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ 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;
|
||||
@@ -42,6 +43,13 @@ 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 ) {
|
||||
@@ -75,12 +83,14 @@ 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 >() {
|
||||
|
||||
@@ -351,6 +351,24 @@ public interface IMogoMarker {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用缓存过的3d资源
|
||||
*
|
||||
* @param resName
|
||||
*/
|
||||
default void use3DResource( String resName ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用缓存过的2d资源
|
||||
*
|
||||
* @param resName
|
||||
*/
|
||||
default void use2DResource( String resName ) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置3D车模颜色
|
||||
*
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
@@ -13,6 +15,7 @@ import com.mogo.module.common.R;
|
||||
import com.mogo.module.common.constants.DataTypes;
|
||||
import com.mogo.module.common.kt.ScopeManager;
|
||||
import com.mogo.realtime.entity.ADASRecognizedResult;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
import java.util.List;
|
||||
@@ -34,9 +37,39 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
private Handler pointSettingHandler = null;
|
||||
|
||||
private AdasRecognizedResultDrawer() {
|
||||
super();
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
initHandler();
|
||||
}
|
||||
|
||||
private class SettingData {
|
||||
public IMogoMarker marker;
|
||||
public List< PointData > points;
|
||||
}
|
||||
|
||||
private void initHandler() {
|
||||
pointSettingHandler = new Handler( WorkThreadHandler.newInstance( "point-setting-thread" ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.obj instanceof SettingData ) {
|
||||
List< PointData > points = ( ( SettingData ) msg.obj ).points;
|
||||
IMogoMarker marker = ( ( SettingData ) msg.obj ).marker;
|
||||
for ( int i = 0; i < points.size(); i++ ) {
|
||||
marker.setRotateAngle( points.get( i ).angle );
|
||||
marker.setPosition( points.get( i ).point.lat, points.get( i ).point.lon );
|
||||
try {
|
||||
Thread.sleep( 10 );
|
||||
} catch ( InterruptedException e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private final Map< String, ADASRecognizedResult > mLastPositions = new ConcurrentHashMap<>();
|
||||
@@ -106,17 +139,17 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
return;
|
||||
}
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
double[] matchedPoint = matchRoad( recognizedListResult.lon,
|
||||
recognizedListResult.lat,
|
||||
recognizedListResult.heading,
|
||||
recognizedListResult.dataAccuracy == 1
|
||||
);
|
||||
Log.i( "match-road-timer", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
if ( matchedPoint != null ) {
|
||||
recognizedListResult.lon = matchedPoint[0];
|
||||
recognizedListResult.lat = matchedPoint[1];
|
||||
}
|
||||
// final long start = System.currentTimeMillis();
|
||||
// double[] matchedPoint = matchRoad( recognizedListResult.lon,
|
||||
// recognizedListResult.lat,
|
||||
// recognizedListResult.heading,
|
||||
// recognizedListResult.dataAccuracy == 1
|
||||
// );
|
||||
// Log.i( "match-road-timer", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
// if ( matchedPoint != null ) {
|
||||
// recognizedListResult.lon = matchedPoint[0];
|
||||
// recognizedListResult.lat = matchedPoint[1];
|
||||
// }
|
||||
|
||||
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( uniqueKey );
|
||||
ADASRecognizedResult lastPosition = mLastPositions.put( uniqueKey, recognizedListResult );
|
||||
@@ -131,8 +164,26 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
if ( lastPosition != null ) {
|
||||
MogoLatLng endLatLon = new MogoLatLng( recognizedListResult.lat, recognizedListResult.lon );
|
||||
long interval = computeAnimDuration( lastPosition.systemTime, recognizedListResult.systemTime, lastPosition.satelliteTime, recognizedListResult.satelliteTime );
|
||||
marker.addDynamicAnchorPosition( endLatLon, interval );
|
||||
Logger.d( TAG, "anim duration: %s", interval );
|
||||
MogoLatLng lastPoint = new MogoLatLng( lastPosition.lat, lastPosition.lon );
|
||||
lastPoint.setTime( lastPosition.satelliteTime );
|
||||
endLatLon.setTime( recognizedListResult.satelliteTime );
|
||||
PointData endPoint = new PointData();
|
||||
endPoint.point = endLatLon;
|
||||
endPoint.angle = (float)recognizedListResult.heading;
|
||||
|
||||
PointData startPoint = new PointData();
|
||||
startPoint.point = lastPoint;
|
||||
startPoint.angle = (float)lastPosition.heading;
|
||||
List< PointData > points = interpolate( startPoint, endPoint, 30, interval );
|
||||
Message msg = new Message();
|
||||
SettingData obj = new SettingData();
|
||||
obj.marker = marker;
|
||||
obj.points = points;
|
||||
msg.obj = obj;
|
||||
pointSettingHandler.sendMessage( msg );
|
||||
// marker.startSmoothInMs( points, interval );
|
||||
// marker.addDynamicAnchorPosition( endLatLon, interval );
|
||||
Logger.d( TAG, "anim duration: %s, points size = %s", interval, points.size() );
|
||||
} else {
|
||||
marker.setRotateAngle( ( ( float ) recognizedListResult.heading ) );
|
||||
marker.setPosition( recognizedListResult.lat, recognizedListResult.lon );
|
||||
@@ -162,6 +213,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
.owner( DataTypes.TYPE_MARKER_ADAS )
|
||||
.anchor( 0.5f, 0.5f )
|
||||
.set3DMode( true )
|
||||
.gps( true )
|
||||
.controlAngle( true )
|
||||
.resName( mMarkerCachesResMd5Values.get( resIdVal ) )
|
||||
.icon3DRes( resId )
|
||||
|
||||
@@ -17,10 +17,14 @@ import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.constants.AdasRecognizedType;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static java.lang.Math.PI;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -215,4 +219,44 @@ class BaseDrawer {
|
||||
}
|
||||
return interval;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在两点之间插值
|
||||
*
|
||||
* @param start
|
||||
* @param end
|
||||
* @param frameInterval
|
||||
* @return
|
||||
*/
|
||||
public static List< PointData > interpolate( PointData start, PointData end, long frameInterval, long duration ) {
|
||||
if ( start == null || end == null ) {
|
||||
return null;
|
||||
}
|
||||
int interpolateFrame = ( int ) ( duration / frameInterval ) - 1;
|
||||
List< PointData > arrayList = new ArrayList<>();
|
||||
double _angle = ( end.angle + start.angle ) / 2;
|
||||
if ( Math.abs( end.angle - start.angle ) > 5 ) {
|
||||
_angle = Math.atan2( Math.abs( start.point.lon - end.point.lon ), Math.abs( start.point.lat - end.point.lat ) ) * ( 180 / PI );
|
||||
}
|
||||
arrayList.add( start );
|
||||
if ( interpolateFrame > 0 ) {
|
||||
double lonStep = ( end.point.lon - start.point.lon ) / ( interpolateFrame + 1 );
|
||||
double latStep = ( end.point.lat - start.point.lat ) / ( interpolateFrame + 1 );
|
||||
for ( int i = 0; i < interpolateFrame; i++ ) {
|
||||
double lon = start.point.lon + lonStep * ( i + 1 );
|
||||
double lat = start.point.lat + latStep * ( i + 1 );
|
||||
PointData pd = new PointData();
|
||||
pd.point = new MogoLatLng( lat, lon );
|
||||
pd.angle = ( float ) _angle;
|
||||
arrayList.add( pd );
|
||||
}
|
||||
}
|
||||
arrayList.add( end );
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public static class PointData {
|
||||
public MogoLatLng point;
|
||||
public float angle;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.mogo.realtime.entity.CloudRoadData;
|
||||
import com.mogo.realtime.entity.MogoSnapshotSetData;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
import com.mogo.utils.ViewUtils;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
import com.zhidao.carchattingprovider.ICarsChattingProvider;
|
||||
import com.zhidao.carchattingprovider.MogoDriverInfo;
|
||||
@@ -96,6 +97,18 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
AdasRecognizedResultDrawer.getInstance().notifyVrModeChanged();
|
||||
}
|
||||
|
||||
public boolean isVrMode() {
|
||||
return mIsVrMode;
|
||||
}
|
||||
|
||||
public boolean isChangeCarModeStatus() {
|
||||
return mChangeCarModeStatus;
|
||||
}
|
||||
|
||||
public void setChangeCarModeStatus( boolean mChangeCarModeStatus ) {
|
||||
this.mChangeCarModeStatus = mChangeCarModeStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除就数据操作
|
||||
*
|
||||
@@ -131,7 +144,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
return false;
|
||||
}
|
||||
|
||||
Map<String,String> cloudKeyCache = new ArrayMap<>();
|
||||
Map< String, String > cloudKeyCache = new ArrayMap<>();
|
||||
|
||||
/**
|
||||
* mogo 他车、mogo 他车识别的社会车辆、路边单元识别的车辆
|
||||
@@ -146,87 +159,16 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
|
||||
List< CloudRoadData > allDatumsList = new ArrayList<>();
|
||||
prepareData( data.getAllList(), allDatumsList );
|
||||
Map< String, String > newMarkersCaches = new ArrayMap<>(allDatumsList.size());
|
||||
Map< String, IMogoMarker > newAdasRecognizedMarkersCaches = new ConcurrentHashMap<>(allDatumsList.size());
|
||||
Map< String, String > newMarkersCaches = new ArrayMap<>( allDatumsList.size() );
|
||||
for ( CloudRoadData cloudRoadData : allDatumsList ) {
|
||||
cloudKeyCache.remove(cloudRoadData.getUniqueKey());
|
||||
newMarkersCaches.put(cloudRoadData.getUniqueKey(), cloudRoadData.getUniqueKey());
|
||||
SimpleHandlerThreadPool.getInstance().post(cloudRoadData);
|
||||
// ScopeManager.INSTANCE.mainScope( () -> {
|
||||
// rendCarOneFrame( cloudRoadData, newAdasRecognizedMarkersCaches );
|
||||
// } );
|
||||
cloudKeyCache.remove( cloudRoadData.getUniqueKey() );
|
||||
newMarkersCaches.put( cloudRoadData.getUniqueKey(), cloudRoadData.getUniqueKey() );
|
||||
SimpleHandlerThreadPool.getInstance().post( cloudRoadData );
|
||||
}
|
||||
SimpleHandlerThreadPool.getInstance().removeDirtyMarker(cloudKeyCache.values());
|
||||
SimpleHandlerThreadPool.getInstance().removeDirtyMarker( cloudKeyCache.values() );
|
||||
cloudKeyCache = newMarkersCaches;
|
||||
// ScopeManager.INSTANCE.mainScope( () -> {
|
||||
// sendMessage( MSG_REMOVE_DIRTY_MARKERS, mCloudSnapshotMarkersCaches );
|
||||
// mCloudSnapshotMarkersCaches = newAdasRecognizedMarkersCaches;
|
||||
// } );
|
||||
}
|
||||
|
||||
public void rendCarOneFrame( CloudRoadData cloudRoadData, Map< String, IMogoMarker > newAdasRecognizedMarkersCaches ) {
|
||||
|
||||
if ( cloudRoadData == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 暂时只显示车辆
|
||||
if ( TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
|
||||
if ( !isCarType( cloudRoadData.getType() ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String uniqueKey = cloudRoadData.getUniqueKey();
|
||||
if ( TextUtils.isEmpty( uniqueKey )
|
||||
// 本地过滤重复下发的adas识别车辆
|
||||
|| AdasRecognizedResultDrawer.getInstance().hasCached( uniqueKey ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( uniqueKey );
|
||||
CloudRoadData lastPosition = mLastPositions.put( uniqueKey, cloudRoadData );
|
||||
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawSnapshotDataMarker( cloudRoadData );
|
||||
if ( marker == null ) {
|
||||
return;
|
||||
}
|
||||
if ( !TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
|
||||
bindClickListener( marker );
|
||||
}
|
||||
}
|
||||
if(newAdasRecognizedMarkersCaches != null) {
|
||||
newAdasRecognizedMarkersCaches.put(uniqueKey, marker);
|
||||
}
|
||||
//
|
||||
// if ( mChangeCarModeStatus ) {
|
||||
// mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode();
|
||||
// mChangeCarModeStatus = false;
|
||||
// if ( mIsVrMode ) {
|
||||
// marker.getMogoMarkerOptions().set3DMode( true );
|
||||
// marker.use3DResource( getVrModelResId( cloudRoadData ) );
|
||||
// } else {
|
||||
// marker.getMogoMarkerOptions().set3DMode( false );
|
||||
// marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData ) ) );
|
||||
// }
|
||||
// }
|
||||
|
||||
if ( lastPosition != null && !lastPosition.equals( cloudRoadData ) ) {
|
||||
long interval = computeAnimDuration( lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime() );
|
||||
interval = System.currentTimeMillis() - mLastPositionExecutionTime.get( uniqueKey );
|
||||
marker.addDynamicAnchorPosition( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ), interval );
|
||||
Logger.d( TAG, "anim duration: %s", interval );
|
||||
} else {
|
||||
marker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
|
||||
marker.setPosition( cloudRoadData.getLat(), cloudRoadData.getLon() );
|
||||
Logger.d( TAG, "设置点位置" );
|
||||
}
|
||||
mLastPositionExecutionTime.put( uniqueKey, System.currentTimeMillis() );
|
||||
showSelfSpeed( mContext, marker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 过滤数据
|
||||
*
|
||||
@@ -287,8 +229,9 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
.anchor( 0.5f, 0.5f )
|
||||
.rotate( ( float ) data.getHeading() )
|
||||
.object( data )
|
||||
.gps( true )
|
||||
.controlAngle( true )
|
||||
.position( new MogoLatLng( data.getLat(), data.getLon() ) );
|
||||
.position( new MogoLatLng( data.getWgslat(), data.getWgslon() ) );
|
||||
String resIdVal = null;
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
options.set3DMode( true );
|
||||
@@ -308,13 +251,17 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
return marker;
|
||||
}
|
||||
|
||||
public String get3DCacheId( String resIdVal ) {
|
||||
return mMarkerCachesResMd5Values.get( resIdVal );
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车辆 3d 模型
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private int getVrModelResId( CloudRoadData data ) {
|
||||
public int getVrModelResId( CloudRoadData data ) {
|
||||
switch ( data.getFromType() ) {
|
||||
case CloudRoadData.FROM_ADAS:
|
||||
return R.raw.cargrey;
|
||||
@@ -332,7 +279,7 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
private View inflateView( CloudRoadData data ) {
|
||||
public View inflateView( CloudRoadData data ) {
|
||||
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
|
||||
ImageView iv = rootView.findViewById( R.id.module_commons_marker_car_model );
|
||||
int viewIdLike = get2DModel( data );
|
||||
@@ -388,4 +335,32 @@ public class SnapshotSetDataDrawer extends BaseDrawer implements IMogoMarkerClic
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void changeIconResourceIfNecessary( CloudRoadData cloudRoadData, IMogoMarker marker ) {
|
||||
if ( isChangeCarModeStatus() ) {
|
||||
setChangeCarModeStatus( false );
|
||||
if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) {
|
||||
marker.getMogoMarkerOptions().set3DMode( true );
|
||||
int resId = getVrModelResId( cloudRoadData );
|
||||
String resName = get3DCacheId( resId + "" );
|
||||
if ( TextUtils.isEmpty( resName ) ) {
|
||||
marker.use3DResource( resId );
|
||||
cacheMarkerIconResMd5Val( resId + "", marker );
|
||||
} else {
|
||||
marker.use3DResource( resName );
|
||||
}
|
||||
} else {
|
||||
marker.getMogoMarkerOptions().set3DMode( false );
|
||||
View view = inflateView( cloudRoadData );
|
||||
int resId = view.getId();
|
||||
String resName = get3DCacheId( resId + "" );
|
||||
if ( TextUtils.isEmpty( resName ) ) {
|
||||
marker.setIcon( ViewUtils.fromView( view ) );
|
||||
cacheMarkerIconResMd5Val( resId + "", marker );
|
||||
} else {
|
||||
marker.use2DResource( resName );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,12 +29,12 @@ import static com.mogo.module.common.drawer.BaseDrawer.MSG_REMOVE_DIRTY_MARKERS;
|
||||
*/
|
||||
public class SimpleHandlerThreadPool {
|
||||
private static final String TAG = "SimpleHandlerThreadPool";
|
||||
private HandlerThread renderThread = new HandlerThread("one-frame-render-thread");
|
||||
private HandlerThread renderThread = new HandlerThread( "one-frame-render-thread" );
|
||||
private Handler renderHandler;
|
||||
|
||||
private SimpleHandlerThreadPool() {
|
||||
renderThread.start();
|
||||
renderHandler = new Handler(renderThread.getLooper());
|
||||
renderHandler = new Handler( renderThread.getLooper() );
|
||||
}
|
||||
|
||||
private static final SimpleHandlerThreadPool INSTANCE = new SimpleHandlerThreadPool();
|
||||
@@ -50,38 +50,38 @@ public class SimpleHandlerThreadPool {
|
||||
|
||||
private int threadCount = DEFAULT_THREAD_COUNT;
|
||||
|
||||
public void setThreadCount(int threadCount) {
|
||||
public void setThreadCount( int threadCount ) {
|
||||
this.threadCount = threadCount;
|
||||
}
|
||||
|
||||
Map<String, WorkHandler> dataHandlerMap = new ArrayMap<>();
|
||||
Map<Integer, WorkHandler> handlerPool = new ArrayMap<>();
|
||||
Map< String, WorkHandler > dataHandlerMap = new ArrayMap<>();
|
||||
Map< Integer, WorkHandler > handlerPool = new ArrayMap<>();
|
||||
private int lastUseThreadId = -1;
|
||||
|
||||
public void post(CloudRoadData cloudRoadData) {
|
||||
public void post( CloudRoadData cloudRoadData ) {
|
||||
String uuid = cloudRoadData.getUniqueKey();
|
||||
Message msg;
|
||||
if (dataHandlerMap.containsKey(uuid)) {
|
||||
msg = dataHandlerMap.get(uuid).obtainMessage();
|
||||
if ( dataHandlerMap.containsKey( uuid ) ) {
|
||||
msg = dataHandlerMap.get( uuid ).obtainMessage();
|
||||
} else {
|
||||
if (handlerPool.size() < threadCount) {
|
||||
if ( handlerPool.size() < threadCount ) {
|
||||
// 新开线程
|
||||
lastUseThreadId = handlerPool.size();
|
||||
HandlerThread thread = new HandlerThread("one-frame-work-thread-" + handlerPool.size());
|
||||
HandlerThread thread = new HandlerThread( "one-frame-work-thread-" + handlerPool.size() );
|
||||
thread.start();
|
||||
WorkHandler handler = new WorkHandler(thread.getLooper());
|
||||
handlerPool.put(handlerPool.size(), handler);
|
||||
dataHandlerMap.put(uuid, handler);
|
||||
WorkHandler handler = new WorkHandler( thread.getLooper() );
|
||||
handlerPool.put( handlerPool.size(), handler );
|
||||
dataHandlerMap.put( uuid, handler );
|
||||
msg = handler.obtainMessage();
|
||||
} else {
|
||||
// 复用线程
|
||||
if (lastUseThreadId == threadCount - 1) {
|
||||
if ( lastUseThreadId == threadCount - 1 ) {
|
||||
lastUseThreadId = 0;
|
||||
} else {
|
||||
lastUseThreadId++;
|
||||
}
|
||||
WorkHandler handler = handlerPool.get(lastUseThreadId);
|
||||
dataHandlerMap.put(uuid, handler);
|
||||
WorkHandler handler = handlerPool.get( lastUseThreadId );
|
||||
dataHandlerMap.put( uuid, handler );
|
||||
msg = handler.obtainMessage();
|
||||
}
|
||||
}
|
||||
@@ -89,118 +89,116 @@ public class SimpleHandlerThreadPool {
|
||||
msg.sendToTarget();
|
||||
}
|
||||
|
||||
public void removeDirtyMarker(Collection<String> keys) {
|
||||
for (WorkHandler handler : handlerPool.values()) {
|
||||
handler.removeDirtyMarker(keys);
|
||||
public void removeDirtyMarker( Collection< String > keys ) {
|
||||
for ( WorkHandler handler : handlerPool.values() ) {
|
||||
handler.removeDirtyMarker( keys );
|
||||
}
|
||||
}
|
||||
|
||||
class WorkHandler extends Handler {
|
||||
public WorkHandler(Looper looper) {
|
||||
super(looper);
|
||||
public WorkHandler( Looper looper ) {
|
||||
super( looper );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
CloudRoadData cloudRoadData = (CloudRoadData) msg.obj;
|
||||
rendCarOneFrame(cloudRoadData);
|
||||
public void handleMessage( Message msg ) {
|
||||
CloudRoadData cloudRoadData = ( CloudRoadData ) msg.obj;
|
||||
renderCarOneFrame( cloudRoadData );
|
||||
}
|
||||
|
||||
private final Map<String, IMogoMarker> markerCache = new ArrayMap<>();
|
||||
private final Map<String, CloudRoadData> roadDataCache = new ArrayMap<>();
|
||||
private final Map<String, Long> lastExecutionTimeCache = new ArrayMap<>();
|
||||
private final Map<String, Boolean> isMatchStatusCache = new ArrayMap<>();
|
||||
private final Map< String, IMogoMarker > markerCache = new ArrayMap<>();
|
||||
private final Map< String, CloudRoadData > roadDataCache = new ArrayMap<>();
|
||||
private final Map< String, Long > lastExecutionTimeCache = new ArrayMap<>();
|
||||
private final Map< String, Boolean > isMatchStatusCache = new ArrayMap<>();
|
||||
|
||||
private void rendCarOneFrame(CloudRoadData cloudRoadData) {
|
||||
if (cloudRoadData == null) {
|
||||
private void renderCarOneFrame( CloudRoadData cloudRoadData ) {
|
||||
if ( cloudRoadData == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 暂时只显示车辆
|
||||
if (TextUtils.isEmpty(cloudRoadData.getSn())) {
|
||||
if (!SnapshotSetDataDrawer.getInstance().isCarType(cloudRoadData.getType())) {
|
||||
if ( TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
|
||||
if ( !SnapshotSetDataDrawer.getInstance().isCarType( cloudRoadData.getType() ) ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
String uniqueKey = cloudRoadData.getUniqueKey();
|
||||
if (TextUtils.isEmpty(uniqueKey)
|
||||
if ( TextUtils.isEmpty( uniqueKey )
|
||||
// 本地过滤重复下发的adas识别车辆
|
||||
|| AdasRecognizedResultDrawer.getInstance().hasCached(uniqueKey)) {
|
||||
|| AdasRecognizedResultDrawer.getInstance().hasCached( uniqueKey ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
IMogoMarker marker = markerCache.get(uniqueKey);
|
||||
CloudRoadData lastPosition = roadDataCache.put(uniqueKey, cloudRoadData);
|
||||
if (marker == null || marker.isDestroyed()) {
|
||||
marker = SnapshotSetDataDrawer.getInstance().drawSnapshotDataMarker(cloudRoadData);
|
||||
if (marker == null) {
|
||||
IMogoMarker marker = markerCache.get( uniqueKey );
|
||||
CloudRoadData lastPosition = roadDataCache.put( uniqueKey, cloudRoadData );
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = SnapshotSetDataDrawer.getInstance().drawSnapshotDataMarker( cloudRoadData );
|
||||
if ( marker == null ) {
|
||||
return;
|
||||
}
|
||||
markerCache.put(uniqueKey, marker);
|
||||
if (!TextUtils.isEmpty(cloudRoadData.getSn())) {
|
||||
SnapshotSetDataDrawer.getInstance().bindClickListener(marker);
|
||||
markerCache.put( uniqueKey, marker );
|
||||
if ( !TextUtils.isEmpty( cloudRoadData.getSn() ) ) {
|
||||
SnapshotSetDataDrawer.getInstance().bindClickListener( marker );
|
||||
}
|
||||
}
|
||||
|
||||
// if (cloudRoadData.getFromType() != CloudRoadData.FROM_MY_LOCATION) {
|
||||
|
||||
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad(cloudRoadData.getLon(),
|
||||
cloudRoadData.getLat(),
|
||||
cloudRoadData.getHeading(),
|
||||
true
|
||||
);
|
||||
Boolean isMathch = isMatchStatusCache.get(uniqueKey);
|
||||
if (matchedPoint != null) {
|
||||
if ((isMathch == null || !isMathch)) {
|
||||
if (matchedPoint[2] < 0.5) {
|
||||
isMathch = true;
|
||||
}
|
||||
} else {
|
||||
if (matchedPoint[2] > 1) {
|
||||
isMathch = false;
|
||||
}
|
||||
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad( cloudRoadData.getWgslon(),
|
||||
cloudRoadData.getWgslat(),
|
||||
cloudRoadData.getHeading(),
|
||||
true
|
||||
);
|
||||
Boolean isMatch = isMatchStatusCache.get( uniqueKey );
|
||||
if ( matchedPoint != null ) {
|
||||
if ( ( isMatch == null || !isMatch ) ) {
|
||||
if ( matchedPoint[2] < 0.5 ) {
|
||||
isMatch = true;
|
||||
}
|
||||
if (isMathch == null) {
|
||||
isMathch = false;
|
||||
}
|
||||
isMatchStatusCache.put(uniqueKey, isMathch);
|
||||
|
||||
if (isMathch) {
|
||||
cloudRoadData.setLon(matchedPoint[0]);
|
||||
cloudRoadData.setLat(matchedPoint[1]);
|
||||
} else {
|
||||
if ( matchedPoint[2] > 1 ) {
|
||||
isMatch = false;
|
||||
}
|
||||
}
|
||||
// }
|
||||
if ( isMatch == null ) {
|
||||
isMatch = false;
|
||||
}
|
||||
isMatchStatusCache.put( uniqueKey, isMatch );
|
||||
|
||||
if ( isMatch ) {
|
||||
cloudRoadData.setLon( matchedPoint[0] );
|
||||
cloudRoadData.setLat( matchedPoint[1] );
|
||||
}
|
||||
}
|
||||
|
||||
SnapshotSetDataDrawer.getInstance().changeIconResourceIfNecessary( cloudRoadData, marker );
|
||||
|
||||
final IMogoMarker finalMarker = marker;
|
||||
Logger.d(TAG, "work in " + Thread.currentThread().getName());
|
||||
renderHandler.post(() -> {
|
||||
Logger.d( TAG, "work in " + Thread.currentThread().getName() );
|
||||
renderHandler.post( () -> {
|
||||
// 由于地图现在不支持addDynamicAnchorPosition并发,所以工作线程仅做相关计算,真正绘制发送到另外一条绘制线程中做
|
||||
if (lastPosition != null && !lastPosition.equals(cloudRoadData)) {
|
||||
long interval = SnapshotSetDataDrawer.getInstance().computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
|
||||
interval = SystemClock.uptimeMillis() - lastExecutionTimeCache.get(uniqueKey);
|
||||
finalMarker.addDynamicAnchorPosition(new MogoLatLng(cloudRoadData.getLat(), cloudRoadData.getLon()), interval);
|
||||
Logger.d(TAG, "anim duration: %s in thread: %s", interval, Thread.currentThread().getName());
|
||||
if ( lastPosition != null && !lastPosition.equals( cloudRoadData ) ) {
|
||||
long interval = SystemClock.uptimeMillis() - lastExecutionTimeCache.get( uniqueKey );
|
||||
finalMarker.addDynamicAnchorPosition( new MogoLatLng( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() ), interval );
|
||||
Logger.d( TAG, "anim duration: %s in thread: %s", interval, Thread.currentThread().getName() );
|
||||
} else {
|
||||
finalMarker.setRotateAngle((float) cloudRoadData.getHeading());
|
||||
finalMarker.setPosition(cloudRoadData.getLat(), cloudRoadData.getLon());
|
||||
Logger.d(TAG, "设置点位置 in thread: %s", Thread.currentThread().getName());
|
||||
finalMarker.setRotateAngle( ( float ) cloudRoadData.getHeading() );
|
||||
finalMarker.setPosition( cloudRoadData.getWgslat(), cloudRoadData.getWgslon() );
|
||||
Logger.d( TAG, "设置点位置 in thread: %s", Thread.currentThread().getName() );
|
||||
}
|
||||
lastExecutionTimeCache.put(uniqueKey, SystemClock.uptimeMillis());
|
||||
SnapshotSetDataDrawer.getInstance().showSelfSpeed(AbsMogoApplication.getApp(), finalMarker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode());
|
||||
});
|
||||
lastExecutionTimeCache.put( uniqueKey, SystemClock.uptimeMillis() );
|
||||
SnapshotSetDataDrawer.getInstance().showSelfSpeed( AbsMogoApplication.getApp(), finalMarker, cloudRoadData.getSpeed(), MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() );
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
public void removeDirtyMarker(Collection<String> keys) {
|
||||
Map<String, IMogoMarker> result = new ArrayMap<>(keys.size());
|
||||
for (String key : keys) {
|
||||
if (markerCache.containsKey(key)) {
|
||||
result.put(key, markerCache.remove(key));
|
||||
public void removeDirtyMarker( Collection< String > keys ) {
|
||||
Map< String, IMogoMarker > result = new ArrayMap<>( keys.size() );
|
||||
for ( String key : keys ) {
|
||||
if ( markerCache.containsKey( key ) ) {
|
||||
result.put( key, markerCache.remove( key ) );
|
||||
}
|
||||
}
|
||||
SnapshotSetDataDrawer.getInstance().sendMessage(MSG_REMOVE_DIRTY_MARKERS, result);
|
||||
SnapshotSetDataDrawer.getInstance().sendMessage( MSG_REMOVE_DIRTY_MARKERS, result );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -557,9 +557,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
break;
|
||||
case 47:
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 1, 200L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 2, 0 );
|
||||
// mLocationMockHandler.sendEmptyMessageDelayed( 2, 0 );
|
||||
// mLocationMockHandler.sendEmptyMessageDelayed( 21, 200 );
|
||||
// mLocationMockHandler.sendEmptyMessageDelayed( 3, 300L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -624,26 +624,7 @@ public class MockIntentHandler implements IntentHandler {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private Handler mLocationMockHandler2 = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread2" ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.what == 2 ) {
|
||||
try {
|
||||
handleMockSnapshotIntent();
|
||||
} catch ( Exception e ) {
|
||||
try {
|
||||
br2.close();
|
||||
} catch ( IOException ex ) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
br2 = null;
|
||||
}
|
||||
} else if ( msg.what == 3 ) {
|
||||
}else if ( msg.what == 3 ) {
|
||||
try {
|
||||
handleMockAdasIntent();
|
||||
} catch ( Exception e ) {
|
||||
@@ -692,9 +673,9 @@ public class MockIntentHandler implements IntentHandler {
|
||||
if ( cloudRoadData == null ) {
|
||||
return false;
|
||||
}
|
||||
double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
|
||||
cloudRoadData.setLon( coor[0] );
|
||||
cloudRoadData.setLat( coor[1] );
|
||||
// double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
|
||||
// cloudRoadData.setLon( coor[0] );
|
||||
// cloudRoadData.setLat( coor[1] );
|
||||
allList.add( cloudRoadData );
|
||||
data.setAllList( allList );
|
||||
|
||||
@@ -721,10 +702,10 @@ public class MockIntentHandler implements IntentHandler {
|
||||
if ( cloudRoadData == null ) {
|
||||
return false;
|
||||
}
|
||||
double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
|
||||
// double[] coor = CoordinateUtils.transformWgsToGcj( cloudRoadData.getLat(), cloudRoadData.getLon() );
|
||||
cloudRoadData.setUuid("1_21");
|
||||
cloudRoadData.setLon( coor[0] );
|
||||
cloudRoadData.setLat( coor[1] );
|
||||
// cloudRoadData.setLon( coor[0] );
|
||||
// cloudRoadData.setLat( coor[1] );
|
||||
allList.add( cloudRoadData );
|
||||
data.setAllList( allList );
|
||||
|
||||
@@ -750,15 +731,15 @@ public class MockIntentHandler implements IntentHandler {
|
||||
if ( adasRecognizedResult == null ) {
|
||||
return false;
|
||||
}
|
||||
double[] coor = CoordinateUtils.transformWgsToGcj( adasRecognizedResult.lat, adasRecognizedResult.lon );
|
||||
adasRecognizedResult.lon = coor[0];
|
||||
adasRecognizedResult.lat = coor[1];
|
||||
// double[] coor = CoordinateUtils.transformWgsToGcj( adasRecognizedResult.lat, adasRecognizedResult.lon );
|
||||
// adasRecognizedResult.lon = coor[0];
|
||||
// adasRecognizedResult.lat = coor[1];
|
||||
allList.add( adasRecognizedResult );
|
||||
|
||||
final long start = System.currentTimeMillis();
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( allList );
|
||||
Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" );
|
||||
mLocationMockHandler2.sendEmptyMessageDelayed( 3, 100L );
|
||||
mLocationMockHandler.sendEmptyMessageDelayed( 3, 100L );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ public class MogoRTKLocation {
|
||||
cloudLocationInfo.setSpeed( location.getSpeed() );
|
||||
cloudLocationInfo.setSatelliteTime( location.getTime() );
|
||||
cloudLocationInfo.setSystemTime( System.currentTimeMillis() );
|
||||
cloudLocationInfo.convertCoor2GCJ02();
|
||||
SnapshotLocationController.getInstance().syncLocationInfo( cloudLocationInfo );
|
||||
} else {
|
||||
Logger.e( TAG, "location == null" );
|
||||
|
||||
@@ -93,7 +93,6 @@ class SnapshotLocationController {
|
||||
cloudLocationInfo.setSpeed( speed );
|
||||
cloudLocationInfo.setSatelliteTime( satelliteTime );
|
||||
cloudLocationInfo.setSystemTime( systemTime );
|
||||
cloudLocationInfo.convertCoor2GCJ02();
|
||||
mLastLocationInfo = cloudLocationInfo;
|
||||
mMachineCacheList.add( cloudLocationInfo );
|
||||
}
|
||||
|
||||
@@ -59,14 +59,8 @@ class AdasObjectUtils {
|
||||
ADASRecognizedResult result = new ADASRecognizedResult();
|
||||
result.uuid = model.getUuid();
|
||||
|
||||
double[] amapCoord = CoordinateUtils.transformWgsToGcj( model.getLat(), model.getLon() );
|
||||
if ( amapCoord != null ) {
|
||||
result.lat = amapCoord[1];
|
||||
result.lon = amapCoord[0];
|
||||
} else {
|
||||
result.lat = model.getLat();
|
||||
result.lon = model.getLon();
|
||||
}
|
||||
result.lat = model.getLat();
|
||||
result.lon = model.getLon();
|
||||
result.type = Integer.parseInt( model.getType() );
|
||||
result.heading = model.getHeading();
|
||||
result.systemTime = Long.parseLong( model.getSystemTime() );
|
||||
|
||||
@@ -248,8 +248,7 @@ public class MogoADASController implements IMogoADASController {
|
||||
if ( DebugConfig.isMapBased() ) {
|
||||
Logger.d( TAG, "requestGetCarModelListInfo" );
|
||||
// 向adas发送车模list
|
||||
String carModelList = SharedPrefsMgr.getInstance( context ).getString(
|
||||
"CAR_MODEL_LIST", "" );
|
||||
String carModelList = SharedPrefsMgr.getInstance( context ).getString( "CAR_MODEL_LIST", "" );
|
||||
if ( carModelList != null && !carModelList.isEmpty() ) {
|
||||
AutopilotServiceManage.getInstance().settingCarModelListInfo( carModelList );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user