Merge branch 'dev2_aiSdk' of http://gitlab.zhidaoauto.com/ecos/yycp-service/Launcher into dev2_aiSdk
This commit is contained in:
@@ -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;
|
||||
// }
|
||||
|
||||
|
||||
@@ -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;
|
||||
@@ -78,8 +84,7 @@ import static com.mogo.module.common.constants.DataTypes.TYPE_MARKER_CLOUD_WARN_
|
||||
public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
IMogoOnMessageListener< MarkerResponse >,
|
||||
IMogoBizActionDoneListener,
|
||||
IMogoADASControlStatusChangedListener,
|
||||
IMogoCarLocationChangedListener2 {
|
||||
IMogoADASControlStatusChangedListener {
|
||||
private static final String TAG = "MapMarkerManager";
|
||||
|
||||
private Context mContext;
|
||||
@@ -126,7 +131,7 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
CloudPoiManager.getInstance().updateFromConfig( context );
|
||||
MarkerServiceHandler.getActionManager().registerBizActionDoneListener( this );
|
||||
MarkerServiceHandler.getApis().getRegisterCenterApi().registerADASControlStatusChangedListener( TAG, this );
|
||||
MogoApisHandler.getInstance().getApis().getRegisterCenterApi().registerCarLocationChangedListener(TAG, this);
|
||||
|
||||
if ( CallChatApi.getInstance().getApiProvider() != null ) {
|
||||
CallChatApi.getInstance().getApiProvider().registerUserWindowStatusListener( TAG, mContext, new ICallChatResponse() {
|
||||
|
||||
@@ -162,83 +167,58 @@ public class MapMarkerManager implements IMogoMarkerClickListener,
|
||||
msg.sendToTarget();
|
||||
}
|
||||
} );
|
||||
|
||||
// adas 每隔一秒传递的数据
|
||||
MarkerServiceHandler.getApis().getAdasControllerApi().addAdasRecognizedDataCallback( resultList -> {
|
||||
// 绘制近景识别到的车辆
|
||||
AdasRecognizedResultDrawer.getInstance().renderAdasRecognizedResult( resultList );
|
||||
//绘制他车的线 liyz TODO
|
||||
|
||||
//添加自车的定位图标,碰撞只有一个预警 TODO
|
||||
ADASRecognizedResult result = null;
|
||||
for (int i = 0; i < resultList.size(); i++) {
|
||||
result = resultList.get(i);
|
||||
}
|
||||
//添加自车的定位图标,碰撞只有一个预警,还需要和adas 联调,还需要改 liyz
|
||||
// ADASRecognizedResult result = null;
|
||||
// for (int i = 0; i < resultList.size(); i++) {
|
||||
// result = resultList.get(i);
|
||||
// if (result.type) { //找出可能碰撞的车
|
||||
// result = resultList.get(i);
|
||||
// }
|
||||
|
||||
//通过这个传值 ADASRecognizedResult
|
||||
MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().setAdasRecognizedResult(GsonUtil.jsonFromObject(result));
|
||||
//绘制他车的线,从列表中查出可能碰撞的车的经纬度(没有或者只有一个),然后预设20米的长度
|
||||
//绘制碰撞的他车指引线,需要实时给数据更新 TODO
|
||||
// drawLimberCollisionPolyline(result);
|
||||
// }
|
||||
|
||||
// //通过这个传值到 AMapViewWrapper,根据数据更新自车的模型数据 ADASRecognizedResult
|
||||
// MarkerServiceHandler.getApis().getMapServiceApi().getMapUIController().setAdasRecognizedResult(result);
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged2(Location latLng) {
|
||||
Log.d("liyz", "long =" + latLng.getLongitude() + "---lat = " + latLng.getLatitude());
|
||||
MarkerLocation location = new MarkerLocation();
|
||||
location.setLat(latLng.getLatitude());
|
||||
location.setLon(latLng.getLongitude());
|
||||
|
||||
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
|
||||
markerShowEntity.setMarkerLocation(location);
|
||||
markerShowEntity.setMarkerType(TYPE_MARKER_CLOUD_WARN_DATA);
|
||||
|
||||
IMogoMarker marker = drawMarker(markerShowEntity);
|
||||
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
int resId = getModelRes(6);
|
||||
marker.use3DResource( resId );
|
||||
}, 10000);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCarLocationChanged(MogoLatLng latLng) {
|
||||
|
||||
}
|
||||
|
||||
public IMogoMarker drawMarker(MarkerShowEntity markerShowEntity) {
|
||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||
.object(markerShowEntity)
|
||||
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
||||
.longitude(markerShowEntity.getMarkerLocation().getLon());
|
||||
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
|
||||
options.icon3DRes(getModelRes(6)); //TODO
|
||||
|
||||
options.anchorColor("#FB3C3CFF"); //红色#FF3036 蓝色:#256BFF
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), options);
|
||||
iMarkerView.setMarker(marker);
|
||||
marker.setToTop();
|
||||
|
||||
return marker;
|
||||
}
|
||||
|
||||
public int getModelRes(int type) {
|
||||
AdasRecognizedType recognizedType = AdasRecognizedType.valueFrom(type);
|
||||
if (recognizedType == AdasRecognizedType.classIdCar
|
||||
|| recognizedType == AdasRecognizedType.classIdTrafficTruck) {
|
||||
return com.mogo.module.common.R.raw.othercar;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdTrafficBus) {
|
||||
return com.mogo.module.common.R.raw.bus;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdBicycle
|
||||
|| recognizedType == AdasRecognizedType.classIdMoto) {
|
||||
return com.mogo.module.common.R.raw.motorbike;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdStopLine) {
|
||||
return com.mogo.module.common.R.raw.stopline;
|
||||
} else if (recognizedType == AdasRecognizedType.classIdWarningArrows) {
|
||||
return com.mogo.module.common.R.raw.arraw;
|
||||
/**
|
||||
* 实时绘制连线
|
||||
* @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<MogoLatLng> latLngs = new ArrayList<>();
|
||||
latLngs.add(startLatLng);
|
||||
latLngs.add(endLatlng);
|
||||
LimberCollisionPolyline.getInstance().draw((float) result.roadWidth, latLngs);
|
||||
}
|
||||
} else {
|
||||
LimberCollisionPolyline.getInstance().clearLine();
|
||||
}
|
||||
return com.mogo.module.common.R.raw.people;
|
||||
}
|
||||
|
||||
|
||||
private Handler mSnapshotHandler = new Handler( WorkThreadHandler.newInstance( "snapshot-thread" ).getLooper() ) {
|
||||
@Override
|
||||
public void handleMessage( Message msg ) {
|
||||
|
||||
@@ -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<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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user