diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 83405b8de1..4ff10f68a5 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -91,6 +91,7 @@ diff --git a/app/src/main/java/com/mogo/launcher/MogoApplication.java b/app/src/main/java/com/mogo/launcher/MogoApplication.java index d748a8a008..dd46fdd897 100644 --- a/app/src/main/java/com/mogo/launcher/MogoApplication.java +++ b/app/src/main/java/com/mogo/launcher/MogoApplication.java @@ -183,20 +183,16 @@ public class MogoApplication extends AbsMogoApplication { */ private void prepareBaseService(IMogoServiceApis apis, long delay) { - UiThreadHandler.postDelayed(() -> { - // 第三方平台的sn是服务端生成的,所以必须在返回后才能开启 - if (TextUtils.isEmpty(Utils.getSn())) { - preparePassportEnvironment(apis, () -> { - prepareSocketAndLocationServices(apis); - }); - } else { - preparePassportEnvironment(apis, null); - prepareSocketAndLocationServices(apis); - } - }, delay); + // 第三方平台的sn是由AI云SDK中服务调用通过服务端生成的 + preparePassportEnvironment(); + prepareSocketAndLocationServices(apis); + //无延迟 +// UiThreadHandler.postDelayed(() -> { +// +// }, delay); } - private void preparePassportEnvironment(IMogoServiceApis apis, Runnable after) { + private void preparePassportEnvironment() { // 配置云服务API MoGoAiCloudClientConfig clientConfig = MoGoAiCloudClientConfig.getInstance(); // 设置网络环境:HTTP_DNS_ENV_QA、HTTP_DNS_ENV_RELEASE、HTTP_DNS_ENV_DEV @@ -257,6 +253,7 @@ public class MogoApplication extends AbsMogoApplication { } private void prepareSocketAndLocationServices(IMogoServiceApis apis) { + //开启Socket长链服务 apis.getSocketManagerApi(getApplicationContext()).init(getApplicationContext(), DebugConfig.getSocketAppId()); if (DebugConfig.getCarMachineType() != DebugConfig.CAR_MACHINE_TYPE_SELF_INNOVATE) { apis.getLocationInfoApi().start(); diff --git a/foudations/mogo-utils/src/main/java/com/mogo/utils/UiThreadHandler.java b/foudations/mogo-utils/src/main/java/com/mogo/utils/UiThreadHandler.java index 7225548d91..383ff712f7 100644 --- a/foudations/mogo-utils/src/main/java/com/mogo/utils/UiThreadHandler.java +++ b/foudations/mogo-utils/src/main/java/com/mogo/utils/UiThreadHandler.java @@ -5,9 +5,9 @@ import android.os.Looper; public class UiThreadHandler { - private static Handler sUiHandler = new Handler( Looper.getMainLooper() ); + private static final Handler sUiHandler = new Handler( Looper.getMainLooper() ); - private static Object sToken = new Object(); + private static final Object sToken = new Object(); public UiThreadHandler() { } diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModulePaths.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModulePaths.java index d204367c99..139b433a1c 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModulePaths.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/MogoModulePaths.java @@ -15,10 +15,10 @@ import java.util.List; */ public class MogoModulePaths { - private static List< MogoModule > mMogoModules = new ArrayList<>(); + private static final List< MogoModule > mMogoModules = new ArrayList<>(); // 不需要启动APP也能运行的模块 - private static List< MogoModule > mMogoBaseModules = new ArrayList<>(); + private static final List< MogoModule > mMogoBaseModules = new ArrayList<>(); /** * 地图模块 fragment 路径 diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java index 45beef469b..4cc2bc677c 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/MarkerDrawer.java @@ -68,11 +68,20 @@ class MarkerDrawer { return drawMapMarkerImpl( markerShowEntity, matchRoadSide, zIndex, 0, listener ); } + /** + * add marker, {@link OnlineCarDrawer 如果是需要在3D模式下显示,则需要设置 {@link MogoMarkerOptions icon3DRes 资源id}} + * @param markerShowEntity marker展示数据结构体 + * @param matchRoadSide 设置是否道路吸附,暂时没用到这个字段 + * @param zIndex zOrder + * @param icon3DRes 3D Res资源 + * @param listener marker回调 + * @return {@link IMogoMarker} + */ public IMogoMarker drawMapMarkerImpl( MarkerShowEntity markerShowEntity, boolean matchRoadSide, int zIndex, int icon3DRes, IMogoMarkerClickListener listener ) { if ( markerShowEntity == null || markerShowEntity.getMarkerLocation() == null ) { return null; } - MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes( icon3DRes ).matchOnRoadSide( matchRoadSide ).owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() ); + MogoMarkerOptions options = new MogoMarkerOptions().icon3DRes( icon3DRes ).set3DMode(MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()).matchOnRoadSide( matchRoadSide ).owner( markerShowEntity.getMarkerType() ).zIndex( zIndex ).object( markerShowEntity ).latitude( markerShowEntity.getMarkerLocation().getLat() ).longitude( markerShowEntity.getMarkerLocation().getLon() ); IMarkerView markerView = MapMarkerAdapter.getMarkerView( AbsMogoApplication.getApp(), markerShowEntity, options ); if ( markerView instanceof OnlineCarMarkerView ) { try { diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/OnlineCarDrawer.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/OnlineCarDrawer.java index f4a1dd5756..d72eb87fb5 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/OnlineCarDrawer.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/drawer/OnlineCarDrawer.java @@ -105,7 +105,7 @@ class OnlineCarDrawer { String sn = MarkerDrawer.getInstance().getPrimaryKeyFromEntity( markerOnlineCar ); IMogoMarker mogoMarker = existCarMap.get( sn ); if ( mogoMarker == null || mogoMarker.isDestroyed() ) { - mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, false, MarkerDrawer.MARKER_Z_INDEX_LOW, R.raw.othercar, listener ); + mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, false, MarkerDrawer.MARKER_Z_INDEX_LOW, 0, listener ); } if ( mogoMarker != null ) { mogoMarker.setVisible( true ); diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java index f9feb2a41c..02f4ca2e39 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/MainActivity.java @@ -53,7 +53,7 @@ public class MainActivity extends MvpActivity implement IMogoADASControlStatusChangedListener, FragmentStackTransactionListener { - protected static final String TAG = MainActivity.class.getSimpleName(); + protected static final String TAG = "MainActivity"; protected IMogoServiceApis mServiceApis; protected IMogoFragmentManager mMogoFragmentManager; diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java index e7f8271915..9a0d9d421c 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MogoServices.java @@ -119,7 +119,12 @@ public class MogoServices implements IMogoMapListener, /** * 自动刷新策略 */ - private AutoRefreshStrategy mAutoRefreshStrategy = new AutoRefreshStrategy(); + private final AutoRefreshStrategy mAutoRefreshStrategy = new AutoRefreshStrategy(); + /** + * 手动刷新策略 + */ + private final CustomRefreshStrategy mCustomRefreshStrategy = new CustomRefreshStrategy(); + private MogoLatLng mLastAutoRefreshLocation = null; private IMogoMapUIController mUiController; @@ -135,13 +140,9 @@ public class MogoServices implements IMogoMapListener, private boolean mIsVertical = false; private MogoReceiver mAIAssistReceiver; - - /** - * 手动刷新策略 - */ - private CustomRefreshStrategy mCustomRefreshStrategy = new CustomRefreshStrategy(); - private float mLastZoomLevel = 0; private RefreshModel mRefreshModel; + + private float mLastZoomLevel = 0; private TtsConfigModleData mTtsModle; private long mRefreshRemainingTime = Long.MAX_VALUE; // 上次手动操作的中心点坐标 @@ -169,7 +170,7 @@ public class MogoServices implements IMogoMapListener, */ private boolean mLoopRequest = false; - private Handler mHandler = new MainLooperHandler( Looper.getMainLooper() ) { + private final Handler mHandler = new MainLooperHandler( Looper.getMainLooper() ) { @Override protected void handleRefreshDecrease( Message msg ) { @@ -255,7 +256,7 @@ public class MogoServices implements IMogoMapListener, /** * 自动刷新回调 */ - private RefreshCallback mAutoRefreshCallback = new RefreshCallback< MarkerResponse >() { + private final RefreshCallback mAutoRefreshCallback = new RefreshCallback< MarkerResponse >() { @Override public void onSuccess( MarkerResponse o ) { MapMarkerManager.getInstance().onSyncMarkerResponse( o ); @@ -285,7 +286,7 @@ public class MogoServices implements IMogoMapListener, */ private int mCurrentLimit = -1; - private IMogoStatusChangedListener statusChangedListener = new StatusChangedAdapter() { + private final IMogoStatusChangedListener statusChangedListener = new StatusChangedAdapter() { @Override public void onSearchUIShow( boolean visible ) { @@ -433,10 +434,10 @@ public class MogoServices implements IMogoMapListener, return; } mRefreshModel.refreshExplorerWayData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback ); - if ( !DebugConfig. - isNeedUploadCoordinatesDurationInTime() ) { - MapMarkerManager.getInstance().getOnlineCarDataByAutoRefreshStrategy( ro.mLonLat ); - } +// if ( !DebugConfig. +// isNeedUploadCoordinatesDurationInTime() ) { //todo 实时在线车辆需要注释,否则在2D模式下不能展示 +// } + MapMarkerManager.getInstance().getOnlineCarDataByAutoRefreshStrategy( ro.mLonLat ); Logger.i( TAG, "刷新半径 = %s, 点 = %s, zoomLevel = %s, amount = %s", ro.mRadius, ro.mLonLat, mLastZoomLevel, ro.mAmount ); } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java index cddffedaab..4190d57534 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/marker/MapMarkerManager.java @@ -547,7 +547,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener, getOnlineCarDataImpl( latLng, onlyFocus, onlySameCity, limit, radius, true ); } - private Runnable runnable = new Runnable() { + private final Runnable runnable = new Runnable() { @Override public void run() { getOnlineCarDataImpl( mCarLatLng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false ); @@ -579,9 +579,9 @@ public class MapMarkerManager implements IMogoMarkerClickListener, int radius, boolean fitBounds ) { - if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) { - return; - } +// if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {//todo 实时在线车辆需要注释,否则在2D模式下不能展示 +// return; +// } if ( DebugConfig.isDebug() ) { if ( !DebugConfig.isRequestOnlineCarData() ) { diff --git a/modules/mogo-module-smp/src/main/assets/small_map_style.data b/modules/mogo-module-smp/src/main/assets/small_map_style.data index f8b175ad2c..e3775a88b1 100644 Binary files a/modules/mogo-module-smp/src/main/assets/small_map_style.data and b/modules/mogo-module-smp/src/main/assets/small_map_style.data differ diff --git a/modules/mogo-module-smp/src/main/assets/small_map_style_extra.data b/modules/mogo-module-smp/src/main/assets/small_map_style_extra.data index 2de0626f28..d12089b70e 100644 Binary files a/modules/mogo-module-smp/src/main/assets/small_map_style_extra.data and b/modules/mogo-module-smp/src/main/assets/small_map_style_extra.data differ diff --git a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java index d2ffb31959..67799b666b 100644 --- a/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java +++ b/modules/mogo-module-smp/src/main/java/com/mogo/module/small/map/SmallMapDirectionView.java @@ -4,8 +4,7 @@ import android.content.Context; import android.graphics.BitmapFactory; import android.util.AttributeSet; import android.util.Log; -import android.view.animation.LinearInterpolator; -import android.widget.ImageView; +import android.view.MotionEvent; import android.widget.RelativeLayout; import androidx.annotation.Nullable; @@ -14,16 +13,13 @@ import com.amap.api.maps.AMap; import com.amap.api.maps.CameraUpdate; import com.amap.api.maps.CameraUpdateFactory; import com.amap.api.maps.UiSettings; -import com.amap.api.maps.model.CameraPosition; import com.amap.api.navi.AMapNaviView; import com.amap.api.navi.AMapNaviViewOptions; import com.mogo.commons.AbsMogoApplication; -import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.module.common.MogoApisHandler; import com.mogo.module.small.map.animation.DirectionRotateAnimation; import com.mogo.utils.FileUtils; -import java.io.File; import java.io.IOException; /** @@ -35,7 +31,6 @@ import java.io.IOException; public class SmallMapDirectionView extends RelativeLayout { private String styleFilePath = "/mnt/sdcard/amap/small_map_style.data"; - private ImageView mIvMapBorder; private AMapNaviView mAMapNaviView; private DirectionRotateAnimation mRotateAnimation; private int lastAngle = 0; @@ -62,7 +57,6 @@ public class SmallMapDirectionView extends RelativeLayout { mRotateAnimation = new DirectionRotateAnimation(context, null); AbsMogoApplication.getLayoutInflaterNoSkin().inflate(R.layout.module_small_map_view, this); - mIvMapBorder = findViewById(R.id.ivMapBorder); mAMapNaviView = findViewById(R.id.aMapNaviView); mAMapNaviView.onCreate(null); @@ -136,7 +130,7 @@ public class SmallMapDirectionView extends RelativeLayout { options.setNaviArrowVisible(false); // 通过路线是否自动置灰,仅支持驾车导航 options.setAfterRouteAutoGray(false); - //options.setZoom(((int) 9)); + options.setZoom(((int) 10)); //options.setPointToCenter(0.7D, 0.5D); // 2D模式 options.setTilt(0); @@ -151,21 +145,6 @@ public class SmallMapDirectionView extends RelativeLayout { CameraUpdate cameraUpdate = CameraUpdateFactory.zoomTo(zoomLevel); aMap.moveCamera(cameraUpdate); - aMap.setOnCameraChangeListener(new AMap.OnCameraChangeListener() { - @Override - public void onCameraChange(CameraPosition cameraPosition) { - if (cameraPosition != null) { - //Log.w("onCameraChange", "cameraPosition=" + cameraPosition.bearing); - changeAngle((int) cameraPosition.bearing); - } - } - - @Override - public void onCameraChangeFinish(CameraPosition cameraPosition) { - - } - }); - aMap.setOnMapLoadedListener(new AMap.OnMapLoadedListener() { @Override @@ -229,46 +208,22 @@ public class SmallMapDirectionView extends RelativeLayout { e.printStackTrace(); } - mIvMapBorder.setOnClickListener( view -> { + setOnClickListener(view -> { MogoApisHandler.getInstance().getApis() .getMapServiceApi() .getMapUIController() .changeMapMode( MogoApisHandler.getInstance() - .getApis() - .getAdasControllerApi() - .getCurrentSkinMode() + .getApis() + .getAdasControllerApi() + .getCurrentSkinMode() ); - } ); + }); } - /** - * 修改角度 - * - * @param angle 角度 0 - 359度旋转,相对于自身中心位置 - */ - public void changeAngle(int angle) { - int tempAngle = 360 - angle; - - if (tempAngle <= 180) { - tempAngle = tempAngle; - } else { - tempAngle = -(360 - tempAngle); - } - - mRotateAnimation.setFromDegrees(lastAngle); - mRotateAnimation.setToDegrees(tempAngle); - - //设置线性插值,可以解决旋转一圈后卡顿问题 - mRotateAnimation.setInterpolator(new LinearInterpolator()); - //设置旋转一圈时间 - mRotateAnimation.setDuration(300); - //控件动画结束时是否保持动画最后的状态 - mRotateAnimation.setFillAfter(true); - mIvMapBorder.startAnimation(mRotateAnimation); - // 刷新最后一次角度 - lastAngle = tempAngle; + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + return true; } - } diff --git a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml index dd0630dcfc..693f7da327 100644 --- a/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml +++ b/modules/mogo-module-smp/src/main/res/layout/module_small_map_view.xml @@ -2,10 +2,10 @@ + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:padding="@dimen/dp_40" + tools:parentTag="RelativeLayout"> - - \ No newline at end of file diff --git a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml index abea40f5d9..45bdd66ca6 100644 --- a/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml +++ b/modules/mogo-module-smp/src/main/res/values-xhdpi/dimens.xml @@ -8,8 +8,8 @@ 250px 250px - 1525px - 695px + 1620px + 780px 0px 0px diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java index 23fd49041f..3550dad486 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/manager/impl/MoGoV2XCloundDataManager.java @@ -47,6 +47,10 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog private static String TAG = "MoGoV2XCloundDataManager"; private boolean isSelfLineClear; private List fillPoints = new ArrayList();//停止线经纬度合集 + private boolean isFirstLocation = false; + private MogoLatLng mNewLocation; + + private static long showTime = 0; @Override public void init(Context context) { @@ -57,34 +61,35 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog @Override public void analysisV2XCloundDataEvent(V2XWarningEntity cloundWarningInfo) { Log.d(V2XConst.LOG_NAME_WARN, "analysisV2XCloundDataEvent -----> "); - mCloundWarningInfo = cloundWarningInfo; + showTime = mCloundWarningInfo.getShowTime(); pointsBetween(); //发送预警提示 MarkerServiceHandler.getApis().getV2XListenerManager().warningChangedForListenerWithDirection(cloundWarningInfo.getType(), MogoReceiver.ACTION_V2X_FRONT_WARNING); - isSelfLineClear = false; + isFirstLocation = false; - Log.d(V2XConst.LOG_NAME_WARN, "direction = " + cloundWarningInfo.getDirection()); if (cloundWarningInfo.getDirection() == 1) { //前方 - //停止线前方画线 MogoLatLng newLocation = LocationUtils.getNewLocation((MogoLatLng) fillPoints.get(0), 80, cloundWarningInfo.getAngle()); + //停止线前方画线 WorkThreadHandler.getInstance().postDelayed(() -> { - //添加停止线marker + //添加停止线 drawStopLineWith2Resource(); //二轮车和行人的渲染和移动 V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo); //绘制识别物与交汇点连线,并且更新连线数据 drawStopLine(cloundWarningInfo, newLocation); - }, 200); + //添加停止线marker + handleStopLine(); + }, 800); UiThreadHandler.postDelayed(() -> { V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine(); V2XServiceManager.getMoGoWarnPolylineManager().clearLine(); V2XServiceManager.getMoGoStopPolylineManager().clearLine(); isSelfLineClear = true; - }, 8000); + }, showTime); } else { //左侧或者右侧 WorkThreadHandler.getInstance().postDelayed(() -> { @@ -92,17 +97,15 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog drawOtherObjectLine(cloundWarningInfo); //二轮车和行人的渲染和移动 V2XWarnDataDrawer.getInstance().renderWarnData(cloundWarningInfo); - }, 200); + }, 500); //延迟3秒清理线 UiThreadHandler.postDelayed(() -> { V2XServiceManager.getMoGoPersonWarnPolylineManager().clearLine(); V2XServiceManager.getMoGoWarnPolylineManager().clearLine(); - isSelfLineClear = true; - }, 8000); + }, showTime); } - } @@ -110,7 +113,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog for (int i = 0; i < fillPoints.size(); i++) { V2XWarningEntity entity = new V2XWarningEntity(); MogoLatLng latLng = (MogoLatLng) fillPoints.get(i); - Log.d("liyz", "handleStopLine lat = " + latLng.lat + "--lon =" + latLng.lon); entity.setLat(latLng.lat); entity.setLon(latLng.lon); entity.setCollisionLat(mCloundWarningInfo.getCollisionLat()); @@ -124,10 +126,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog * 2D资源绘制停止线 * */ private void drawStopLineWith2Resource() { - - //自车位置39.97665425796924--116.41769983329762 - mCloundWarningInfo.setCarLocation(new MogoLatLng(39.97665425796924,116.41769983329762));//测试数据 - MogoLatLng carlo = mCloundWarningInfo.getCarLocation(); if (carlo == null) { double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon(); @@ -136,11 +134,11 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog } //自车行驶方向的前方*米的经纬度,该经纬度在停止线上 MogoLatLng drawStopLineLon = LocationUtils.getNewLocation(carlo, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getAngle()); - Log.d(TAG, "2D资源绘制停止线"+drawStopLineLon); + Log.d(TAG, "2D资源绘制停止线" + drawStopLineLon); MogoMarkerOptions optionsRipple = new MogoMarkerOptions() .latitude(drawStopLineLon.getLat()) .longitude(drawStopLineLon.getLon()) - .anchor(0.5f, 0.5f) + .anchor(1.0f, 1.0f) .zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH); optionsRipple @@ -148,9 +146,9 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog IMogoMarker stopLine = V2XServiceManager.getMarkerManager().addMarker(TYPE_MARKER_CLOUD_STOP_LINE_DATA, optionsRipple); stopLine.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(V2XServiceManager.getContext()))); stopLine.showInfoWindow(); -// UiThreadHandler.postDelayed(() -> { -// stopLine.hideInfoWindow(); -// }, 8000); + UiThreadHandler.postDelayed(() -> { + stopLine.hideInfoWindow(); + }, showTime); } /** @@ -161,20 +159,15 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog if (info != null) { if (polyLine != null) { Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null"); - polyLine.setPoints(Arrays.asList(new MogoLatLng(info.getLat(), info.getLon()), - new MogoLatLng(info.getCollisionLat(), info.getCollisionLon()))); + polyLine.setPoints(Arrays.asList(new MogoLatLng(mNewLocation.lat, mNewLocation.lon), + new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon))); polyLine.setTransparency(0.5f); } else { - Log.e(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine == null"); DrawLineInfo lineInfo = new DrawLineInfo(); - MogoLatLng startLatlng = new MogoLatLng( - ((MogoLatLng) fillPoints.get(0)).lat, - ((MogoLatLng) fillPoints.get(0)).lon); - Log.d(V2XConst.LOG_NAME_WARN, "stop drawStopLine lon =" + startLatlng.lon + "--lat =" + startLatlng.lat); + MogoLatLng startLatlng = new MogoLatLng(mNewLocation.lat, mNewLocation.lon); MogoLatLng endLatlng = new MogoLatLng(mogoLatLng.lat, mogoLatLng.lon); - Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine lon =" + mogoLatLng.lon + "--lat =" + mogoLatLng.lat); - Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine lon =" + endLatlng.lon + "--lat =" + endLatlng.lat); - + Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine endLatlng lon =" + endLatlng.lon + "--lat =" + endLatlng.lat + + "--startLatlng lon = " + startLatlng.lon + "-lat = " + startLatlng.lat); lineInfo.setStartLocation(startLatlng); lineInfo.setEndLocation(endLatlng); lineInfo.setHeading(info.heading); @@ -201,7 +194,6 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog new MogoLatLng(info.getCollisionLat(), info.getCollisionLon()))); polyLine.setTransparency(0.5f); } else { - Log.e(V2XConst.LOG_NAME_WARN, "polyLine == null"); DrawLineInfo lineInfo = new DrawLineInfo(); MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon()); MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon()); @@ -228,7 +220,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog */ @Override public void onCarLocationChanged2(Location latLng) { - Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear); +// Log.d(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 latLng = " + latLng.getLatitude() + "--" + latLng.getLongitude() + "---isSelfLineClear = " + isSelfLineClear); //当行人经纬度交点 开始画线,否则清理 mCloundWarningInfo.setCarLocation(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude())); drawSlefCarLine(latLng); @@ -246,17 +238,22 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog if (!isSelfLineClear) { IMogoPolyline mogoPolyline = V2XServiceManager.getMoGoWarnPolylineManager().getMogoWarnPolyline(); if (mCloundWarningInfo != null) { + if (!isFirstLocation) { + mNewLocation = getMogoLat(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude())); + Log.d(V2XConst.LOG_NAME_WARN, "drawSlefCarLine lon = " + mNewLocation.lon + "---lat = " + mNewLocation.lat); + isFirstLocation = true; + } if (mogoPolyline != null) { mogoPolyline.setPoints(Arrays.asList(new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()), - new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lat : mCloundWarningInfo.getCollisionLat(), - mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lon : mCloundWarningInfo.getCollisionLon()))); + new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lat : mCloundWarningInfo.getCollisionLat(), + mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lon : mCloundWarningInfo.getCollisionLon()))); mogoPolyline.setTransparency(0.5f); } else { - Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 mogoPolyline == null width = " + mCloundWarningInfo.getRoadwidth()); +// Log.e(V2XConst.LOG_NAME_WARN, "onCarLocationChanged2 mogoPolyline == null width = " + mCloundWarningInfo.getRoadwidth()); DrawLineInfo info = new DrawLineInfo(); // 对象 MogoLatLng startLatlng = new MogoLatLng(latLng.getLatitude(), latLng.getLongitude()); - MogoLatLng endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lat : mCloundWarningInfo.getCollisionLat(), - mCloundWarningInfo.getDirection() == 1 ? mCloundWarningInfo.getStopLines().get(0).lon : mCloundWarningInfo.getCollisionLon()); + MogoLatLng endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lat : mCloundWarningInfo.getCollisionLat(), + mCloundWarningInfo.getDirection() == 1 ? mNewLocation.lon : mCloundWarningInfo.getCollisionLon()); info.setHeading(latLng.getBearing()); info.setStartLocation(startLatlng); info.setEndLocation(endLatlng); @@ -297,12 +294,10 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog } catch (Exception e) { e.printStackTrace(); } - } private MogoLatLng getMogoLat(MogoLatLng latlng) { MogoLatLng newLocation = LocationUtils.getNewLocation(latlng, mCloundWarningInfo.getDistance(), mCloundWarningInfo.getDirection()); - return newLocation; } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java index 6470241db7..c6b26b9c3a 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/scenario/scene/warning/V2XWarningMarker.java @@ -24,6 +24,7 @@ import com.mogo.module.v2x.marker.OptimalSpeedMarkerView; import com.mogo.module.v2x.marker.V2XFrontTargetMarkerView; import com.mogo.module.v2x.scenario.view.IV2XMarker; import com.mogo.module.v2x.utils.LocationUtils; +import com.mogo.utils.UiThreadHandler; import com.mogo.utils.ViewUtils; import com.mogo.utils.WorkThreadHandler; @@ -65,6 +66,9 @@ public class V2XWarningMarker implements IV2XMarker { optimalMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_FRONT_WARNING_MARKER, optionsRipple); optimalMarker.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(mContext))); optimalMarker.showInfoWindow(); + UiThreadHandler.postDelayed(() -> { + optimalMarker.hideInfoWindow(); + }, 8000); } catch (Exception e) { diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java index 33eafe8543..e47a234730 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/utils/TestOnLineCarUtils.java @@ -430,7 +430,7 @@ public class TestOnLineCarUtils { try { InputStream inputStream = V2XUtils.getApp() .getResources() - .openRawResource(R.raw.scenario_push_vr_event_data_yongdu_gongsi); + .openRawResource(R.raw.scenario_push_vr_event_data_yongdu_gongsi_1); ByteArrayOutputStream baos = new ByteArrayOutputStream(); int len = -1; byte[] buffer = new byte[1024]; diff --git a/modules/mogo-module-v2x/src/main/res/raw/scenario_push_vr_event_data_yongdu_gongsi_1.json b/modules/mogo-module-v2x/src/main/res/raw/scenario_push_vr_event_data_yongdu_gongsi_1.json new file mode 100644 index 0000000000..1f41a45323 --- /dev/null +++ b/modules/mogo-module-v2x/src/main/res/raw/scenario_push_vr_event_data_yongdu_gongsi_1.json @@ -0,0 +1,71 @@ +{ + "sceneId": "200008", + "alarmContent": "拥堵路线推荐", + "expireTime": 10000, + "sceneCategory": 0, + "sceneDescription": "拥堵路线推荐", + "sceneName": "拥堵路线推荐", + "sceneLevel": 0, + "videoUrl": "", + "videoChannel": "", + "videoSn": "", + "tts": "发现前方拥堵,最优路线快6分钟", + "zoom": false, + "zoomScale": 15, + "userHead": "", + "msgImgUrl": "", + "lat":39.969088, + "lon":116.41808, + "polyline": [ + [ + 116.417388,39.983351 + ], + [ + 116.417351,39.9841 + ], + [ + 116.417286,39.985423 + ], + [ + 116.417233,39.98673 + ], + [ + 116.417179,39.988156 + ], + [ + 116.417158,39.988493 + ], + [ + 116.417142,39.989245 + ], + [ + 116.417174,39.990199 + ] + ], + "recommendPolyline": [ + [ + 116.417388,39.983351 + ], + [ + 116.417351,39.9841 + ], + [ + 116.417286,39.985423 + ], + [ + 116.417233,39.98673 + ], + [ + 116.417179,39.988156 + ], + [ + 116.417158,39.988493 + ], + [ + 116.417142,39.989245 + ], + [ + 116.417174,39.990199 + ] + ] +} \ No newline at end of file diff --git a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json index 5963e668f3..c9530e4ff2 100644 --- a/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json +++ b/modules/mogo-module-v2x/src/main/res/raw/scenario_warning_event_data.json @@ -20,9 +20,13 @@ "direction": 1, "speed": 11.108121, "targetColor": "#FF4040", - "stopLineDistance": 15, + "stopLineDistance": 3000, "warningContent": "小心行人", "heading": 0, - "showTime": 3000, - "roadwidth": 60.0 + "showTime": 8000, + "roadwidth": 60.0, + "carLocation": { + "lat": 39.97665425, + "lon": 116.41769983 + } } \ No newline at end of file