diff --git a/libraries/map-custom/build.gradle b/libraries/map-custom/build.gradle index 0dc9651ed6..873947c869 100644 --- a/libraries/map-custom/build.gradle +++ b/libraries/map-custom/build.gradle @@ -67,7 +67,7 @@ dependencies { implementation project(':foudations:mogo-commons') } - implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.1.8' + implementation 'com.zhidaoauto.machine:map:1.0.0-vr-7.3.3' } apply from: new File(rootProject.rootDir, "gradle/upload.gradle").toString() diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapApiBuilder.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapApiBuilder.java index 9bf1e3ea1f..2dd9320480 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapApiBuilder.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/CustomMapApiBuilder.java @@ -96,6 +96,7 @@ class CustomMapApiBuilder implements IMogoMapApiBuilder { .setCoordinateType( MapParams.COORDINATETYPE_GCJ02 ) .setPerspectiveMode( MapParams.MAP_PERSPECTIVE_2D ) .setZoom( 16 ) + .setPointToCenter( 0.734375f, 0.5f ) .setStyleMode( MapParams.MAP_STYLE_NIGHT ), NavParams.Companion.init() ); MapAutoView mapAutoView = new MapAutoView( context ); IMogoMapView mapView = new AMapViewWrapper( mapAutoView ); diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java index a8d1fa242a..8fcb4d7a54 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/AdasRecognizedResultDrawer.java @@ -1,6 +1,7 @@ package com.mogo.module.common.drawer; import android.content.Context; +import android.os.SystemClock; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; @@ -14,6 +15,7 @@ import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.R; import com.mogo.module.common.constants.DataTypes; import com.mogo.service.adas.entity.ADASRecognizedListResult; +import com.mogo.utils.ViewUtils; import java.util.ArrayList; import java.util.HashMap; @@ -38,6 +40,10 @@ class AdasRecognizedResultDrawer extends BaseDrawer { mContext = AbsMogoApplication.getApp(); } + private long mLastReceiveTime = 0L; + + private Map< String, MogoLatLng > mLastPositions = new ConcurrentHashMap<>(); + public static AdasRecognizedResultDrawer getInstance() { if ( sInstance == null ) { synchronized ( AdasRecognizedResultDrawer.class ) { @@ -61,6 +67,8 @@ class AdasRecognizedResultDrawer extends BaseDrawer { // adas marker 缓存 private Map< String, IMogoMarker > mAdasRecognizedMarkersCaches = new ConcurrentHashMap<>(); + private boolean mIsVrMode = false; + public void renderAdasRecognizedResult( List< ADASRecognizedListResult > resultList, boolean machineVision, double curSpeed ) { if ( resultList == null || resultList.isEmpty() ) { MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).removeMarkers( DataTypes.TYPE_MARKER_ADAS ); @@ -85,10 +93,18 @@ class AdasRecognizedResultDrawer extends BaseDrawer { continue; } mAdasRecognizedMarkersCaches.put( uniqueKey, marker ); + } else { + if ( mIsVrMode != MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) { + mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode(); + if ( mIsVrMode ) { + marker.use3DResource( getVrModel() ); + } else { + marker.setIcon( ViewUtils.fromView( inflateView( recognizedListResult, machineVision, 0 ) ) ); + } + } } - if ( marker.getObject() instanceof MogoLatLng ) { - marker.setPosition( ( ( MogoLatLng ) marker.getObject() ).lat, ( ( MogoLatLng ) marker.getObject() ).lon ); - } + + MogoLatLng lastPosition = mLastPositions.get( uniqueKey ); List< MogoLatLng > points = new ArrayList<>(); MogoLatLng endLatLon = null; @@ -107,23 +123,21 @@ class AdasRecognizedResultDrawer extends BaseDrawer { } else if ( recognizedListResult.latLonList != null && recognizedListResult.latLonList.size() == 1 ) { // 原来的点和新的点做一个数组进行平滑移动 - MogoLatLng latLng = marker.getPosition(); ADASRecognizedListResult.LatLon latLon = recognizedListResult.latLonList.get( 0 ); if ( latLon == null ) { continue; } - points.add( latLng ); + points.add( lastPosition ); // double targetPos[] = transformGcj02ToFitMap( latLon.lat, latLon.lon ); // points.add( endLatLon = new MogoLatLng( targetPos[POS_LAT], targetPos[POS_LON] ) ); points.add( endLatLon = new MogoLatLng( latLon.lat, latLon.lon ) ); } - if ( endLatLon != null ) { - marker.setObject( endLatLon ); - } + mLastPositions.put( uniqueKey, endLatLon ); if ( points.size() >= 1 ) { - marker.startSmooth( points, 1 ); + marker.startSmoothInMs( points, SystemClock.elapsedRealtime() - mLastReceiveTime ); } } + mLastReceiveTime = SystemClock.elapsedRealtime(); } /** @@ -151,6 +165,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer { if ( !existMarker.isEmpty() ) { for ( String key : mAdasRecognizedMarkersCaches.keySet() ) { if ( !existMarker.containsKey( key ) ) { + mLastPositions.remove( key ); try { IMogoMarker marker = mAdasRecognizedMarkersCaches.remove( key ); marker.destroy(); @@ -172,14 +187,24 @@ class AdasRecognizedResultDrawer extends BaseDrawer { // double targetPos[] = transformGcj02ToFitMap( recognizedListResult.latLonList.get( 0 ).lat, recognizedListResult.latLonList.get( 0 ).lon ); MogoMarkerOptions options = new MogoMarkerOptions() .owner( DataTypes.TYPE_MARKER_ADAS ) - .icon( inflateView( recognizedListResult, machineVision, curSpeed ) ) .anchor( 0.5f, 0.5f ) .rotate( ( float ) recognizedListResult.heading ) // .position( new MogoLatLng( targetPos[POS_LAT], targetPos[POS_LON] ) ); .position( new MogoLatLng( recognizedListResult.latLonList.get( 0 ).lat, recognizedListResult.latLonList.get( 0 ).lon ) ); + + if ( mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) { + options.icon3DRes( getVrModel() ); + } else { + options.icon( inflateView( recognizedListResult, machineVision, curSpeed ) ); + } + return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_ADAS, options ); } + private int getVrModel() { + return R.raw.taxi; + } + private View inflateView( ADASRecognizedListResult data, boolean machineVision, double curSpeed ) { View rootView = LayoutInflater.from( AbsMogoApplication.getApp() ).inflate( R.layout.module_commons_layout_car, null ); // SafeType safeType = getSafeType( data.distanceX, data.distanceY, data.speed, curSpeed ); @@ -193,7 +218,7 @@ class AdasRecognizedResultDrawer extends BaseDrawer { // safeType // ) ); - iv.setImageResource( R.drawable.icon_map_marker_car_gray ); + iv.setImageResource( R.drawable.icon_map_marker_car_type_taxi ); return rootView; } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java index d819d36607..1fb911a3b8 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/SnapshotSetDataDrawer.java @@ -1,6 +1,7 @@ package com.mogo.module.common.drawer; import android.content.Context; +import android.os.SystemClock; import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; @@ -72,6 +73,8 @@ class SnapshotSetDataDrawer extends BaseDrawer { private boolean mIsVrMode = false; + private long mLastReceiveTime = 0L; + /** * 其他车辆、rsu 车辆数据 * @@ -123,7 +126,7 @@ class SnapshotSetDataDrawer extends BaseDrawer { if ( mIsVrMode != MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) { mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode(); if ( mIsVrMode ) { - marker.use3DResource( getVrModel() ); + marker.use3DResource( getVrModel( cloudRoadData ) ); } else { marker.setIcon( ViewUtils.fromView( inflateView( cloudRoadData, machineVision, 0 ) ) ); } @@ -139,7 +142,7 @@ class SnapshotSetDataDrawer extends BaseDrawer { List< MogoLatLng > points = new ArrayList<>(); points.add( new MogoLatLng( lastPosition.lat, lastPosition.lon ) ); points.add( new MogoLatLng( target.lat, target.lon ) ); - marker.startSmoothInMs( points, 1000L ); + marker.startSmoothInMs( points, SystemClock.elapsedRealtime() - mLastReceiveTime ); } } else { marker.setRotateAngle( 360 - ( float ) cloudRoadData.getHeading() ); @@ -147,6 +150,7 @@ class SnapshotSetDataDrawer extends BaseDrawer { } } mLastPositions.put( uniqueKey, target ); + mLastReceiveTime = SystemClock.elapsedRealtime(); } } @@ -205,15 +209,23 @@ class SnapshotSetDataDrawer extends BaseDrawer { // .position( new MogoLatLng( coor[POS_LAT], coor[POS_LON] ) ); .position( new MogoLatLng( data.getLat(), data.getLon() ) ); if ( mIsVrMode = MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) { - options.icon3DRes( getVrModel() ); + options.icon3DRes( getVrModel( data ) ); } else { options.icon( inflateView( data, machineVision, curSpeed ) ); } return MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( mContext ).addMarker( DataTypes.TYPE_MARKER_CLOUD_DATA, options ); } - private int getVrModel() { - return R.raw.taxi; + private int getVrModel( CloudRoadData data ) { + switch ( data.getFromType() ) { + case CloudRoadData.FROM_ADAS: + return R.raw.taxi; + case CloudRoadData.FROM_ROAD_UNIT: + return R.raw.bus; + case CloudRoadData.FROM_MY_LOCATION: + default: + return R.raw.carred; + } } private View inflateView( CloudRoadData data, boolean machineVision, double curSpeed ) { @@ -229,7 +241,19 @@ class SnapshotSetDataDrawer extends BaseDrawer { // getCarModelType(), // safeType // ) ); - iv.setImageResource( R.drawable.icon_map_marker_car_gray ); + iv.setImageResource( get2DModel( data ) ); return rootView; } + + private int get2DModel( CloudRoadData data ) { + switch ( data.getFromType() ) { + case CloudRoadData.FROM_ADAS: + return R.drawable.icon_map_marker_car_type_taxi; + case CloudRoadData.FROM_ROAD_UNIT: + return R.drawable.icon_map_marker_car_type_bus; + case CloudRoadData.FROM_MY_LOCATION: + default: + return R.drawable.icon_map_marker_car_gray; + } + } } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java index 9ded911563..2bacde6a7e 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerInfoView.java @@ -6,6 +6,7 @@ import android.util.AttributeSet; import android.view.LayoutInflater; import android.view.View; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.TextView; import androidx.annotation.Nullable; @@ -33,7 +34,7 @@ public class MapMarkerInfoView extends MapMarkerBaseView { private String TAG = "MapMarkerInfoView"; private TextView tvMarkerContent; - private ConstraintLayout clMarkerContent; + private LinearLayout clMarkerContent; private ImageView ivReverseTriangle; public MapMarkerInfoView( Context context ) { diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerView.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerView.java index be7ebf2ab0..4d4eecb5e8 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerView.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/marker/MapMarkerView.java @@ -49,7 +49,11 @@ public class MapMarkerView extends MapMarkerBaseView { @Override protected void initView( Context context ) { - LayoutInflater.from( context ).inflate( R.layout.modudle_services_marker_layout, this ); + if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) { + LayoutInflater.from( context ).inflate( R.layout.modudle_services_marker_vr_layout, this ); + } else { + LayoutInflater.from( context ).inflate( R.layout.modudle_services_marker_layout, this ); + } ivIcon = findViewById( R.id.ivIcon ); clMarkerTopView = findViewById( R.id.clMarkerTopView ); ivCar = findViewById( R.id.ivCar ); @@ -59,13 +63,6 @@ public class MapMarkerView extends MapMarkerBaseView { public void updateView( MarkerShowEntity markerShowEntity ) { try { Object bindObj = markerShowEntity.getBindObj(); - if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) { - ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow_vr ); - clMarkerTopView.setBackgroundResource( R.drawable.module_services_marker_vr_bkg ); - } else { - clMarkerTopView.setBackgroundResource( R.drawable.module_services_marker_bkg ); - ivCar.setImageResource( R.drawable.icon_map_marker_location_yellow ); - } switch ( markerShowEntity.getMarkerType() ) { case ModuleNames.CARD_TYPE_ROAD_CONDITION: case ModuleNames.CARD_TYPE_NOVELTY: diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/CloudLocationInfo.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/CloudLocationInfo.java index 70dd512fb6..80d9306709 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/CloudLocationInfo.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/CloudLocationInfo.java @@ -21,9 +21,6 @@ public class CloudLocationInfo implements Parcelable { private double alt; private double speed; - public double oldLat; - public double oldLon; - public CloudLocationInfo() { } @@ -38,8 +35,6 @@ public class CloudLocationInfo implements Parcelable { } public void convertCoor2GCJ02(){ - this.oldLat = lat; - this.oldLon = lon; double[] amapCoord = CoordinateUtils.transformFromWGSToGCJ( lat, lon ); if ( amapCoord != null ) { this.lat = amapCoord[0]; diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/CloudRoadData.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/CloudRoadData.java index 3968a35a51..6a591d2d9c 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/CloudRoadData.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/entity/CloudRoadData.java @@ -8,12 +8,22 @@ import java.util.List; /** * 云端道路数据 + * * @author tongchenfei */ public class CloudRoadData implements Parcelable { - /**物体类型*/ + + public static final int FROM_MY_LOCATION = 1; + public static final int FROM_ADAS = 2; + public static final int FROM_ROAD_UNIT = 3; + + /** + * 物体类型 + */ private int type = -1; + private int fromType; + private double lat; private double lon; @@ -25,23 +35,29 @@ public class CloudRoadData implements Parcelable { private long systemTime; - /**红绿灯状态 1红 2绿 3黄*/ + /** + * 红绿灯状态 1红 2绿 3黄 + */ private int lightStatus;// - /**红绿灯剩余时间 读秒*/ + /** + * 红绿灯剩余时间 读秒 + */ private int lightLeftTime; - /**视频流直播地址*/ + /** + * 视频流直播地址 + */ private String rtmpUrl;// - private double distance ;//距离 + private double distance;//距离 - private List coordinates; + private List< CloudLocationInfo > coordinates; public int getType() { return type; } - public void setType(int type) { + public void setType( int type ) { this.type = type; } @@ -49,7 +65,7 @@ public class CloudRoadData implements Parcelable { return lat; } - public void setLat(double lat) { + public void setLat( double lat ) { this.lat = lat; } @@ -57,7 +73,7 @@ public class CloudRoadData implements Parcelable { return lon; } - public void setLon(double lon) { + public void setLon( double lon ) { this.lon = lon; } @@ -65,7 +81,7 @@ public class CloudRoadData implements Parcelable { return speed; } - public void setSpeed(double speed) { + public void setSpeed( double speed ) { this.speed = speed; } @@ -73,7 +89,7 @@ public class CloudRoadData implements Parcelable { return systemTime; } - public void setSystemTime(long systemTime) { + public void setSystemTime( long systemTime ) { this.systemTime = systemTime; } @@ -81,7 +97,7 @@ public class CloudRoadData implements Parcelable { return lightStatus; } - public void setLightStatus(int lightStatus) { + public void setLightStatus( int lightStatus ) { this.lightStatus = lightStatus; } @@ -89,7 +105,7 @@ public class CloudRoadData implements Parcelable { return lightLeftTime; } - public void setLightLeftTime(int lightLeftTime) { + public void setLightLeftTime( int lightLeftTime ) { this.lightLeftTime = lightLeftTime; } @@ -97,7 +113,7 @@ public class CloudRoadData implements Parcelable { return rtmpUrl; } - public void setRtmpUrl(String rtmpUrl) { + public void setRtmpUrl( String rtmpUrl ) { this.rtmpUrl = rtmpUrl; } @@ -105,15 +121,15 @@ public class CloudRoadData implements Parcelable { return distance * 1000; } - public void setDistance(double distance) { + public void setDistance( double distance ) { this.distance = distance; } - public List getCoordinates() { + public List< CloudLocationInfo > getCoordinates() { return coordinates; } - public void setCoordinates(List coordinates) { + public void setCoordinates( List< CloudLocationInfo > coordinates ) { this.coordinates = coordinates; } @@ -133,13 +149,21 @@ public class CloudRoadData implements Parcelable { this.heading = heading; } - public String getUniqueKey(){ - if (! TextUtils.isEmpty( uuid ) ) { + public String getUniqueKey() { + if ( !TextUtils.isEmpty( uuid ) ) { return uuid; } return sn; } + public int getFromType() { + return fromType; + } + + public void setFromType( int fromType ) { + this.fromType = fromType; + } + public CloudRoadData() { } @@ -151,6 +175,7 @@ public class CloudRoadData implements Parcelable { @Override public void writeToParcel( Parcel dest, int flags ) { dest.writeInt( this.type ); + dest.writeInt( this.fromType ); dest.writeDouble( this.lat ); dest.writeDouble( this.lon ); dest.writeString( this.uuid ); @@ -167,6 +192,7 @@ public class CloudRoadData implements Parcelable { protected CloudRoadData( Parcel in ) { this.type = in.readInt(); + this.fromType = in.readInt(); this.lat = in.readDouble(); this.lon = in.readDouble(); this.uuid = in.readString(); diff --git a/modules/mogo-module-common/src/main/res/layout/modudle_services_marker_layout_info.xml b/modules/mogo-module-common/src/main/res/layout/modudle_services_marker_layout_info.xml index 444e398c97..42ee3f0db1 100644 --- a/modules/mogo-module-common/src/main/res/layout/modudle_services_marker_layout_info.xml +++ b/modules/mogo-module-common/src/main/res/layout/modudle_services_marker_layout_info.xml @@ -6,59 +6,49 @@ android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" - android:padding="1px" - tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"> + android:padding="1px"> - + android:background="@drawable/bg_map_marker_yellow_info"> - + + + + + + - - + android:textSize="@dimen/sp_32" /> + + + + + + + + + + + \ No newline at end of file diff --git a/modules/mogo-module-common/src/main/res/raw/bus.n3d b/modules/mogo-module-common/src/main/res/raw/bus.n3d new file mode 100644 index 0000000000..f4d862c630 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/raw/bus.n3d differ diff --git a/modules/mogo-module-common/src/main/res/raw/carred.n3d b/modules/mogo-module-common/src/main/res/raw/carred.n3d new file mode 100644 index 0000000000..8cb2c78f90 Binary files /dev/null and b/modules/mogo-module-common/src/main/res/raw/carred.n3d differ diff --git a/modules/mogo-module-common/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-common/src/main/res/values-xhdpi/dimens.xml index 1f8f71e5f9..1913dd1d63 100644 --- a/modules/mogo-module-common/src/main/res/values-xhdpi/dimens.xml +++ b/modules/mogo-module-common/src/main/res/values-xhdpi/dimens.xml @@ -1065,9 +1065,13 @@ 20dp 4dp 100px + 55px 117px + 69px 60px 60px + 35px + 35px 8px diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/EventDispatchCenter.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/EventDispatchCenter.java index efbc64f845..aad31916ea 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/EventDispatchCenter.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/EventDispatchCenter.java @@ -275,13 +275,6 @@ public class EventDispatchCenter implements } } } - if ( ui == EnumMapUI.Type_VR ) { - MogoApisHandler.getInstance().getApis().getStatusManagerApi() - .setVrMode( TAG, true ); - } else { - MogoApisHandler.getInstance().getApis().getStatusManagerApi() - .setVrMode( TAG, false ); - } } @Override diff --git a/modules/mogo-module-service/src/main/res/layout/modudle_services_marker_layout_info.xml b/modules/mogo-module-service/src/main/res/layout/modudle_services_marker_layout_info.xml deleted file mode 100644 index a8b9a0e207..0000000000 --- a/modules/mogo-module-service/src/main/res/layout/modudle_services_marker_layout_info.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - \ No newline at end of file