Merge remote-tracking branch 'origin/demo/shunyi_vr_map' into demo/shunyi_vr_map
This commit is contained in:
@@ -55,7 +55,7 @@ dependencies {
|
||||
implementation project(':foudations:mogo-commons')
|
||||
}
|
||||
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-online-19'
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-online-21'
|
||||
}
|
||||
|
||||
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()
|
||||
|
||||
@@ -68,7 +68,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
|
||||
|
||||
private float mDefaultZoomLevel = 16.0f;
|
||||
private final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder()
|
||||
.carCursorRes( R.drawable.map_api_ic_current_location2 )
|
||||
.carCursorRes( R.drawable.map_custom_ic_current_location2 )
|
||||
.naviCursorRes( R.drawable.ic_amap_navi_cursor )
|
||||
.build();
|
||||
private CarCursorOption mCarCursorOption = DEFAULT_OPTION;
|
||||
|
||||
@@ -23,12 +23,14 @@ public class CustomMapView implements IMogoMapViewCreator {
|
||||
|
||||
@Override
|
||||
public IMogoMapView create( Context context ) {
|
||||
MapAutoApi.INSTANCE.init( context, MapParams.Companion.init().setDebugMode( true )
|
||||
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
|
||||
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
|
||||
.setZoom( 16 )
|
||||
.setPointToCenter( 0.5f, 0.5f )
|
||||
.setStyleMode( MapParams.MAP_STYLE_VR ) );
|
||||
if ( mapView == null ) {
|
||||
MapAutoApi.INSTANCE.init( context, MapParams.Companion.init().setDebugMode( false )
|
||||
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
|
||||
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
|
||||
.setZoom( 16 )
|
||||
.setPointToCenter( 0.5f, 0.5f )
|
||||
.setStyleMode( MapParams.MAP_STYLE_VR ) );
|
||||
}
|
||||
MapAutoView mapAutoView = new MapAutoView( context );
|
||||
mapView = new AMapViewWrapper( mapAutoView );
|
||||
return mapView;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
@@ -95,6 +95,16 @@ public class MogoMapView extends MogoBaseMapView implements ILifeCycle {
|
||||
mCustomMapView.getMapView().setVisibility( View.VISIBLE );
|
||||
mAMapView.onPause();
|
||||
mAMapView.getMapView().setVisibility( View.GONE );
|
||||
post( new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
mAMapView.getMap().getUIController().showMyLocation( true );
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public boolean isVrMode() {
|
||||
|
||||
@@ -7,4 +7,8 @@ import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||
interface IMachineVisionInterface {
|
||||
|
||||
oneway void postData(in MogoSnapshotSetData data);
|
||||
|
||||
oneway void hideViewIfExist();
|
||||
|
||||
oneway void showViewIfExist();
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.mogo.module.common.entity;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -11,11 +12,14 @@ import java.util.List;
|
||||
*/
|
||||
public class CloudRoadData implements Parcelable {
|
||||
/**物体类型*/
|
||||
private int type;
|
||||
private int type = -1;
|
||||
|
||||
private double lat;
|
||||
private double lon;
|
||||
|
||||
private String uuid;
|
||||
private String sn;
|
||||
|
||||
private double speed;
|
||||
|
||||
private long systemTime;
|
||||
@@ -29,53 +33,9 @@ public class CloudRoadData implements Parcelable {
|
||||
|
||||
private double distance ;//距离
|
||||
|
||||
public List<CloudLocationInfo> coordinates;
|
||||
private List<CloudLocationInfo> coordinates;
|
||||
|
||||
|
||||
protected CloudRoadData(Parcel in) {
|
||||
type = in.readInt();
|
||||
lat = in.readDouble();
|
||||
lon = in.readDouble();
|
||||
speed = in.readDouble();
|
||||
systemTime = in.readLong();
|
||||
lightStatus = in.readInt();
|
||||
lightLeftTime = in.readInt();
|
||||
rtmpUrl = in.readString();
|
||||
distance = in.readDouble();
|
||||
coordinates = in.createTypedArrayList(CloudLocationInfo.CREATOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(type);
|
||||
dest.writeDouble(lat);
|
||||
dest.writeDouble(lon);
|
||||
dest.writeDouble(speed);
|
||||
dest.writeLong(systemTime);
|
||||
dest.writeInt(lightStatus);
|
||||
dest.writeInt(lightLeftTime);
|
||||
dest.writeString(rtmpUrl);
|
||||
dest.writeDouble(distance);
|
||||
dest.writeTypedList(coordinates);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static final Creator<CloudRoadData> CREATOR = new Creator<CloudRoadData>() {
|
||||
@Override
|
||||
public CloudRoadData createFromParcel(Parcel in) {
|
||||
return new CloudRoadData(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudRoadData[] newArray(int size) {
|
||||
return new CloudRoadData[size];
|
||||
}
|
||||
};
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
@@ -155,4 +115,70 @@ public class CloudRoadData implements Parcelable {
|
||||
public void setCoordinates(List<CloudLocationInfo> coordinates) {
|
||||
this.coordinates = coordinates;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getSn() {
|
||||
return sn;
|
||||
}
|
||||
|
||||
public String getUniqueKey(){
|
||||
if (! TextUtils.isEmpty( uuid ) ) {
|
||||
return uuid;
|
||||
}
|
||||
return sn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel( Parcel dest, int flags ) {
|
||||
dest.writeInt( this.type );
|
||||
dest.writeDouble( this.lat );
|
||||
dest.writeDouble( this.lon );
|
||||
dest.writeString( this.uuid );
|
||||
dest.writeString( this.sn );
|
||||
dest.writeDouble( this.speed );
|
||||
dest.writeLong( this.systemTime );
|
||||
dest.writeInt( this.lightStatus );
|
||||
dest.writeInt( this.lightLeftTime );
|
||||
dest.writeString( this.rtmpUrl );
|
||||
dest.writeDouble( this.distance );
|
||||
dest.writeTypedList( this.coordinates );
|
||||
}
|
||||
|
||||
public CloudRoadData() {
|
||||
}
|
||||
|
||||
protected CloudRoadData( Parcel in ) {
|
||||
this.type = in.readInt();
|
||||
this.lat = in.readDouble();
|
||||
this.lon = in.readDouble();
|
||||
this.uuid = in.readString();
|
||||
this.sn = in.readString();
|
||||
this.speed = in.readDouble();
|
||||
this.systemTime = in.readLong();
|
||||
this.lightStatus = in.readInt();
|
||||
this.lightLeftTime = in.readInt();
|
||||
this.rtmpUrl = in.readString();
|
||||
this.distance = in.readDouble();
|
||||
this.coordinates = in.createTypedArrayList( CloudLocationInfo.CREATOR );
|
||||
}
|
||||
|
||||
public static final Creator< CloudRoadData > CREATOR = new Creator< CloudRoadData >() {
|
||||
@Override
|
||||
public CloudRoadData createFromParcel( Parcel source ) {
|
||||
return new CloudRoadData( source );
|
||||
}
|
||||
|
||||
@Override
|
||||
public CloudRoadData[] newArray( int size ) {
|
||||
return new CloudRoadData[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -96,6 +96,7 @@ public class MogoServiceProvider implements IMogoModuleProvider {
|
||||
public void init( Context context ) {
|
||||
Logger.d( TAG, "init" );
|
||||
MarkerServiceHandler.init( context );
|
||||
MogoServices.getInstance().preInit( context );
|
||||
UiThreadHandler.postDelayed( () -> {
|
||||
MogoServices.getInstance().init( AbsMogoApplication.getApp() );
|
||||
}, 5_000L );
|
||||
|
||||
@@ -339,6 +339,7 @@ public class MogoServices implements IMogoMapListener,
|
||||
unregisterInternalUnWakeupWords();
|
||||
stopAutoRefreshStrategy();
|
||||
}
|
||||
VrModeController.getInstance().onMainPageResumeStatusChanged( resume );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -373,15 +374,14 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
};
|
||||
|
||||
public void init( Context context ) {
|
||||
public void preInit( Context context ) {
|
||||
mContext = context;
|
||||
|
||||
initWorkThread();
|
||||
|
||||
mRefreshModel = new RefreshModel( context );
|
||||
mMogoMapService = MarkerServiceHandler.getMapService();
|
||||
mUiController = mMogoMapService.getMapUIController();
|
||||
mNavi = mMogoMapService.getNavi( context );
|
||||
|
||||
mStatusManager = MarkerServiceHandler.getMogoStatusManager();
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.USER_INTERACTED, statusChangedListener );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.SEARCH_UI, statusChangedListener );
|
||||
@@ -390,6 +390,12 @@ public class MogoServices implements IMogoMapListener,
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.ACC_STATUS, statusChangedListener );
|
||||
mStatusManager.registerStatusChangedListener( ServiceConst.TYPE, StatusDescriptor.VR_MODE, statusChangedListener );
|
||||
mStatusManager.setAIAssistReady( TAG, AIAssist.getInstance( mContext ).hasFlush() );
|
||||
}
|
||||
|
||||
public void init( Context context ) {
|
||||
|
||||
|
||||
initWorkThread();
|
||||
|
||||
registerMogoReceiver( context );
|
||||
registerInternalUnWakeupWords();
|
||||
@@ -461,16 +467,17 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( lastCarLocation != null ) {
|
||||
locationResult = new LocationResult();
|
||||
locationResult.lastCoordinate = new CloudLocationInfo();
|
||||
locationResult.lastCoordinate.setAlt(lastCarLocation.getAltitude());
|
||||
locationResult.lastCoordinate.setHeading(lastCarLocation.getBearing());
|
||||
locationResult.lastCoordinate.setLat(lastCarLocation.getLatitude());
|
||||
locationResult.lastCoordinate.setLon(lastCarLocation.getLongitude());
|
||||
locationResult.lastCoordinate.setSatelliteTime(lastCarLocation.getTime());
|
||||
locationResult.lastCoordinate.setSystemTime(System.currentTimeMillis());
|
||||
locationResult.lastCoordinate.setSpeed(lastCarLocation.getSpeed());
|
||||
locationResult.lastCoordinate.setAlt( lastCarLocation.getAltitude() );
|
||||
locationResult.lastCoordinate.setHeading( lastCarLocation.getBearing() );
|
||||
locationResult.lastCoordinate.setLat( lastCarLocation.getLatitude() );
|
||||
locationResult.lastCoordinate.setLon( lastCarLocation.getLongitude() );
|
||||
locationResult.lastCoordinate.setSatelliteTime( lastCarLocation.getTime() );
|
||||
locationResult.lastCoordinate.setSystemTime( System.currentTimeMillis() );
|
||||
locationResult.lastCoordinate.setSpeed( lastCarLocation.getSpeed() );
|
||||
locationResult.coordinates = new ArrayList<>();
|
||||
locationResult.sn = com.mogo.commons.network.Utils.getSn();
|
||||
locationResult.mortonCode = MortonCode.wrapEncodeMorton( locationResult.lastCoordinate.getLon(), locationResult.lastCoordinate.getLat() );
|
||||
locationResult.coordinates.add( locationResult.lastCoordinate );
|
||||
}
|
||||
List< ADASRecognizedResult > recognizedResults = MarkerServiceHandler.getADASController().getLastADASRecognizedResult();
|
||||
OnePerSecondSendContent content = new OnePerSecondSendContent();
|
||||
|
||||
@@ -228,4 +228,14 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final long INTERVAL_SEND_CAR_LOCATION_AND_ADAS_RECOGNIZED_RESULT_2_SERVER = 1 * 1_000L;
|
||||
|
||||
/**
|
||||
* adas识别数据
|
||||
*/
|
||||
public static final String TYPE_MARKER_ADAS = "TYPE_MARKER_ADAS";
|
||||
|
||||
/**
|
||||
* 云端下发数据
|
||||
*/
|
||||
public static final String TYPE_MARKER_CLOUD_DATA = "TYPE_MARKER_CLOUD_DATA";
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedListResult;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/28
|
||||
*
|
||||
* 绘制adas近景识别到的车辆
|
||||
*/
|
||||
class AdasRecognizedResultDrawer {
|
||||
|
||||
private static volatile AdasRecognizedResultDrawer sInstance;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private AdasRecognizedResultDrawer() {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
}
|
||||
|
||||
public static AdasRecognizedResultDrawer getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( AdasRecognizedResultDrawer.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new AdasRecognizedResultDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
// adas marker 缓存
|
||||
private Map< String, IMogoMarker > mAdasRecognizedMarkersCaches = new ConcurrentHashMap<>();
|
||||
|
||||
public void renderAdasRecognizedResult( List< ADASRecognizedListResult > resultList ) {
|
||||
if ( resultList == null || resultList.isEmpty() ) {
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers( ServiceConst.TYPE_MARKER_ADAS );
|
||||
return;
|
||||
}
|
||||
purgeAdasRecognizedData( resultList );
|
||||
for ( ADASRecognizedListResult recognizedListResult : resultList ) {
|
||||
if ( recognizedListResult == null ) {
|
||||
continue;
|
||||
}
|
||||
IMogoMarker marker = null;
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
if ( mAdasRecognizedMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
marker = mAdasRecognizedMarkersCaches.get( uniqueKey );
|
||||
}
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawAdasRecognizedDataMarker( recognizedListResult );
|
||||
mAdasRecognizedMarkersCaches.put( uniqueKey, marker );
|
||||
}
|
||||
|
||||
if ( recognizedListResult.latLonList != null
|
||||
|| recognizedListResult.latLonList.size() > 1 ) {
|
||||
List< MogoLatLng > points = new ArrayList<>();
|
||||
for ( int j = 0; j < recognizedListResult.latLonList.size(); j++ ) {
|
||||
ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( j );
|
||||
if ( latLon == null ) {
|
||||
continue;
|
||||
}
|
||||
points.add( new MogoLatLng( latLon.lat, latLon.lon ) );
|
||||
}
|
||||
if ( points.size() >= 1 ) {
|
||||
marker.startSmooth( points, 1000 );
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤adas数据中,不存在的 marker
|
||||
*
|
||||
* @param resultList
|
||||
*/
|
||||
private void purgeAdasRecognizedData( List< ADASRecognizedListResult > resultList ) {
|
||||
if ( resultList == null || resultList.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
if ( mAdasRecognizedMarkersCaches.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
Map< String, IMogoMarker > existMarker = new HashMap<>();
|
||||
for ( ADASRecognizedListResult recognizedListResult : resultList ) {
|
||||
if ( recognizedListResult == null ) {
|
||||
continue;
|
||||
}
|
||||
String uniqueKey = recognizedListResult.uuid;
|
||||
if ( mAdasRecognizedMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
existMarker.put( uniqueKey, mAdasRecognizedMarkersCaches.get( uniqueKey ) );
|
||||
}
|
||||
}
|
||||
if ( !existMarker.isEmpty() ) {
|
||||
for ( String key : mAdasRecognizedMarkersCaches.keySet() ) {
|
||||
if ( !existMarker.containsKey( key ) ) {
|
||||
try {
|
||||
IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( key );
|
||||
marker.destroy();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IMogoMarker drawAdasRecognizedDataMarker( ADASRecognizedListResult recognizedListResult ) {
|
||||
if ( recognizedListResult == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( recognizedListResult.type == AdasRecognizedType.classIdBackground ) {
|
||||
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner( ServiceConst.TYPE_MARKER_ADAS )
|
||||
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.map_custom_ic_current_location2 ) )
|
||||
.position( new MogoLatLng( recognizedListResult.latLonList.get( 0 ).lat, recognizedListResult.latLonList.get( 0 ).lon ) );
|
||||
return MarkerServiceHandler.getMapService().getMarkerManager( mContext ).addMarker( ModuleNames.CARD_TYPE_ROAD_CONDITION, options );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/27
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
class AdasRecognizedType {
|
||||
//背景
|
||||
public static final int classIdBackground = 0;
|
||||
//人
|
||||
public static final int classIdPerson = 1;
|
||||
//自行车
|
||||
public static final int classIdBicycle = 2;
|
||||
//小轿车
|
||||
public static final int classIdCar = 3;
|
||||
//摩托车
|
||||
public static final int classIdMoto = 4;
|
||||
//红绿灯
|
||||
public static final int classIdTrafficSign = 5;
|
||||
//bus
|
||||
public static final int classIdTrafficBus = 6;
|
||||
//track
|
||||
public static final int classIdTrafficTruck = 8;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Rect;
|
||||
import android.text.TextUtils;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
@@ -16,6 +17,8 @@ import com.mogo.map.marker.anim.OnMarkerAnimationListener;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.api.CallChatApi;
|
||||
import com.mogo.module.common.entity.CloudLocationInfo;
|
||||
import com.mogo.module.common.entity.CloudRoadData;
|
||||
import com.mogo.module.common.entity.MarkerCarPois;
|
||||
import com.mogo.module.common.entity.MarkerCardResult;
|
||||
import com.mogo.module.common.entity.MarkerExploreWay;
|
||||
@@ -35,6 +38,7 @@ import com.mogo.module.service.network.RefreshModel;
|
||||
import com.mogo.module.service.utils.ViewUtils;
|
||||
import com.mogo.module.service.vrmode.VrModeController;
|
||||
import com.mogo.service.adas.IMogoADASControlStatusChangedListener;
|
||||
import com.mogo.service.adas.entity.ADASRecognizedListResult;
|
||||
import com.mogo.service.connection.IMogoOnMessageListener;
|
||||
import com.mogo.service.connection.IMogoOnWebSocketMessageListener;
|
||||
import com.mogo.service.connection.WebSocketMsgType;
|
||||
@@ -53,6 +57,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
@@ -133,6 +138,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
} );
|
||||
|
||||
// 每隔一秒下发的数据
|
||||
MarkerServiceHandler.getApis().getWebSocketManagerApi( mContext )
|
||||
.registerOnWebSocketMessageListener( new IMogoOnWebSocketMessageListener< MogoSnapshotSetData >() {
|
||||
|
||||
@@ -156,6 +162,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
if ( data == null ) {
|
||||
return;
|
||||
}
|
||||
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data );
|
||||
VrModeController.getInstance().renderMogoSnapshotSetData( data );
|
||||
}
|
||||
|
||||
@@ -164,15 +171,17 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
}
|
||||
} );
|
||||
// adas 每隔一秒传递的数据
|
||||
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback( resultList -> {
|
||||
if ( resultList == null || resultList.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
// 绘制近景识别到的车辆,每秒绘制一次
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );
|
||||
} );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 地图上的Marker点击回调
|
||||
*/
|
||||
@@ -242,7 +251,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
updateCarUserInfoWindow( mogoMarker );
|
||||
} else {
|
||||
Object object = mogoMarker.getObject();
|
||||
if ( object != null ) {
|
||||
if ( object instanceof MarkerShowEntity ) {
|
||||
MarkerShowEntity markerShowEntity = ( MarkerShowEntity ) object;
|
||||
markerShowEntity.setChecked( true );
|
||||
IMarkerView markerView = MapMarkerAdapter.getMarkerView( mContext, markerShowEntity, mogoMarker.getMogoMarkerOptions() );
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.mogo.module.service.marker;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.MogoLatLng;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.MogoMarkerOptions;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.entity.CloudLocationInfo;
|
||||
import com.mogo.module.common.entity.CloudRoadData;
|
||||
import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.R;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/28
|
||||
*
|
||||
* 云端数据绘制
|
||||
*/
|
||||
class SnapshotSetDataDrawer {
|
||||
|
||||
private static volatile SnapshotSetDataDrawer sInstance;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private SnapshotSetDataDrawer() {
|
||||
mContext = AbsMogoApplication.getApp();
|
||||
}
|
||||
|
||||
public static SnapshotSetDataDrawer getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( SnapshotSetDataDrawer.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new SnapshotSetDataDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
// 云端 marker 缓存
|
||||
private Map< String, IMogoMarker > mCloudSnapshotMarkersCaches = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
* 其他车辆、rsu 车辆数据
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
public void renderSnapshotData( MogoSnapshotSetData data ) {
|
||||
if ( data == null || data.getAllList() == null || data.getAllList().isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
purgeCloudSnapshotData( data );
|
||||
for ( CloudRoadData cloudRoadData : data.getAllList() ) {
|
||||
if ( cloudRoadData == null ) {
|
||||
continue;
|
||||
}
|
||||
if ( cloudRoadData.getDistance() < 50 ) {
|
||||
// 过滤 adas 识别的车辆
|
||||
continue;
|
||||
}
|
||||
IMogoMarker marker = null;
|
||||
String uniqueKey = cloudRoadData.getUniqueKey();
|
||||
if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
marker = mCloudSnapshotMarkersCaches.get( uniqueKey );
|
||||
}
|
||||
if ( marker == null || marker.isDestroyed() ) {
|
||||
marker = drawSnapshotDataMarker( cloudRoadData );
|
||||
mCloudSnapshotMarkersCaches.put( uniqueKey, marker );
|
||||
}
|
||||
if ( cloudRoadData.getCoordinates() != null
|
||||
|| cloudRoadData.getCoordinates().size() > 1 ) {
|
||||
List< MogoLatLng > points = new ArrayList<>();
|
||||
for ( int j = 0; j < cloudRoadData.getCoordinates().size(); j++ ) {
|
||||
CloudLocationInfo poi = cloudRoadData.getCoordinates().get( j );
|
||||
if ( poi == null ) {
|
||||
continue;
|
||||
}
|
||||
double lat = poi.getLat();
|
||||
double lng = poi.getLon();
|
||||
points.add( new MogoLatLng( lat, lng ) );
|
||||
}
|
||||
if ( points.size() >= 1 ) {
|
||||
marker.startSmooth( points, 1000 );
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤本次数据中,不存在的 marker
|
||||
*
|
||||
* @param data
|
||||
*/
|
||||
private void purgeCloudSnapshotData( MogoSnapshotSetData data ) {
|
||||
if ( data == null || data.getAllList() == null || data.getAllList().isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
if ( mCloudSnapshotMarkersCaches.isEmpty() ) {
|
||||
return;
|
||||
}
|
||||
Map< String, IMogoMarker > existMarker = new HashMap<>();
|
||||
for ( CloudRoadData cloudRoadData : data.getAllList() ) {
|
||||
if ( cloudRoadData == null ) {
|
||||
continue;
|
||||
}
|
||||
String uniqueKey = cloudRoadData.getUniqueKey();
|
||||
if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) {
|
||||
existMarker.put( uniqueKey, mCloudSnapshotMarkersCaches.get( uniqueKey ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !existMarker.isEmpty() ) {
|
||||
for ( String key : mCloudSnapshotMarkersCaches.keySet() ) {
|
||||
if ( !existMarker.containsKey( key ) ) {
|
||||
try {
|
||||
IMogoMarker marker = mCloudSnapshotMarkersCaches.remove( key );
|
||||
marker.destroy();
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IMogoMarker drawSnapshotDataMarker( CloudRoadData data ) {
|
||||
if ( data == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( data.getType() == AdasRecognizedType.classIdBackground ) {
|
||||
|
||||
}
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.owner( ServiceConst.TYPE_MARKER_CLOUD_DATA )
|
||||
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.map_custom_ic_current_location2 ) )
|
||||
.position( new MogoLatLng( data.getLat(), data.getLon() ) );
|
||||
return MarkerServiceHandler.getMapService().getMarkerManager( mContext ).addMarker( ModuleNames.CARD_TYPE_ROAD_CONDITION, options );
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.mogo.module.service.MogoServices;
|
||||
import com.mogo.service.MogoServicePaths;
|
||||
import com.mogo.service.strategy.IMogoRefreshStrategyController;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
@@ -16,9 +17,15 @@ import com.mogo.service.strategy.IMogoRefreshStrategyController;
|
||||
@Route( path = MogoServicePaths.PATH_REFRESH_STRATEGY_API )
|
||||
public class MogoRefreshStrategyController implements IMogoRefreshStrategyController {
|
||||
|
||||
private static final String TAG = "MogoRefreshStrategyController";
|
||||
|
||||
@Override
|
||||
public void restartAutoRefreshAtTime( int delay ) {
|
||||
MogoServices.getInstance().restartAutoRefreshAtTime( delay );
|
||||
try {
|
||||
MogoServices.getInstance().restartAutoRefreshAtTime( delay );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e(TAG, e, "restartAutoRefreshAtTime");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||
@@ -93,6 +94,24 @@ class VrModeController {
|
||||
}
|
||||
}
|
||||
|
||||
public void onMainPageResumeStatusChanged( boolean isResume ) {
|
||||
if ( mMachineVisionInterface != null ) {
|
||||
if ( isResume ) {
|
||||
try {
|
||||
mMachineVisionInterface.showViewIfExist();
|
||||
} catch ( RemoteException e ) {
|
||||
Logger.e( TAG, e, "onMainPageResumeStatusChanged" );
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
mMachineVisionInterface.hideViewIfExist();
|
||||
} catch ( RemoteException e ) {
|
||||
Logger.e( TAG, e, "onMainPageResumeStatusChanged" );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void renderMogoSnapshotSetData( MogoSnapshotSetData data ) {
|
||||
if ( data == null ) {
|
||||
return;
|
||||
|
||||
@@ -6,6 +6,8 @@ import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -13,6 +15,7 @@ import androidx.annotation.Nullable;
|
||||
import com.mogo.module.common.entity.MogoSnapshotSetData;
|
||||
import com.mogo.module.common.machinevision.IMachineVisionInterface;
|
||||
import com.mogo.module.common.wm.WindowManagerView;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
public
|
||||
@@ -29,6 +32,7 @@ class MachineVisionMapService extends Service {
|
||||
private IBinder mBinder;
|
||||
|
||||
private WindowManagerView mMachineVisionMapViewManager;
|
||||
private View mRootView;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -80,14 +84,38 @@ class MachineVisionMapService extends Service {
|
||||
public boolean unlinkToDeath( @NonNull DeathRecipient recipient, int flags ) {
|
||||
return super.unlinkToDeath( recipient, flags );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideViewIfExist() throws RemoteException {
|
||||
if ( mRootView != null ) {
|
||||
Logger.d( TAG, "hideViewIfExist" );
|
||||
UiThreadHandler.post( () -> {
|
||||
if ( mRootView != null ) {
|
||||
mRootView.setVisibility( View.GONE );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showViewIfExist() throws RemoteException {
|
||||
if ( mRootView != null ) {
|
||||
Logger.d( TAG, "showViewIfExist" );
|
||||
UiThreadHandler.post( () -> {
|
||||
if ( mRootView != null ) {
|
||||
mRootView.setVisibility( View.VISIBLE );
|
||||
}
|
||||
} );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addMachineVisionMapView() {
|
||||
mMachineVisionMapViewManager = new WindowManagerView.Builder( getApplicationContext() )
|
||||
.contentView( R.layout.module_mvision_layout_view )
|
||||
.size(
|
||||
getResources().getDimensionPixelOffset( R.dimen.module_mvision_view_width ),
|
||||
getResources().getDimensionPixelOffset( R.dimen.module_mvision_view_height )
|
||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
||||
WindowManager.LayoutParams.WRAP_CONTENT
|
||||
)
|
||||
.position(
|
||||
getResources().getDimensionPixelOffset( R.dimen.module_mvision_view_x ),
|
||||
@@ -95,7 +123,7 @@ class MachineVisionMapService extends Service {
|
||||
)
|
||||
.gravity( Gravity.TOP | Gravity.LEFT )
|
||||
.showInWindowManager();
|
||||
|
||||
mRootView = mMachineVisionMapViewManager.findViewById( R.id.module_mvision_map_root );
|
||||
MachineVisionMapViewHandler.getInstance().setMachineVisionMapView( mMachineVisionMapViewManager.findViewById( R.id.module_mvision_map_view ) );
|
||||
mMachineVisionMapViewManager.show();
|
||||
}
|
||||
@@ -103,8 +131,10 @@ class MachineVisionMapService extends Service {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
MachineVisionMapViewHandler.getInstance().release();
|
||||
if ( mMachineVisionMapViewManager != null ) {
|
||||
mMachineVisionMapViewManager.dismiss();
|
||||
mRootView = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import android.widget.FrameLayout;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.mogo.map.IMogoMapView;
|
||||
import com.mogo.map.MogoBaseMapView;
|
||||
import com.mogo.map.impl.custom.CustomMapView;
|
||||
import com.mogo.utils.logger.Logger;
|
||||
|
||||
@@ -20,7 +21,7 @@ public
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class MachineVisionMapView extends FrameLayout {
|
||||
class MachineVisionMapView extends MogoBaseMapView {
|
||||
|
||||
private static final String TAG = "MachineVisionMapView";
|
||||
|
||||
@@ -34,10 +35,10 @@ class MachineVisionMapView extends FrameLayout {
|
||||
|
||||
public MachineVisionMapView( Context context, @Nullable AttributeSet attrs, int defStyleAttr ) {
|
||||
super( context, attrs, defStyleAttr );
|
||||
addMapView();
|
||||
}
|
||||
|
||||
private void addMapView() {
|
||||
@Override
|
||||
protected void addDleMaps() {
|
||||
IMogoMapView machineMapView = new CustomMapView().create( getContext() );
|
||||
if ( machineMapView != null ) {
|
||||
final View mapView = machineMapView.getMapView();
|
||||
@@ -49,5 +50,24 @@ class MachineVisionMapView extends FrameLayout {
|
||||
} else {
|
||||
Logger.e( TAG, "create IMogoMapView instance failed." );
|
||||
}
|
||||
mMapView = machineMapView;
|
||||
onCreate( null );
|
||||
postDelayed( ()->{
|
||||
getMap().getUIController().showMyLocation( true );
|
||||
}, 5000 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void display2DMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayVRMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) {
|
||||
|
||||
}
|
||||
|
||||
private void addMapView() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,5 +50,6 @@ class MachineVisionMapViewHandler {
|
||||
if ( mMachineVisionMapView == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
android:id="@+id/module_mvision_map_root"
|
||||
android:layout_width="@dimen/module_mvision_view_width"
|
||||
android:layout_height="@dimen/module_mvision_view_height">
|
||||
|
||||
<com.mogo.module.machine.vision.MachineVisionMapView
|
||||
android:id="@+id/module_mvision_map_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_width="@dimen/module_mvision_view_width"
|
||||
android:layout_height="@dimen/module_mvision_view_height" />
|
||||
</FrameLayout>
|
||||
Reference in New Issue
Block a user