@@ -538,8 +538,6 @@ public class MoGoV2XMarkerManager implements IMoGoV2XMarkerManager {
|
||||
}
|
||||
if (isVrMode) {
|
||||
mAlarmInfoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl(markerShowEntity, MarkerDrawer.MARKER_Z_INDEX_HIGH, clickListener);
|
||||
// mAlarmInfoMarker.setInfoWindowAdapter(new RoadConditionInfoWindow3DAdapter(markerShowEntity, AbsMogoApplication.getApp(), mAlarmInfoMarker.getMogoMarkerOptions()));
|
||||
// mAlarmInfoMarker.showInfoWindow();
|
||||
} else {
|
||||
optionsRipple.icon(V2XMarkerAdapter.getV2XRoadEventViewPng(context, roadEventEntity));
|
||||
IMogoMarkerManager marker = BridgeApi.INSTANCE.marker();
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
package com.mogo.module.common.adapter;
|
||||
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.map.listener.IMogoMapListener;
|
||||
import com.mogo.map.model.MogoPoi;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.map.uicontroller.VisualAngleMode;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-01-10
|
||||
* <p>
|
||||
* 适配器
|
||||
*/
|
||||
public abstract class MogoMapListenerAdapter implements IMogoMapListener {
|
||||
|
||||
@Override
|
||||
public void onMapLoaded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTouch( MotionEvent motionEvent ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPOIClick( MogoPoi poi ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapClick( MogoLatLng latLng ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLockMap( boolean isLock ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapVisualAngleChanged(VisualAngleMode visualAngleMode) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapChanged( MogoLatLng latLng, float zoom, float tilt, float bearing ) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,7 @@ package com.mogo.module.common.drawer;
|
||||
import static com.mogo.cloud.socket.entity.SocketDownDataHelper.FROM_ADAS;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
|
||||
@@ -71,7 +71,7 @@ class MarkerDrawer {
|
||||
}
|
||||
|
||||
/**
|
||||
* add marker, {@link OnlineCarDrawer 如果是需要在3D模式下显示,则需要设置 {@link MogoMarkerOptions icon3DRes 资源id}}
|
||||
* add marker, { 如果是需要在3D模式下显示,则需要设置 {@link MogoMarkerOptions icon3DRes 资源id}}
|
||||
*
|
||||
* @param markerShowEntity marker展示数据结构体
|
||||
* @param matchRoadSide 设置是否道路吸附,暂时没用到这个字段
|
||||
|
||||
@@ -1,202 +0,0 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import android.graphics.Rect;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.map.marker.IMogoMarker;
|
||||
import com.mogo.map.marker.IMogoMarkerClickListener;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.entity.MarkerCarPois;
|
||||
import com.mogo.module.common.entity.MarkerLocation;
|
||||
import com.mogo.module.common.entity.MarkerOnlineCar;
|
||||
import com.mogo.module.common.entity.MarkerShowEntity;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/10/28
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class OnlineCarDrawer implements IMogoStatusChangedListener {
|
||||
|
||||
private static final String TAG = "OnlineCarDrawer";
|
||||
|
||||
// 平滑移动事件间隔(单位:秒)
|
||||
private static final int SMOOTH_DURATION = 15;
|
||||
|
||||
private static volatile OnlineCarDrawer sInstance;
|
||||
|
||||
private OnlineCarDrawer() {
|
||||
MogoApisHandler.getInstance().getApis()
|
||||
.getStatusManagerApi()
|
||||
.registerStatusChangedListener( TAG, StatusDescriptor.VR_MODE, this );
|
||||
}
|
||||
|
||||
public static OnlineCarDrawer getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( OnlineCarDrawer.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new OnlineCarDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
public void clearMarkers(){
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager( AbsMogoApplication.getApp() ).removeMarkers( ModuleNames.CARD_TYPE_USER_DATA );
|
||||
}
|
||||
|
||||
/**
|
||||
* 绘制在线车辆marker
|
||||
*
|
||||
* @param onlineCarList
|
||||
*/
|
||||
public void drawOnlineCarMarkers( List< MarkerOnlineCar > onlineCarList,
|
||||
int maxAmount,
|
||||
boolean clearOld,
|
||||
boolean showBounds,
|
||||
Rect bound,
|
||||
MogoLatLng centerPoint,
|
||||
IMogoMarkerClickListener listener ) {
|
||||
// 将数据同步给在线车辆,避免每次 perform 的时候去拉取,造成消耗
|
||||
if ( onlineCarList == null || onlineCarList.isEmpty() ) {
|
||||
clearMarkers();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( clearOld ) {
|
||||
clearMarkers();
|
||||
}
|
||||
|
||||
int size = MarkerDrawer.getInstance().getAppropriateSize( maxAmount, onlineCarList );
|
||||
|
||||
Map< String, IMogoMarker > existCarMap = MarkerDrawer.getInstance().purgeMarkerData( onlineCarList, ModuleNames.CARD_TYPE_USER_DATA );
|
||||
|
||||
List< MogoLatLng > carPoints = new ArrayList<>();
|
||||
for ( int i = 0; i < size; i++ ) {
|
||||
MarkerOnlineCar markerOnlineCar = onlineCarList.get( i );
|
||||
MarkerLocation markerLocation = markerOnlineCar.getLocation();
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setBindObj( markerOnlineCar );
|
||||
markerShowEntity.setMarkerLocation( markerLocation );
|
||||
markerShowEntity.setMarkerType( markerOnlineCar.getType() );
|
||||
|
||||
if ( markerOnlineCar.getCarInfo() != null ) {
|
||||
markerShowEntity.setTextContent( markerOnlineCar.getUserInfo().getUserName() );
|
||||
markerShowEntity.setIconUrl( markerOnlineCar.getUserInfo().getUserHead() );
|
||||
}
|
||||
|
||||
if ( i <= 5 ) {
|
||||
carPoints.add( new MogoLatLng( markerLocation.getLat(), markerLocation.getLon() ) );
|
||||
}
|
||||
|
||||
String sn = MarkerDrawer.getInstance().getPrimaryKeyFromEntity( markerOnlineCar );
|
||||
IMogoMarker mogoMarker = existCarMap.get( sn );
|
||||
if ( mogoMarker == null || mogoMarker.isDestroyed() ) {
|
||||
mogoMarker = MarkerDrawer.getInstance().drawMapMarkerImpl( markerShowEntity, false, MarkerDrawer.MARKER_Z_INDEX_LOW, 0, listener );
|
||||
}
|
||||
if ( mogoMarker != null ) {
|
||||
mogoMarker.setVisible( true );
|
||||
}
|
||||
startSmooth( mogoMarker, markerOnlineCar, markerLocation );
|
||||
}
|
||||
|
||||
if ( showBounds && bound != null ) {
|
||||
// 将前6个点显示在固定范围内
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().showBounds( TAG, centerPoint, carPoints, bound, false );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 平滑移动
|
||||
private void startSmooth( IMogoMarker iMogoMarker, MarkerOnlineCar markerOnlineCar,
|
||||
MarkerLocation markerLocation ) {
|
||||
if ( iMogoMarker == null ) {
|
||||
return;
|
||||
}
|
||||
List< MarkerCarPois > poiList = markerOnlineCar.getPois();
|
||||
if ( filterErrorPoint( poiList ) ) {
|
||||
return;
|
||||
}
|
||||
if ( poiList == null || poiList.size() < 2 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
List< MogoLatLng > points = new ArrayList<>();
|
||||
|
||||
double lastLat = 0.0d;
|
||||
double lastLon = 0.0d;
|
||||
|
||||
for ( int j = 0; j < poiList.size(); j++ ) {
|
||||
MarkerCarPois poi = poiList.get( j );
|
||||
if ( poi == null || poi.getCoordinates() == null && poi.getCoordinates().size() != 2 ) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
double lat = Double.valueOf( poi.getCoordinates().get( 1 ) + "" );
|
||||
double lng = Double.valueOf( poi.getCoordinates().get( 0 ) + "" );
|
||||
|
||||
float distance = MarkerDrawer.calculateLineDistance( lastLon, lastLat, lng, lat );
|
||||
lastLon = lng;
|
||||
lastLat = lat;
|
||||
if ( distance < 0.2f ) {// 距离过短,认为静止不动
|
||||
continue;
|
||||
}
|
||||
|
||||
points.add( new MogoLatLng( lat, lng ) );
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
}
|
||||
if ( points.size() >= 1 ) {
|
||||
iMogoMarker.startSmooth( points, SMOOTH_DURATION );
|
||||
} else {
|
||||
Logger.d( TAG, "静止小车,但是有相同的连续坐标" );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 有可能出现终点到起点跳跃的情况,需要用"500M"约束起点和终点
|
||||
*
|
||||
* @param poiList
|
||||
*/
|
||||
private boolean filterErrorPoint( List< MarkerCarPois > poiList ) {
|
||||
if ( poiList == null || poiList.size() < 2 ) {
|
||||
return false;
|
||||
}
|
||||
MarkerCarPois start = poiList.get( 0 );
|
||||
MarkerCarPois end = poiList.get( poiList.size() - 1 );
|
||||
|
||||
try {
|
||||
double lat1 = Double.valueOf( start.getCoordinates().get( 1 ) + "" );
|
||||
double lng1 = Double.valueOf( start.getCoordinates().get( 0 ) + "" );
|
||||
double lat2 = Double.valueOf( end.getCoordinates().get( 1 ) + "" );
|
||||
double lng2 = Double.valueOf( end.getCoordinates().get( 0 ) + "" );
|
||||
if ( MarkerDrawer.calculateLineDistance( new MogoLatLng( lat1, lng1 ), new MogoLatLng( lat2, lng2 ) ) >= 500 ) {
|
||||
Logger.d( TAG, "filter point" );
|
||||
return true;
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
clearMarkers();
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.mogo.module.common.drawer;
|
||||
|
||||
import com.mogo.map.overlay.IMogoPolyline;
|
||||
|
||||
/**
|
||||
* @author donghongyu
|
||||
* @since 2020/10/30
|
||||
* TODO 推送路况信息绘制,用于演示
|
||||
*/
|
||||
public class PushRoadConditionDrawer {
|
||||
|
||||
private static final String TAG = "PushRoadConditionDrawer";
|
||||
private static volatile PushRoadConditionDrawer sInstance;
|
||||
|
||||
private static IMogoPolyline mMogoPolyline;
|
||||
|
||||
private PushRoadConditionDrawer() {
|
||||
}
|
||||
|
||||
public static PushRoadConditionDrawer getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (PushRoadConditionDrawer.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new PushRoadConditionDrawer();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
clearPolyline();
|
||||
mMogoPolyline = null;
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
public void clearPolyline() {
|
||||
if (mMogoPolyline != null) {
|
||||
mMogoPolyline.remove();
|
||||
mMogoPolyline = null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,7 +30,6 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
|
||||
private static final String TAG = "V2XWarnDataDrawer";
|
||||
private static volatile V2XWarnDataDrawer sInstance;
|
||||
private boolean mChangeCarModeStatus;
|
||||
|
||||
private V2XWarnDataDrawer() {
|
||||
super();
|
||||
@@ -59,7 +58,6 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
@Override
|
||||
public void onStatusChanged(StatusDescriptor descriptor, boolean isTrue) {
|
||||
Logger.d(TAG, "%s - %s", descriptor, isTrue);
|
||||
mChangeCarModeStatus = true;
|
||||
}
|
||||
|
||||
public boolean isVrMode() {
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package com.mogo.module.common.map;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.utilcode.util.AppUtils;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/6/5
|
||||
* <p>
|
||||
* 自定义导航功能拦截器
|
||||
*/
|
||||
class CustomNaviInterrupter implements Interrupter {
|
||||
|
||||
private static final String TAG = "CustomNaviInterrupter";
|
||||
|
||||
private static volatile CustomNaviInterrupter sInstance;
|
||||
|
||||
private CustomNaviInterrupter() {
|
||||
}
|
||||
|
||||
public static CustomNaviInterrupter getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( CustomNaviInterrupter.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new CustomNaviInterrupter();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否用自己的导航
|
||||
* 1. 项目是否强制使用自己的导航
|
||||
* 2. 是否安装了高德车机版地图
|
||||
* 3. 默认使用自己的导航
|
||||
*
|
||||
* @return true-用高德公版车机版地图 false-用Launcher自己的导航
|
||||
*/
|
||||
@Override
|
||||
public boolean interrupt() {
|
||||
if ( DebugConfig.isUseCustomNavi() ) {
|
||||
return false;
|
||||
}
|
||||
if ( AppUtils.isAppInstalled( AbsMogoApplication.getApp(), "com.autonavi.amapauto" ) ) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mogo.module.common.map;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
|
||||
@@ -1,124 +0,0 @@
|
||||
package com.mogo.module.common.map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Looper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.bumptech.glide.request.target.SimpleTarget;
|
||||
import com.bumptech.glide.request.transition.Transition;
|
||||
import com.mogo.commons.context.ContextHolderUtil;
|
||||
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.eagle.core.utilcode.util.ViewUtils;
|
||||
import com.mogo.map.uicontroller.CarCursorOption;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.R;
|
||||
|
||||
/**
|
||||
* 自车图标工具类
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class MyLocationUtil {
|
||||
|
||||
private static boolean isLoadingIcon = false;
|
||||
private static boolean needEmphasizeMyLocation = false;
|
||||
|
||||
static {
|
||||
MogoApisHandler.getInstance().getApis().getDataManagerApi()
|
||||
.registerDataListener( "ADAS", data ->{
|
||||
if ( data == null ) {
|
||||
emphasizeMyLocation();
|
||||
} else if( data instanceof String ){
|
||||
setMyLocationIconUrl( ContextHolderUtil.getContext(), ( ( String ) data ));
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
public static void emphasizeMyLocation(){
|
||||
if (!isLoadingIcon) {
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().emphasizeMyLocation();
|
||||
}else{
|
||||
needEmphasizeMyLocation = true;
|
||||
}
|
||||
}
|
||||
|
||||
private static final CarCursorOption DEFAULT_OPTION = new CarCursorOption.Builder()
|
||||
.build();
|
||||
|
||||
public static void setMyLocationIconUrl(Context context){
|
||||
setMyLocationIconUrl( context, SharedPrefsMgr.getInstance( context ).getString( "MY_LOCATION_CONFIG", "" ) );
|
||||
}
|
||||
|
||||
public static void setMyLocationIconUrl(Context context, String url) {
|
||||
if (url == null || url.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
UiThreadHandler.post(() -> loadMyLocationIconInUiThread(context, url));
|
||||
} else {
|
||||
loadMyLocationIconInUiThread(context, url);
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadMyLocationIconInUiThread(Context context, String url) {
|
||||
if (!url.isEmpty()) {
|
||||
isLoadingIcon = true;
|
||||
RequestOptions options = new RequestOptions()
|
||||
.placeholder(DEFAULT_OPTION.getCarCursorRes())
|
||||
.error(DEFAULT_OPTION.getCarCursorRes())
|
||||
.dontAnimate();
|
||||
GlideApp.with(context)
|
||||
.asBitmap()
|
||||
.load(url)
|
||||
.apply(options)
|
||||
.into(new SimpleTarget<Bitmap>() {
|
||||
@Override
|
||||
public void onResourceReady(@NonNull Bitmap resource,
|
||||
@Nullable Transition<? super Bitmap> transition) {
|
||||
DEFAULT_OPTION.setCarCursorBmp(inflateMyLocation(context, resource));
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().setCarCursorOption(DEFAULT_OPTION);
|
||||
if (needEmphasizeMyLocation) {
|
||||
needEmphasizeMyLocation = false;
|
||||
MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().emphasizeMyLocation();
|
||||
}
|
||||
isLoadingIcon = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadStarted(@Nullable Drawable placeholder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadCleared(@Nullable Drawable placeholder) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFailed(@Nullable Drawable errorDrawable) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static Bitmap inflateMyLocation(Context context, Bitmap res) {
|
||||
if (res == null) {
|
||||
throw new IllegalArgumentException("inflate myLocation bitmap can not be null!");
|
||||
}
|
||||
View root = LayoutInflater.from(context).inflate(R.layout.module_common_my_location, null, false);
|
||||
ImageView iv = root.findViewById(R.id.module_map_amap_my_location_iv);
|
||||
iv.setImageBitmap(res);
|
||||
return ViewUtils.fromView(root);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package com.mogo.module.common.utils;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
|
||||
|
||||
/**
|
||||
* author : donghongyu
|
||||
* e-mail : 1358506549@qq.com
|
||||
* date : 2020/5/15 10:31 AM
|
||||
* desc : 基于位置工具类
|
||||
* version: 1.0
|
||||
*/
|
||||
public class LocationUtils {
|
||||
private static final String TAG = "LocationUtils";
|
||||
|
||||
|
||||
/**
|
||||
* 获取传入的经纬度在车辆的什么位置
|
||||
*
|
||||
* @return 顺时针,true-前,false-后
|
||||
*/
|
||||
public static boolean isPointOnCarFront(MogoLocation carLocal, MogoLatLng pointLocal) {
|
||||
double carLon = carLocal.getLongitude();
|
||||
double carLat = carLocal.getLatitude();
|
||||
double poiLon = pointLocal.getLon();
|
||||
double poiLat = pointLocal.getLat();
|
||||
float carAngle = carLocal.getBearing();
|
||||
|
||||
// 计算车辆与点之间的夹角
|
||||
int diffAngle = DrivingDirectionUtils.getDegreeOfCar2Poi(
|
||||
carLon, carLat, poiLon, poiLat, (int) carAngle);
|
||||
|
||||
if (diffAngle <= 90) {
|
||||
Log.i(TAG, "目标点在车辆--前方");
|
||||
return true;
|
||||
} else {
|
||||
Log.i(TAG, "目标点在车辆--后方");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,5 @@ public class SPConst {
|
||||
|
||||
private static String SP_GUIDE = "SP_GUIDE_2020_09_09";
|
||||
|
||||
//用于多模块之间引导状态判断
|
||||
public static String getSpGuide() {
|
||||
return SP_GUIDE;
|
||||
}
|
||||
|
||||
private static String SP_GUIDE_FIRST_TIME_RECORD = "SP_GUIDE_FIRST_TIME_RECORD";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
package com.mogo.module.common.utils;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
|
||||
/**
|
||||
* 简单HandlerThread线程池实现
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class SimpleHandlerThreadPool {
|
||||
private static final String TAG = "SimpleHandlerThreadPool";
|
||||
private final HandlerThread renderThread = new HandlerThread( "one-frame-render-thread" );
|
||||
private final Handler renderHandler;
|
||||
|
||||
private SimpleHandlerThreadPool() {
|
||||
renderThread.start();
|
||||
renderHandler = new Handler( renderThread.getLooper() );
|
||||
}
|
||||
|
||||
private static final SimpleHandlerThreadPool INSTANCE = new SimpleHandlerThreadPool();
|
||||
|
||||
public static SimpleHandlerThreadPool getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public void postRender( Runnable runnable ) {
|
||||
renderHandler.post( runnable );
|
||||
}
|
||||
}
|
||||
@@ -139,8 +139,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
private float mLastZoomLevel = 0;
|
||||
private TtsConfigModleData mTtsModle;
|
||||
private long mRefreshRemainingTime = Long.MAX_VALUE;
|
||||
// 上次手动操作的中心点坐标
|
||||
private MogoLatLng mLastCustomRefreshCenterLocation;
|
||||
|
||||
private IMogoMapService mMogoMapService;
|
||||
private IMogoStatusManager mStatusManager;
|
||||
@@ -328,9 +326,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
}
|
||||
|
||||
public void init( Context context ) {
|
||||
|
||||
initWorkThread();
|
||||
|
||||
registerMogoReceiver( context );
|
||||
registerInternalUnWakeupWords();
|
||||
|
||||
@@ -351,19 +346,12 @@ public class MogoServices implements IMogoMapListener,
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_SWITCH_CARD, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_MY_LOCATION, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_ADAS_STATUS, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_OPERATION, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_VOICE_READY, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_MOCK, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_CAR_ONLINE, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_ONLINE, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_USER_ONLINE, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_BYLOCATION, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_BACK, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_RECEIVER, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_AUTO_NAVI_SEND, this );
|
||||
mIntentManager.registerIntentListener( MogoReceiver.ACTION_MOGO, this );
|
||||
mIntentManager.registerIntentListener( ServiceConst.COMMAND_ONLINE_CAR_PANEL, this );
|
||||
mIntentManager.registerIntentListener( ConnectivityManager.CONNECTIVITY_ACTION, this );
|
||||
|
||||
mADASController = MarkerServiceHandler.getADASController();
|
||||
@@ -384,44 +372,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
TimeDelayUploadManager.getInstance().init(context);
|
||||
}
|
||||
|
||||
private void initWorkThread() {
|
||||
mThreadHandler = new RefreshWorkThreadHandler( WorkThreadHandler.getInstance().getLooper() ) {
|
||||
@Override
|
||||
protected void handleMapChangedMessage( Message msg ) {
|
||||
if ( msg.obj instanceof RefreshObject ) {
|
||||
RefreshObject ro = ( ( RefreshObject ) msg.obj );
|
||||
if ( invokeRefreshWhenTranslationByUser( ro.mLonLat ) ) {
|
||||
notifyRefreshData( ro.mLonLat, ro.mRadius, ro.mCallback );
|
||||
mLastCustomRefreshCenterLocation = ro.mLonLat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleRequestDataMessage( Message msg ) {
|
||||
if ( msg.obj instanceof RefreshObject ) {
|
||||
RefreshObject ro = ( ( RefreshObject ) msg.obj );
|
||||
if ( ro.mLonLat == null ) {
|
||||
invokeAutoRefreshStrategy();
|
||||
Logger.w( TAG, "lonLat is null." );
|
||||
return;
|
||||
}
|
||||
//请求大而全数据,刷新地图POI
|
||||
mRefreshModel.refreshExplorerWayData( ro.mLonLat, ro.mRadius, ro.mAmount, ro.mCallback );
|
||||
// if ( !DebugConfig.
|
||||
// isNeedUploadCoordinatesDurationInTime() ) { //todo 实时在线车辆需要注释,否则在2D模式下不能展示
|
||||
// }
|
||||
//请求在线车辆数据,刷新地图在线车辆
|
||||
if (!mLastStatusIsVr){
|
||||
MapMarkerManager.getInstance().getOnlineCarDataByAutoRefreshStrategy( ro.mLonLat );
|
||||
}
|
||||
|
||||
Logger.i( TAG, "刷新半径 = %s, 点 = %s, zoomLevel = %s, amount = %s", ro.mRadius, ro.mLonLat, mLastZoomLevel, ro.mAmount );
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void registerMogoReceiver( Context context ) {
|
||||
if ( context == null ) {
|
||||
return;
|
||||
@@ -545,7 +495,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
|
||||
if ( mIsCameraInited ) {
|
||||
mLastZoomLevel = zoom;
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mIsCameraInited = false;
|
||||
initMapStatus();
|
||||
return;
|
||||
@@ -554,21 +503,18 @@ public class MogoServices implements IMogoMapListener,
|
||||
// 部分非用户操作导致地图视图变化:绘线、圈点等不触发用户刷新
|
||||
// 消费状态
|
||||
if ( mStatusManager.isUserInteracted() ) {
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
return;
|
||||
}
|
||||
|
||||
// v2x // adas 状态下不做任何操作
|
||||
if ( mStatusManager.isV2XShow() ) {
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
return;
|
||||
}
|
||||
|
||||
// 搜索页面显示时不做任何策略
|
||||
if ( mStatusManager.isSearchUIShow() ) {
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
return;
|
||||
}
|
||||
@@ -577,7 +523,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
if ( mLastZoomLevel - zoom > mCustomRefreshStrategy.getZoomOutLevel() ) {
|
||||
// 缩放级别缩小
|
||||
notifyRefreshData( latLng, getQueryRadius(), mCustomRefreshCallback );
|
||||
mLastCustomRefreshCenterLocation = latLng;
|
||||
mLastZoomLevel = zoom;
|
||||
} else if ( mLastZoomLevel - zoom < 0 ) {
|
||||
mLastZoomLevel = zoom;
|
||||
@@ -602,28 +547,6 @@ public class MogoServices implements IMogoMapListener,
|
||||
return Math.max(radius, 1000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 平移地图刷新策略
|
||||
*/
|
||||
private boolean invokeRefreshWhenTranslationByUser( MogoLatLng latLng ) {
|
||||
try {
|
||||
float factor;
|
||||
if ( mIsVertical ) {
|
||||
factor = getMapCameraFactWidth();
|
||||
} else {
|
||||
factor = getMapCameraFactHeight();
|
||||
}
|
||||
if ( factor == 0.0f ) {
|
||||
return false;
|
||||
}
|
||||
float distance = Utils.calculateLineDistance( latLng, mLastCustomRefreshCenterLocation );
|
||||
return distance > ( factor / 2 );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "warming. " );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChanged( MogoLocation location ) {
|
||||
|
||||
@@ -899,20 +822,8 @@ public class MogoServices implements IMogoMapListener,
|
||||
MoGoAiCloudRealTime.stopRealTime();
|
||||
}
|
||||
|
||||
public Location getLastCarLocation() {
|
||||
return mLastCarLocation;
|
||||
}
|
||||
|
||||
private boolean mLastStatusIsVr = false;
|
||||
|
||||
public boolean isLastStatusIsVr() {
|
||||
return mLastStatusIsVr;
|
||||
}
|
||||
|
||||
public void setLastStatusIsVr(boolean lastStatusIsVr) {
|
||||
this.mLastStatusIsVr = lastStatusIsVr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMapModeChanged( EnumMapUI ui ) {
|
||||
Log.i(TAG, "onMapModeChanged:" + ui + " mLastStatusIsVr:" + mLastStatusIsVr);
|
||||
|
||||
@@ -42,20 +42,11 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final int LOOP_INTERVAL = 10_000;
|
||||
|
||||
/**
|
||||
* 卡片 车聊聊
|
||||
*/
|
||||
public static final String CARD_TYPE_CARS_CHATTING = "CARD_TYPE_CARS_CHATTING";
|
||||
|
||||
/**
|
||||
* 卡片 探路数据
|
||||
*/
|
||||
public static final String CARD_TYPE_ROAD_CONDITION = "CARD_TYPE_ROAD_CONDITION";
|
||||
|
||||
/**
|
||||
* 卡片 分享音乐
|
||||
*/
|
||||
public static final String CARD_TYPE_SHARE_MUSIC = "CARD_TYPE_SHARE_MUSIC";
|
||||
|
||||
/**
|
||||
* 卡片 用户数据
|
||||
@@ -67,11 +58,6 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final String CARD_TYPE_NOVELTY = "CARD_TYPE_NOVELTY";
|
||||
|
||||
/**
|
||||
* 运营位
|
||||
*/
|
||||
public static final String CARD_TYPE_BUSINESS_OPERATION = "CARD_TYPE_BUSINESS_OPERATION";
|
||||
|
||||
/**
|
||||
* 默认地图缩放比例
|
||||
*/
|
||||
@@ -97,10 +83,6 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final int MAX_AMOUNT_ALL = Integer.MAX_VALUE;
|
||||
|
||||
/**
|
||||
* 单个卡片显示时的最大数据量
|
||||
*/
|
||||
public static final int MAX_AMOUNT_SINGLE_CARD = 10;
|
||||
|
||||
/**
|
||||
* 地图变化消息
|
||||
@@ -141,10 +123,6 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final String COMMAND_SWITCH_CARD = "com.zhidao.desk.switchCard";
|
||||
|
||||
/**
|
||||
* 打开/关闭车聊聊
|
||||
*/
|
||||
public static final String COMMAND_OPERATION = "system.application.operation";
|
||||
|
||||
/**
|
||||
* 回到自车
|
||||
@@ -161,41 +139,6 @@ public class ServiceConst {
|
||||
public static final String CMD_BACK = "back";
|
||||
public static final String[] CMD_BACK_WORDS = new String[]{"关闭", "返回"};
|
||||
|
||||
|
||||
/**
|
||||
* 查询附近的人
|
||||
* "data"="{"op":"查询","location":"附近","obj":"人"}"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_NEARBY_CAR_ONLINE = "com.zhidao.nearby.car.online";
|
||||
|
||||
/**
|
||||
* 查询附近的好友
|
||||
* 搜索当前车机所在位置同城市本人有好友关系
|
||||
* (如果一期做不了根据车机所在位置同城查询,则根据车机激活城市查询)
|
||||
* "data"="{"op":"查询","status":"","location":"","obj":"好友"}"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_NEARBY_FRIEND_ONLINE = "com.zhidao.nearby.friend.online";
|
||||
|
||||
/**
|
||||
* 查询在线的好友
|
||||
* "data"="{"op":"查询","status":"在线","obj":"好友"}"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_NEARBY_FRIEND = "com.zhidao.nearby.friend";
|
||||
|
||||
/**
|
||||
* 查询在线的人
|
||||
* <p>
|
||||
* "data"="{"op":"查询","status":"在线","obj":"车主"}"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_NEARBY_USER_ONLINE = "com.zhidao.nearby.user.online";
|
||||
|
||||
/**
|
||||
* 查询指定位置的好友
|
||||
* <p>
|
||||
* "data"="{"op":"看看","obj":"好友","location":"中关村"}"
|
||||
*/
|
||||
public static final String COMMAND_ZHIDAO_NEARBY_FRIEND_BYLOCATION = "com.zhidao.nearby.friend.bylocation";
|
||||
|
||||
/**
|
||||
* 返回桌面
|
||||
*/
|
||||
@@ -204,11 +147,6 @@ public class ServiceConst {
|
||||
public static final int ONLINE_SEARCH_LIMIT = 20;
|
||||
public static final int ONLINE_SEARCH_RADIUS = 2_000;
|
||||
|
||||
/**
|
||||
* 查找目的地车友
|
||||
*/
|
||||
public static final String COMMAND_ONLINE_CAR_PANEL = "com.zhidao.search.riders";
|
||||
|
||||
/**
|
||||
* 导航开始后,延时1分钟开启推送策略
|
||||
*/
|
||||
@@ -219,24 +157,5 @@ public class ServiceConst {
|
||||
*/
|
||||
public static final long INTERVAL_SCHEDULE_CALCULATE_NOT_HOME_COMPANY_DISTANCE_FOR_PUSH = 60 * 1_000L;
|
||||
|
||||
/**
|
||||
* 发送自车位置和adas识别结果给服务端
|
||||
*/
|
||||
public static final int MSG_SEND_CAR_LOCATION_AND_ADAS_RECOGNIZED_RESULT_2_SERVER = 0x401;
|
||||
|
||||
/**
|
||||
* 间隔 1s 发送一次
|
||||
*/
|
||||
public static final long INTERVAL_SEND_CAR_LOCATION_AND_ADAS_RECOGNIZED_RESULT_2_SERVER = 1 * 1_000L;
|
||||
|
||||
/**
|
||||
* adas识别数据
|
||||
*/
|
||||
public static final String TYPE_MARKER_ADAS = "TYPE_MARKER_ADAS";
|
||||
|
||||
/**
|
||||
* 云端下发数据
|
||||
*/
|
||||
public static final String TYPE_MARKER_CLOUD_DATA = "TYPE_MARKER_CLOUD_DATA";
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,8 @@ public class MogoDataHandler implements IMogoDataManager {
|
||||
return InstanceHolder.INSTANCE;
|
||||
}
|
||||
|
||||
public synchronized void registerDataListener( String tag, IMogoDataChangedListener listener ) {
|
||||
@Override
|
||||
public synchronized void registerDataListener(String tag, IMogoDataChangedListener listener ) {
|
||||
if ( listener == null || TextUtils.isEmpty( tag ) ) {
|
||||
return;
|
||||
}
|
||||
@@ -48,7 +49,8 @@ public class MogoDataHandler implements IMogoDataManager {
|
||||
mListeners.get( tag ).add( listener );
|
||||
}
|
||||
|
||||
public synchronized void unregisterListener( String tag, IMogoDataChangedListener listener ) {
|
||||
@Override
|
||||
public synchronized void unregisterListener(String tag, IMogoDataChangedListener listener ) {
|
||||
if ( listener == null || TextUtils.isEmpty( tag ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -6,14 +6,14 @@ import android.content.Intent;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
|
||||
public
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/6/5
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
class AIAssistIntentHandler implements IntentHandler {
|
||||
public class AIAssistIntentHandler implements IntentHandler {
|
||||
|
||||
private static final String TAG = "AIAssistIntentHandler";
|
||||
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.util.LaunchUtils;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.TipToast;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020-04-17
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
public class AppOperationIntentHandler implements IntentHandler {
|
||||
|
||||
public final Map< String, String > sAppPackages = new HashMap<>();
|
||||
|
||||
public AppOperationIntentHandler() {
|
||||
// sAppPackages.put( "车聊聊", "com.zhidao.imdemo" );
|
||||
// sAppPackages.put( "VR模式", "" );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
try {
|
||||
JSONObject object = new JSONObject( intent.getStringExtra( "data" ) );
|
||||
String app = object.optString( "object" );
|
||||
String operation = object.optString( "operation" );
|
||||
if ( TextUtils.equals( "打开", operation ) ) {
|
||||
if ( TextUtils.equals( "VR模式", app ) ) {
|
||||
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isMainPageOnResume() ) {
|
||||
MarkerServiceHandler.getApis().getMapFrameControllerApi().changeToVRMode();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ( TextUtils.isEmpty( sAppPackages.get( app ) ) ) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
LaunchUtils.launchByPkg( context, sAppPackages.get( app ) );
|
||||
} catch ( Exception e ) {
|
||||
TipToast.shortTip( "应用程序未安装" );
|
||||
}
|
||||
} else if ( TextUtils.equals( "关闭", operation ) ) {
|
||||
if ( TextUtils.equals( "VR模式", app ) ) {
|
||||
if ( MarkerServiceHandler.getApis().getStatusManagerApi().isMainPageOnResume() ) {
|
||||
MarkerServiceHandler.getApis().getMapFrameControllerApi().changeTo2dMode();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch ( Exception e ) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,13 +22,7 @@ public class IntentHandlerFactory {
|
||||
private IntentHandlerFactory() {
|
||||
// private constructor
|
||||
mHandlers.put( MogoReceiver.ACTION_MOCK, new MockIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_OPERATION, new AppOperationIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_MY_LOCATION, new MyLocationHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_CAR_ONLINE, OnlineCarSearchIntentHandler.getInstance() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_ONLINE, OnlineCarSearchIntentHandler.getInstance() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND, OnlineCarSearchIntentHandler.getInstance() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_USER_ONLINE, OnlineCarSearchIntentHandler.getInstance() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_BYLOCATION, OnlineCarSearchIntentHandler.getInstance() );
|
||||
mHandlers.put( MogoReceiver.ACTION_VOICE_UI, new VoiceUiIntentHandler() );
|
||||
mHandlers.put( Intent.ACTION_POWER_CONNECTED, AccStatusIntentHandler.getInstance() );
|
||||
mHandlers.put( Intent.ACTION_POWER_DISCONNECTED, AccStatusIntentHandler.getInstance() );
|
||||
@@ -38,7 +32,6 @@ public class IntentHandlerFactory {
|
||||
mHandlers.put( MogoReceiver.ACTION_VOICE_READY, new AIAssistIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_BACK, WholeVoiceCommandIntentHandler.getInstance() );
|
||||
mHandlers.put( MogoReceiver.ACTION_MOGO, new MogoControllerIntentHandler() );
|
||||
mHandlers.put( ServiceConst.COMMAND_ONLINE_CAR_PANEL, new OnlineCarPanelIntentHandler() );
|
||||
mHandlers.put( ConnectivityManager.CONNECTIVITY_ACTION, new NetworkChangedIntentHandler() );
|
||||
}
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.storage.SpStorage;
|
||||
import com.mogo.commons.voice.AIAssist;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/9/21
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class OnlineCarPanelIntentHandler implements IntentHandler {
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
String json = SpStorage.getNavigationTarget();
|
||||
if ( TextUtils.isEmpty( json ) ) {
|
||||
AIAssist.getInstance( context ).speakTTSVoice( "没有导航目的地" );
|
||||
return;
|
||||
}
|
||||
AIAssist.getInstance( context ).speakTTSVoice( "正在查询" );
|
||||
if ( MarkerServiceHandler.getMogoStatusManager().isMainPageOnResume() ) {
|
||||
MarkerServiceHandler.getApis().getOnlineCarPanelApi().showPanel();
|
||||
} else {
|
||||
Intent start = new Intent( Intent.ACTION_VIEW );
|
||||
start.addFlags( Intent.FLAG_ACTIVITY_NEW_TASK );
|
||||
start.setData( Uri.parse( "mogo://launcher/main/switch2?type=showOnlineCarPanel" ) );
|
||||
context.startActivity( start );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
package com.mogo.module.service.intent;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.map.search.geo.IMogoGeoSearch;
|
||||
import com.mogo.map.search.geo.IMogoGeoSearchListener;
|
||||
import com.mogo.map.search.geo.MogoGeocodeAddress;
|
||||
import com.mogo.map.search.geo.MogoGeocodeResult;
|
||||
import com.mogo.map.search.geo.query.MogoGeocodeQuery;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.ServiceConst;
|
||||
import com.mogo.module.service.marker.MapMarkerManager;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
|
||||
import org.json.JSONObject;
|
||||
|
||||
public
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2020/6/5
|
||||
* <p>
|
||||
* 描述
|
||||
*/
|
||||
class OnlineCarSearchIntentHandler implements IntentHandler {
|
||||
|
||||
private static final String TAG = "OnlineCarSearchIntentHandler";
|
||||
|
||||
private static volatile OnlineCarSearchIntentHandler sInstance;
|
||||
|
||||
private OnlineCarSearchIntentHandler() {
|
||||
}
|
||||
|
||||
public static OnlineCarSearchIntentHandler getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( OnlineCarSearchIntentHandler.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new OnlineCarSearchIntentHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle( Context context, Intent intent ) {
|
||||
|
||||
if ( DebugConfig.isNeedUploadCoordinatesDurationInTime() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
String command = intent.getStringExtra( MogoReceiver.PARAM_COMMAND );
|
||||
if ( TextUtils.isEmpty( command ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
MogoLocation location = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation();
|
||||
MogoLatLng target = null;
|
||||
if ( location != null ) {
|
||||
target = new MogoLatLng( location.getLatitude(), location.getLongitude() );
|
||||
}
|
||||
boolean isFocus = false;
|
||||
boolean isSameCity = false;
|
||||
switch ( command ) {
|
||||
case ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND:
|
||||
case ServiceConst.COMMAND_ZHIDAO_NEARBY_USER_ONLINE:
|
||||
isFocus = true;
|
||||
isSameCity = true;
|
||||
case ServiceConst.COMMAND_ZHIDAO_NEARBY_CAR_ONLINE:
|
||||
case ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_ONLINE:
|
||||
Logger.d( TAG, "搜索附近的好友/在线车辆" );
|
||||
doDataRequest(
|
||||
target,
|
||||
isFocus,
|
||||
isSameCity,
|
||||
ServiceConst.ONLINE_SEARCH_LIMIT,
|
||||
ServiceConst.ONLINE_SEARCH_RADIUS );
|
||||
break;
|
||||
case ServiceConst.COMMAND_ZHIDAO_NEARBY_FRIEND_BYLOCATION:
|
||||
handleAreaSearch( intent, context, target );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void handleAreaSearch( Intent intent, Context context, MogoLatLng target ) {
|
||||
String data = intent.getStringExtra( "data" );
|
||||
if ( TextUtils.isEmpty( data ) ) {
|
||||
Logger.e( TAG, "语音没有携带数据!!!!!" );
|
||||
return;
|
||||
}
|
||||
String keyword = null;
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject( data );
|
||||
keyword = jsonObject.get( "location" ).toString();
|
||||
Logger.d( TAG, "location 查询指定位置的好友 keyword = " + keyword );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, "语音携带数据异常!!!!!" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( TextUtils.isEmpty( keyword ) ) {
|
||||
Logger.e( TAG, "语音携带数据为空!!!!!" );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( TextUtils.equals( "附近", keyword ) ) {
|
||||
doDataRequest(
|
||||
target,
|
||||
false,
|
||||
false,
|
||||
ServiceConst.ONLINE_SEARCH_LIMIT,
|
||||
ServiceConst.ONLINE_SEARCH_RADIUS );
|
||||
} else {
|
||||
String cityCode = MarkerServiceHandler.getMogoLocationClient().getLastKnowLocation().getCityCode();
|
||||
IMogoGeoSearch search = MarkerServiceHandler.getMapService().getGeoSearch( context );
|
||||
search.setGeoSearchListener( new IMogoGeoSearchListener() {
|
||||
@Override
|
||||
public void onGeocodeSearched( MogoGeocodeResult geocodeResult ) {
|
||||
MogoLatLng target = getGeoTargetAddress( geocodeResult );
|
||||
if ( target == null ) {
|
||||
Logger.e( TAG, "geo 检索位置错误" );
|
||||
return;
|
||||
}
|
||||
doDataRequest(
|
||||
target,
|
||||
false,
|
||||
false,
|
||||
ServiceConst.ONLINE_SEARCH_LIMIT,
|
||||
ServiceConst.ONLINE_SEARCH_RADIUS );
|
||||
}
|
||||
} );
|
||||
MogoGeocodeQuery mogoGeocodeQuery = new MogoGeocodeQuery();
|
||||
mogoGeocodeQuery.setCity( cityCode );
|
||||
mogoGeocodeQuery.setLocationName( keyword );
|
||||
search.getFromLocationNameAsyn( mogoGeocodeQuery );
|
||||
}
|
||||
}
|
||||
|
||||
private MogoLatLng getGeoTargetAddress( MogoGeocodeResult geocodeResult ) {
|
||||
if ( geocodeResult == null
|
||||
|| geocodeResult.getAddresses() == null
|
||||
|| geocodeResult.getAddresses().isEmpty() ) {
|
||||
return null;
|
||||
}
|
||||
for ( MogoGeocodeAddress address : geocodeResult.getAddresses() ) {
|
||||
if ( address == null ) {
|
||||
continue;
|
||||
}
|
||||
if ( address.getLatlng() == null ) {
|
||||
continue;
|
||||
}
|
||||
return address.getLatlng();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void doDataRequest( MogoLatLng target,
|
||||
boolean onlyFocus,
|
||||
boolean onlySameCity,
|
||||
int limit,
|
||||
int radius ) {
|
||||
MarkerServiceHandler.getApis().getRefreshStrategyControllerApi().restartAutoRefreshAtTime( 30_000 );
|
||||
MarkerServiceHandler.getMogoStatusManager().setUserInteractionStatus( TAG, true, false );
|
||||
if(!MarkerServiceHandler.getApis().getStatusManagerApi().isVrMode()){
|
||||
MarkerServiceHandler.getMapUIController().moveToCenter( target );
|
||||
}
|
||||
MapMarkerManager.getInstance().getOnlineCarDataByVoiceControl(
|
||||
target,
|
||||
onlyFocus,
|
||||
onlySameCity,
|
||||
limit,
|
||||
radius );
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadPoolService;
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler;
|
||||
import com.mogo.eagle.core.utilcode.util.ViewUtils;
|
||||
@@ -19,7 +20,6 @@ import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.ModuleNames;
|
||||
import com.mogo.module.common.api.CallChatApi;
|
||||
import com.mogo.module.common.drawer.MarkerDrawer;
|
||||
import com.mogo.module.common.drawer.OnlineCarDrawer;
|
||||
import com.mogo.module.common.drawer.RoadConditionDrawer;
|
||||
import com.mogo.module.common.drawer.marker.IMarkerView;
|
||||
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
|
||||
@@ -39,7 +39,6 @@ import com.mogo.realtime.api.MoGoAiCloudRealTime;
|
||||
import com.mogo.realtime.socket.IMogoCloudOnMsgListener;
|
||||
import com.mogo.service.adas.IMogoADASControlStatusChangedListener;
|
||||
import com.mogo.service.module.IMogoBizActionDoneListener;
|
||||
import com.mogo.eagle.core.utilcode.mogo.toast.ResourcesHelper;
|
||||
import com.zhidao.carchattingprovider.ICallChatResponse;
|
||||
|
||||
import org.json.JSONArray;
|
||||
@@ -555,32 +554,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
mCarLatLng = new MogoLatLng(lat, lon);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据经纬度请求数据
|
||||
*
|
||||
* @param latlng
|
||||
*/
|
||||
public void getOnlineCarDataByAutoRefreshStrategy(MogoLatLng latlng) {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
getOnlineCarDataImpl(latlng, false, false, ServiceConst.ONLINE_SEARCH_LIMIT, ServiceConst.ONLINE_SEARCH_RADIUS, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param latLng
|
||||
* @param onlyFocus
|
||||
* @param onlySameCity
|
||||
* @param limit
|
||||
* @param radius
|
||||
*/
|
||||
public void getOnlineCarDataByVoiceControl(MogoLatLng latLng,
|
||||
boolean onlyFocus,
|
||||
boolean onlySameCity,
|
||||
int limit,
|
||||
int radius) {
|
||||
UiThreadHandler.removeCallbacks(runnable);
|
||||
getOnlineCarDataImpl(latLng, onlyFocus, onlySameCity, limit, radius, true);
|
||||
}
|
||||
|
||||
private final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -662,7 +635,6 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
|
||||
runOnTargetThread(() -> {
|
||||
trackData(size);
|
||||
OnlineCarDrawer.getInstance().drawOnlineCarMarkers(onlineCarList, Integer.MAX_VALUE, fitBounds, fitBounds, mMarkerDisplayBounds, latLng, MapMarkerManager.this);
|
||||
UiThreadHandler.postDelayed(runnable, SMOOTH_DURATION * 1000);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.mogo.module.service.mocktools;
|
||||
|
||||
import android.os.Environment;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
|
||||
import com.mogo.eagle.core.utilcode.mogo.thread.WorkThreadHandler;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DataCollectionHandler {
|
||||
|
||||
private static volatile DataCollectionHandler handler;
|
||||
private static final byte[] obj = new byte[0];
|
||||
private volatile boolean openDataCollect = false;
|
||||
|
||||
private Handler mLocationDataCollectHandler;
|
||||
private Handler mRecognizeDataCollectHandler;
|
||||
|
||||
private static final String WRITE_FILE_PATH = Environment.getExternalStorageDirectory().getPath() + File.separator + "mockWrite";
|
||||
|
||||
private DataCollectionHandler() {
|
||||
|
||||
}
|
||||
|
||||
public static DataCollectionHandler getInstance() {
|
||||
if (handler == null) {
|
||||
synchronized (obj) {
|
||||
if (handler == null) {
|
||||
handler = new DataCollectionHandler();
|
||||
}
|
||||
}
|
||||
}
|
||||
return handler;
|
||||
}
|
||||
|
||||
public void start() {
|
||||
openDataCollect = true;
|
||||
}
|
||||
|
||||
public boolean canCollectData() {
|
||||
return openDataCollect;
|
||||
}
|
||||
|
||||
public void collectLocationDataToFile(String locationData) {
|
||||
if (mLocationDataCollectHandler == null) {
|
||||
mLocationDataCollectHandler = new Handler(WorkThreadHandler.newInstance("data-collect-thread").getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void collectRecogniseDataToFile() {
|
||||
if (mRecognizeDataCollectHandler == null) {
|
||||
mRecognizeDataCollectHandler = new Handler(WorkThreadHandler.newInstance("recognize-collect-thread").getLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
openDataCollect = false;
|
||||
mLocationDataCollectHandler = null;
|
||||
mRecognizeDataCollectHandler = null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.mogo.module.service.polyline;
|
||||
|
||||
import com.mogo.eagle.core.data.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<MogoLatLng> 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<MogoLatLng> polylinePoint) {
|
||||
try {
|
||||
if (mMoGoPolyline != null) {
|
||||
mMoGoPolyline.remove();
|
||||
mPolylinePointList.clear();
|
||||
}
|
||||
|
||||
// 连接线参数
|
||||
MogoPolylineOptions options = new MogoPolylineOptions();
|
||||
|
||||
// 渐变色
|
||||
List<Integer> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,161 +0,0 @@
|
||||
package com.mogo.module.service.status;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.mogo.cloud.passport.MoGoAiCloudClientConfig;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr;
|
||||
import com.mogo.eagle.core.utilcode.util.NetworkUtils;
|
||||
import com.mogo.map.uicontroller.EnumMapUI;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.wm.WindowManagerView;
|
||||
import com.mogo.module.service.R;
|
||||
|
||||
import static com.mogo.eagle.core.utilcode.util.CommonUtils.getVersionName;
|
||||
|
||||
|
||||
/**
|
||||
* @author congtaowang
|
||||
* @since 2021/3/17
|
||||
*
|
||||
* 环境状态
|
||||
*/
|
||||
public class EnvStatusManager {
|
||||
|
||||
private static volatile EnvStatusManager sInstance;
|
||||
|
||||
private EnvStatusManager() {
|
||||
}
|
||||
|
||||
public static EnvStatusManager getInstance() {
|
||||
if (sInstance == null) {
|
||||
synchronized (EnvStatusManager.class) {
|
||||
if (sInstance == null) {
|
||||
sInstance = new EnvStatusManager();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private WindowManagerView mPanelView;
|
||||
private TextView mStatusTv;
|
||||
private final Handler mMainHandler = new Handler(Looper.getMainLooper()) {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
super.handleMessage(msg);
|
||||
if (mPanelView.isShowing()) {
|
||||
renderStatus();
|
||||
mMainHandler.sendEmptyMessageDelayed(MSG, 5_000L);
|
||||
}
|
||||
}
|
||||
};
|
||||
public static final int MSG = 10000;
|
||||
|
||||
private void renderStatus() {
|
||||
String[] sStatusName = {
|
||||
"工控机定位",
|
||||
"ADAS近景感知",
|
||||
"云端远景感知",
|
||||
"自动驾驶状态",
|
||||
"socket长链",
|
||||
"经度",
|
||||
"纬度",
|
||||
"网络状态",
|
||||
"App版本",
|
||||
"Map版本",
|
||||
"SN",
|
||||
"OBU状态",
|
||||
"HV状态",
|
||||
"RV状态"
|
||||
};
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
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 == 4) {
|
||||
stringBuilder.append(DebugConfig.isDownloadSnapshot() ? "正常" : "异常").append("\n");
|
||||
} else if (i == 5 || i == 6) {
|
||||
stringBuilder.append(DebugConfig.getStatusData(i)).append("\n");
|
||||
} else if (i == 7) {
|
||||
stringBuilder.append(NetworkUtils.isConnected(mContext)).append("\n");
|
||||
} else if (i == 8) {
|
||||
stringBuilder.append(getVersionName(mContext, "com.mogo.launcher.f")).append("\n");
|
||||
} else if (i == 9) {
|
||||
String mapVersion = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapVersion();
|
||||
if (!TextUtils.isEmpty(mapVersion)) {
|
||||
stringBuilder.append(mapVersion).append("\n");
|
||||
}
|
||||
} else if(i == 10){
|
||||
stringBuilder.append(MoGoAiCloudClientConfig.getInstance().getSn()).append("\n");
|
||||
} else if (i == 11) {
|
||||
boolean isObuConnect = SharedPrefsMgr.getInstance(mContext).getBoolean("OBU", false);
|
||||
stringBuilder.append(isObuConnect == true ? "已连接" : "未连接").append("\n");
|
||||
} else if (i == 12) {
|
||||
boolean isHv = SharedPrefsMgr.getInstance( mContext ).getBoolean("OBU_HV", false );
|
||||
stringBuilder.append(isHv == true ? "已连接" : "未连接").append("\n");
|
||||
} else if (i == 13) {
|
||||
boolean isRv = SharedPrefsMgr.getInstance( mContext ).getBoolean("OBU_RV", false );
|
||||
stringBuilder.append(isRv == true ? "已连接" : "未连接").append("\n");
|
||||
} else {
|
||||
stringBuilder.append("true".equals(DebugConfig.getStatus(i, true)) ? "正常" : "异常").append("\n");
|
||||
}
|
||||
}
|
||||
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);
|
||||
} else {
|
||||
mStatusTv.setTextColor(Color.WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Context mContext;
|
||||
|
||||
public void showPanel(Context context) {
|
||||
mContext = 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.show();
|
||||
mMainHandler.sendEmptyMessageDelayed(MSG, 0L);
|
||||
}
|
||||
|
||||
public void closePanel() {
|
||||
if (mPanelView != null) {
|
||||
mPanelView.dismiss();
|
||||
mMainHandler.removeMessages(MSG);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.mogo.module.service.utils;
|
||||
|
||||
import android.location.Location;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.service.cloud.location.CloudLocationInfo;
|
||||
|
||||
@@ -11,25 +9,6 @@ import com.mogo.service.cloud.location.CloudLocationInfo;
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class LocationParseUtil {
|
||||
/**
|
||||
* 从Location 转 CloudLocationInfo
|
||||
* @param info 待转数据
|
||||
* @return 转后数据
|
||||
*/
|
||||
public static CloudLocationInfo locationToCloudLocation(Location info) {
|
||||
if (info == null) {
|
||||
return null;
|
||||
}
|
||||
CloudLocationInfo cloud = new CloudLocationInfo();
|
||||
cloud.setLat(info.getLatitude());
|
||||
cloud.setLon(info.getLongitude());
|
||||
cloud.setAlt(info.getAltitude());
|
||||
cloud.setHeading(info.getBearing());
|
||||
cloud.setSpeed(info.getSpeed());
|
||||
cloud.setSatelliteTime(info.getTime());
|
||||
cloud.setSystemTime(System.currentTimeMillis());
|
||||
return cloud;
|
||||
}
|
||||
|
||||
public static MogoLatLng cloudLocationToMogoLatLng(CloudLocationInfo info) {
|
||||
if (info == null) {
|
||||
|
||||
@@ -1,256 +0,0 @@
|
||||
package com.mogo.module.service.utils;
|
||||
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.service.cloud.location.CloudLocationInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 定位预测纠错策略
|
||||
*
|
||||
* @author tongchenfei
|
||||
*/
|
||||
public class SimpleLocationCorrectStrategy {
|
||||
private static final String TAG = "SimpleLocationCorrectStrategy";
|
||||
private static final int ERR_COUNT_THRESHOLD = 3;
|
||||
/**
|
||||
* 目标距离误差是10米,就是在原目标距离基础上增加10米
|
||||
*/
|
||||
private static final float TARGET_DISTANCE_DEVIATION = 10;
|
||||
|
||||
private CloudLocationInfo lastLocation = null;
|
||||
private long anchorTime;
|
||||
private int errCount;
|
||||
|
||||
private static final SimpleLocationCorrectStrategy instance = new SimpleLocationCorrectStrategy();
|
||||
|
||||
public static SimpleLocationCorrectStrategy getInstance(){
|
||||
return instance;
|
||||
}
|
||||
|
||||
private final List<CloudLocationInfo> historyList = new ArrayList<>();
|
||||
private final List<CloudLocationInfo> validList = new ArrayList<>();
|
||||
private final List<CloudLocationInfo> correctList = new ArrayList<>();
|
||||
private final List<CloudLocationInfo> errList = new ArrayList<>();
|
||||
|
||||
public CloudLocationInfo correct(CloudLocationInfo info) {
|
||||
Logger.d(TAG, "info: " + info.print());
|
||||
if(isLocationValid(info)) {
|
||||
if(recordLocation()) {
|
||||
historyList.add(info);
|
||||
}
|
||||
|
||||
if (lastLocation == null) {
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
Logger.d(TAG, "第一条数据");
|
||||
if(recordLocation()) {
|
||||
validList.add(lastLocation);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
if (lastLocation.equals(info)) {
|
||||
Logger.d(TAG, "相同坐标点==");
|
||||
return info;
|
||||
}
|
||||
try {
|
||||
float targetDistance =
|
||||
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
|
||||
float distance = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().calculateLineDistance(LocationParseUtil.cloudLocationToMogoLatLng(lastLocation), LocationParseUtil.cloudLocationToMogoLatLng(info));
|
||||
Logger.d(TAG,
|
||||
"准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
if (distance <= targetDistance) {
|
||||
// 新的定位点在目标距离范围内,认为此数据有效
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount = 0;
|
||||
Logger.d(TAG, "在范围内,为有效点");
|
||||
if(recordLocation()) {
|
||||
validList.add(lastLocation);
|
||||
}
|
||||
return info;
|
||||
} else {
|
||||
// 出现异常点
|
||||
if (errCount >= ERR_COUNT_THRESHOLD) {
|
||||
// 出错次数超过阈值,认为本次出错点为正确点
|
||||
if(recordLocation()) {
|
||||
errList.add(new CloudLocationInfo(lastLocation));
|
||||
correctList.add(info);
|
||||
}
|
||||
lastLocation = info;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount = 0;
|
||||
Logger.d(TAG, "出错次数超限,异常点变有效点");
|
||||
return info;
|
||||
} else {
|
||||
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
|
||||
CloudLocationInfo nextInfo = new CloudLocationInfo(lastLocation);
|
||||
MogoLatLng nextLatLon = computerThatLonLat(lastLocation.getLon(),
|
||||
lastLocation.getLat(), lastLocation.getHeading(), targetDistance);
|
||||
nextInfo.setLon(nextLatLon.lon);
|
||||
nextInfo.setLat(nextLatLon.lat);
|
||||
if(recordLocation()) {
|
||||
errList.add(info);
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
lastLocation = nextInfo;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount++;
|
||||
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
|
||||
// return lastLocation;
|
||||
if(recordLocation()) {
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
return nextInfo;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
Logger.e(TAG, e, "纠偏异常");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
Logger.d(TAG, "定位点异常");
|
||||
if (lastLocation == null) {
|
||||
return null;
|
||||
}else{
|
||||
try {
|
||||
float targetDistance =
|
||||
(float) (lastLocation.getSpeed() * (SystemClock.elapsedRealtime() - anchorTime) / 1000) + TARGET_DISTANCE_DEVIATION;
|
||||
float distance = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMapUIController().calculateLineDistance(LocationParseUtil.cloudLocationToMogoLatLng(lastLocation), LocationParseUtil.cloudLocationToMogoLatLng(info));
|
||||
Logger.d(TAG,
|
||||
"异常定位点\n准备计算{ lastInfo: " + lastLocation.print() + " info: " + info.print() + " targetDistance: " + targetDistance + " distance : " + distance + "}");
|
||||
// 按照上一个点的方向和速度,计算下一个点的位置,下一个点除坐标点外,其余数据与上一个点相同
|
||||
CloudLocationInfo nextInfo = new CloudLocationInfo(lastLocation);
|
||||
MogoLatLng nextLatLon = computerThatLonLat(lastLocation.getLon(),
|
||||
lastLocation.getLat(), lastLocation.getHeading(), targetDistance);
|
||||
nextInfo.setLon(nextLatLon.lon);
|
||||
nextInfo.setLat(nextLatLon.lat);
|
||||
if(recordLocation()) {
|
||||
errList.add(info);
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
lastLocation = nextInfo;
|
||||
anchorTime = SystemClock.elapsedRealtime();
|
||||
errCount++;
|
||||
Logger.d(TAG, "异常点纠偏 info: " + lastLocation);
|
||||
if(recordLocation()) {
|
||||
correctList.add(nextInfo);
|
||||
}
|
||||
// return lastLocation;
|
||||
return nextInfo;
|
||||
}catch (Exception e){
|
||||
Logger.e(TAG, e, "纠偏异常");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isLocationValid(CloudLocationInfo info) {
|
||||
return info.getLat() != 0 && info.getLon() != 0;
|
||||
}
|
||||
|
||||
private RecordLocationListener recordLocationListener = null;
|
||||
private boolean hasCallbackRecord = false;
|
||||
|
||||
public void setRecordLocationListener(RecordLocationListener recordLocationListener) {
|
||||
this.recordLocationListener = recordLocationListener;
|
||||
}
|
||||
|
||||
private boolean recordLocation(){
|
||||
if (historyList.size() >= 100 && !hasCallbackRecord && recordLocationListener != null) {
|
||||
hasCallbackRecord = true;
|
||||
recordLocationListener.onRecordFinish(historyList, correctList,validList,correctList);
|
||||
}
|
||||
return historyList.size() < 100;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据距离和角度计算下一个经纬度
|
||||
* 大地坐标系资料WGS-84 长半径a=6378137 短半径b=6356752.3142 扁率f=1/298.2572236
|
||||
*/
|
||||
public MogoLatLng computerThatLonLat(double lon, double lat, double brng, double dist) {
|
||||
|
||||
double alpha1 = rad(brng);
|
||||
double sinAlpha1 = Math.sin(alpha1);
|
||||
double cosAlpha1 = Math.cos(alpha1);
|
||||
|
||||
// 扁率f=1/298.2572236
|
||||
double f = 1 / 298.2572236;
|
||||
double tanU1 = (1 - f) * Math.tan(rad(lat));
|
||||
double cosU1 = 1 / Math.sqrt((1 + tanU1 * tanU1));
|
||||
double sinU1 = tanU1 * cosU1;
|
||||
double sigma1 = Math.atan2(tanU1, cosAlpha1);
|
||||
double sinAlpha = cosU1 * sinAlpha1;
|
||||
double cosSqAlpha = 1 - sinAlpha * sinAlpha;
|
||||
// 长半径a=6378137
|
||||
double a = 6378137;
|
||||
// 短半径b=6356752.3142
|
||||
double b = 6356752.3142;
|
||||
double uSq = cosSqAlpha * (a * a - b * b) / (b * b);
|
||||
double A = 1 + uSq / 16384 * (4096 + uSq * (-768 + uSq * (320 - 175 * uSq)));
|
||||
double B = uSq / 1024 * (256 + uSq * (-128 + uSq * (74 - 47 * uSq)));
|
||||
|
||||
double cos2SigmaM=0;
|
||||
double sinSigma=0;
|
||||
double cosSigma=0;
|
||||
double sigma = dist / (b * A), sigmaP = 2 * Math.PI;
|
||||
while (Math.abs(sigma - sigmaP) > 1e-12) {
|
||||
cos2SigmaM = Math.cos(2 * sigma1 + sigma);
|
||||
sinSigma = Math.sin(sigma);
|
||||
cosSigma = Math.cos(sigma);
|
||||
double deltaSigma = B * sinSigma * (cos2SigmaM + B / 4 * (cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)
|
||||
- B / 6 * cos2SigmaM * (-3 + 4 * sinSigma * sinSigma) * (-3 + 4 * cos2SigmaM * cos2SigmaM)));
|
||||
sigmaP = sigma;
|
||||
sigma = dist / (b * A) + deltaSigma;
|
||||
}
|
||||
|
||||
double tmp = sinU1 * sinSigma - cosU1 * cosSigma * cosAlpha1;
|
||||
double lat2 = Math.atan2(sinU1 * cosSigma + cosU1 * sinSigma * cosAlpha1,
|
||||
(1 - f) * Math.sqrt(sinAlpha * sinAlpha + tmp * tmp));
|
||||
double lambda = Math.atan2(sinSigma * sinAlpha1, cosU1 * cosSigma - sinU1 * sinSigma * cosAlpha1);
|
||||
double C = f / 16 * cosSqAlpha * (4 + f * (4 - 3 * cosSqAlpha));
|
||||
double L = lambda - (1 - C) * f * sinAlpha
|
||||
* (sigma + C * sinSigma * (cos2SigmaM + C * cosSigma * (-1 + 2 * cos2SigmaM * cos2SigmaM)));
|
||||
|
||||
// final bearing
|
||||
double revAz = Math.atan2(sinAlpha, -tmp);
|
||||
|
||||
System.out.println(revAz);
|
||||
System.out.println(lon+deg(L)+","+deg(lat2));
|
||||
return new MogoLatLng(deg(lat2), lon + deg(L));
|
||||
}
|
||||
|
||||
/**
|
||||
* 度换成弧度
|
||||
*
|
||||
* @param d
|
||||
* 度
|
||||
* @return 弧度
|
||||
*/
|
||||
private double rad(double d) {
|
||||
return d * Math.PI / 180.0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 弧度换成度
|
||||
*
|
||||
* @param x
|
||||
* 弧度
|
||||
* @return 度
|
||||
*/
|
||||
private double deg(double x) {
|
||||
return x * 180 / Math.PI;
|
||||
}
|
||||
|
||||
public interface RecordLocationListener{
|
||||
void onRecordFinish(List<CloudLocationInfo> history, List<CloudLocationInfo> correct,List<CloudLocationInfo> valid,List<CloudLocationInfo> err);
|
||||
}
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.mogo.module.service.vrmode;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.mogo.commons.AbsMogoApplication;
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.Logger;
|
||||
|
||||
public
|
||||
/*
|
||||
* @author congtaowang
|
||||
* @since 2020/10/27
|
||||
*
|
||||
* 描述
|
||||
*/
|
||||
class VrModeController {
|
||||
|
||||
private static final String TAG = "VrModeController";
|
||||
|
||||
private static volatile VrModeController sInstance;
|
||||
private ServiceConnection mServiceConnection;
|
||||
|
||||
private VrModeController() {
|
||||
}
|
||||
|
||||
public static VrModeController getInstance() {
|
||||
if ( sInstance == null ) {
|
||||
synchronized ( VrModeController.class ) {
|
||||
if ( sInstance == null ) {
|
||||
sInstance = new VrModeController();
|
||||
}
|
||||
}
|
||||
}
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
public synchronized void release() {
|
||||
sInstance = null;
|
||||
}
|
||||
|
||||
private Object readResolve() {
|
||||
// 阻止反序列化,必须实现 Serializable 接口
|
||||
return sInstance;
|
||||
}
|
||||
|
||||
private boolean mIsBinding = false;
|
||||
|
||||
public void onVrModeChanged( boolean isVrMode ) {
|
||||
if ( isVrMode ) {
|
||||
bindVrModeService();
|
||||
} else {
|
||||
unbindVrModeService();
|
||||
}
|
||||
}
|
||||
|
||||
private void bindVrModeService() {
|
||||
if ( mIsBinding ) {
|
||||
return;
|
||||
}
|
||||
mIsBinding = true;
|
||||
Intent intent = new Intent();
|
||||
intent.setComponent( new ComponentName( "com.mogo.launcher.f", "com.mogo.module.machine.vision.MachineVisionMapService" ) );
|
||||
AbsMogoApplication.getApp().bindService( intent, mServiceConnection = new ServiceConnection() {
|
||||
@Override
|
||||
public void onServiceConnected( ComponentName name, IBinder service ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onServiceDisconnected( ComponentName name ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindingDied( ComponentName name ) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNullBinding( ComponentName name ) {
|
||||
}
|
||||
}, Context.BIND_AUTO_CREATE );
|
||||
}
|
||||
|
||||
private void unbindVrModeService() {
|
||||
mIsBinding = false;
|
||||
if ( mServiceConnection != null ) {
|
||||
try {
|
||||
AbsMogoApplication.getApp().unbindService( mServiceConnection );
|
||||
} catch ( Exception e ) {
|
||||
Logger.e( TAG, e, "unbindVrModeService" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onMainPageResumeStatusChanged( boolean isResume ) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user