优化显示逻辑
This commit is contained in:
@@ -68,7 +68,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
crashSystem.init();
|
||||
//设置debug模式,日志不上传
|
||||
crashSystem.setDebug( BuildConfig.DEBUG );
|
||||
Logger.init( BuildConfig.DEBUG ? LogLevel.VERBOSE : LogLevel.OFF );
|
||||
Logger.init( BuildConfig.DEBUG ? LogLevel.DEBUG : LogLevel.OFF );
|
||||
|
||||
if( DebugConfig.isNeedLoadGuideModule() ){
|
||||
MogoModulePaths.addModule( new MogoModule( MogoModulePaths.PATH_GUIDE, MogoModulePaths.PATH_GUIDE ) );
|
||||
@@ -214,7 +214,7 @@ public class MogoApplication extends AbsMogoApplication {
|
||||
// 设置是否是第三APP登录
|
||||
clientConfig.setThirdLogin(false);
|
||||
// 设置是否输出日志
|
||||
clientConfig.setShowDebugLog(true);
|
||||
clientConfig.setShowDebugLog(false);
|
||||
// 设置从蘑菇AI开放平台获取的APPKey
|
||||
clientConfig.setThirdPartyAppKey("wbvpzgar");
|
||||
// 设置应用服务AppId 长链、鉴权
|
||||
|
||||
@@ -67,7 +67,7 @@ dependencies {
|
||||
implementation project(':foudations:mogo-commons')
|
||||
}
|
||||
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.2.0'
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.2.2'
|
||||
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-test-3.4'
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.graphics.Typeface;
|
||||
import android.location.Location;
|
||||
import android.os.Bundle;
|
||||
import android.os.Trace;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@@ -25,6 +26,7 @@ import com.mogo.map.impl.custom.navi.NaviClient;
|
||||
import com.mogo.map.impl.custom.utils.MogoMapUtils;
|
||||
import com.mogo.map.impl.custom.utils.ObjectUtils;
|
||||
import com.mogo.map.impl.custom.utils.PointInterpolatorUtil;
|
||||
import com.mogo.map.impl.custom.utils.ResIdCache;
|
||||
import com.mogo.map.listener.MogoMapListenerHandler;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.uicontroller.CarCursorOption;
|
||||
@@ -67,7 +69,9 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class AMapViewWrapper implements IMogoMapView,
|
||||
IMogoMapUIController,
|
||||
@@ -770,7 +774,6 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
showSelfSpeed( location.getSpeed() );
|
||||
}
|
||||
|
||||
private float mLastSpeed = 0;
|
||||
private TextView mSpeedView = null;
|
||||
|
||||
private void showSelfSpeed( float speed ) {
|
||||
@@ -786,19 +789,28 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
mSelfMarker.hideInfoWindow();
|
||||
return;
|
||||
}
|
||||
if ( Math.abs( mLastSpeed - speed ) > 0 ) {
|
||||
|
||||
int speedIntVal = ( int ) ( speed * 3.6 );
|
||||
if ( speedIntVal <= 0 ) {
|
||||
mSelfMarker.hideInfoWindow();
|
||||
return;
|
||||
}
|
||||
|
||||
String speedVal = String.valueOf( speedIntVal );
|
||||
String infoResName = ResIdCache.getVal( speedVal );
|
||||
if ( TextUtils.isEmpty( infoResName ) ) {
|
||||
if ( mSpeedView == null ) {
|
||||
mSpeedView = new TextView( mMapView.getContext() );
|
||||
mSpeedView.setTextColor( Color.WHITE );
|
||||
mSpeedView.setTypeface( Typeface.defaultFromStyle( Typeface.BOLD ) );
|
||||
// mSpeedView.setShadowLayer( 10f, 5F, 5F, Color.BLACK );
|
||||
mSpeedView.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT ) );
|
||||
}
|
||||
mSpeedView.setText( String.valueOf( ( ( int ) ( speed * 3.6 ) ) ) );
|
||||
mSpeedView.setText( speedVal );
|
||||
mSelfMarker.setInfoWindowOffset( 0, 20 );
|
||||
mSelfMarker.setInfoWindowView( mSpeedView );
|
||||
ResIdCache.putVal( speedVal, mSelfMarker.getMarkeOptions().getMarkerInfoName() );
|
||||
} else {
|
||||
mSelfMarker.hideInfoWindow();
|
||||
mSelfMarker.setMarkerInfoName( infoResName );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1021,44 +1033,31 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
private float lastRoadId;
|
||||
|
||||
@Override
|
||||
public double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
|
||||
double wgs[] = new double[]{lon, lat};//CoordinateUtils.transformGcj02toWgs84( lat, lon );
|
||||
double wgs[] = new double[]{lon, lat};
|
||||
long start = System.currentTimeMillis();
|
||||
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad( ( ( float ) wgs[0] ), ( ( float ) wgs[1] ), ( ( float ) angle ), isGpsLocation, isRTK );
|
||||
Log.i("timer-matchRoad-1", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
if ( singlePointRoadInfo != null
|
||||
&& singlePointRoadInfo.getCoords() != null
|
||||
&& !singlePointRoadInfo.getCoords().isEmpty() ) {
|
||||
start = System.currentTimeMillis();
|
||||
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]);
|
||||
|
||||
// matchedPoint[0] = trans[0];
|
||||
// matchedPoint[1] = trans[1];
|
||||
// MarkerOptions options
|
||||
// = new MarkerOptions();
|
||||
// options.markerIcon( R.drawable.red )
|
||||
// .position( new LonLatPoint( matchedPoint[0], matchedPoint[1] ) )
|
||||
// .setGps( false );
|
||||
// mMapView.getMapAutoViewHelper().addMarker( options );
|
||||
//
|
||||
// MarkerOptions options2 = new MarkerOptions();
|
||||
// options2.markerIcon( R.drawable.blue )
|
||||
// .position( new LonLatPoint( lon, lat ) )
|
||||
// .setGps( true );
|
||||
// mMapView.getMapAutoViewHelper().addMarker( options2 );
|
||||
|
||||
// if(lastRoadId != singlePointRoadInfo.getRoadId()) {
|
||||
// lastRoadId = singlePointRoadInfo.getRoadId();
|
||||
// PolylineOptions lineOptions = new PolylineOptions();
|
||||
// lineOptions.setGps(true)
|
||||
// .lonLatPoints(singlePointRoadInfo.getCoords())
|
||||
// .color(Color.RED)
|
||||
// .lineWidth(10);
|
||||
// mMapView.getMapAutoViewHelper().drawLine(lineOptions);
|
||||
// }
|
||||
Log.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
return matchedPoint;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerInfoResName( String speedVal ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarkerInfoResName( String speedVal, String val ) {
|
||||
ResIdCache.putVal( speedVal, val );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import android.view.animation.Interpolator;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.impl.custom.utils.ObjectUtils;
|
||||
import com.mogo.map.impl.custom.utils.ResIdCache;
|
||||
import com.mogo.map.marker.IMogoInfoWindowAdapter;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
@@ -543,6 +544,15 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInfoWindowView( String viewResName ) {
|
||||
try {
|
||||
mMarker.setMarkerInfoName( viewResName );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "error." );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInfoWindowOffset( int offsetX, int offsetY ) {
|
||||
try {
|
||||
@@ -571,4 +581,15 @@ public class AMapMarkerWrapper implements IMogoMarker, Observer {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerInfoResName() {
|
||||
if ( mMarker != null ) {
|
||||
try {
|
||||
return mMarker.getMarkeOptions().getMarkerInfoName();
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,4 +321,19 @@ public class AMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerInfoResName( String speedVal ) {
|
||||
if ( mClient != null ) {
|
||||
return mClient.getMarkerInfoResName( speedVal );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarkerInfoResName( String speedVal, String val ) {
|
||||
if ( mClient != null ) {
|
||||
mClient.setMarkerInfoResName( speedVal, val );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.mogo.map.impl.custom.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/3/8
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class ResIdCache {
|
||||
|
||||
public static Map< String, String > sMarkerCachesResMd5Values = new HashMap<>();
|
||||
|
||||
public static String getVal( String name ) {
|
||||
return sMarkerCachesResMd5Values.get( name );
|
||||
}
|
||||
|
||||
public static void putVal( String name, String val ) {
|
||||
sMarkerCachesResMd5Values.put( name, val );
|
||||
}
|
||||
}
|
||||
@@ -382,6 +382,10 @@ public interface IMogoMarker {
|
||||
|
||||
}
|
||||
|
||||
default void updateInfoWindowView( String viewResName ) {
|
||||
|
||||
}
|
||||
|
||||
default void setInfoWindowOffset( int offsetX, int offsetY ) {
|
||||
|
||||
}
|
||||
@@ -398,4 +402,13 @@ public interface IMogoMarker {
|
||||
default String getMarkerResName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 marker infowindow 内部使用资源内容 md5
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
default String getMarkerInfoResName() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,4 +288,22 @@ public interface IMogoMapUIController {
|
||||
default double[] matchRoad( double lon, double lat, double angle, boolean isGpsLocation, boolean isRTK ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车速资源缓存 id
|
||||
* @param speedVal
|
||||
* @return
|
||||
*/
|
||||
default String getMarkerInfoResName(String speedVal){
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取车速资源缓存 id
|
||||
* @param speedVal
|
||||
* @return
|
||||
*/
|
||||
default void setMarkerInfoResName(String speedVal, String val){
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,4 +362,21 @@ public class MogoMapUIController implements IMogoMapUIController {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMarkerInfoResName( String speedVal ) {
|
||||
initDelegate();
|
||||
if ( mDelegate != null ) {
|
||||
return mDelegate.getMarkerInfoResName( speedVal );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMarkerInfoResName( String speedVal, String val ) {
|
||||
initDelegate();
|
||||
if ( mDelegate != null ) {
|
||||
mDelegate.setMarkerInfoResName( speedVal, val );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
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;
|
||||
import android.util.ArrayMap;
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
@@ -38,7 +36,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
private Handler pointSettingHandler = null;
|
||||
private Handler mPointSettingHandler = null;
|
||||
public static final int MSG_POINTS_SETTING = 9;
|
||||
public static final int MSG_SET_POINT = 10;
|
||||
public static final int MSG_SET_SPEED = 11;
|
||||
@@ -50,25 +48,21 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
}
|
||||
|
||||
private void initHandler() {
|
||||
pointSettingHandler = new Handler( WorkThreadHandler.newInstance( "point-setting-thread" ).getLooper() ) {
|
||||
mPointSettingHandler = new Handler( WorkThreadHandler.newInstance( "moving-points-thread" ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.what == MSG_POINTS_SETTING ) {
|
||||
if ( msg.obj instanceof SettingData ) {
|
||||
startSettingPointLooper( ( ( SettingData ) msg.obj ) );
|
||||
if ( msg.obj instanceof MovingPoints ) {
|
||||
startSettingPointLooper( ( ( MovingPoints ) msg.obj ) );
|
||||
}
|
||||
} else if ( msg.what == MSG_SET_POINT ) {
|
||||
if ( msg.obj instanceof PointData ) {
|
||||
moveMarker( ( ( PointData ) msg.obj ) );
|
||||
if ( msg.obj instanceof MovingPoint ) {
|
||||
moveMarker( ( ( MovingPoint ) msg.obj ) );
|
||||
}
|
||||
} else if( msg.what == MSG_SET_SPEED ){
|
||||
if ( msg.obj instanceof SpeedData ) {
|
||||
try {
|
||||
( ( SpeedData ) msg.obj ).showSpeed();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
showSpeed( ( SpeedData ) msg.obj );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,46 +74,33 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
private void startSettingPointLooper( SettingData data ) {
|
||||
List< PointData > points = data.points;
|
||||
private void startSettingPointLooper( MovingPoints data ) {
|
||||
List< MovingPoint > points = data.points;
|
||||
for ( int i = 0; i < points.size(); i++ ) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_SET_POINT;
|
||||
msg.obj = points.get( i );
|
||||
pointSettingHandler.sendMessageDelayed( msg, ( i + 1 ) * 10 );
|
||||
mPointSettingHandler.sendMessageDelayed( msg, ( i + 1 ) * 10 );
|
||||
}
|
||||
}
|
||||
|
||||
private String markerRes;
|
||||
|
||||
/**
|
||||
* 设置 marker 的点到新的位置
|
||||
*
|
||||
* @param pointData
|
||||
*/
|
||||
private void moveMarker( PointData pointData ) {
|
||||
private void moveMarker( MovingPoint pointData ) {
|
||||
if ( pointData == null ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
pointData.move();
|
||||
// MogoMarkerOptions options = new MogoMarkerOptions();
|
||||
// options.gps( true )
|
||||
// .position( pointData.point)
|
||||
// .anchor( 0.5f, 0.5f )
|
||||
// .rotate( pointData.angle);
|
||||
// if ( TextUtils.isEmpty( markerRes ) ) {
|
||||
// options.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.blue ) );
|
||||
// }else {
|
||||
// options.resName( markerRes );
|
||||
// }
|
||||
// IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( TAG, options );
|
||||
// if ( TextUtils.isEmpty( markerRes ) ) {
|
||||
// markerRes = marker.getMarkerResName();
|
||||
// }
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
pointData.move();
|
||||
}
|
||||
|
||||
private void showSpeed(SpeedData data){
|
||||
if ( data == null ) {
|
||||
return;
|
||||
}
|
||||
data.showSpeed();
|
||||
}
|
||||
|
||||
private final Map< String, ADASRecognizedResult > mLastPositions = new ConcurrentHashMap<>();
|
||||
@@ -173,8 +154,13 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
mAdasRecognizedMarkersCaches = newAdasRecognizedMarkersCaches;
|
||||
}
|
||||
|
||||
private final Map< String, Boolean > isMatchStatusCache = new ArrayMap<>();
|
||||
private final Map< String, Boolean > mIsMatchStatusCache = new ArrayMap<>();
|
||||
|
||||
/**
|
||||
* 绘制某个物体的一个数据
|
||||
* @param recognizedListResult
|
||||
* @param newAdasRecognizedMarkersCaches
|
||||
*/
|
||||
private void renderAdasOneFrame( ADASRecognizedResult recognizedListResult, Map< String, IMogoMarker > newAdasRecognizedMarkersCaches ) {
|
||||
// 暂时只显示车辆
|
||||
if ( !isCarType( recognizedListResult.type ) ) {
|
||||
@@ -191,7 +177,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
recognizedListResult.heading,
|
||||
true
|
||||
);
|
||||
Boolean isMatch = isMatchStatusCache.get( uniqueKey );
|
||||
Boolean isMatch = mIsMatchStatusCache.get( uniqueKey );
|
||||
if ( matchedPoint != null ) {
|
||||
if ( ( isMatch == null || !isMatch ) ) {
|
||||
if ( matchedPoint[2] < 0.5 ) {
|
||||
@@ -205,7 +191,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
if ( isMatch == null ) {
|
||||
isMatch = false;
|
||||
}
|
||||
isMatchStatusCache.put( uniqueKey, isMatch );
|
||||
mIsMatchStatusCache.put( uniqueKey, isMatch );
|
||||
|
||||
if ( isMatch ) {
|
||||
recognizedListResult.lon = matchedPoint[0];
|
||||
@@ -229,22 +215,22 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
MogoLatLng lastPoint = new MogoLatLng( lastPosition.lat, lastPosition.lon );
|
||||
lastPoint.setTime( lastPosition.satelliteTime );
|
||||
endLatLon.setTime( recognizedListResult.satelliteTime );
|
||||
PointData endPoint = new PointData();
|
||||
MovingPoint endPoint = new MovingPoint();
|
||||
endPoint.point = endLatLon;
|
||||
endPoint.marker = marker;
|
||||
endPoint.angle = ( float ) recognizedListResult.heading;
|
||||
|
||||
PointData startPoint = new PointData();
|
||||
MovingPoint startPoint = new MovingPoint();
|
||||
startPoint.point = lastPoint;
|
||||
startPoint.marker = marker;
|
||||
startPoint.angle = ( float ) lastPosition.heading;
|
||||
List< PointData > points = interpolate( startPoint, endPoint, 30, interval );
|
||||
List< MovingPoint > points = interpolate( startPoint, endPoint, 30, interval );
|
||||
Message msg = new Message();
|
||||
SettingData obj = new SettingData();
|
||||
MovingPoints obj = new MovingPoints();
|
||||
obj.points = points;
|
||||
msg.obj = obj;
|
||||
msg.what = MSG_POINTS_SETTING;
|
||||
pointSettingHandler.sendMessage( msg );
|
||||
mPointSettingHandler.sendMessage( msg );
|
||||
// marker.startSmoothInMs( points, interval );
|
||||
// marker.addDynamicAnchorPosition( endLatLon, interval );
|
||||
Logger.d( TAG, "anim duration: %s, points size = %s", interval, points.size() );
|
||||
@@ -259,7 +245,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer {
|
||||
obj.speed = recognizedListResult.speed;
|
||||
msg.obj = obj;
|
||||
msg.what = MSG_SET_SPEED;
|
||||
pointSettingHandler.sendMessage( msg );
|
||||
mPointSettingHandler.sendMessage( msg );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,10 +6,10 @@ import android.graphics.Typeface;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
@@ -127,23 +127,29 @@ class BaseDrawer {
|
||||
mogoMarker.hideInfoWindow();
|
||||
return;
|
||||
}
|
||||
if ( speed > 0 ) {
|
||||
int speedIntVal = ( int ) ( speed * 3.6 );
|
||||
if ( speedIntVal <= 0 ) {
|
||||
mogoMarker.hideInfoWindow();
|
||||
return;
|
||||
}
|
||||
String speedVal = speedIntVal + "";
|
||||
String infoResName = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getMarkerInfoResName( speedVal );
|
||||
if ( TextUtils.isEmpty( infoResName ) ) {
|
||||
if ( mSpeedView == null ) {
|
||||
mSpeedView = new TextView( context );
|
||||
mSpeedView.setTextColor( Color.WHITE );
|
||||
mSpeedView.setTypeface( Typeface.defaultFromStyle( Typeface.BOLD ) );
|
||||
// mSpeedView.setShadowLayer( 10f, 5F, 5F, Color.BLACK );
|
||||
mSpeedView.setLayoutParams( new ViewGroup.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT ) );
|
||||
}
|
||||
mSpeedView.setText( String.valueOf( ( ( int ) ( speed * 3.6 ) ) ) );
|
||||
mSpeedView.setText( speedVal );
|
||||
mogoMarker.setInfoWindowOffset( 0, 20 );
|
||||
mogoMarker.updateInfoWindowView( mSpeedView );
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().setMarkerInfoResName( speedVal, mogoMarker.getMarkerInfoResName() );
|
||||
} else {
|
||||
mogoMarker.hideInfoWindow();
|
||||
mogoMarker.updateInfoWindowView( infoResName );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 移除markers
|
||||
*
|
||||
@@ -194,11 +200,14 @@ class BaseDrawer {
|
||||
* @return
|
||||
*/
|
||||
public double[] matchRoad( double lon, double lat, double angle, boolean isRtk ) {
|
||||
return MogoApisHandler.getInstance()
|
||||
final long start = System.currentTimeMillis();
|
||||
double[] matchRoad = MogoApisHandler.getInstance()
|
||||
.getApis()
|
||||
.getMapServiceApi()
|
||||
.getMapUIController()
|
||||
.matchRoad( lon, lat, angle, true, isRtk );
|
||||
Log.i("timer-matchRoad", "cost " + (System.currentTimeMillis() - start) + "ms");
|
||||
return matchRoad;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,12 +237,12 @@ class BaseDrawer {
|
||||
* @param frameInterval
|
||||
* @return
|
||||
*/
|
||||
public static List< PointData > interpolate( PointData start, PointData end, long frameInterval, long duration ) {
|
||||
public static List< MovingPoint > interpolate( MovingPoint start, MovingPoint end, long frameInterval, long duration ) {
|
||||
if ( start == null || end == null ) {
|
||||
return null;
|
||||
}
|
||||
int interpolateFrame = ( int ) ( duration / frameInterval ) - 1;
|
||||
List< PointData > arrayList = new ArrayList<>();
|
||||
List< MovingPoint > 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 );
|
||||
@@ -245,7 +254,7 @@ class BaseDrawer {
|
||||
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();
|
||||
MovingPoint pd = new MovingPoint();
|
||||
pd.point = new MogoLatLng( lat, lon );
|
||||
pd.angle = ( float ) _angle;
|
||||
pd.marker = start.marker;
|
||||
@@ -259,24 +268,32 @@ class BaseDrawer {
|
||||
/**
|
||||
* marker 单个点移动的对象
|
||||
*/
|
||||
public static class PointData {
|
||||
public static class MovingPoint {
|
||||
|
||||
public MogoLatLng point;
|
||||
public float angle;
|
||||
public IMogoMarker marker;
|
||||
|
||||
public void move() {
|
||||
marker.setRotateAngle( angle );
|
||||
marker.setPosition( point.lat, point.lon );
|
||||
try {
|
||||
marker.setRotateAngle( angle );
|
||||
marker.setPosition( point.lat, point.lon );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* marker 平滑移动的对象
|
||||
*/
|
||||
public static class SettingData {
|
||||
public List< PointData > points;
|
||||
public static class MovingPoints {
|
||||
public List< MovingPoint > points;
|
||||
}
|
||||
|
||||
/**
|
||||
* 速度显示对象
|
||||
*/
|
||||
public class SpeedData {
|
||||
|
||||
public IMogoMarker marker;
|
||||
|
||||
@@ -4,7 +4,6 @@ import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.os.SystemClock;
|
||||
import android.text.TextUtils;
|
||||
import android.util.ArrayMap;
|
||||
|
||||
@@ -44,12 +43,12 @@ public class SimpleHandlerThreadPool {
|
||||
public void handleMessage( Message msg ) {
|
||||
super.handleMessage( msg );
|
||||
if ( msg.what == MSG_POINTS_SETTING ) {
|
||||
if ( msg.obj instanceof BaseDrawer.SettingData) {
|
||||
startSettingPointLooper( ( (BaseDrawer.SettingData) msg.obj ) );
|
||||
if ( msg.obj instanceof BaseDrawer.MovingPoints ) {
|
||||
startSettingPointLooper( ( ( BaseDrawer.MovingPoints ) msg.obj ) );
|
||||
}
|
||||
} else if ( msg.what == MSG_SET_POINT ) {
|
||||
if ( msg.obj instanceof BaseDrawer.PointData) {
|
||||
moveMarker( ( (BaseDrawer.PointData) msg.obj ) );
|
||||
if ( msg.obj instanceof BaseDrawer.MovingPoint ) {
|
||||
moveMarker( ( ( BaseDrawer.MovingPoint ) msg.obj ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,8 +60,8 @@ public class SimpleHandlerThreadPool {
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
private void startSettingPointLooper( BaseDrawer.SettingData data ) {
|
||||
List<BaseDrawer.PointData> points = data.points;
|
||||
private void startSettingPointLooper( BaseDrawer.MovingPoints data ) {
|
||||
List< BaseDrawer.MovingPoint > points = data.points;
|
||||
for ( int i = 0; i < points.size(); i++ ) {
|
||||
Message msg = Message.obtain();
|
||||
msg.what = MSG_SET_POINT;
|
||||
@@ -76,7 +75,7 @@ public class SimpleHandlerThreadPool {
|
||||
*
|
||||
* @param pointData
|
||||
*/
|
||||
private void moveMarker( BaseDrawer.PointData pointData ) {
|
||||
private void moveMarker( BaseDrawer.MovingPoint pointData ) {
|
||||
if ( pointData == null ) {
|
||||
return;
|
||||
}
|
||||
@@ -227,18 +226,18 @@ public class SimpleHandlerThreadPool {
|
||||
MogoLatLng lastPoint = new MogoLatLng( lastPosition.getWgslat(), lastPosition.getWgslon() );
|
||||
lastPoint.setTime( lastPosition.getSatelliteTime() );
|
||||
endLatLon.setTime( cloudRoadData.getSatelliteTime() );
|
||||
BaseDrawer.PointData endPoint = new BaseDrawer.PointData();
|
||||
BaseDrawer.MovingPoint endPoint = new BaseDrawer.MovingPoint();
|
||||
endPoint.point = endLatLon;
|
||||
endPoint.marker = marker;
|
||||
endPoint.angle = ( float ) cloudRoadData.getHeading();
|
||||
|
||||
BaseDrawer.PointData startPoint = new BaseDrawer.PointData();
|
||||
BaseDrawer.MovingPoint startPoint = new BaseDrawer.MovingPoint();
|
||||
startPoint.point = lastPoint;
|
||||
startPoint.marker = marker;
|
||||
startPoint.angle = ( float ) lastPosition.getHeading();
|
||||
List<BaseDrawer.PointData> points = BaseDrawer.interpolate( startPoint, endPoint, 30, interval );
|
||||
List< BaseDrawer.MovingPoint > points = BaseDrawer.interpolate( startPoint, endPoint, 30, interval );
|
||||
Message msg = new Message();
|
||||
BaseDrawer.SettingData obj = new BaseDrawer.SettingData();
|
||||
BaseDrawer.MovingPoints obj = new BaseDrawer.MovingPoints();
|
||||
obj.points = points;
|
||||
msg.obj = obj;
|
||||
msg.what = MSG_POINTS_SETTING;
|
||||
|
||||
Reference in New Issue
Block a user