Merge branch 'ff' into dev2_aiSdk

This commit is contained in:
liujing
2021-04-09 17:11:03 +08:00
7 changed files with 114 additions and 102 deletions

View File

@@ -0,0 +1,44 @@
package com.mogo.module.v2x.marker;
import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.mogo.module.common.drawer.marker.MapMarkerBaseView;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.v2x.R;
/**
* @author liujing
* @description 前方预警目标物2D资源实现,目前只有停止线,可以按需添加其他类型
* @since: 2021/4/9
*/
public class V2XFrontTargetMarkerView extends MapMarkerBaseView {
private String TAG = "V2XFrontTargetMarkerView";
public V2XFrontTargetMarkerView(Context context) {
super(context);
}
public V2XFrontTargetMarkerView(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public V2XFrontTargetMarkerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void initView(Context context) {
LayoutInflater.from( context ).inflate(R.layout.v2x_front_target_info_view, this );
}
@Override
public void updateView(MarkerShowEntity markerShowEntity) {
}
}

View File

@@ -53,6 +53,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
private Button mBtnTriggerRoadEvent;
private Button mBtnClearRoadEvent;
private Button mBtnTriggerPushEvent;
private Button mBtnTriggerWarningEvent;
private Button mBtnTriggerPushLiveCarEvent;
private Button mBtnTriggerAnimationEvent;
private Button mBtnbtnFrontCarLiveEvent;
@@ -67,6 +68,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
private ToggleButton nBtnTriggerVR;
private Button mBtnAdasDataWarn;
private Button btnTriggerRearVIPCarTip,
btnTriggerVehicleBrakes,
btnTriggerRearDangerousVehicles,
@@ -114,6 +116,7 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
flTestPanelShunYi = findViewById(R.id.flTestPanelShunYi);
flTestPanelVR = findViewById(R.id.flTestPanelVR);
mBtnTriggerOpen = findViewById(R.id.btnTriggerOpen);
mBtnTriggerWarningEvent = findViewById(R.id.btnTriggerWarningEvent);
mBtnClearRoadEvent = findViewById(R.id.btnClearRoadEvent);
mBtnTriggerRoadEvent = findViewById(R.id.btnTriggerRoadEvent);
mBtnTriggerPushEvent = findViewById(R.id.btnTriggerPushEvent);
@@ -220,6 +223,16 @@ public class V2XTestConsoleWindow extends ConstraintLayout {
});
//车路云—场景预警-V1.0 碰撞预警
mBtnTriggerWarningEvent.setOnClickListener(v -> {
V2XMessageEntity<V2XWarningEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushFrontWarningEventData();
Intent intent = new Intent(V2XConst.BROADCAST_SCENE_HANDLER_ACTION);
intent.putExtra(V2XConst.BROADCAST_SCENE_EXTRA_KEY, v2XMessageEntity);
LocalBroadcastManager.getInstance(getContext()).sendBroadcast(intent);
});
mBtnTriggerPushEvent.setOnClickListener(v -> {
V2XMessageEntity<V2XPushMessageEntity> v2XMessageEntity =
TestOnLineCarUtils.getV2XScenarioPushEventData();

View File

@@ -8,21 +8,31 @@ import com.mogo.map.MogoLatLng;
import com.mogo.map.marker.IMogoMarker;
import com.mogo.map.marker.MogoMarkerOptions;
import com.mogo.module.common.MogoApisHandler;
import com.mogo.module.common.drawer.MarkerDrawer;
import com.mogo.module.common.drawer.marker.EmptyMarkerView;
import com.mogo.module.common.drawer.marker.IMarkerView;
import com.mogo.module.common.drawer.marker.MapMarkerAdapter;
import com.mogo.module.common.drawer.marker.SimpleWindow3DAdapter;
import com.mogo.module.common.entity.MarkerLocation;
import com.mogo.module.common.entity.MarkerShowEntity;
import com.mogo.module.common.entity.V2XWarningEntity;
import com.mogo.module.v2x.R;
import com.mogo.module.v2x.V2XConst;
import com.mogo.module.v2x.V2XServiceManager;
import com.mogo.module.v2x.entity.model.DrawLineInfo;
import com.mogo.module.v2x.marker.OptimalSpeedMarkerView;
import com.mogo.module.v2x.marker.V2XFrontTargetMarkerView;
import com.mogo.module.v2x.scenario.view.IV2XMarker;
import com.mogo.module.v2x.utils.LocationUtils;
import com.mogo.utils.ViewUtils;
import com.mogo.utils.WorkThreadHandler;
import java.util.ArrayList;
import java.util.List;
import static com.mogo.module.v2x.V2XConst.V2X_FRONT_WARNING_MARKER;
import static com.mogo.module.v2x.V2XConst.V2X_OPTIMAL_SPEED_MARKER;
/**
* @author liujing
* @description 前方预警marker打点 绘制安全线和预警线
@@ -33,7 +43,7 @@ public class V2XWarningMarker implements IV2XMarker {
private V2XWarningEntity mMarkerEntity;
private MarkerShowEntity markerShowEntity = new MarkerShowEntity();
private Context mContext = V2XServiceManager.getContext();
private List fillPoints = new ArrayList();//停止线经纬度合集
private IMogoMarker optimalMarker = null;
@Override
public void drawPOI(Object entity) {
@@ -45,16 +55,20 @@ public class V2XWarningMarker implements IV2XMarker {
markerShowEntity.setMarkerLocation(location);
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
.latitude(mMarkerEntity.getLat())
.longitude(mMarkerEntity.getLon())
.anchor(0.5f, 0.5f)
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
pointsBetween();
//绘制停止线
// drawStopLines(fillPoints);
drawSafeLine();
WorkThreadHandler.getInstance().postDelayed(() -> {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_STOP_LINE);
V2XServiceManager.getMoGoWarnPolylineManager().clearLine();
}, 6_000);
}
optionsRipple
.icon(ViewUtils.fromView(new EmptyMarkerView(V2XServiceManager.getContext())));
// optionsRipple.icon3DRes(com.mogo.module.common.R.raw.people);
optimalMarker = V2XServiceManager.getMarkerManager().addMarker(V2X_FRONT_WARNING_MARKER, optionsRipple);
optimalMarker.setInfoWindowAdapter(new SimpleWindow3DAdapter(new V2XFrontTargetMarkerView(V2XServiceManager.getContext())));
optimalMarker.showInfoWindow();
} catch (Exception e) {
@@ -62,61 +76,6 @@ public class V2XWarningMarker implements IV2XMarker {
}
//绘制安全距离
private void drawSafeLine() {
clearPOI();
WorkThreadHandler.getInstance().postDelayed(() -> {
//自车位置
MogoLatLng car = V2XServiceManager.getNavi().getCarLocation();
if (car != null) {
//根据到停止线的距离和方向角获取经纬度
MogoLatLng
stopLineLo = LocationUtils.getNewLocation(car, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
// if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() > 0) {
// drawLine(car, stopLineLo);
// }
} else {
Log.d(TAG, "自车位置没有拿到");
}
}, 0);
}
//补点后的停止线经纬度合集
public void pointsBetween() {
try {
fillPoints.clear();
List stopLines = mMarkerEntity.getStopLines();
if (stopLines.size() > 1) {
MogoLatLng x = mMarkerEntity.getStopLines().get(0);
MogoLatLng y = mMarkerEntity.getStopLines().get(1);
//两点间的距离
float distance = CoordinateUtils.calculateLineDistance(x.lon, x.lat, y.lon, y.lat);
float average = distance / 3;
//两点间的角度
double angle = LocationUtils.getAngle(x.lon, x.lat, y.lon, y.lat);
//根据距离和角度获取下个点的经纬度
fillPoints.add(x);
for (int i = 1; i < 3; i++) {
MogoLatLng newLocation = LocationUtils.getNewLocation(x, average * i, angle);
fillPoints.add(newLocation);
}
fillPoints.add(y);
}
} catch (Exception e) {
e.printStackTrace();
}
}
//绘制停止线-通过打点的方式实现
private void drawStopLines(List points) {
clearPOI();
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_STOP_LINE);
for (int i = 0; i < points.size(); i++) {
MogoLatLng latLng = (MogoLatLng) points.get(i);
drawMarkerWithLocation(latLng, V2XConst.V2X_FRONT_STOP_LINE);
}
}
private void drawMarkerWithLocation(MogoLatLng latLng, String tag) {
MogoMarkerOptions options = new MogoMarkerOptions()
@@ -132,47 +91,10 @@ public class V2XWarningMarker implements IV2XMarker {
marker.setToTop();
}
//绘制并返回marker
public IMogoMarker drawMarkerAndReturn(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(com.mogo.module.service.R.raw.people);
options.anchorColor("#FF4040");
IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(V2XConst.V2X_FRONT_WARNING_MARKER, options);
iMarkerView.setMarker(marker);
marker.setToTop();
return marker;
}
//绘制线
public void drawLine(MogoLatLng s, MogoLatLng e) {
DrawLineInfo drawLineInfo = new DrawLineInfo();
drawLineInfo.setStartLocation(s);
drawLineInfo.setEndLocation(e);
drawLineInfo.setWidth(60);
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, drawLineInfo);
}
//平移
public void smooth(IMogoMarker marker) {
List<MogoLatLng> latLngs = new ArrayList<>();
MogoLatLng sLocation = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon());
MogoLatLng endLocation = new MogoLatLng(mMarkerEntity.getCollisionLat(), mMarkerEntity.getCollisionLon());
latLngs.add(sLocation);
latLngs.add(endLocation);
marker.startSmoothInMs(latLngs, 3000);
WorkThreadHandler.getInstance().postDelayed(() -> {
clearLine();
}, 3_000);
}
@Override
public void clearPOI() {
V2XServiceManager.getMarkerManager().removeMarkers(V2XConst.V2X_FRONT_WARNING_MARKER);
V2XServiceManager.getMarkerManager().removeMarkers(V2X_FRONT_WARNING_MARKER);
}
public void clearLine() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="@+id/topResource"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="@drawable/v2x_stop_line" />
<ImageView
android:id="@+id/bottomBg"
android:layout_width="1dp"
android:layout_height="1dp"
android:layout_gravity="center"/>
</LinearLayout>

View File

@@ -237,6 +237,19 @@
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_22"
android:textStyle="bold" />
<Button
android:id="@+id/btnTriggerWarningEvent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_10"
android:layout_marginBottom="@dimen/dp_10"
android:background="#FF0606"
android:padding="@dimen/dp_10"
android:text="前方碰撞预警"
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_22"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<Button
android:id="@+id/btnTriggerPushEvent"