修改在线车辆刷新
This commit is contained in:
34905
libraries/map-custom/src/main/assets/20201105_1.csv
Normal file
34905
libraries/map-custom/src/main/assets/20201105_1.csv
Normal file
File diff suppressed because it is too large
Load Diff
@@ -15,6 +15,7 @@ import com.mogo.commons.debug.DebugConfig;
|
|||||||
import com.mogo.map.IMogoMap;
|
import com.mogo.map.IMogoMap;
|
||||||
import com.mogo.map.IMogoMapView;
|
import com.mogo.map.IMogoMapView;
|
||||||
import com.mogo.map.MogoLatLng;
|
import com.mogo.map.MogoLatLng;
|
||||||
|
import com.mogo.map.impl.custom.location.GpsTester;
|
||||||
import com.mogo.map.impl.custom.navi.NaviClient;
|
import com.mogo.map.impl.custom.navi.NaviClient;
|
||||||
import com.mogo.map.impl.custom.utils.MogoMapUtils;
|
import com.mogo.map.impl.custom.utils.MogoMapUtils;
|
||||||
import com.mogo.map.impl.custom.utils.ObjectUtils;
|
import com.mogo.map.impl.custom.utils.ObjectUtils;
|
||||||
@@ -76,7 +77,7 @@ public class AMapViewWrapper implements IMogoMapView,
|
|||||||
|
|
||||||
private float mDefaultZoomLevel = 16.0f;
|
private float mDefaultZoomLevel = 16.0f;
|
||||||
private final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder()
|
private final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder()
|
||||||
.carCursorRes( R.drawable.map_custom_ic_current_location2 )
|
.carCursorRes( R.drawable.map_api_ic_current_location2 )
|
||||||
.naviCursorRes( R.drawable.ic_amap_navi_cursor )
|
.naviCursorRes( R.drawable.ic_amap_navi_cursor )
|
||||||
.build();
|
.build();
|
||||||
private CarCursorOption mCarCursorOption = DEFAULT_OPTION;
|
private CarCursorOption mCarCursorOption = DEFAULT_OPTION;
|
||||||
@@ -88,6 +89,9 @@ public class AMapViewWrapper implements IMogoMapView,
|
|||||||
startTime = System.currentTimeMillis();
|
startTime = System.currentTimeMillis();
|
||||||
Logger.i( TAG, "autoop--AMapViewWrapper: init" );
|
Logger.i( TAG, "autoop--AMapViewWrapper: init" );
|
||||||
this.mMapView = mMapView;
|
this.mMapView = mMapView;
|
||||||
|
if ( DebugConfig.isDebug() ) {
|
||||||
|
GpsTester.getInstance().init( mMapView );
|
||||||
|
}
|
||||||
initListeners();
|
initListeners();
|
||||||
this.mIMap = new AMapWrapper( this.mMapView.getMapAutoViewHelper(), this.mMapView, this );
|
this.mIMap = new AMapWrapper( this.mMapView.getMapAutoViewHelper(), this.mMapView, this );
|
||||||
}
|
}
|
||||||
@@ -787,4 +791,9 @@ public class AMapViewWrapper implements IMogoMapView,
|
|||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void testGpsData() {
|
||||||
|
GpsTester.getInstance().testGpsData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ class CustomMapApiBuilder implements IMogoMapApiBuilder {
|
|||||||
.setDebugMode( true )
|
.setDebugMode( true )
|
||||||
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
|
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
|
||||||
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
|
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
|
||||||
|
.setCachePath( "sdcard/tiles" )
|
||||||
.setZoom( 16 )
|
.setZoom( 16 )
|
||||||
.setPointToCenter( 0.734375f, 0.5f )
|
.setPointToCenter( 0.734375f, 0.5f )
|
||||||
.setStyleMode( MapParams.MAP_STYLE_NIGHT ), NavParams.Companion.init() );
|
.setStyleMode( MapParams.MAP_STYLE_NIGHT ), NavParams.Companion.init() );
|
||||||
|
|||||||
@@ -0,0 +1,171 @@
|
|||||||
|
package com.mogo.map.impl.custom.location;
|
||||||
|
|
||||||
|
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.view.TextureView;
|
||||||
|
|
||||||
|
import com.zhidaoauto.map.sdk.open.location.MogoLocation;
|
||||||
|
import com.zhidaoauto.map.sdk.open.view.MapAutoView;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
public
|
||||||
|
/**
|
||||||
|
* @author congtaowang
|
||||||
|
* @since 2020/12/22
|
||||||
|
*
|
||||||
|
* 描述
|
||||||
|
*/
|
||||||
|
class GpsTester {
|
||||||
|
|
||||||
|
private static volatile GpsTester sInstance;
|
||||||
|
private MapAutoView mMapAutoView;
|
||||||
|
|
||||||
|
private GpsTester() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GpsTester getInstance() {
|
||||||
|
if ( sInstance == null ) {
|
||||||
|
synchronized ( GpsTester.class ) {
|
||||||
|
if ( sInstance == null ) {
|
||||||
|
sInstance = new GpsTester();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized void release() {
|
||||||
|
sInstance = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object readResolve() {
|
||||||
|
// 阻止反序列化,必须实现 Serializable 接口
|
||||||
|
return sInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init( MapAutoView view ) {
|
||||||
|
mMapAutoView = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
private class GpsTestThreadHandler extends Handler {
|
||||||
|
|
||||||
|
public GpsTestThreadHandler( Looper looper ) {
|
||||||
|
super( looper );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMessage( Message msg ) {
|
||||||
|
super.handleMessage( msg );
|
||||||
|
switch ( msg.what ) {
|
||||||
|
case 1:
|
||||||
|
try {
|
||||||
|
prepareGpsData();
|
||||||
|
sendEmptyMessageDelayed( 2, 0 );
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
try {
|
||||||
|
readOneLineGpsDataAndSet2Map();
|
||||||
|
sendEmptyMessageDelayed( 2, 0 );
|
||||||
|
} catch ( Exception e ) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Handler mHandler = null;
|
||||||
|
private BufferedReader br = null;
|
||||||
|
private long mLastTime = 0;
|
||||||
|
private float mLastHeading = 0;
|
||||||
|
private int step = 0;
|
||||||
|
private MogoLocation mogoLocation = new MogoLocation();
|
||||||
|
|
||||||
|
public void testGpsData() {
|
||||||
|
if ( mHandler != null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final HandlerThread ht = new HandlerThread( "gps-test-thread" );
|
||||||
|
ht.start();
|
||||||
|
mHandler = new GpsTestThreadHandler( ht.getLooper() );
|
||||||
|
mMapAutoView.getLocationClient().setIsUseExtraGPSData( true );
|
||||||
|
mHandler.sendEmptyMessage( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepareGpsData() throws Exception {
|
||||||
|
InputStreamReader isr = new InputStreamReader( mMapAutoView.getContext().getAssets().open( "20201105_1.csv" ) );
|
||||||
|
br = new BufferedReader( isr );
|
||||||
|
}
|
||||||
|
|
||||||
|
private long readOneLineGpsDataAndSet2Map() throws Exception {
|
||||||
|
String line = br.readLine();
|
||||||
|
if ( TextUtils.isEmpty( line ) ) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int count = 0;
|
||||||
|
long duration = 3;
|
||||||
|
|
||||||
|
|
||||||
|
String datums[] = line.split( "," );
|
||||||
|
long time = Long.valueOf( datums[0] );
|
||||||
|
mogoLocation.setProvider( "GPS_SELF" );
|
||||||
|
mogoLocation.setLon( Double.valueOf( datums[1] ) );
|
||||||
|
mogoLocation.setLat( Double.valueOf( datums[2] ) );
|
||||||
|
float angle = Float.valueOf( datums[4] );
|
||||||
|
if ( mLastTime > 0 ) {
|
||||||
|
duration = time - mLastTime;
|
||||||
|
} else {
|
||||||
|
duration = 3;
|
||||||
|
}
|
||||||
|
mogoLocation.setDuration( mogoLocation.getDuration() + duration - 2 );
|
||||||
|
mLastTime = time;
|
||||||
|
float heading = angle;
|
||||||
|
if ( heading == -100f ) {
|
||||||
|
if ( mLastHeading != 400f ) {
|
||||||
|
heading = mLastHeading;
|
||||||
|
} else {
|
||||||
|
heading = 0f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if ( mLastHeading == 400f || Math.abs( mLastHeading - heading ) > 0.5f ) {
|
||||||
|
mLastHeading = heading;
|
||||||
|
} else {
|
||||||
|
heading = mLastHeading;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( heading < 40 ) {
|
||||||
|
mogoLocation.setHeading( heading + 4f );
|
||||||
|
} else {
|
||||||
|
mogoLocation.setHeading( heading );
|
||||||
|
}
|
||||||
|
|
||||||
|
step++;
|
||||||
|
if ( step >= 50 ) {
|
||||||
|
step = 0;
|
||||||
|
count++;
|
||||||
|
|
||||||
|
long realDuration = mogoLocation.getDuration() + 75;
|
||||||
|
realDuration = realDuration / 4;
|
||||||
|
mogoLocation.setDuration( realDuration );
|
||||||
|
mMapAutoView.getLocationClient().setExtraSelfGPSData( mogoLocation );
|
||||||
|
mogoLocation.setDuration( 0L );
|
||||||
|
|
||||||
|
return realDuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -237,4 +237,8 @@ public interface IMogoMapUIController {
|
|||||||
default void setAnchorRate( float rate ) {
|
default void setAnchorRate( float rate ) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default void testGpsData(){
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
|
import com.mogo.commons.debug.DebugConfig;
|
||||||
import com.mogo.map.MogoLatLng;
|
import com.mogo.map.MogoLatLng;
|
||||||
import com.mogo.map.location.MogoLocation;
|
import com.mogo.map.location.MogoLocation;
|
||||||
import com.mogo.map.search.geo.IMogoGeoSearch;
|
import com.mogo.map.search.geo.IMogoGeoSearch;
|
||||||
@@ -53,6 +54,10 @@ class OnlineCarSearchIntentHandler implements IntentHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void handle( Context context, Intent intent ) {
|
public void handle( Context context, Intent intent ) {
|
||||||
|
|
||||||
|
if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String command = intent.getStringExtra( MogoReceiver.PARAM_COMMAND );
|
String command = intent.getStringExtra( MogoReceiver.PARAM_COMMAND );
|
||||||
if ( TextUtils.isEmpty( command ) ) {
|
if ( TextUtils.isEmpty( command ) ) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.mogo.module.service.marker;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Rect;
|
import android.graphics.Rect;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.mogo.commons.AbsMogoApplication;
|
import com.mogo.commons.AbsMogoApplication;
|
||||||
import com.mogo.commons.debug.DebugConfig;
|
import com.mogo.commons.debug.DebugConfig;
|
||||||
@@ -574,6 +575,11 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
|||||||
int radius,
|
int radius,
|
||||||
boolean fitBounds ) {
|
boolean fitBounds ) {
|
||||||
|
|
||||||
|
if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
|
||||||
|
Logger.d( TAG, Log.getStackTraceString( new Throwable() ) );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ( DebugConfig.isDebug() ) {
|
if ( DebugConfig.isDebug() ) {
|
||||||
if ( !DebugConfig.isRequestOnlineCarData() ) {
|
if ( !DebugConfig.isRequestOnlineCarData() ) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user