Merge remote-tracking branch 'origin/demo/shunyi_vr_map' into demo/shunyi_vr_map

This commit is contained in:
董宏宇
2020-10-29 14:21:20 +08:00
14 changed files with 147 additions and 40 deletions

View File

@@ -57,12 +57,22 @@ public class AbsMogoApplication extends Application {
public void onCreate() {
super.onCreate();
sApp = this;
initARouter();
if ( shouldInit() ) {
init();
}
}
protected boolean shouldInit(){
private void initARouter() {
ARouter.init( sApp );
// 初始化 arouter
if ( DebugConfig.isDebug() ) {
ARouter.openDebug();
ARouter.openLog();
}
}
protected boolean shouldInit() {
return true;
}
@@ -72,31 +82,25 @@ public class AbsMogoApplication extends Application {
}
private void syncInit() {
// 初始化 arouter
if ( DebugConfig.isDebug() ) {
ARouter.openDebug();
ARouter.openLog();
}
ARouter.init( sApp );
TipToast.init( this, ( ( context, message, tipDrawable ) -> {
if ( TextUtils.isEmpty( message ) ) {
return null;
}
View contentView;
if(tipDrawable==null) {
contentView = LayoutInflater.from(context).inflate(R.layout.module_commons_layout_toast, null);
TextView txt = contentView.findViewById(R.id.module_commons_toast_msg);
txt.setText(message);
}else{
if ( tipDrawable == null ) {
contentView = LayoutInflater.from( context ).inflate( R.layout.module_commons_layout_toast, null );
TextView txt = contentView.findViewById( R.id.module_commons_toast_msg );
txt.setText( message );
} else {
// 有图片,使用带图片的布局,当前只实现了左侧图片
contentView = LayoutInflater.from(context).inflate(R.layout.module_commons_layout_toast_with_left_drawable, null);
TextView txt = contentView.findViewById(R.id.module_commons_toast_msg);
ImageView img = contentView.findViewById(R.id.module_commons_toast_left_drawable);
img.setImageDrawable(tipDrawable.getDrawable());
contentView = LayoutInflater.from( context ).inflate( R.layout.module_commons_layout_toast_with_left_drawable, null );
TextView txt = contentView.findViewById( R.id.module_commons_toast_msg );
ImageView img = contentView.findViewById( R.id.module_commons_toast_left_drawable );
img.setImageDrawable( tipDrawable.getDrawable() );
ViewGroup.LayoutParams params = img.getLayoutParams();
params.width = tipDrawable.getWidth();
params.height = tipDrawable.getHeight();
txt.setText(message);
txt.setText( message );
}
return contentView;
} ) );
@@ -133,7 +137,7 @@ public class AbsMogoApplication extends Application {
} );
}
protected void asyncInitImpl(){
protected void asyncInitImpl() {
}

View File

@@ -55,7 +55,7 @@ dependencies {
implementation project(':foudations:mogo-commons')
}
implementation 'com.zhidaoauto.machine:map:1.0.0-online-25'
implementation 'com.zhidaoauto.machine:map:1.0.0-online-26'
}
apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString()

View File

@@ -97,6 +97,7 @@ public class AMapViewWrapper implements IMogoMapView, IMogoMapUIController, Loca
// options.setRouteOverlayOptions( MapStyleUtils.getRouteOverlayOptions() );
// 设置自车的图片对象
options.setMyLocationStyle( options.getMyLocationStyle().myLocationIcon( DEFAULT_OPTION.getCarCursorRes() ) );
options.setAnchorScale(1.2f, 2 );
// 设置指南针图标否在导航界面显示默认显示。true显示false隐藏。
// options.hiddenDirection();
// 黑夜模式

View File

@@ -24,7 +24,7 @@ public class CustomMapView implements IMogoMapViewCreator {
@Override
public IMogoMapView create( Context context ) {
if ( mapView == null ) {
MapAutoApi.INSTANCE.init( context, MapParams.Companion.init().setDebugMode( false )
MapAutoApi.INSTANCE.init( context, MapParams.Companion.init().setDebugMode( true )
.setCoordinateType( MapParams.COORDINATETYPE_GCJ02 )
.setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D )
.setZoom( 16 )

View File

@@ -2,6 +2,7 @@ package com.mogo.module.common.drawer;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
@@ -72,6 +73,9 @@ class AdasRecognizedResultDrawer {
}
IMogoMarker marker = null;
String uniqueKey = recognizedListResult.uuid;
if ( TextUtils.isEmpty( uniqueKey ) ) {
continue;
}
if ( mAdasRecognizedMarkersCaches.containsKey( uniqueKey ) ) {
marker = mAdasRecognizedMarkersCaches.get( uniqueKey );
}
@@ -81,17 +85,19 @@ class AdasRecognizedResultDrawer {
}
List< MogoLatLng > points = new ArrayList<>();
MogoLatLng endLatLon = null;
if ( recognizedListResult.latLonList != null
|| recognizedListResult.latLonList.size() > 1 ) {
&& recognizedListResult.latLonList.size() > 1 ) {
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 ) );
points.add( endLatLon = new MogoLatLng( latLon.lat, latLon.lon ) );
}
} else {
} else if ( recognizedListResult.latLonList != null
&& recognizedListResult.latLonList.size() == 1 ) {
// 原来的点和新的点做一个数组进行平滑移动
MogoLatLng latLng = marker.getPosition();
ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( 0 );
@@ -99,7 +105,10 @@ class AdasRecognizedResultDrawer {
continue;
}
points.add( latLng );
points.add( new MogoLatLng( latLng.lat, latLon.lon ) );
points.add( endLatLon = new MogoLatLng( latLng.lat, latLon.lon ) );
}
if ( endLatLon != null ) {
marker.setPosition( endLatLon.lat, endLatLon.lon );
}
if ( points.size() >= 1 ) {
marker.startSmooth( points, 1 );
@@ -153,6 +162,7 @@ class AdasRecognizedResultDrawer {
}
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_ADAS )
.gps( true )
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.module_common_online_car_vr_middle ) )
.position( new MogoLatLng( recognizedListResult.latLonList.get( 0 ).lat, recognizedListResult.latLonList.get( 0 ).lon ) );
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options );

View File

@@ -77,10 +77,12 @@ class MarkerDrawer {
}
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).addMarker( markerShowEntity.getMarkerType(), options );
marker.setOwner( markerShowEntity.getMarkerType() );
markerView.setMarker( marker );
marker.setOnMarkerClickListener( listener );
markerShowEntity.setMarker( marker );
if ( marker != null ) {
marker.setOwner( markerShowEntity.getMarkerType() );
markerView.setMarker( marker );
marker.setOnMarkerClickListener( listener );
markerShowEntity.setMarker( marker );
}
return marker;
}

View File

@@ -2,6 +2,10 @@ package com.mogo.module.common.drawer;
import android.content.Context;
import android.graphics.BitmapFactory;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.mogo.commons.AbsMogoApplication;
import com.mogo.map.MogoLatLng;
@@ -15,6 +19,7 @@ import com.mogo.module.common.constants.DataTypes;
import com.mogo.module.common.entity.CloudLocationInfo;
import com.mogo.module.common.entity.CloudRoadData;
import com.mogo.module.common.entity.MogoSnapshotSetData;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.HashMap;
@@ -31,6 +36,8 @@ public
*/
class SnapshotSetDataDrawer {
private static final String TAG = "SnapshotSetDataDrawer";
private static volatile SnapshotSetDataDrawer sInstance;
private Context mContext;
@@ -84,16 +91,23 @@ class SnapshotSetDataDrawer {
}
IMogoMarker marker = null;
String uniqueKey = cloudRoadData.getUniqueKey();
if ( TextUtils.isEmpty( uniqueKey ) ) {
continue;
}
if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) {
marker = mCloudSnapshotMarkersCaches.get( uniqueKey );
}
if ( marker == null || marker.isDestroyed() ) {
marker = drawSnapshotDataMarker( cloudRoadData );
if ( marker == null ) {
continue;
}
mCloudSnapshotMarkersCaches.put( uniqueKey, marker );
}
MogoLatLng endLatLon = null;
List< MogoLatLng > points = new ArrayList<>();
if ( cloudRoadData.getCoordinates() != null
|| cloudRoadData.getCoordinates().size() > 1 ) {
&& cloudRoadData.getCoordinates().size() > 1 ) {
for ( int j = 0; j < cloudRoadData.getCoordinates().size(); j++ ) {
CloudLocationInfo poi = cloudRoadData.getCoordinates().get( j );
if ( poi == null ) {
@@ -101,12 +115,14 @@ class SnapshotSetDataDrawer {
}
double lat = poi.getLat();
double lng = poi.getLon();
points.add( new MogoLatLng( lat, lng ) );
points.add( endLatLon = new MogoLatLng( lat, lng ) );
}
} else {
points.add( marker.getPosition() );
points.add( new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) );
points.add( endLatLon = new MogoLatLng( cloudRoadData.getLat(), cloudRoadData.getLon() ) );
}
if ( endLatLon != null ) {
marker.setPosition( endLatLon.lat, endLatLon.lon );
}
if ( points.size() >= 1 ) {
marker.startSmooth( points, 1 );
@@ -132,6 +148,9 @@ class SnapshotSetDataDrawer {
continue;
}
String uniqueKey = cloudRoadData.getUniqueKey();
if ( TextUtils.isEmpty( uniqueKey ) ) {
continue;
}
if ( mCloudSnapshotMarkersCaches.containsKey( uniqueKey ) ) {
existMarker.put( uniqueKey, mCloudSnapshotMarkersCaches.get( uniqueKey ) );
}
@@ -159,10 +178,19 @@ class SnapshotSetDataDrawer {
if ( data.getType() == AdasRecognizedType.classIdBackground ) {
}
Logger.d( TAG, "draw marker uniqueKey = %s", data.getUniqueKey() );
MogoMarkerOptions options = new MogoMarkerOptions()
.owner( DataTypes.TYPE_MARKER_CLOUD_DATA )
.icon( BitmapFactory.decodeResource( mContext.getResources(), R.drawable.module_common_online_car_vr_middle ) )
.icon( inflateView( data ) )
.gps( true )
.position( new MogoLatLng( data.getLat(), data.getLon() ) );
return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options );
}
private View inflateView( CloudRoadData data ) {
View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null );
TextView tv = rootView.findViewById( R.id.tvSn );
tv.setText( data.getUniqueKey() );
return rootView;
}
}

View File

@@ -0,0 +1,13 @@
package com.mogo.module.common.drawer.marker;
public
/**
* @author congtaowang
* @since 2020/10/29
* <p>
* 描述
*/
class MarkerResourceManager {
}

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/tvSn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textColor="#FFFFFF" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/module_common_online_car_vr_middle" />
</FrameLayout>

View File

@@ -12,6 +12,7 @@ import com.mogo.map.marker.IMogoMarkerClickListener;
import com.mogo.map.marker.IMogoMarkerManager;
import com.mogo.map.uicontroller.EnumMapUI;
import com.mogo.module.common.ModuleNames;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.api.CallChatApi;
import com.mogo.module.common.drawer.AdasRecognizedResultDrawer;
import com.mogo.module.common.drawer.MarkerDrawer;
@@ -156,6 +157,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
if ( data == null ) {
return;
}
if ( !MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().isVrMode() ) {
return;
}
SnapshotSetDataDrawer.getInstance().renderSnapshotData( data, false );
VrModeController.getInstance().renderMogoSnapshotSetData( data );
}

View File

@@ -1,5 +1,8 @@
package com.mogo.module.v2x.scenario.scene.pushVR;
import android.util.Log;
import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.map.overlay.IMogoPolyline;
@@ -13,6 +16,7 @@ import com.mogo.module.v2x.utils.MarkerUtils;
import com.mogo.utils.logger.Logger;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import static com.mogo.module.v2x.V2XConst.V2X_EVENT_ALARM_POI;
@@ -55,13 +59,32 @@ public class V2XPushVREventMarker implements IV2XMarker<V2XPushMessageEntity> {
optionsRipple.icon(V2XMarkerAdapter.getV2XVRRoadEventViewPng(entity));
mAlarmInfoMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_EVENT_ALARM_POI, optionsRipple);
drawablePloyLine(entity);
moveTrack(entity);
// drawablePloyLine(entity);
} catch (Exception e) {
e.printStackTrace();
}
}
/*
平滑移动
* */
void moveTrack(V2XPushMessageEntity entity) {
List<MogoLatLng> points = new ArrayList();
List<double[]> polylines = entity.getMoveTrack();
for (int i = 0; i < polylines.size(); i++) {
try {
double[] latlonList = polylines.get(i);
MogoLatLng latLng = new MogoLatLng(latlonList[1], latlonList[0]);
points.add(latLng);
} catch (Exception e) {
e.printStackTrace();
}
}
Log.d("平滑移动经纬度=====",points.toString());
mAlarmInfoMarker.startSmooth(points, 1);
}
void drawablePloyLine(V2XPushMessageEntity entity) {
// 连接线参数
MogoPolylineOptions options = new MogoPolylineOptions();

View File

@@ -48,6 +48,7 @@ class MachineVisionMapService extends Service {
if ( mMachineVisionMapViewManager != null && mMachineVisionMapViewManager.isShowing() ) {
mMachineVisionMapViewManager.dismiss();
}
MachineVisionMapViewHandler.getInstance().destroyMapView();
mMachineVisionMapViewManager = null;
Logger.d( TAG, "onUnbind" );
return true;

View File

@@ -11,6 +11,7 @@ import androidx.annotation.Nullable;
import com.mogo.map.IMogoMapView;
import com.mogo.map.MogoBaseMapView;
import com.mogo.map.MogoMap;
import com.mogo.map.impl.custom.CustomMapView;
import com.mogo.utils.logger.Logger;
@@ -51,10 +52,11 @@ class MachineVisionMapView extends MogoBaseMapView {
Logger.e( TAG, "create IMogoMapView instance failed." );
}
mMapView = machineMapView;
MogoMap.getInstance().init( getContext(), mMapView.getMap() );
onCreate( null );
postDelayed( ()->{
getMap().getUIController().showMyLocation( true );
}, 5000 );
}, 1000 );
}
@Override
@@ -66,8 +68,4 @@ class MachineVisionMapView extends MogoBaseMapView {
public void displayVRMap( boolean invokeCreateAuto, boolean invokeResumeAuto ) {
}
private void addMapView() {
}
}

View File

@@ -44,6 +44,12 @@ class MachineVisionMapViewHandler {
this.mMachineVisionMapView = mMachineVisionMapView;
}
public void destroyMapView(){
if ( mMachineVisionMapView != null ) {
mMachineVisionMapView.onDestroy();
}
}
public void renderSnapshotSetData( MogoSnapshotSetData data ) {
if ( data == null ) {
return;