Merge branch 'z' into dev2_aiSdk

This commit is contained in:
liujing
2021-04-02 14:09:38 +08:00
3 changed files with 61 additions and 25 deletions

View File

@@ -29,7 +29,9 @@ import java.util.List;
*/
public class V2XWarningMarker implements IV2XMarker {
private V2XWarningEntity mMarkerEntity;
private MarkerShowEntity markerShowEntity = new MarkerShowEntity();
private Context mContext = V2XServiceManager.getContext();
List fillPoints = new ArrayList();//停止线经纬度合集
@Override
public void drawPOI(Object entity) {
@@ -39,32 +41,43 @@ public class V2XWarningMarker implements IV2XMarker {
location.setLat(mMarkerEntity.getLat());
location.setLon(mMarkerEntity.getLon());
MarkerShowEntity markerShowEntity = new MarkerShowEntity();
markerShowEntity.setMarkerLocation(location);
markerShowEntity.setMarkerType(V2XConst.V2X_FRONT_WARNING_MARKER);
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
// drawLineAndSmooth();
pointsBetween();
//绘制停止线
drawStopLines(fillPoints);
WorkThreadHandler.getInstance().postDelayed(() -> {
clearPOI();
WorkThreadHandler.getInstance().postDelayed(() -> {
IMogoMarker marker = drawMarkerAndReturn(markerShowEntity);
//如果有预警碰撞点,识别物与预警碰撞点之间连线,并执行平移动画
if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() != 0) {
drawLine();
smooth(marker);
}
}, 0);
}, 6_000);
//绘制安全距离
} else {
}
} catch (Exception e) {
}
}
private void drawLineAndSmooth() {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
clearPOI();
WorkThreadHandler.getInstance().postDelayed(() -> {
IMogoMarker marker = drawMarkerAndReturn(markerShowEntity);
//如果有预警碰撞点,识别物与预警碰撞点之间连线,并执行平移动画
if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() != 0) {
drawLine();
smooth(marker);
}
}, 0);
} else {
}
}
//补点后的停止线经纬度合集
public void pointsBetween() {
try {
fillPoints.clear();
List stopLines = mMarkerEntity.getStopLines();
if (stopLines.size() > 1) {
MogoLatLng x = mMarkerEntity.getStopLines().get(0);
@@ -75,11 +88,12 @@ public class V2XWarningMarker implements IV2XMarker {
//两点间的角度
double angle = LocationUtils.getAngle(x.lon, x.lat, y.lon, y.lat);
//根据距离和角度获取下个点的经纬度
List replenish = new ArrayList();
fillPoints.add(x);
for (int i = 1; i < 3; i++) {
MogoLatLng newLocation = LocationUtils.getNewLocation(x, average * i, angle);
replenish.add(newLocation);
fillPoints.add(newLocation);
}
fillPoints.add(y);
}
} catch (Exception e) {
@@ -87,7 +101,29 @@ public class V2XWarningMarker implements IV2XMarker {
}
//绘制marker
private void drawStopLines(List points) {
clearPOI();
for (int i = 0; i < points.size(); i++) {
MogoLatLng latLng = (MogoLatLng) points.get(i);
drawMarkerWithLocation(latLng);
}
}
private void drawMarkerWithLocation(MogoLatLng latLng) {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
.latitude(latLng.lat)
.longitude(latLng.lon);
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
options.icon3DRes(com.mogo.module.service.R.raw.people);
options.anchor(0.5f, 0.5f);
options.anchorColor("#FF4040");
IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(V2XConst.V2X_FRONT_WARNING_MARKER, options);
iMarkerView.setMarker(marker);
marker.setToTop();
}
//绘制并返回marker
public IMogoMarker drawMarkerAndReturn(MarkerShowEntity markerShowEntity) {
MogoMarkerOptions options = new MogoMarkerOptions()
.object(markerShowEntity)
@@ -96,7 +132,7 @@ public class V2XWarningMarker implements IV2XMarker {
IMarkerView iMarkerView = MapMarkerAdapter.getMarkerView(mContext, markerShowEntity, options);
options.icon3DRes(com.mogo.module.service.R.raw.people);
options.anchorColor("#FF4040");
IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(markerShowEntity.getMarkerType(), options);
IMogoMarker marker = V2XServiceManager.getMarkerManager().addMarker(V2XConst.V2X_FRONT_WARNING_MARKER, options);
iMarkerView.setMarker(marker);
marker.setToTop();
return marker;

View File

@@ -246,7 +246,7 @@
android:layout_marginBottom="@dimen/dp_10"
android:background="#FF0606"
android:padding="@dimen/dp_10"
android:text="前碰撞预警"
android:text="前碰撞预警"
android:textColor="#FFFFFF"
android:textSize="@dimen/dp_22"
app:layout_constraintBottom_toBottomOf="parent"

View File

@@ -2,17 +2,17 @@
"type": 2,
"lat": 39.977148,
"lon": 116.417478,
"distance": 2.22,
"distance": 2,
"collisionLat": 39.977094,
"collisionLon": 116.417634,
"stopLines":[
{
"lat": 39.977082,
"lon": 116.417553
"lat": 39.976858,
"lon": 116.417651
},
{
"lat": 39.977078,
"lon": 116.417666
"lat": 39.976874,
"lon": 116.417757
}
],
"from": 1,