绘制停止线

This commit is contained in:
liujing
2021-04-02 14:08:58 +08:00
parent 9417136b15
commit a917bd280b
3 changed files with 43 additions and 11 deletions

View File

@@ -31,6 +31,7 @@ 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) {
@@ -41,16 +42,22 @@ public class V2XWarningMarker implements IV2XMarker {
location.setLon(mMarkerEntity.getLon());
markerShowEntity.setMarkerLocation(location);
markerShowEntity.setMarkerType(V2XConst.V2X_FRONT_WARNING_MARKER);
// drawLineAndSmooth();
pointsBetween();
//绘制停止线
drawStopLines(fillPoints);
WorkThreadHandler.getInstance().postDelayed(() -> {
clearPOI();
}, 6_000);
//绘制安全距离
} catch (Exception e) {
}
}
private void drawLineAndSmooth(){
private void drawLineAndSmooth() {
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
clearPOI();
WorkThreadHandler.getInstance().postDelayed(() -> {
@@ -67,8 +74,10 @@ public class V2XWarningMarker implements IV2XMarker {
}
}
//补点后的停止线经纬度合集
public void pointsBetween() {
try {
fillPoints.clear();
List stopLines = mMarkerEntity.getStopLines();
if (stopLines.size() > 1) {
MogoLatLng x = mMarkerEntity.getStopLines().get(0);
@@ -79,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) {
@@ -91,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)
@@ -100,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;