diff --git a/foudations/mogo-commons/build.gradle b/foudations/mogo-commons/build.gradle index 790d2b2598..7f4fbc1edc 100644 --- a/foudations/mogo-commons/build.gradle +++ b/foudations/mogo-commons/build.gradle @@ -42,6 +42,8 @@ dependencies { annotationProcessor rootProject.ext.dependencies.aroutercompiler implementation rootProject.ext.dependencies.rxjava implementation rootProject.ext.dependencies.accountsdk + api rootProject.ext.dependencies.mogoaicloudrealtime + if (Boolean.valueOf(RELEASE)) { implementation rootProject.ext.dependencies.mogoutils api rootProject.ext.dependencies.ttsbase diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/data/ADASRecognizedResultConvert.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/data/ADASRecognizedResultConvert.java deleted file mode 100644 index 8f95af1893..0000000000 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/data/ADASRecognizedResultConvert.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.mogo.commons.data; - -/** - * @author lixiaopeng - * @description adas识别数据需要转换一下 - * @since 2021/4/23 - */ -public class ADASRecognizedResultConvert { - - /** - * 识别物体类型 - */ - public int type; - - /** - * 识别物体唯一标识 - */ - public String uuid; - - /** - * 红绿灯颜色 - */ - public String color; - - /** - * 车ID - */ - public String carId; - - /** - * 识别物体的纬度 - */ - public double lat; - - /** - * 识别物体的经度 - */ - public double lon; - - /** - * 车头朝向 - */ - public double heading; - - /** - * 系统时间 - */ - public long systemTime; - - /** - * 定位卫星时间 - */ - public long satelliteTime; - - /** - * 海拔 - */ - public double alt; - - /** - * 速度 - */ - public double speed; - - /** - * 莫顿码 - */ - public long mortonCode; - - /** - * 实际距离 - * 使用distanceX和distanceY计算 - */ - public double distance; - - /** - * 数据来源精度 - * 0:普通定位 - * 1:高精定位 - */ - public int dataAccuracy; - - /** - * 道路ID - */ - private String roadId; - - /** - * 车道ID-2D路段 - */ - private String laneId; - - /** - * 车道号:中心线编号为0,中心线右侧编号为负数,3车道通行Road的车道编号,0,-1,-2,-3 - */ - private int laneNum; - - /** - * 限速 - */ - private double rateLimiting; - - /** - * 车道宽度 - */ - private double roadWidth; -} diff --git a/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java b/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java index 1713f11156..66e764dab9 100644 --- a/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java +++ b/foudations/mogo-commons/src/main/java/com/mogo/commons/debug/DebugConfig.java @@ -1,7 +1,5 @@ package com.mogo.commons.debug; -import android.text.TextUtils; - /** * @author congtaowang * @since 2019-12-23 @@ -28,7 +26,7 @@ public class DebugConfig { * * @param sDebug true - 调试模式 false - 非调试模式 */ - public static void setDebug( boolean sDebug ) { + public static void setDebug(boolean sDebug) { DebugConfig.sDebug = sDebug; } @@ -69,7 +67,7 @@ public class DebugConfig { */ public static final int AI_TYPE_SPEECH = 2; - private static int sAIType = AI_TYPE_TXZ; + private static final int sAIType = AI_TYPE_TXZ; /** * 自研车机 @@ -116,7 +114,7 @@ public class DebugConfig { * {@link #NET_MODE_DEMO} * {@link #NET_MODE_RELEASE} */ - public static void setNetMode( int netMode ) { + public static void setNetMode(int netMode) { DebugConfig.sNetMode = netMode; } @@ -129,7 +127,7 @@ public class DebugConfig { return sLaunchLocationService; } - public static void setLaunchLocationService( boolean launchLocationService ) { + public static void setLaunchLocationService(boolean launchLocationService) { DebugConfig.sLaunchLocationService = launchLocationService; } @@ -142,7 +140,7 @@ public class DebugConfig { return sUseCustomNavi; } - public static void setUseCustomNavi( boolean sUseCustomNavi ) { + public static void setUseCustomNavi(boolean sUseCustomNavi) { DebugConfig.sUseCustomNavi = sUseCustomNavi; } @@ -151,7 +149,7 @@ public class DebugConfig { * * @param type {@link #CAR_MACHINE_TYPE_SELF_INNOVATE} {@link #CAR_MACHINE_TYPE_BYD} */ - public static void setCarMachineType( int type ) { + public static void setCarMachineType(int type) { sCarMachineType = type; } @@ -173,7 +171,7 @@ public class DebugConfig { return sIsLauncher; } - public static void setLauncher( boolean isLauncher ) { + public static void setLauncher(boolean isLauncher) { DebugConfig.sIsLauncher = isLauncher; } @@ -183,7 +181,7 @@ public class DebugConfig { return sRequestOnlineCarData; } - public static void setRequestOnlineCarData( boolean sRequestOnlineCarData ) { + public static void setRequestOnlineCarData(boolean sRequestOnlineCarData) { DebugConfig.sRequestOnlineCarData = sRequestOnlineCarData; } @@ -193,7 +191,7 @@ public class DebugConfig { return sUseCustomMap; } - public static void setUseCustomMap( boolean sUseCustomMap ) { + public static void setUseCustomMap(boolean sUseCustomMap) { DebugConfig.sUseCustomMap = sUseCustomMap; } @@ -206,13 +204,13 @@ public class DebugConfig { return sActiveAIAssistFlag; } - public static void setActiveAIAssistFlag( boolean sActiveAIAssistFlag ) { + public static void setActiveAIAssistFlag(boolean sActiveAIAssistFlag) { DebugConfig.sActiveAIAssistFlag = sActiveAIAssistFlag; } private static boolean useMockObuData; - public static void setUseMockObuData( boolean use ) { + public static void setUseMockObuData(boolean use) { useMockObuData = use; } @@ -231,13 +229,13 @@ public class DebugConfig { * * @param sProductFlavor */ - public static void setProductFlavor( String sProductFlavor ) { + public static void setProductFlavor(String sProductFlavor) { DebugConfig.sProductFlavor = sProductFlavor; } private static String sSocketAppId; - public static void setSocketAppId( String sSocketAppId ) { + public static void setSocketAppId(String sSocketAppId) { DebugConfig.sSocketAppId = sSocketAppId; } @@ -254,14 +252,14 @@ public class DebugConfig { return sRoadEventAnimated; } - public static void setRoadEventAnimated( boolean sRoadEventAnimated ) { + public static void setRoadEventAnimated(boolean sRoadEventAnimated) { DebugConfig.sRoadEventAnimated = sRoadEventAnimated; } private static boolean sLoadGuideModule = false; - public static void setLoadGuideModule( boolean sLoadGuideModule ) { + public static void setLoadGuideModule(boolean sLoadGuideModule) { DebugConfig.sLoadGuideModule = sLoadGuideModule; } @@ -277,7 +275,7 @@ public class DebugConfig { private static boolean isSkinSupported = false; - public static void setSkinSupported( boolean isSkinSupported ) { + public static void setSkinSupported(boolean isSkinSupported) { DebugConfig.isSkinSupported = isSkinSupported; } @@ -290,7 +288,7 @@ public class DebugConfig { */ private static boolean isSupportedSearchDestinationOnlineCarList = false; - public static void setSupportedSearchDestinationOnlineCarList( boolean isSupportedSearchDestinationOnlineCarList ) { + public static void setSupportedSearchDestinationOnlineCarList(boolean isSupportedSearchDestinationOnlineCarList) { DebugConfig.isSupportedSearchDestinationOnlineCarList = isSupportedSearchDestinationOnlineCarList; } @@ -303,7 +301,7 @@ public class DebugConfig { */ private static boolean isScheduleCalculateNotHomeCompanyDistanceForPush = false; - public static void setScheduleCalculateNotHomeCompanyDistanceForPush( boolean isScheduleCalculateNotHomeCompanyDistanceForPush ) { + public static void setScheduleCalculateNotHomeCompanyDistanceForPush(boolean isScheduleCalculateNotHomeCompanyDistanceForPush) { DebugConfig.isScheduleCalculateNotHomeCompanyDistanceForPush = isScheduleCalculateNotHomeCompanyDistanceForPush; } @@ -316,7 +314,7 @@ public class DebugConfig { */ private static boolean isSupportLauncherCardRefreshStrategy = false; - public static void setSupportLauncherCardRefreshStrategy( boolean isSupportLauncherCardRefreshStrategy ) { + public static void setSupportLauncherCardRefreshStrategy(boolean isSupportLauncherCardRefreshStrategy) { DebugConfig.isSupportLauncherCardRefreshStrategy = isSupportLauncherCardRefreshStrategy; } @@ -330,7 +328,7 @@ public class DebugConfig { return obuType; } - public static void setObuType( int type ) { + public static void setObuType(int type) { obuType = type; } @@ -339,7 +337,7 @@ public class DebugConfig { */ private static boolean needRequestUserInfo = false; - public static void setNeedRequestUserInfo( boolean needRequestUserInfo ) { + public static void setNeedRequestUserInfo(boolean needRequestUserInfo) { DebugConfig.needRequestUserInfo = needRequestUserInfo; } @@ -356,13 +354,13 @@ public class DebugConfig { return isMapBased; } - public static void setMapBased( boolean isMapBased ) { + public static void setMapBased(boolean isMapBased) { DebugConfig.isMapBased = isMapBased; } private static boolean isNeedLoadGuideModule = true; - public static void setNeedLoadGuideModule( boolean isNeedLoadGuideModule ) { + public static void setNeedLoadGuideModule(boolean isNeedLoadGuideModule) { DebugConfig.isNeedLoadGuideModule = isNeedLoadGuideModule; } @@ -376,7 +374,7 @@ public class DebugConfig { return isNeedHideAdasWhenShare; } - public static void setNeedHideAdasWhenShare( boolean isNeedHideAdas ) { + public static void setNeedHideAdasWhenShare(boolean isNeedHideAdas) { DebugConfig.isNeedHideAdasWhenShare = isNeedHideAdas; } @@ -389,7 +387,7 @@ public class DebugConfig { return sIsNeedUploadCoordinatesInTime; } - public static void setNeedUploadCoordinatesInTime( boolean sIsNeedUploadCoordinatesInTime ) { + public static void setNeedUploadCoordinatesInTime(boolean sIsNeedUploadCoordinatesInTime) { DebugConfig.sIsNeedUploadCoordinatesInTime = sIsNeedUploadCoordinatesInTime; } @@ -402,7 +400,7 @@ public class DebugConfig { return sIsUseAdasRtkLocationInfo; } - public static void setUseAdasRtkLocationInfo( boolean sIsUseAdasRtkLocationInfo ) { + public static void setUseAdasRtkLocationInfo(boolean sIsUseAdasRtkLocationInfo) { DebugConfig.sIsUseAdasRtkLocationInfo = sIsUseAdasRtkLocationInfo; } @@ -412,17 +410,17 @@ public class DebugConfig { return sIsNotSmooth; } - public static void setNotSmooth( boolean sIsNotSmooth ) { + public static void setNotSmooth(boolean sIsNotSmooth) { DebugConfig.sIsNotSmooth = sIsNotSmooth; } public static boolean isOCHModule() { - return sProductFlavor != null && sProductFlavor.startsWith( "foch" ); + return sProductFlavor != null && sProductFlavor.startsWith("foch"); } public static int sSelfCarSpeedYOffset = 20; - public static void setSelfCarSpeedYOffset( int sSelfCarSpeedYOffset ) { + public static void setSelfCarSpeedYOffset(int sSelfCarSpeedYOffset) { DebugConfig.sSelfCarSpeedYOffset = sSelfCarSpeedYOffset; } @@ -436,20 +434,28 @@ public class DebugConfig { public static final int sDownloadSnapshot = 2; public static final int sAutoPilotStatus = 3; public static final int sDownloadLink = 4; + public static final int sLon = 5; + public static final int sLat = 6; public static String[] sStatus = new String[]{ "false", "false", "false", "0", - "false" + "false", + "0", + "0" }; - public synchronized static void setStatus( int type, boolean status ) { - sStatus[type] = String.valueOf( status ); + public synchronized static void setStatus(int type, boolean status) { + sStatus[type] = String.valueOf(status); } - public synchronized static void setAutoPilotStatus( String status ) { + public synchronized static void setStatusData(int type, double data) { + sStatus[type] = String.valueOf(data); + } + + public synchronized static void setAutoPilotStatus(String status) { sStatus[sAutoPilotStatus] = status; } @@ -457,13 +463,21 @@ public class DebugConfig { return sStatus[sAutoPilotStatus]; } - public synchronized static String getStatus( int type, boolean set2False ) { + public synchronized static String getStatus(int type, boolean set2False) { String result = sStatus[type]; - if ( set2False ) { + if (set2False) { sStatus[type] = "false"; } return result; } + + public synchronized static String getStatusData(int type){ + if(type > 4){ + return sStatus[type].toString(); + }else{ + return "0"; + } + } private static boolean isUseAdasRecognize = true; @@ -471,7 +485,7 @@ public class DebugConfig { isUseAdasRecognize = status; } - public static boolean isUseAdasRecognize(){ + public static boolean isUseAdasRecognize() { return isUseAdasRecognize; } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java index a613ac51e8..353a895fcb 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapNaviViewWrapper.java @@ -50,6 +50,7 @@ import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.MapCameraPosition; import com.mogo.map.uicontroller.MapControlResult; +import com.mogo.realtime.entity.ADASRecognizedResult; import com.mogo.utils.WindowUtils; import com.mogo.utils.logger.Logger; @@ -1044,7 +1045,7 @@ public class AMapNaviViewWrapper implements IMogoMapView, } @Override - public void setAdasRecognizedResult(String result) { - //liyz + public void setAdasRecognizedResult(ADASRecognizedResult result) { + } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java index 57c8ca3287..827d11b6e0 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/AMapViewWrapper.java @@ -47,6 +47,7 @@ import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.MapCameraPosition; import com.mogo.map.uicontroller.MapControlResult; +import com.mogo.realtime.entity.ADASRecognizedResult; import com.mogo.utils.NetworkUtils; import com.mogo.utils.WindowUtils; import com.mogo.utils.logger.Logger; @@ -817,7 +818,7 @@ public class AMapViewWrapper implements IMogoMapView, } @Override - public void setAdasRecognizedResult(String result) { - //liyz + public void setAdasRecognizedResult(ADASRecognizedResult result) { + } } diff --git a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java index a3736b90b5..27daabc64b 100644 --- a/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java +++ b/libraries/map-amap/src/main/java/com/mogo/map/impl/amap/uicontroller/AMapUIController.java @@ -14,6 +14,7 @@ import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.MapCameraPosition; import com.mogo.map.uicontroller.MapControlResult; +import com.mogo.realtime.entity.ADASRecognizedResult; import com.mogo.utils.logger.Logger; import java.util.List; @@ -300,7 +301,7 @@ public class AMapUIController implements IMogoMapUIController { } @Override - public void setAdasRecognizedResult(String result) { + public void setAdasRecognizedResult(ADASRecognizedResult result) { if ( mClient != null ) { mClient.setAdasRecognizedResult(result); } diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java index 3ed503ae0f..8b0023dcf1 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java @@ -16,8 +16,6 @@ import android.view.ViewGroup; import android.view.animation.Interpolator; import android.widget.TextView; -import com.autonavi.nge.map.LonLat; -import com.mogo.commons.data.ADASRecognizedResultConvert; import com.mogo.commons.debug.DebugConfig; import com.mogo.map.IMogoMap; import com.mogo.map.IMogoMapView; @@ -35,6 +33,7 @@ import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.MapCameraPosition; import com.mogo.map.uicontroller.MapControlResult; +import com.mogo.realtime.entity.ADASRecognizedResult; import com.mogo.utils.TipToast; import com.mogo.utils.UiThreadHandler; import com.mogo.utils.WorkThreadHandler; @@ -288,15 +287,6 @@ public class AMapViewWrapper implements IMogoMapView, } - private ADASRecognizedResultConvert mAdasResultConvert; - - - @Override - public void setAdasRecognizedResult(String result) { - Log.d("liyz", "------- setAdasRecognizedResult ------>result = " + result); - mAdasResultConvert = GsonUtil.objectFromJson(result, ADASRecognizedResultConvert.class); - } - @Override public void setTrafficEnabled(boolean visible) { if (checkAMapView()) { @@ -773,7 +763,6 @@ public class AMapViewWrapper implements IMogoMapView, } if (mSelfMarker == null) { //TODO mAdasResultConvert -// Log.d("liyz", "-------1------>"); try { mSelfMarker = mMapView.getMapAutoViewHelper().getMyLocationStyle().getSelfMarker(); mSelfMarker.setInfoWindowEnable(true); @@ -781,15 +770,28 @@ public class AMapViewWrapper implements IMogoMapView, } catch (Exception e) { } // } else { -// Log.d("liyz", "-------2------>"); -// mSelfMarker.marker3DIcon(R.raw.people); // WorkThreadHandler.getInstance().postDelayed(() -> { // mSelfMarker.marker3DIcon(R.raw.people); // }, 10000); + +// if (mAdasResult.type == 1) { //通过不同的方向类型来改变车模,目前暂定三种模型,还未定 +// Log.d("liyz", "-------1------>") +// mSelfMarker.marker3DIcon(R.raw.people); +// } + } + showSelfSpeed(location.getSpeed()); } + private ADASRecognizedResult mAdasResult; + + @Override + public void setAdasRecognizedResult(ADASRecognizedResult result) { + mAdasResult = result; + } + + private TextView mSpeedView = null; private int mLastYOffset = 20; diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java index 5aed07f73e..e2aa930e1b 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/uicontroller/AMapUIController.java @@ -13,6 +13,7 @@ import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.MapCameraPosition; import com.mogo.map.uicontroller.MapControlResult; +import com.mogo.realtime.entity.ADASRecognizedResult; import com.zhidaoauto.map.sdk.open.MapAutoApi; import org.json.JSONObject; @@ -359,7 +360,7 @@ public class AMapUIController implements IMogoMapUIController { } @Override - public void setAdasRecognizedResult(String result) { + public void setAdasRecognizedResult(ADASRecognizedResult result) { if (mClient != null) { mClient.setAdasRecognizedResult(result); } diff --git a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java index 77d1460bab..a5a53de416 100644 --- a/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java +++ b/libraries/mogo-map-api/src/main/java/com/mogo/map/uicontroller/IMogoMapUIController.java @@ -11,6 +11,7 @@ import androidx.annotation.Nullable; import com.mogo.map.MogoLatLng; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.anim.OnMarkerAnimationListener; +import com.mogo.realtime.entity.ADASRecognizedResult; import org.json.JSONObject; @@ -236,7 +237,7 @@ public interface IMogoMapUIController { */ void changeBearing( float bearing ); - void setAdasRecognizedResult(String result); + void setAdasRecognizedResult(ADASRecognizedResult result); /** * 获取瓦片id diff --git a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java index 14b7db6a78..a92d3f251b 100644 --- a/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java +++ b/libraries/mogo-map/src/main/java/com/mogo/map/MogoMapUIController.java @@ -12,6 +12,7 @@ import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.map.uicontroller.MapCameraPosition; import com.mogo.map.uicontroller.MapControlResult; +import com.mogo.realtime.entity.ADASRecognizedResult; import com.mogo.utils.logger.Logger; import org.json.JSONObject; @@ -403,7 +404,7 @@ public class MogoMapUIController implements IMogoMapUIController { } @Override - public void setAdasRecognizedResult(String result) { + public void setAdasRecognizedResult(ADASRecognizedResult result) { initDelegate(); if (mDelegate != null) { mDelegate.setAdasRecognizedResult(result); diff --git a/modules/mogo-module-common/src/main/java/com/mogo/module/common/uploadintime/SnapshotLocationController.java b/modules/mogo-module-common/src/main/java/com/mogo/module/common/uploadintime/SnapshotLocationController.java index 8ff04c3c59..c3e01a13b4 100644 --- a/modules/mogo-module-common/src/main/java/com/mogo/module/common/uploadintime/SnapshotLocationController.java +++ b/modules/mogo-module-common/src/main/java/com/mogo/module/common/uploadintime/SnapshotLocationController.java @@ -11,12 +11,12 @@ import java.util.ArrayList; import java.util.List; public -/* - * @author congtaowang - * @since 2020/12/14 - * - * 实时坐标数据处理中心 - */ + /* + * @author congtaowang + * @since 2020/12/14 + * + * 实时坐标数据处理中心 + */ class SnapshotLocationController { private static final String TAG = "SnapshotLocationController"; @@ -27,9 +27,9 @@ class SnapshotLocationController { } public static SnapshotLocationController getInstance() { - if ( sInstance == null ) { - synchronized ( SnapshotLocationController.class ) { - if ( sInstance == null ) { + if (sInstance == null) { + synchronized (SnapshotLocationController.class) { + if (sInstance == null) { sInstance = new SnapshotLocationController(); } } @@ -44,10 +44,10 @@ class SnapshotLocationController { private CloudLocationInfo mLastLocationInfo = null; // GPS(1s1次) RTK(OS侧)缓存数据, - private final List< CloudLocationInfo > mLocationList = new ArrayList<>(); + private final List mLocationList = new ArrayList<>(); // adda 工控机数据缓存 - private final List< CloudLocationInfo > mMachineCacheList = new ArrayList<>(); + private final List mMachineCacheList = new ArrayList<>(); private int mDataAccuracy = 0; private double mCurSpeed; @@ -59,15 +59,15 @@ class SnapshotLocationController { * * @param cli {@link CloudLocationInfo} */ - public void syncLocationInfo( CloudLocationInfo cli ) { - if ( cli == null ) { + public void syncLocationInfo(CloudLocationInfo cli) { + if (cli == null) { return; } mLastLocationInfo = cli; mCurSpeed = cli.getSpeed(); mCurLon = cli.getLon(); mCurLat = cli.getLat(); - mLocationList.add( cli ); + mLocationList.add(cli); } /** @@ -75,33 +75,39 @@ class SnapshotLocationController { * * @param data JSON结构化数据 */ - public void syncAdasLocationInfo( JSONObject data ) { - if ( data == null ) { + public void syncAdasLocationInfo(JSONObject data) { + if (data == null) { return; } - DebugConfig.setStatus( DebugConfig.sLocation, true ); - Logger.d( TAG, "同步到rtk数据" ); - double lon = data.optDouble( "lon", -1 ); - double lat = data.optDouble( "lat", -1 ); - double alt = data.optDouble( "alt", -1 ); - double heading = data.optDouble( "heading", -1 ); - double acceleration = data.optDouble( "acceleration", -1 ); - double yawRate = data.optDouble( "yawRate", -1 ); - double speed = data.optDouble( "speed", -1 ); - long satelliteTime = data.optLong( "satelliteTime" ); - long systemTime = data.optLong( "systemTime" ); + //测试面板状态同步 + DebugConfig.setStatus(DebugConfig.sLocation, true); + + Logger.d(TAG, "同步到rtk数据"); + double lon = data.optDouble("lon", -1); + double lat = data.optDouble("lat", -1); + double alt = data.optDouble("alt", -1); + double heading = data.optDouble("heading", -1); + double acceleration = data.optDouble("acceleration", -1); + double yawRate = data.optDouble("yawRate", -1); + double speed = data.optDouble("speed", -1); + long satelliteTime = data.optLong("satelliteTime"); + long systemTime = data.optLong("systemTime"); + + //测试面板状态同步 + DebugConfig.setStatusData(DebugConfig.sLon, lon); + DebugConfig.setStatusData(DebugConfig.sLat, lat); CloudLocationInfo cloudLocationInfo = new CloudLocationInfo(); - cloudLocationInfo.setAlt( alt ); - cloudLocationInfo.setHeading( heading ); - cloudLocationInfo.setLat( lat ); - cloudLocationInfo.setLon( lon ); - cloudLocationInfo.setSpeed( speed ); - cloudLocationInfo.setSatelliteTime( satelliteTime ); - cloudLocationInfo.setSystemTime( systemTime ); - cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getTileId(lon,lat))); + cloudLocationInfo.setAlt(alt); + cloudLocationInfo.setHeading(heading); + cloudLocationInfo.setLat(lat); + cloudLocationInfo.setLon(lon); + cloudLocationInfo.setSpeed(speed); + cloudLocationInfo.setSatelliteTime(satelliteTime); + cloudLocationInfo.setSystemTime(systemTime); + cloudLocationInfo.setTileId(String.valueOf(MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().getTileId(lon, lat))); mLastLocationInfo = cloudLocationInfo; - mMachineCacheList.add( cloudLocationInfo ); + mMachineCacheList.add(cloudLocationInfo); mCurSpeed = cloudLocationInfo.getSpeed(); mCurLon = cloudLocationInfo.getLon(); @@ -113,29 +119,29 @@ class SnapshotLocationController { * * @return 坐标合集 */ - public List< CloudLocationInfo > getSendLocationData() { + public List getSendLocationData() { - List< CloudLocationInfo > list = null; - if ( mMachineCacheList != null ) { + List list = null; + if (mMachineCacheList != null) { mDataAccuracy = 1; - list = new ArrayList<>( mMachineCacheList ); + list = new ArrayList<>(mMachineCacheList); mMachineCacheList.clear(); } - if ( list == null || list.isEmpty() ) { + if (list == null || list.isEmpty()) { mDataAccuracy = 0; - if ( mLocationList != null ) { - list = new ArrayList<>( mLocationList ); + if (mLocationList != null) { + list = new ArrayList<>(mLocationList); mLocationList.clear(); } } - if ( list == null || list.isEmpty() ) { - if ( mLastLocationInfo != null ) { + if (list == null || list.isEmpty()) { + if (mLastLocationInfo != null) { list = new ArrayList(); - list.add( mLastLocationInfo ); + list.add(mLastLocationInfo); mLastLocationInfo = null; } } - Logger.d( TAG, "upload loc size = %s", list == null ? 0 : list.size() ); + Logger.d(TAG, "upload loc size = %s", list == null ? 0 : list.size()); return list; } @@ -145,7 +151,7 @@ class SnapshotLocationController { * @return 精度 */ public int getDataAccuracy() { - Logger.d( TAG, "upload loc accuracy = %s", mDataAccuracy ); + Logger.d(TAG, "upload loc accuracy = %s", mDataAccuracy); return mDataAccuracy; } diff --git a/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java b/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java index 214d81ea08..9b9f0d7615 100644 --- a/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java +++ b/modules/mogo-module-main/src/main/java/com/mogo/module/main/service/MogoMainService.java @@ -26,7 +26,7 @@ public * * 描述 */ -@Route( path = "/service/base/info" ) +@Route(path = "/service/base/info") class MogoMainService extends Service implements IMogoLocationListener { private static final String TAG = "MogoMainService"; @@ -39,10 +39,10 @@ class MogoMainService extends Service implements IMogoLocationListener { @Override public void onCreate() { - Logger.d( TAG, "基本服务启动" ); + Logger.d(TAG, "基本服务启动"); mServiceApis = MogoApisHandler.getInstance().getApis(); initAndStartLocation(); - UiThreadHandler.postDelayed( () -> { + UiThreadHandler.postDelayed(() -> { loadBaseModules(); startTanluService(); initADAS(); @@ -56,53 +56,61 @@ class MogoMainService extends Service implements IMogoLocationListener { @Nullable @Override - public IBinder onBind( Intent intent ) { + public IBinder onBind(Intent intent) { return null; } @Override - public int onStartCommand( Intent intent, int flags, int startId ) { + public int onStartCommand(Intent intent, int flags, int startId) { return START_STICKY; } private void initAndStartLocation() { - Logger.d( TAG, "开始定位" ); - mLocationClient = mServiceApis.getMapServiceApi().getSingletonLocationClient( AbsMogoApplication.getApp() ); - mLocationClient.addLocationListener( this ); - mLocationClient.start( 2_000L ); + Logger.d(TAG, "开始定位"); + if (mServiceApis != null) { + mLocationClient = mServiceApis.getMapServiceApi().getSingletonLocationClient(AbsMogoApplication.getApp()); + mLocationClient.addLocationListener(this); + mLocationClient.start(2_000L); + } } private void initGpsSimulatorListener() { - mServiceApis.getMapServiceApi().getNavi( this ).registerCarLocationChangedListener( EventDispatchCenter.getInstance() ); + if (mServiceApis != null) { + mServiceApis.getMapServiceApi().getNavi(this).registerCarLocationChangedListener(EventDispatchCenter.getInstance()); + } } private void loadBaseModules() { - Logger.d( TAG, "加载基本模块" ); + Logger.d(TAG, "加载基本模块"); MogoModulesManager.getInstance().loadBaseModule(); } private void startTanluService() { - UiThreadHandler.postDelayed( () -> { - Logger.d( TAG, "startTanluService ---------- " ); - mServiceApis.getTanluApi().startTanluService(); + UiThreadHandler.postDelayed(() -> { + Logger.d(TAG, "startTanluService ---------- "); + if (mServiceApis != null) { + mServiceApis.getTanluApi().startTanluService(); + } }, 2_000L ); } private void initADAS() { - mServiceApis.getAdasControllerApi().init( AbsMogoApplication.getApp() ); + if (mServiceApis != null) { + mServiceApis.getAdasControllerApi().init(AbsMogoApplication.getApp()); + } } @Override - public void onLocationChanged( MogoLocation location ) { - EventDispatchCenter.getInstance().onLocationChanged( location ); + public void onLocationChanged(MogoLocation location) { + EventDispatchCenter.getInstance().onLocationChanged(location); } @Override public void onDestroy() { super.onDestroy(); - if ( mLocationClient != null ) { - mLocationClient.removeLocationListener( this ); + if (mLocationClient != null) { + mLocationClient.removeLocationListener(this); mLocationClient.stop(); mLocationClient.destroy(); mLocationClient = null; diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java index abbc83a430..c2046944b6 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/MarkerServiceHandler.java @@ -7,6 +7,7 @@ import com.mogo.map.location.IMogoLocationClient; import com.mogo.map.marker.IMogoMarker; import com.mogo.map.marker.IMogoMarkerManager; import com.mogo.map.navi.IMogoNavi; +import com.mogo.map.overlay.IMogoOverlayManager; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.drawer.MarkerDrawer; @@ -61,6 +62,7 @@ public class MarkerServiceHandler { private static IMogoFragmentManager sFragmentManager; private static ICarsChattingProvider sCarChatting; private static IV2XProvider sIV2XProvider; + private static IMogoOverlayManager sIMogoOverlayManager; // private static IMogoGpsSimulatorManager sGpsSimulatorManager; @@ -77,6 +79,7 @@ public class MarkerServiceHandler { sMogoSocketManager = sApis.getSocketManagerApi( context ); sMogoAnalytics = sApis.getAnalyticsApi(); sMarkerManager = sMapService.getMarkerManager( context ); + sIMogoOverlayManager = sMapService.getOverlayManager(context); sNavi = sMapService.getNavi( context ); sMapUIController = sMapService.getMapUIController(); sLocationClient = sMapService.getSingletonLocationClient( context ); @@ -87,7 +90,6 @@ public class MarkerServiceHandler { sADASController = sApis.getAdasControllerApi(); sLauncher = sApis.getLauncherApi(); sFragmentManager = sApis.getFragmentManagerApi(); - sCarChatting = ( ICarsChattingProvider ) ARouter.getInstance().build( CallChattingProviderConstant.CAR_CALL_PROVIDER ).navigation( context ); sIV2XProvider = sApis.getV2XListenerManager(); @@ -172,7 +174,15 @@ public class MarkerServiceHandler { return sCarChatting; } -// public static IMogoGpsSimulatorManager getGpsSimulatorManager() { + public static IMogoOverlayManager getsIMogoOverlayManager() { + return sIMogoOverlayManager; + } + + public static void setsIMogoOverlayManager(IMogoOverlayManager sIMogoOverlayManager) { + MarkerServiceHandler.sIMogoOverlayManager = sIMogoOverlayManager; + } + + // public static IMogoGpsSimulatorManager getGpsSimulatorManager() { // return sGpsSimulatorManager; // } diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java index 7899318da8..aee1f07bf2 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/intent/MockIntentHandler.java @@ -30,7 +30,6 @@ import com.mogo.map.search.geo.query.MogoRegeocodeQuery; import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.constants.DataTypes; import com.mogo.module.common.dialog.WMDialog; -import com.mogo.module.common.drawer.AdasRecognizedResultDrawer; import com.mogo.module.common.drawer.SnapshotSetDataDrawer; import com.mogo.module.common.uploadintime.SnapshotLocationController; import com.mogo.module.service.MarkerServiceHandler; @@ -48,7 +47,6 @@ import com.mogo.utils.logger.Logger; import com.mogo.utils.network.utils.GsonUtil; import com.mogo.utils.storage.SharedPrefsMgr; -import org.json.JSONArray; import org.json.JSONObject; import java.io.BufferedReader; @@ -70,107 +68,103 @@ public class MockIntentHandler implements IntentHandler { private IMogoMarker centerMarker; @Override - public void handle( Context context, Intent intent ) { - if ( !DebugConfig.isDebug() ) { + public void handle(Context context, Intent intent) { + if (!DebugConfig.isDebug()) { return; } - final int oper = intent.getIntExtra( "oper", -1 ); - switch ( oper ) { + final int oper = intent.getIntExtra("oper", -1); + switch (oper) { case 1: - MarkerServiceHandler.getMapUIController().showMyLocation( intent.getBooleanExtra( "status", true ) ); + MarkerServiceHandler.getMapUIController().showMyLocation(intent.getBooleanExtra("status", true)); break; case 2: - boolean status = intent.getBooleanExtra( "status", false ); - MarkerServiceHandler.getMogoStatusManager().setSeekHelping( TAG, status ); + boolean status = intent.getBooleanExtra("status", false); + MarkerServiceHandler.getMogoStatusManager().setSeekHelping(TAG, status); break; case 3: - String msg = intent.getStringExtra( "msg" ); - if ( !TextUtils.isEmpty( msg ) ) { - TipToast.shortTip( msg ); + String msg = intent.getStringExtra("msg"); + if (!TextUtils.isEmpty(msg)) { + TipToast.shortTip(msg); } break; case 4:// 测试左侧按钮1 - TextView button1 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON1 ); - if ( button1 != null ) { - button1.setVisibility( View.VISIBLE ); - button1.setBackgroundColor( Color.RED ); - button1.setOnClickListener( view -> { - } ); + TextView button1 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton(ButtonIndex.BUTTON1); + if (button1 != null) { + button1.setVisibility(View.VISIBLE); + button1.setBackgroundColor(Color.RED); + button1.setOnClickListener(view -> { + }); } break; case 5:// 测试左侧按钮2 - TextView button2 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON2 ); - if ( button2 != null ) { - button2.setOnClickListener( null ); - button2.setVisibility( View.GONE ); + TextView button2 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton(ButtonIndex.BUTTON2); + if (button2 != null) { + button2.setOnClickListener(null); + button2.setVisibility(View.GONE); } break; case 6:// - boolean status1 = intent.getBooleanExtra( "status", false ); - MarkerServiceHandler.getMogoStatusManager().setUploadingStatus( TAG, status1 ); + boolean status1 = intent.getBooleanExtra("status", false); + MarkerServiceHandler.getMogoStatusManager().setUploadingStatus(TAG, status1); break; case 7:// 打开微信 - TextView button11 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton( ButtonIndex.BUTTON1 ); - if ( button11 != null ) { - button11.setVisibility( View.VISIBLE ); - button11.setBackgroundColor( Color.RED ); - button11.setOnClickListener( view -> { + TextView button11 = MarkerServiceHandler.getApis().getEntranceButtonController().getButton(ButtonIndex.BUTTON1); + if (button11 != null) { + button11.setVisibility(View.VISIBLE); + button11.setBackgroundColor(Color.RED); + button11.setOnClickListener(view -> { Intent intent1 = new Intent(); - intent1.setAction( Intent.ACTION_VIEW ); - intent1.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK ); - intent1.setData( Uri.parse( "wechathelper://com.zhidao.wechathelper/main/transform?type=navi&lon=116.327007&lat=39.977639&from=os2.0" ) ); + intent1.setAction(Intent.ACTION_VIEW); + intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent1.setData(Uri.parse("wechathelper://com.zhidao.wechathelper/main/transform?type=navi&lon=116.327007&lat=39.977639&from=os2.0")); try { - view.setOnClickListener( null ); - view.getContext().startActivity( intent1 ); - } catch ( Exception e ) { + view.setOnClickListener(null); + view.getContext().startActivity(intent1); + } catch (Exception e) { e.printStackTrace(); } - view.setVisibility( View.GONE ); - } ); + view.setVisibility(View.GONE); + }); } break; case 8:// 测试修改车头角度 - float bearing = intent.getFloatExtra( "bearing", 0 ); - MarkerServiceHandler.getMapUIController().changeBearing( bearing ); + float bearing = intent.getFloatExtra("bearing", 0); + MarkerServiceHandler.getMapUIController().changeBearing(bearing); break; case 9:// 测试弹窗 - new WMDialog.Builder( context ) - .setOkButton( "确认", ( dlg, which ) -> { - dlg.dismiss(); - } ) - .setCancelButton( "取消", ( dlg, which ) -> { - dlg.dismiss(); - } ) - .setContent( "内容内容内容内容内容内容内容内容" ) + new WMDialog.Builder(context) + .setOkButton("确认", (dlg, which) -> dlg.dismiss()) + .setCancelButton("取消", (dlg, which) -> dlg.dismiss()) + .setContent("内容内容内容内容内容内容内容内容") .build() .show(); break; case 10://测试GEO查询 - IMogoGeoSearch geoSearch = MarkerServiceHandler.getMapService().getGeoSearch( context ); - geoSearch.setGeoSearchListener( new IMogoGeoSearchListener() { + IMogoGeoSearch geoSearch = MarkerServiceHandler.getMapService().getGeoSearch(context); + geoSearch.setGeoSearchListener(new IMogoGeoSearchListener() { @Override - public void onRegeocodeSearched( MogoRegeocodeResult regeocodeResult ) { - Logger.d( TAG, GsonUtil.jsonFromObject( regeocodeResult ) ); + public void onRegeocodeSearched(MogoRegeocodeResult regeocodeResult) { + Logger.d(TAG, GsonUtil.jsonFromObject(regeocodeResult)); } @Override - public void onGeocodeSearched( MogoGeocodeResult geocodeResult ) { + public void onGeocodeSearched(MogoGeocodeResult geocodeResult) { } - } ); + }); MogoRegeocodeQuery query = new MogoRegeocodeQuery(); - query.setLatlngType( "autonavi" ); - query.setPoint( new MogoLatLng( intent.getFloatExtra( "lat", 39.917366f ), intent.getFloatExtra( "lon", 116.39962f ) ) ); - query.setRadius( 1000 ); - geoSearch.getFromLocationAsyn( query ); + query.setLatlngType("autonavi"); + query.setPoint(new MogoLatLng(intent.getFloatExtra("lat", 39.917366f), intent.getFloatExtra("lon", 116.39962f))); + query.setRadius(1000); + geoSearch.getFromLocationAsyn(query); break; case 11:// 控制ADAS中的设置页面 - MarkerServiceHandler.getADASController().setSettingStatus( intent.getBooleanExtra( "status", false ) ); + MarkerServiceHandler.getADASController().setSettingStatus(intent.getBooleanExtra("status", false)); break; case 12: {// 控制ADAS显示隐藏 - boolean status2 = intent.getBooleanExtra( "status", false ); - if ( status2 ) { + boolean status2 = intent.getBooleanExtra("status", false); + if (status2) { MarkerServiceHandler.getADASController().showADAS(); } else { MarkerServiceHandler.getADASController().closeADAS(); @@ -178,10 +172,10 @@ public class MockIntentHandler implements IntentHandler { } break; case 13: {// 唤起高德地图 - double lat = intent.getFloatExtra( "lat", 0.0f ); - double lon = intent.getFloatExtra( "lon", 0.0f ); - boolean real = intent.getBooleanExtra( "real", false ); - MarkerServiceHandler.getRegisterCenter().registerMogoNaviListener( TAG, new IMogoNaviListener() { + double lat = intent.getFloatExtra("lat", 0.0f); + double lon = intent.getFloatExtra("lon", 0.0f); + boolean real = intent.getBooleanExtra("real", false); + MarkerServiceHandler.getRegisterCenter().registerMogoNaviListener(TAG, new IMogoNaviListener() { @Override public void onInitNaviFailure() { @@ -193,7 +187,7 @@ public class MockIntentHandler implements IntentHandler { } @Override - public void onNaviInfoUpdate( MogoNaviInfo naviinfo ) { + public void onNaviInfoUpdate(MogoNaviInfo naviinfo) { } @@ -209,8 +203,8 @@ public class MockIntentHandler implements IntentHandler { @Override public void onCalculateSuccess() { - MarkerServiceHandler.getRegisterCenter().unregisterMogoNaviListener( TAG ); - MarkerServiceHandler.getNavi().startNavi( real ); + MarkerServiceHandler.getRegisterCenter().unregisterMogoNaviListener(TAG); + MarkerServiceHandler.getNavi().startNavi(real); } @Override @@ -219,134 +213,132 @@ public class MockIntentHandler implements IntentHandler { } @Override - public void onUpdateTraffic( MogoTraffic traffic ) { + public void onUpdateTraffic(MogoTraffic traffic) { } - } ); - MarkerServiceHandler.getNavi().naviTo( new MogoLatLng( lat, lon ) ); + }); + MarkerServiceHandler.getNavi().naviTo(new MogoLatLng(lat, lon)); } case 14: {//测试点的动画移动,模拟周边车辆移动 - List< MogoLatLng > mogoLatLngs = new ArrayList<>(); - mogoLatLngs.add( new MogoLatLng( 39.615986, 116.396716 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616007, 116.396995 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616012, 116.397169 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616017, 116.397343 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616022, 116.397517 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616029, 116.397693 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616039, 116.397896 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616051, 116.3981 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616058, 116.39827 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616066, 116.398441 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616074, 116.398612 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616083, 116.398787 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616093, 116.39899 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616105, 116.399195 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616112, 116.399334 ) ); - mogoLatLngs.add( new MogoLatLng( 39.61612, 116.399473 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616128, 116.399612 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616136, 116.399751 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616148, 116.399893 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616153, 116.40008 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616159, 116.400301 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616167, 116.400471 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616175, 116.400642 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616183, 116.400813 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616192, 116.400988 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616201, 116.401191 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616213, 116.401396 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616235, 116.401728 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616246, 116.401986 ) ); - mogoLatLngs.add( new MogoLatLng( 39.61625, 116.402146 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616255, 116.402307 ) ); - mogoLatLngs.add( new MogoLatLng( 39.61626, 116.402468 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616267, 116.40263 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616272, 116.402762 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616277, 116.402894 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616282, 116.403026 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616287, 116.403158 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616292, 116.40329 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616297, 116.403422 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616302, 116.403554 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616307, 116.403686 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616321, 116.403821 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616331, 116.404045 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616343, 116.404272 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616353, 116.404551 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616363, 116.404753 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616375, 116.404958 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616375, 116.405055 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616379, 116.405184 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616384, 116.405313 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616389, 116.405442 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616394, 116.405571 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616399, 116.4057 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616404, 116.405829 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616409, 116.405958 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616414, 116.406087 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616419, 116.406216 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616424, 116.406345 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616429, 116.406474 ) ); - mogoLatLngs.add( new MogoLatLng( 39.61644, 116.406611 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616461, 116.406879 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616465, 116.407033 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616469, 116.407187 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616473, 116.407341 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616477, 116.407495 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616483, 116.407694 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616493, 116.407876 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616504, 116.408059 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616515, 116.408327 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616526, 116.408596 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616536, 116.408757 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616547, 116.409025 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616556, 116.409227 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616568, 116.409432 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616579, 116.409711 ) ); - mogoLatLngs.add( new MogoLatLng( 39.61659, 116.409914 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616601, 116.410119 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616601, 116.410387 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616601, 116.410602 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616622, 116.410816 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616633, 116.411084 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616643, 116.411395 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616654, 116.411492 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616665, 116.411771 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616674, 116.411974 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616686, 116.412178 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616697, 116.412447 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616697, 116.412586 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616718, 116.412876 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616729, 116.413144 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616738, 116.413347 ) ); - mogoLatLngs.add( new MogoLatLng( 39.61675, 116.413551 ) ); - mogoLatLngs.add( new MogoLatLng( 39.61675, 116.41383 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616761, 116.414002 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616761, 116.414098 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616767, 116.414279 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616774, 116.414461 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616782, 116.414645 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616792, 116.41483 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616802, 116.415016 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616814, 116.415203 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616824, 116.415395 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616836, 116.415589 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616842, 116.415745 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616849, 116.415902 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616857, 116.416061 ) ); - mogoLatLngs.add( new MogoLatLng( 39.616868, 116.416307 ) ); + List mogoLatLngs = new ArrayList<>(); + mogoLatLngs.add(new MogoLatLng(39.615986, 116.396716)); + mogoLatLngs.add(new MogoLatLng(39.616007, 116.396995)); + mogoLatLngs.add(new MogoLatLng(39.616012, 116.397169)); + mogoLatLngs.add(new MogoLatLng(39.616017, 116.397343)); + mogoLatLngs.add(new MogoLatLng(39.616022, 116.397517)); + mogoLatLngs.add(new MogoLatLng(39.616029, 116.397693)); + mogoLatLngs.add(new MogoLatLng(39.616039, 116.397896)); + mogoLatLngs.add(new MogoLatLng(39.616051, 116.3981)); + mogoLatLngs.add(new MogoLatLng(39.616058, 116.39827)); + mogoLatLngs.add(new MogoLatLng(39.616066, 116.398441)); + mogoLatLngs.add(new MogoLatLng(39.616074, 116.398612)); + mogoLatLngs.add(new MogoLatLng(39.616083, 116.398787)); + mogoLatLngs.add(new MogoLatLng(39.616093, 116.39899)); + mogoLatLngs.add(new MogoLatLng(39.616105, 116.399195)); + mogoLatLngs.add(new MogoLatLng(39.616112, 116.399334)); + mogoLatLngs.add(new MogoLatLng(39.61612, 116.399473)); + mogoLatLngs.add(new MogoLatLng(39.616128, 116.399612)); + mogoLatLngs.add(new MogoLatLng(39.616136, 116.399751)); + mogoLatLngs.add(new MogoLatLng(39.616148, 116.399893)); + mogoLatLngs.add(new MogoLatLng(39.616153, 116.40008)); + mogoLatLngs.add(new MogoLatLng(39.616159, 116.400301)); + mogoLatLngs.add(new MogoLatLng(39.616167, 116.400471)); + mogoLatLngs.add(new MogoLatLng(39.616175, 116.400642)); + mogoLatLngs.add(new MogoLatLng(39.616183, 116.400813)); + mogoLatLngs.add(new MogoLatLng(39.616192, 116.400988)); + mogoLatLngs.add(new MogoLatLng(39.616201, 116.401191)); + mogoLatLngs.add(new MogoLatLng(39.616213, 116.401396)); + mogoLatLngs.add(new MogoLatLng(39.616235, 116.401728)); + mogoLatLngs.add(new MogoLatLng(39.616246, 116.401986)); + mogoLatLngs.add(new MogoLatLng(39.61625, 116.402146)); + mogoLatLngs.add(new MogoLatLng(39.616255, 116.402307)); + mogoLatLngs.add(new MogoLatLng(39.61626, 116.402468)); + mogoLatLngs.add(new MogoLatLng(39.616267, 116.40263)); + mogoLatLngs.add(new MogoLatLng(39.616272, 116.402762)); + mogoLatLngs.add(new MogoLatLng(39.616277, 116.402894)); + mogoLatLngs.add(new MogoLatLng(39.616282, 116.403026)); + mogoLatLngs.add(new MogoLatLng(39.616287, 116.403158)); + mogoLatLngs.add(new MogoLatLng(39.616292, 116.40329)); + mogoLatLngs.add(new MogoLatLng(39.616297, 116.403422)); + mogoLatLngs.add(new MogoLatLng(39.616302, 116.403554)); + mogoLatLngs.add(new MogoLatLng(39.616307, 116.403686)); + mogoLatLngs.add(new MogoLatLng(39.616321, 116.403821)); + mogoLatLngs.add(new MogoLatLng(39.616331, 116.404045)); + mogoLatLngs.add(new MogoLatLng(39.616343, 116.404272)); + mogoLatLngs.add(new MogoLatLng(39.616353, 116.404551)); + mogoLatLngs.add(new MogoLatLng(39.616363, 116.404753)); + mogoLatLngs.add(new MogoLatLng(39.616375, 116.404958)); + mogoLatLngs.add(new MogoLatLng(39.616375, 116.405055)); + mogoLatLngs.add(new MogoLatLng(39.616379, 116.405184)); + mogoLatLngs.add(new MogoLatLng(39.616384, 116.405313)); + mogoLatLngs.add(new MogoLatLng(39.616389, 116.405442)); + mogoLatLngs.add(new MogoLatLng(39.616394, 116.405571)); + mogoLatLngs.add(new MogoLatLng(39.616399, 116.4057)); + mogoLatLngs.add(new MogoLatLng(39.616404, 116.405829)); + mogoLatLngs.add(new MogoLatLng(39.616409, 116.405958)); + mogoLatLngs.add(new MogoLatLng(39.616414, 116.406087)); + mogoLatLngs.add(new MogoLatLng(39.616419, 116.406216)); + mogoLatLngs.add(new MogoLatLng(39.616424, 116.406345)); + mogoLatLngs.add(new MogoLatLng(39.616429, 116.406474)); + mogoLatLngs.add(new MogoLatLng(39.61644, 116.406611)); + mogoLatLngs.add(new MogoLatLng(39.616461, 116.406879)); + mogoLatLngs.add(new MogoLatLng(39.616465, 116.407033)); + mogoLatLngs.add(new MogoLatLng(39.616469, 116.407187)); + mogoLatLngs.add(new MogoLatLng(39.616473, 116.407341)); + mogoLatLngs.add(new MogoLatLng(39.616477, 116.407495)); + mogoLatLngs.add(new MogoLatLng(39.616483, 116.407694)); + mogoLatLngs.add(new MogoLatLng(39.616493, 116.407876)); + mogoLatLngs.add(new MogoLatLng(39.616504, 116.408059)); + mogoLatLngs.add(new MogoLatLng(39.616515, 116.408327)); + mogoLatLngs.add(new MogoLatLng(39.616526, 116.408596)); + mogoLatLngs.add(new MogoLatLng(39.616536, 116.408757)); + mogoLatLngs.add(new MogoLatLng(39.616547, 116.409025)); + mogoLatLngs.add(new MogoLatLng(39.616556, 116.409227)); + mogoLatLngs.add(new MogoLatLng(39.616568, 116.409432)); + mogoLatLngs.add(new MogoLatLng(39.616579, 116.409711)); + mogoLatLngs.add(new MogoLatLng(39.61659, 116.409914)); + mogoLatLngs.add(new MogoLatLng(39.616601, 116.410119)); + mogoLatLngs.add(new MogoLatLng(39.616601, 116.410387)); + mogoLatLngs.add(new MogoLatLng(39.616601, 116.410602)); + mogoLatLngs.add(new MogoLatLng(39.616622, 116.410816)); + mogoLatLngs.add(new MogoLatLng(39.616633, 116.411084)); + mogoLatLngs.add(new MogoLatLng(39.616643, 116.411395)); + mogoLatLngs.add(new MogoLatLng(39.616654, 116.411492)); + mogoLatLngs.add(new MogoLatLng(39.616665, 116.411771)); + mogoLatLngs.add(new MogoLatLng(39.616674, 116.411974)); + mogoLatLngs.add(new MogoLatLng(39.616686, 116.412178)); + mogoLatLngs.add(new MogoLatLng(39.616697, 116.412447)); + mogoLatLngs.add(new MogoLatLng(39.616697, 116.412586)); + mogoLatLngs.add(new MogoLatLng(39.616718, 116.412876)); + mogoLatLngs.add(new MogoLatLng(39.616729, 116.413144)); + mogoLatLngs.add(new MogoLatLng(39.616738, 116.413347)); + mogoLatLngs.add(new MogoLatLng(39.61675, 116.413551)); + mogoLatLngs.add(new MogoLatLng(39.61675, 116.41383)); + mogoLatLngs.add(new MogoLatLng(39.616761, 116.414002)); + mogoLatLngs.add(new MogoLatLng(39.616761, 116.414098)); + mogoLatLngs.add(new MogoLatLng(39.616767, 116.414279)); + mogoLatLngs.add(new MogoLatLng(39.616774, 116.414461)); + mogoLatLngs.add(new MogoLatLng(39.616782, 116.414645)); + mogoLatLngs.add(new MogoLatLng(39.616792, 116.41483)); + mogoLatLngs.add(new MogoLatLng(39.616802, 116.415016)); + mogoLatLngs.add(new MogoLatLng(39.616814, 116.415203)); + mogoLatLngs.add(new MogoLatLng(39.616824, 116.415395)); + mogoLatLngs.add(new MogoLatLng(39.616836, 116.415589)); + mogoLatLngs.add(new MogoLatLng(39.616842, 116.415745)); + mogoLatLngs.add(new MogoLatLng(39.616849, 116.415902)); + mogoLatLngs.add(new MogoLatLng(39.616857, 116.416061)); + mogoLatLngs.add(new MogoLatLng(39.616868, 116.416307)); MogoMarkerOptions options = new MogoMarkerOptions(); - options.icon( BitmapFactory.decodeResource( AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray ) ) - .position( mogoLatLngs.get( 0 ) ) - .owner( TAG ) - .autoManager( false ); - int duration = intent.getIntExtra( "duration", 30 ); - MarkerServiceHandler.getApis().getRefreshStrategyControllerApi().restartAutoRefreshAtTime( duration ); - IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker( TAG, options ); - MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus( TAG, true, false ); - MarkerServiceHandler.getMapUIController().moveToCenter( mogoLatLngs.get( 0 ) ); - WorkThreadHandler.getInstance().post( () -> { - marker.startSmooth( mogoLatLngs, duration ); - } ); + options.icon(BitmapFactory.decodeResource(AbsMogoApplication.getApp().getResources(), R.drawable.icon_map_marker_car_gray)) + .position(mogoLatLngs.get(0)) + .owner(TAG) + .autoManager(false); + int duration = intent.getIntExtra("duration", 30); + MarkerServiceHandler.getApis().getRefreshStrategyControllerApi().restartAutoRefreshAtTime(duration); + IMogoMarker marker = MarkerServiceHandler.getMarkerManager().addMarker(TAG, options); + MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus(TAG, true, false); + MarkerServiceHandler.getMapUIController().moveToCenter(mogoLatLngs.get(0)); + WorkThreadHandler.getInstance().post(() -> marker.startSmooth(mogoLatLngs, duration)); } break; // case 15: @@ -356,31 +348,31 @@ public class MockIntentHandler implements IntentHandler { // MarkerServiceHandler.getGpsSimulatorManager().close(); // break; case 17:// 查询在线车辆数据 - DebugConfig.setRequestOnlineCarData( intent.getBooleanExtra( "status", true ) ); + DebugConfig.setRequestOnlineCarData(intent.getBooleanExtra("status", true)); break; case 18:// 设置是否使用自研地图 - TipToast.shortTip( "设置完成,下次启动生效" ); - SharedPrefsMgr.getInstance( context ).putBoolean( "useCustomMap", intent.getBooleanExtra( "useCustomMap", false ) ); + TipToast.shortTip("设置完成,下次启动生效"); + SharedPrefsMgr.getInstance(context).putBoolean("useCustomMap", intent.getBooleanExtra("useCustomMap", false)); break; case 30:// 强制刷新地图 MarkerServiceHandler.getMapService().getMapUIController().forceRender(); break; case 31:// Intent intent3 = new Intent(); - intent3.setAction( "AUTONAVI_STANDARD_BROADCAST_RECV" ); - intent3.putExtra( "KEY_TYPE", 12404 ); - intent3.putExtra( "EXTRA_REQUEST_AUTO_STATE", 0 ); - context.sendBroadcast( intent3 ); + intent3.setAction("AUTONAVI_STANDARD_BROADCAST_RECV"); + intent3.putExtra("KEY_TYPE", 12404); + intent3.putExtra("EXTRA_REQUEST_AUTO_STATE", 0); + context.sendBroadcast(intent3); break; case 32:// 控制实时路况 - MarkerServiceHandler.getMapService().getMapUIController().setTrafficEnabled( true ); + MarkerServiceHandler.getMapService().getMapUIController().setTrafficEnabled(true); break; case 33:// 测试小智语音 - AIAssist.getInstance( context ).speakTTSVoice( "庞帆说这个是一个 hard coding." ); + AIAssist.getInstance(context).speakTTSVoice("庞帆说这个是一个 hard coding."); break; case 34:// 修改地图模式VR OR 2D - int type = intent.getIntExtra( "type", 0 ); - if ( type != 0 ) { + int type = intent.getIntExtra("type", 0); + if (type != 0) { MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().changeToVRMode(); } else { MogoApisHandler.getInstance().getApis().getMapFrameControllerApi().changeTo2dMode(); @@ -394,23 +386,23 @@ public class MockIntentHandler implements IntentHandler { .getMapServiceApi().getMapUIController() .getWindowCenterLocation(); centerMarker = MogoApisHandler.getInstance().getApis() - .getMapServiceApi().getMarkerManager( context ) - .addMarker( TAG, new MogoMarkerOptions() - .position( center ) - .icon( BitmapFactory.decodeResource( context.getResources(), R.drawable.bg_map_marker_red ) ) ); + .getMapServiceApi().getMarkerManager(context) + .addMarker(TAG, new MogoMarkerOptions() + .position(center) + .icon(BitmapFactory.decodeResource(context.getResources(), R.drawable.bg_map_marker_red))); break; case 37:// 销毁测试打点 - if ( centerMarker != null ) { + if (centerMarker != null) { centerMarker.destroy(); } break; case 38:// 控制RTK MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController() - .rtkEnable( false ); + .rtkEnable(false); break; case 39:// 使用自动驾驶车的定位数据 MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController() - .syncLocation2Map( null ); + .syncLocation2Map(null); break; case 40: @@ -486,147 +478,147 @@ public class MockIntentHandler implements IntentHandler { {40.202545166015625, 116.7392807006836}, {40.20254898071289, 116.73928833007812}, {40.20254135131836, 116.7392807006836}}; - for ( double[] coor : coors ) { + for (double[] coor : coors) { double lat = coor[0], lon = coor[1]; - double[] translateCoor = CoordinateUtils.transformWgsToGcj( lat, lon ); - double[] originCoor = CoordinateUtils.transformGcj02toWgs84( translateCoor[1], translateCoor[0] ); - double delta = CoordinateUtils.calculateLineDistance( lon, lat, originCoor[0], originCoor[1] ); - Logger.d( TAG, "偏差值:%s", delta ); + double[] translateCoor = CoordinateUtils.transformWgsToGcj(lat, lon); + double[] originCoor = CoordinateUtils.transformGcj02toWgs84(translateCoor[1], translateCoor[0]); + double delta = CoordinateUtils.calculateLineDistance(lon, lat, originCoor[0], originCoor[1]); + Logger.d(TAG, "偏差值:%s", delta); } break; case 41:// // adb shell am broadcast -a com.mogo.mock --ei oper 41 --ei type 0 平滑移动 // adb shell am broadcast -a com.mogo.mock --ei oper 41 --ei type 1 直接打点 - DebugConfig.setNotSmooth( intent.getIntExtra( "type", 0 ) == 1 ); + DebugConfig.setNotSmooth(intent.getIntExtra("type", 0) == 1); break; case 42:// - WorkThreadHandler.getInstance().post( () -> { + WorkThreadHandler.getInstance().post(() -> { try { - InputStream is = context.getAssets().open( "coors.json" ); - BufferedReader br = new BufferedReader( new InputStreamReader( is ) ); + InputStream is = context.getAssets().open("coors.json"); + BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = ""; - List< ADASCarStateInfo > vals = new ArrayList<>(); - while ( ( line = br.readLine() ) != null ) { - String[] json = line.split( " - " ); - long time = Long.valueOf( json[0] ); - ADASCarStateInfo si = GsonUtil.objectFromJson( json[1], ADASCarStateInfo.class ); + List vals = new ArrayList<>(); + while ((line = br.readLine()) != null) { + String[] json = line.split(" - "); + long time = Long.parseLong(json[0]); + ADASCarStateInfo si = GsonUtil.objectFromJson(json[1], ADASCarStateInfo.class); // si.getValues().setSatelliteTime( time + "" ); - vals.add( si ); + vals.add(si); } long interval = -1; ADASCarStateInfo last = null; - for ( ADASCarStateInfo val : vals ) { - if ( last == null ) { + for (ADASCarStateInfo val : vals) { + if (last == null) { interval = 0; } else { - interval = Long.valueOf( val.getValues().getSatelliteTime() ) - Long.valueOf( last.getValues().getSatelliteTime() ); + interval = Long.parseLong(val.getValues().getSatelliteTime()) - Long.parseLong(last.getValues().getSatelliteTime()); } last = val; - WorkThreadHandler.getInstance().postDelayed( () -> { - onAdasCarDataCallback( val ); - }, interval ); + WorkThreadHandler.getInstance().postDelayed(() -> onAdasCarDataCallback(val), interval); } - } catch ( Exception e ) { + } catch (Exception e) { e.printStackTrace(); } - } ); + }); break; case 43:// MogoApisHandler.getInstance() .getApis() .getAdasControllerApi() - .onAutopilotArriveLike( intent.getIntExtra( "type", 8 ) ); + .onAutopilotArriveLike(intent.getIntExtra("type", 8)); break; case 44:// 控制自动驾驶 RemoteControlAutoPilotParameters parameters = new RemoteControlAutoPilotParameters(); parameters.vehicleType = 9; - parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( 40.1690522746, 116.567374558 ); - parameters.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat( 40.1651999405, 116.567217441 ); + parameters.startLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(40.1690522746, 116.567374558); + parameters.endLatLon = new RemoteControlAutoPilotParameters.AutoPilotLonLat(40.1651999405, 116.567217441); MogoApisHandler.getInstance() .getApis() .getAdasControllerApi() - .aiCloudToAdasData( parameters ); + .aiCloudToAdasData(parameters); break; case 45:// 测试开启鹰眼模式 MogoApisHandler.getInstance() .getApis() .getMapServiceApi() .getMapUIController() - .openVrMode( false ); + .openVrMode(false); break; case 46:// 模拟 自车周边数据 String json = "{\"allList\":[{\"type\":3,\"uuid\":\"10009-5152\",\"lat\":40.1990809296,\"lon\":116.7393252195,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0},{\"type\":3,\"uuid\":\"10009-5161\",\"lat\":40.1990827227,\"lon\":116.739325826,\"speed\":0.0,\"heading\":0.0,\"systemTime\":1614329151909,\"vehicleType\":0,\"distance\":576.0,\"fromType\":3,\"isOnline\":0}],\"nearList\":[],\"time\":1614329152238}"; - SnapshotSetDataDrawer.getInstance().renderSnapshotData( GsonUtil.objectFromJson( json, MogoSnapshotSetData.class ) ); + SnapshotSetDataDrawer.getInstance().renderSnapshotData(GsonUtil.objectFromJson(json, MogoSnapshotSetData.class)); break; case 47:// 模拟鹰眼模式下绘制车辆周边的数据 - mTimeTickHandler.sendEmptyMessageDelayed( 1, 0L ); + mTimeTickHandler.sendEmptyMessageDelayed(1, 0L); break; case 48:// 模拟3D模型绘制 MogoMarkerOptions options = new MogoMarkerOptions() - .owner( DataTypes.TYPE_MARKER_ADAS ) - .anchor( 0.5f, 0.5f ) - .set3DMode( true ) - .position( new MogoLatLng( 39.981971055705, 116.41150648393 ) ) - .gps( true ) - .controlAngle( true ) - .icon3DRes( R.raw.othercar ) - .rotate( ( float ) 358.526123 ); - IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options ); - List< MogoLatLng > latLngs = new ArrayList<>(); - latLngs.add( new MogoLatLng( 39.981971055705, 116.41150648393 ) ); - latLngs.add( new MogoLatLng( 39.981990561932, 116.412893641626 ) ); - marker.startSmoothInMs( latLngs, 20_000L ); + .owner(DataTypes.TYPE_MARKER_ADAS) + .anchor(0.5f, 0.5f) + .set3DMode(true) + .position(new MogoLatLng(39.981971055705, 116.41150648393)) + .gps(true) + .controlAngle(true) + .icon3DRes(R.raw.othercar) + .rotate((float) 358.526123); + IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(context).addMarker(DataTypes.TYPE_MARKER_ADAS, options); + List latLngs = new ArrayList<>(); + latLngs.add(new MogoLatLng(39.981971055705, 116.41150648393)); + latLngs.add(new MogoLatLng(39.981990561932, 116.412893641626)); + marker.startSmoothInMs(latLngs, 20_000L); break; case 49:// 绘制marker // 39.96741320378243, 116.41045709250723 // 39.98232698552779,116.41879656379113; MogoMarkerOptions options1 = new MogoMarkerOptions() - .owner( DataTypes.TYPE_MARKER_ADAS ) - .anchor( 0.5f, 0.5f ) - .set3DMode( false ) - .position( new MogoLatLng( 39.96741320378243, 116.41045709250723 ) ) - .gps( true ) - .controlAngle( false ) - .icon( BitmapFactory.decodeResource( context.getResources(), R.drawable.sy ) ) - .rotate( ( float ) 358.526123 ); - IMogoMarker marker1 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options1 ); + .owner(DataTypes.TYPE_MARKER_ADAS) + .anchor(0.5f, 0.5f) + .set3DMode(false) + .position(new MogoLatLng(39.96741320378243, 116.41045709250723)) + .gps(true) + .controlAngle(false) + .icon(BitmapFactory.decodeResource(context.getResources(), R.drawable.sy)) + .rotate((float) 358.526123); + IMogoMarker marker1 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(context).addMarker(DataTypes.TYPE_MARKER_ADAS, options1); MogoMarkerOptions options2 = new MogoMarkerOptions() - .owner( DataTypes.TYPE_MARKER_ADAS ) - .anchor( 0.5f, 0.5f ) - .set3DMode( false ) - .position( new MogoLatLng( 39.98232698552779, 116.41879656379113 ) ) - .gps( true ) - .controlAngle( false ) - .icon( BitmapFactory.decodeResource( context.getResources(), R.drawable.sr ) ) - .rotate( ( float ) 358.526123 ); - IMogoMarker marker2 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options2 ); + .owner(DataTypes.TYPE_MARKER_ADAS) + .anchor(0.5f, 0.5f) + .set3DMode(false) + .position(new MogoLatLng(39.98232698552779, 116.41879656379113)) + .gps(true) + .controlAngle(false) + .icon(BitmapFactory.decodeResource(context.getResources(), R.drawable.sr)) + .rotate((float) 358.526123); + IMogoMarker marker2 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(context).addMarker(DataTypes.TYPE_MARKER_ADAS, options2); MogoMarkerOptions options3 = new MogoMarkerOptions() - .owner( DataTypes.TYPE_MARKER_ADAS ) - .anchor( 0.5f, 0.5f ) - .set3DMode( false ) - .position( new MogoLatLng( 39.97631642243, 116.418249382739 ) ) - .gps( true ) - .controlAngle( false ) - .icon( BitmapFactory.decodeResource( context.getResources(), R.drawable.bg_map_marker_red ) ) - .rotate( ( float ) 358.526123 ); - IMogoMarker marker3 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( context ).addMarker( DataTypes.TYPE_MARKER_ADAS, options3 ); + .owner(DataTypes.TYPE_MARKER_ADAS) + .anchor(0.5f, 0.5f) + .set3DMode(false) + .position(new MogoLatLng(39.97631642243, 116.418249382739)) + .gps(true) + .controlAngle(false) + .icon(BitmapFactory.decodeResource(context.getResources(), R.drawable.bg_map_marker_red)) + .rotate((float) 358.526123); + IMogoMarker marker3 = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(context).addMarker(DataTypes.TYPE_MARKER_ADAS, options3); break; case 50:// - DebugConfig.setSelfCarSpeedYOffset( intent.getIntExtra( "yOffset", 20 ) ); + DebugConfig.setSelfCarSpeedYOffset(intent.getIntExtra("yOffset", 20)); break; case 51:// 模拟路口车辆移动 - mLocationMockHandler.sendEmptyMessageDelayed( 100, 0L ); - mLocationMockHandler.sendEmptyMessageDelayed( 101, 1000L ); + mLocationMockHandler.sendEmptyMessageDelayed(100, 0L); + mLocationMockHandler.sendEmptyMessageDelayed(101, 1000L); break; - case 52:// 打开连调工控机、ADAS的控制面板 - EnvStatusManager.getInstance().showPanel( context ); + case 52: + // 打开连调工控机、ADAS的控制面板 + //adb shell am broadcast -a com.mogo.mock --ei oper 52 + EnvStatusManager.getInstance().showPanel(context); break; case 53:// 控制 Adas识别 是否可用 - boolean isUseAdasRecognize = intent.getBooleanExtra( "status", false ); - DebugConfig.setUseAdasRecognize( isUseAdasRecognize ); + boolean isUseAdasRecognize = intent.getBooleanExtra("status", false); + DebugConfig.setUseAdasRecognize(isUseAdasRecognize); break; case 54: - mTimeTickCarHandler.sendEmptyMessageDelayed( 1, 0L ); + mTimeTickCarHandler.sendEmptyMessageDelayed(1, 0L); break; } } @@ -635,112 +627,112 @@ public class MockIntentHandler implements IntentHandler { private JSONObject locJo = null; private void handleMockSingleLocDataIntent() throws Exception { - if ( locJo == null ) { + if (locJo == null) { String locLine = "{\"systemTime\":1615529718585,\"satelliteTime\":1615529718585,\"lon\":116.73573385415098,\"lat\":40.19907712731953,\"alt\":34.4018669128417,\"heading\":0.342695406938048,\"speed\":0.003303937}"; - locJo = new JSONObject( locLine ); - locJo.put( "satelliteTime", System.currentTimeMillis() ); - locJo.put( "systemTime", System.currentTimeMillis() ); + locJo = new JSONObject(locLine); + locJo.put("satelliteTime", System.currentTimeMillis()); + locJo.put("systemTime", System.currentTimeMillis()); } - MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( locJo ); - mLocationMockHandler.sendEmptyMessageDelayed( 100, 50L ); + MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(locJo); + mLocationMockHandler.sendEmptyMessageDelayed(100, 50L); } private void handleRoadSideMockDataIntent() throws Exception { - if ( roadSizeBr == null ) { - roadSizeBr = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "roadSide.txt" ) ) ); + if (roadSizeBr == null) { + roadSizeBr = new BufferedReader(new InputStreamReader(AbsMogoApplication.getApp().getAssets().open("roadSide.txt"))); } String carsLine = roadSizeBr.readLine(); MogoSnapshotSetData data = new MogoSnapshotSetData(); - List< CloudRoadData > allList = GsonUtil.arrayFromJson( carsLine, CloudRoadData.class ); - for ( CloudRoadData cloudRoadData : allList ) { - cloudRoadData.setWgslat( cloudRoadData.getLat() ); - cloudRoadData.setWgslon( cloudRoadData.getLon() ); - cloudRoadData.setFromType( CloudRoadData.FROM_ROAD_UNIT ); + List allList = GsonUtil.arrayFromJson(carsLine, CloudRoadData.class); + for (CloudRoadData cloudRoadData : allList) { + cloudRoadData.setWgslat(cloudRoadData.getLat()); + cloudRoadData.setWgslon(cloudRoadData.getLon()); + cloudRoadData.setFromType(CloudRoadData.FROM_ROAD_UNIT); } - data.setAllList( allList ); - SnapshotSetDataDrawer.getInstance().renderSnapshotData( data ); - mLocationMockHandler.sendEmptyMessageDelayed( 101, 100L ); + data.setAllList(allList); + SnapshotSetDataDrawer.getInstance().renderSnapshotData(data); + mLocationMockHandler.sendEmptyMessageDelayed(101, 100L); } - public void onAdasCarDataCallback( ADASCarStateInfo stateInfo ) { - if ( stateInfo != null && stateInfo.getValues() != null ) { + public void onAdasCarDataCallback(ADASCarStateInfo stateInfo) { + if (stateInfo != null && stateInfo.getValues() != null) { JSONObject data = new JSONObject(); try { - data.putOpt( "lon", stateInfo.getValues().getLon() ); - data.putOpt( "lat", stateInfo.getValues().getLat() ); - data.putOpt( "alt", stateInfo.getValues().getAlt() ); - data.putOpt( "speed", stateInfo.getValues().getGnss_speed() ); - data.putOpt( "satelliteTime", stateInfo.getValues().getSatelliteTime() ); - data.putOpt( "heading", stateInfo.getValues().getHeading() ); - data.putOpt( "acceleration", stateInfo.getValues().getAcceleration() ); - data.putOpt( "yawRate", stateInfo.getValues().getYaw_rate() ); - MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( data ); + data.putOpt("lon", stateInfo.getValues().getLon()); + data.putOpt("lat", stateInfo.getValues().getLat()); + data.putOpt("alt", stateInfo.getValues().getAlt()); + data.putOpt("speed", stateInfo.getValues().getGnss_speed()); + data.putOpt("satelliteTime", stateInfo.getValues().getSatelliteTime()); + data.putOpt("heading", stateInfo.getValues().getHeading()); + data.putOpt("acceleration", stateInfo.getValues().getAcceleration()); + data.putOpt("yawRate", stateInfo.getValues().getYaw_rate()); + MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(data); // SnapshotUploadInTime.getInstance().syncAdasLocationInfo( data ); - } catch ( Exception e ) { + } catch (Exception e) { e.printStackTrace(); } } } - private Handler mLocationMockHandler = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread" ).getLooper() ) { + private final Handler mLocationMockHandler = new Handler(WorkThreadHandler.newInstance("loc-mock-thread").getLooper()) { @Override - public void handleMessage( Message msg ) { - super.handleMessage( msg ); - if ( msg.what == 1 ) { + public void handleMessage(Message msg) { + super.handleMessage(msg); + if (msg.what == 1) { try { - if ( !handleMockLocationIntent() ) { + if (!handleMockLocationIntent()) { br.close(); br = null; } - } catch ( Exception e ) { + } catch (Exception e) { try { br.close(); - } catch ( IOException ex ) { + } catch (IOException ex) { ex.printStackTrace(); } br = null; } - } else if ( msg.what == 21 ) { + } else if (msg.what == 21) { try { handleMockSnapshotIntent2(); - } catch ( Exception e ) { + } catch (Exception e) { try { br4.close(); - } catch ( IOException ex ) { + } catch (IOException ex) { ex.printStackTrace(); } } - } else if ( msg.what == 3 ) { + } else if (msg.what == 3) { try { handleMockAdasIntent(); - } catch ( Exception e ) { + } catch (Exception e) { try { - if ( readers != null ) { - for ( BufferedReader reader : readers ) { + if (readers != null) { + for (BufferedReader reader : readers) { reader.close(); } } - } catch ( IOException ex ) { + } catch (IOException ex) { ex.printStackTrace(); } readers = null; } - } else if ( msg.what == 100 ) { + } else if (msg.what == 100) { try { handleMockSingleLocDataIntent(); - } catch ( Exception e ) { + } catch (Exception e) { e.printStackTrace(); } - } else if ( msg.what == 101 ) { + } else if (msg.what == 101) { try { handleRoadSideMockDataIntent(); - } catch ( Exception e ) { + } catch (Exception e) { try { roadSizeBr.close(); - } catch ( IOException ex ) { + } catch (IOException ex) { ex.printStackTrace(); } roadSizeBr = null; @@ -748,16 +740,16 @@ public class MockIntentHandler implements IntentHandler { } else if (msg.what == 8) { try { handleMockAdasCarIntent(); - } catch ( Exception e ) { + } catch (Exception e) { try { - if ( readers2 != null ) { - for ( BufferedReader reader : readers2 ) { + if (readers2 != null) { + for (BufferedReader reader : readers2) { if (reader != null) { reader.close(); } } } - } catch ( IOException ex ) { + } catch (IOException ex) { ex.printStackTrace(); } readers2 = null; @@ -767,20 +759,20 @@ public class MockIntentHandler implements IntentHandler { }; - private Handler mLocationMockHandler1 = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread1" ).getLooper() ) { + private final Handler mLocationMockHandler1 = new Handler(WorkThreadHandler.newInstance("loc-mock-thread1").getLooper()) { @Override - public void handleMessage( Message msg ) { - super.handleMessage( msg ); - if ( msg.what == 1 ) { + public void handleMessage(Message msg) { + super.handleMessage(msg); + if (msg.what == 1) { try { - if ( !handleMockLocationIntent() ) { + if (!handleMockLocationIntent()) { br.close(); br = null; } - } catch ( Exception e ) { + } catch (Exception e) { try { br.close(); - } catch ( IOException ex ) { + } catch (IOException ex) { ex.printStackTrace(); } br = null; @@ -791,49 +783,49 @@ public class MockIntentHandler implements IntentHandler { private long mLocDelay = 0; - private Handler mTimeTickHandler = new Handler( WorkThreadHandler.newInstance( "loc-mock-thread2" ).getLooper() ) { + private final Handler mTimeTickHandler = new Handler(WorkThreadHandler.newInstance("loc-mock-thread2").getLooper()) { @Override - public void handleMessage( Message msg ) { - super.handleMessage( msg ); + public void handleMessage(Message msg) { + super.handleMessage(msg); mLocDelay += 50; - if ( mLocDelay > 4_000L ) { - mLocationMockHandler1.sendEmptyMessageDelayed( 1, 0L ); + if (mLocDelay > 4_000L) { + mLocationMockHandler1.sendEmptyMessageDelayed(1, 0L); } - mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L ); - mTimeTickHandler.sendEmptyMessageDelayed( 0, 50L ); + mLocationMockHandler.sendEmptyMessageDelayed(3, 0L); + mTimeTickHandler.sendEmptyMessageDelayed(0, 50L); } }; - private Handler mTimeTickCarHandler = new Handler( WorkThreadHandler.newInstance( "loc-time-mock-thread" ).getLooper() ) { + private final Handler mTimeTickCarHandler = new Handler(WorkThreadHandler.newInstance("loc-time-mock-thread").getLooper()) { @Override - public void handleMessage( Message msg ) { - super.handleMessage( msg ); + public void handleMessage(Message msg) { + super.handleMessage(msg); mLocDelay += 50; - if ( mLocDelay > 4_000L ) { - mLocationMockHandler1.sendEmptyMessageDelayed( 1, 0L ); + if (mLocDelay > 4_000L) { + mLocationMockHandler1.sendEmptyMessageDelayed(1, 0L); } - mLocationMockHandler.sendEmptyMessageDelayed( 8, 0L ); - mTimeTickCarHandler.sendEmptyMessageDelayed( 0, 50L ); + mLocationMockHandler.sendEmptyMessageDelayed(8, 0L); + mTimeTickCarHandler.sendEmptyMessageDelayed(0, 50L); } }; private BufferedReader br; private boolean handleMockLocationIntent() throws Exception { - if ( br == null ) { - br = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "loc.txt" ) ) ); + if (br == null) { + br = new BufferedReader(new InputStreamReader(AbsMogoApplication.getApp().getAssets().open("loc.txt"))); } final long start = System.currentTimeMillis(); String line = br.readLine(); - if ( line == null ) { - throw new Exception( "end of file." ); + if (line == null) { + throw new Exception("end of file."); } - JSONObject jo = new JSONObject( line ); + JSONObject jo = new JSONObject(line); //改变rtk定位数据,触发自车移动 - MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map( jo ); - Log.i( "mock-timer-loc-map", "cost " + ( System.currentTimeMillis() - start ) + "ms" ); - SnapshotLocationController.getInstance().syncAdasLocationInfo( jo ); - Log.i( "mock-timer-loc", "cost " + ( System.currentTimeMillis() - start ) + "ms" ); + MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().syncLocation2Map(jo); + Log.i("mock-timer-loc-map", "cost " + (System.currentTimeMillis() - start) + "ms"); + SnapshotLocationController.getInstance().syncAdasLocationInfo(jo); + Log.i("mock-timer-loc", "cost " + (System.currentTimeMillis() - start) + "ms"); return true; } @@ -841,28 +833,28 @@ public class MockIntentHandler implements IntentHandler { private BufferedReader br4; private boolean handleMockSnapshotIntent2() throws Exception { - if ( br4 == null ) { - br4 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "snapshot.txt" ) ) ); + if (br4 == null) { + br4 = new BufferedReader(new InputStreamReader(AbsMogoApplication.getApp().getAssets().open("snapshot.txt"))); } String line = br4.readLine(); - if ( line == null ) { - throw new Exception( "end of file 2." ); + if (line == null) { + throw new Exception("end of file 2."); } MogoSnapshotSetData data = new MogoSnapshotSetData(); - List< CloudRoadData > allList = new ArrayList<>(); - CloudRoadData cloudRoadData = GsonUtil.objectFromJson( line, CloudRoadData.class ); - if ( cloudRoadData == null ) { + List allList = new ArrayList<>(); + CloudRoadData cloudRoadData = GsonUtil.objectFromJson(line, CloudRoadData.class); + if (cloudRoadData == null) { return false; } - cloudRoadData.setWgslon( cloudRoadData.getLon() ); - cloudRoadData.setWgslat( cloudRoadData.getLat() ); - cloudRoadData.setUuid( "1_21" ); - allList.add( cloudRoadData ); - data.setAllList( allList ); + cloudRoadData.setWgslon(cloudRoadData.getLon()); + cloudRoadData.setWgslat(cloudRoadData.getLat()); + cloudRoadData.setUuid("1_21"); + allList.add(cloudRoadData); + data.setAllList(allList); final long start = System.currentTimeMillis(); - SnapshotSetDataDrawer.getInstance().renderSnapshotData( data ); - Log.i( "mock-timer-snapshot", "cost " + ( System.currentTimeMillis() - start ) + "ms" ); + SnapshotSetDataDrawer.getInstance().renderSnapshotData(data); + Log.i("mock-timer-snapshot", "cost " + (System.currentTimeMillis() - start) + "ms"); // mLocationMockHandler.sendEmptyMessageDelayed( 21, 100L ); return true; } @@ -873,58 +865,58 @@ public class MockIntentHandler implements IntentHandler { private boolean handleMockAdasIntent() throws Exception { final long start = System.currentTimeMillis(); - if ( readers == null ) { + if (readers == null) { readers = new BufferedReader[10]; - for ( int i = 0; i < 10; i++ ) { - readers[i] = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adas" + i + ".txt" ) ) ); + for (int i = 0; i < 10; i++) { + readers[i] = new BufferedReader(new InputStreamReader(AbsMogoApplication.getApp().getAssets().open("adas" + i + ".txt"))); } } - List< ADASRecognizedResult > allList = new ArrayList<>(); - for ( BufferedReader reader : readers ) { + List allList = new ArrayList<>(); + for (BufferedReader reader : readers) { String line = reader.readLine(); - ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class ); - if ( adasRecognizedResult != null ) { - allList.add( adasRecognizedResult ); + ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson(line, ADASRecognizedResult.class); + if (adasRecognizedResult != null) { + allList.add(adasRecognizedResult); } } AdasRec adasRec = new AdasRec(); adasRec.models = allList; - MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized( GsonUtil.jsonFromObject( adasRec ) ); - Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" ); + MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(GsonUtil.jsonFromObject(adasRec)); + Log.i("mock-timer-adas", "cost " + (System.currentTimeMillis() - start) + "ms"); return true; } private boolean handleMockAdasCarIntent() throws Exception { final long start = System.currentTimeMillis(); - if ( readers2 == null ) { + if (readers2 == null) { readers2 = new BufferedReader[3]; - for ( int i = 0; i < 3; i++ ) { - readers2[i] = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "adascar" + i + ".txt" ) ) ); + for (int i = 0; i < 3; i++) { + readers2[i] = new BufferedReader(new InputStreamReader(AbsMogoApplication.getApp().getAssets().open("adascar" + i + ".txt"))); } } - List< ADASRecognizedResult > allList = new ArrayList<>(); - for ( BufferedReader reader : readers2 ) { + List allList = new ArrayList<>(); + for (BufferedReader reader : readers2) { String line = reader.readLine(); - ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson( line, ADASRecognizedResult.class ); - if ( adasRecognizedResult != null ) { - allList.add( adasRecognizedResult ); + ADASRecognizedResult adasRecognizedResult = GsonUtil.objectFromJson(line, ADASRecognizedResult.class); + if (adasRecognizedResult != null) { + allList.add(adasRecognizedResult); } } AdasRec adasRec = new AdasRec(); adasRec.models = allList; - MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized( GsonUtil.jsonFromObject( adasRec ) ); - Log.i( "mock-timer-adas", "cost " + ( System.currentTimeMillis() - start ) + "ms" ); + MogoApisHandler.getInstance().getApis().getAdasControllerApi().mockAdasRecognized(GsonUtil.jsonFromObject(adasRec)); + Log.i("mock-timer-adas", "cost " + (System.currentTimeMillis() - start) + "ms"); return true; } - public static class AdasRec{ + public static class AdasRec { public String action = "view"; public List models; } 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 72db237f88..ec4f3ff48c 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 @@ -8,6 +8,7 @@ import android.os.Message; import android.text.TextUtils; import android.util.Log; +import com.mogo.cloud.commons.utils.CoordinateUtils; import com.mogo.commons.AbsMogoApplication; import com.mogo.commons.debug.DebugConfig; import com.mogo.map.MogoLatLng; @@ -16,6 +17,7 @@ import com.mogo.map.marker.IMogoMarkerClickListener; import com.mogo.map.marker.IMogoMarkerManager; import com.mogo.map.marker.MogoMarkerOptions; import com.mogo.map.navi.IMogoCarLocationChangedListener2; +import com.mogo.map.overlay.IMogoPolyline; import com.mogo.map.uicontroller.EnumMapUI; import com.mogo.map.uicontroller.IMogoMapUIController; import com.mogo.module.common.ModuleNames; @@ -36,12 +38,15 @@ import com.mogo.module.common.entity.MarkerLocation; import com.mogo.module.common.entity.MarkerOnlineCar; import com.mogo.module.common.entity.MarkerResponse; import com.mogo.module.common.entity.MarkerShowEntity; +import com.mogo.module.common.entity.V2XWarningEntity; import com.mogo.module.common.utils.CloudPoiManager; +import com.mogo.module.common.utils.Trigonometric; import com.mogo.module.service.MarkerServiceHandler; import com.mogo.module.service.R; import com.mogo.module.service.ServiceConst; import com.mogo.module.service.network.RefreshCallback; import com.mogo.module.service.network.RefreshModel; +import com.mogo.module.service.polyline.LimberCollisionPolyline; import com.mogo.realtime.api.MoGoAiCloudRealTime; import com.mogo.realtime.entity.ADASRecognizedResult; import com.mogo.realtime.entity.MogoSnapshotSetData; @@ -62,6 +67,7 @@ import org.json.JSONException; import org.json.JSONObject; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -161,24 +167,58 @@ public class MapMarkerManager implements IMogoMarkerClickListener, msg.sendToTarget(); } } ); + // adas 每隔一秒传递的数据 MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback( resultList -> { // 绘制近景识别到的车辆 AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList ); - //绘制他车的线 liyz - //添加自车的定位图标,碰撞只有一个预警 TODO + //添加自车的定位图标,碰撞只有一个预警,还需要和adas 联调,还需要改 liyz // ADASRecognizedResult result = null; // for (int i = 0; i < resultList.size(); i++) { // result = resultList.get(i); +// if (result.type) { //找出可能碰撞的车 +// result = resultList.get(i); +// } + + //绘制他车的线,从列表中查出可能碰撞的车的经纬度(没有或者只有一个),然后预设20米的长度 + //绘制碰撞的他车指引线,需要实时给数据更新 TODO +// drawLimberCollisionPolyline(result); // } -// -// //通过这个传值 ADASRecognizedResult -// MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().setAdasRecognizedResult(GsonUtil.jsonFromObject(result)); + +// //通过这个传值到 AMapViewWrapper,根据数据更新自车的模型数据 ADASRecognizedResult +// MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().setAdasRecognizedResult(result); } ); } + + /** + * 实时绘制连线 + * @param result + */ + private void drawLimberCollisionPolyline(ADASRecognizedResult result) { + if (result != null) { + IMogoPolyline polyLine = LimberCollisionPolyline.getInstance().getPolyLine(); + MogoLatLng startLatLng = new MogoLatLng(result.lat, result.lon); + MogoLatLng endLatlng = Trigonometric.getNewLocation(startLatLng, 20, result.heading); + Log.d(TAG, "红色区域起始点 = " + startLatLng.lon + "," + startLatLng.lat + + "终点" + endLatlng.lon + "," + endLatlng.lat + "--heading =" + result.heading); + if (polyLine != null) { + Log.d(TAG, "drawStopLine polyLine != null"); + polyLine.setPoints(Arrays.asList(startLatLng, endLatlng)); + } else { + List latLngs = new ArrayList<>(); + latLngs.add(startLatLng); + latLngs.add(endLatlng); + LimberCollisionPolyline.getInstance().draw((float) result.roadWidth, latLngs); + } + } else { + LimberCollisionPolyline.getInstance().clearLine(); + } + } + + private Handler mSnapshotHandler = new Handler( WorkThreadHandler.newInstance( "snapshot-thread" ).getLooper() ) { @Override public void handleMessage( Message msg ) { diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/polyline/LimberCollisionPolyline.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/polyline/LimberCollisionPolyline.java new file mode 100644 index 0000000000..2ae17a8683 --- /dev/null +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/polyline/LimberCollisionPolyline.java @@ -0,0 +1,88 @@ +package com.mogo.module.service.polyline; + +import com.mogo.map.MogoLatLng; +import com.mogo.map.overlay.IMogoPolyline; +import com.mogo.map.overlay.MogoPolylineOptions; +import com.mogo.module.service.MarkerServiceHandler; + +import java.util.ArrayList; +import java.util.List; + +/** + * @author lixiaopeng + * @description 前车碰撞的画线 + * @since 2021/4/25 + */ +public class LimberCollisionPolyline { + + private volatile static LimberCollisionPolyline mInstance = null; + + private IMogoPolyline mMoGoPolyline; + // 连接线参数 + private MogoPolylineOptions mPolylineOptions; + // 线路径集合 + private List mPolylinePointList; + + + public static LimberCollisionPolyline getInstance() { + if (mInstance == null) { + synchronized (LimberCollisionPolyline.class) { + if (mInstance == null) { + mInstance = new LimberCollisionPolyline(); + } + } + } + return mInstance; + } + + protected LimberCollisionPolyline() { + mPolylineOptions = new MogoPolylineOptions(); + // 绘制路径集合 + mPolylinePointList = new ArrayList<>(); + } + + + public IMogoPolyline draw(float width, List polylinePoint) { + try { + if (mMoGoPolyline != null) { + mMoGoPolyline.remove(); + mPolylinePointList.clear(); + } + + // 连接线参数 + MogoPolylineOptions options = new MogoPolylineOptions(); + + // 渐变色 + List colors = new ArrayList<>(); +// colors.add(0x0DE32F46); + colors.add(0xD9E32F46); + colors.add(0x0DE32F46); + + // 线条粗细,渐变,渐变色值 TODO liyz 宽度需要传过来 + options.width(60).useGradient(true).colorValues(colors); + for (int i = 0; i < polylinePoint.size(); i++) { + options.add(polylinePoint.get(i)); + } + // 绘制线的对象 + mMoGoPolyline = MarkerServiceHandler.getsIMogoOverlayManager().addPolyline(options); + } catch (Exception e) { + e.printStackTrace(); + } + return mMoGoPolyline; + } + + + public IMogoPolyline getPolyLine() { + return mMoGoPolyline; + } + + public void clearLine() { + if (mMoGoPolyline != null) { + mMoGoPolyline.remove(); + mMoGoPolyline = null; + } + } + + +} + diff --git a/modules/mogo-module-service/src/main/java/com/mogo/module/service/status/EnvStatusManager.java b/modules/mogo-module-service/src/main/java/com/mogo/module/service/status/EnvStatusManager.java index bc3cdc3824..75f0f85f6c 100644 --- a/modules/mogo-module-service/src/main/java/com/mogo/module/service/status/EnvStatusManager.java +++ b/modules/mogo-module-service/src/main/java/com/mogo/module/service/status/EnvStatusManager.java @@ -15,14 +15,14 @@ import com.mogo.module.common.MogoApisHandler; import com.mogo.module.common.wm.WindowManagerView; import com.mogo.module.service.R; -public -/** + +/* * @author congtaowang * @since 2021/3/17 * * 环境状态 */ -class EnvStatusManager { +public class EnvStatusManager { private static volatile EnvStatusManager sInstance; @@ -30,9 +30,9 @@ class EnvStatusManager { } public static EnvStatusManager getInstance() { - if ( sInstance == null ) { - synchronized ( EnvStatusManager.class ) { - if ( sInstance == null ) { + if (sInstance == null) { + synchronized (EnvStatusManager.class) { + if (sInstance == null) { sInstance = new EnvStatusManager(); } } @@ -51,13 +51,13 @@ class EnvStatusManager { private WindowManagerView mPanelView; private TextView mStatusTv; - private Handler mMainHandler = new Handler( Looper.getMainLooper() ) { + private final Handler mMainHandler = new Handler(Looper.getMainLooper()) { @Override - public void handleMessage( Message msg ) { - super.handleMessage( msg ); - if ( mPanelView.isShowing() ) { + public void handleMessage(Message msg) { + super.handleMessage(msg); + if (mPanelView.isShowing()) { renderStatus(); - mMainHandler.sendEmptyMessageDelayed( MSG, 5_000L ); + mMainHandler.sendEmptyMessageDelayed(MSG, 5_000L); } } }; @@ -69,54 +69,54 @@ class EnvStatusManager { "近景", "下发", "AUTO", - "长链" + "长链", + "经度", + "纬度" }; StringBuilder stringBuilder = new StringBuilder(); - for ( int i = 0; i < sStatusName.length; i++ ) { - stringBuilder.append( sStatusName[i] ).append( ":" ); - if ( i != 3 ) { - stringBuilder.append( "true".equals( DebugConfig.getStatus( i, true ) ) ? "正常" : "异常" ).append( "\n" ); + for (int i = 0; i < sStatusName.length; i++) { + stringBuilder.append(sStatusName[i]).append(":"); + if (i == 3) { + stringBuilder.append(DebugConfig.getAutoPilotStatus()).append("\n"); + } else if (i == 5 || i == 6) { + stringBuilder.append(DebugConfig.getStatusData(i)).append("\n"); } else { - stringBuilder.append( DebugConfig.getAutoPilotStatus() ).append( "\n" ); + stringBuilder.append("true".equals(DebugConfig.getStatus(i, true)) ? "正常" : "异常").append("\n"); } } - mStatusTv.setText( stringBuilder ); - if ( MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode() ) { - mStatusTv.setTextColor( Color.WHITE ); + mStatusTv.setText(stringBuilder); + if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) { + mStatusTv.setTextColor(Color.WHITE); } else { - if ( MogoApisHandler.getInstance().getApis().getAdasControllerApi() - .getCurrentSkinMode() == EnumMapUI.Type_Light ) { - mStatusTv.setTextColor( Color.BLACK ); + if (MogoApisHandler.getInstance().getApis().getAdasControllerApi() + .getCurrentSkinMode() == EnumMapUI.Type_Light) { + mStatusTv.setTextColor(Color.BLACK); } else { - mStatusTv.setTextColor( Color.WHITE ); + mStatusTv.setTextColor(Color.WHITE); } } } - public void showPanel( Context context ) { - if ( mPanelView == null ) { - mPanelView = new WindowManagerView.Builder( context ) - .contentView( R.layout.module_services_status_panel ) - .position( 0, 100 ) - .size( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT ) - .gravity( Gravity.TOP ) + public void showPanel(Context context) { + if (mPanelView == null) { + mPanelView = new WindowManagerView.Builder(context) + .contentView(R.layout.module_services_status_panel) + .position(0, 100) + .size(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT) + .gravity(Gravity.TOP) .showInWindowManager(); - mPanelView.attachTouchEvent( ( ( view, xPos, yPos ) -> { - closePanel(); - } ) ); - mPanelView.findViewById( R.id.module_services_status_iv ).setOnClickListener( view -> { - closePanel(); - } ); - mStatusTv = mPanelView.findViewById( R.id.module_services_status_tv ); + mPanelView.attachTouchEvent(((view, xPos, yPos) -> closePanel())); + mPanelView.findViewById(R.id.module_services_status_iv).setOnClickListener(view -> closePanel()); + mStatusTv = mPanelView.findViewById(R.id.module_services_status_tv); } mPanelView.show(); - mMainHandler.sendEmptyMessageDelayed( MSG, 0L ); + mMainHandler.sendEmptyMessageDelayed(MSG, 0L); } public void closePanel() { - if ( mPanelView != null ) { + if (mPanelView != null) { mPanelView.dismiss(); - mMainHandler.removeMessages( MSG ); + mMainHandler.removeMessages(MSG); } } } diff --git a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XWaringManager.java b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XWaringManager.java index dac23ba544..2c2e0b360e 100644 --- a/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XWaringManager.java +++ b/modules/mogo-module-v2x/src/main/java/com/mogo/module/v2x/V2XWaringManager.java @@ -41,7 +41,6 @@ import static com.mogo.module.v2x.V2XServiceManager.getContext; */ public class V2XWaringManager { - List lonLats = new ArrayList<>(); private Context mContext; private static V2XWaringManager mV2XWaringManager; @@ -111,7 +110,6 @@ public class V2XWaringManager { } catch (Exception e) { e.printStackTrace(); } - } /** @@ -151,43 +149,6 @@ public class V2XWaringManager { String adasResult = (String) intent.getSerializableExtra(V2XConst.BROADCAST_ADAS_EXTRA_KEY); //测试数据 testData(adasResult); - - // adas 每隔一秒传递的他车或行人数据,避免重复。 -// V2XServiceManager.getmIMogoADASController().addAdasRecognizedDataCallback(resultList -> { -// // 处理他车车身变色,这个可以使用 TODO -// AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList ); -// -// // adas自车定位,显示红色碰撞预警图,以及解除碰撞 -// double lon = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon(); -// double lat = MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(); -// //需要把自车的经纬度前移到车头,然后打点红色的marker -// -// } ); - - } - - - /** - * 添加2d的碰撞 marker - * - * @param markerShowEntity - * @return - */ - private IMogoMarker drawMarker2dResource(MarkerShowEntity markerShowEntity) { - MogoLatLng mogoLatLng = new MogoLatLng(markerShowEntity.getMarkerLocation().getLat(), markerShowEntity.getMarkerLocation().getLon()); - MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 8, 180); - MogoMarkerOptions optionsRipple = new MogoMarkerOptions() - .latitude(newLocation.getLat()) - .longitude(newLocation.getLon()) - .anchor(1.0f, 1.0f) - .zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH); - optionsRipple - .icon(ViewUtils.fromView(new EmptyMarkerView(mContext))); - IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), optionsRipple); - - marker.setInfoWindowAdapter(new AheadCollisionWindow3DAdapter(mContext)); - marker.showInfoWindow(); - return marker; }