[add] 预警目标物底层的红色圆圈位置-未完成
This commit is contained in:
@@ -16,6 +16,7 @@ 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.common.utils.Trigonometric;
|
||||
import com.mogo.module.common.view.MarkerBaseFloor;
|
||||
import com.mogo.service.statusmanager.IMogoStatusChangedListener;
|
||||
import com.mogo.service.statusmanager.StatusDescriptor;
|
||||
@@ -122,15 +123,16 @@ public class V2XWarnDataDrawer extends BaseDrawer implements IMogoStatusChangedL
|
||||
}
|
||||
|
||||
/*
|
||||
* 2D资源绘制marker
|
||||
* 2D资源绘制marker底部的红色圆圈
|
||||
* */
|
||||
private IMogoMarker drawMarkerWith2Resource(MarkerShowEntity markerShowEntity) {
|
||||
MogoLatLng mogoLatLng = new MogoLatLng(markerShowEntity.getMarkerLocation().getLat(), markerShowEntity.getMarkerLocation().getLon());
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(mogoLatLng, 80, 180);
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
||||
.longitude(markerShowEntity.getMarkerLocation().getLon())
|
||||
.latitude(newLocation.getLat())
|
||||
.longitude(newLocation.getLon())
|
||||
.anchor(1.0f, 1.0f)
|
||||
.zIndex(MarkerDrawer.MARKER_Z_INDEX_HIGH);
|
||||
|
||||
optionsRipple
|
||||
.icon(ViewUtils.fromView(new EmptyMarkerView(mContext)));
|
||||
IMogoMarker marker = MogoApisHandler.getInstance().getApis().getMapServiceApi().getMarkerManager(mContext).addMarker(markerShowEntity.getMarkerType(), optionsRipple);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.mogo.module.common.utils;
|
||||
|
||||
import com.mogo.map.MogoLatLng;
|
||||
|
||||
/**
|
||||
* @author liujing
|
||||
* @description 描述
|
||||
* @since: 2021/4/13
|
||||
*/
|
||||
public class Trigonometric {
|
||||
private final static double radius_b = 6378137;//大半径
|
||||
private final static double radius_s = 6356725;//小半径
|
||||
private static double mRadLo;
|
||||
private static double mRadLa;
|
||||
private static double Ec;
|
||||
private static double Ed;
|
||||
|
||||
/**
|
||||
* 计算两点间的角度
|
||||
*/
|
||||
public static double getAngle(double lon1, double lat1, double lon2,
|
||||
double lat2) {
|
||||
double fLat = Math.PI * (lat1) / 180.0;
|
||||
double fLng = Math.PI * (lon1) / 180.0;
|
||||
double tLat = Math.PI * (lat2) / 180.0;
|
||||
double tLng = Math.PI * (lon2) / 180.0;
|
||||
|
||||
double degree = (Math.atan2(Math.sin(tLng - fLng) * Math.cos(tLat), Math.cos(fLat) * Math.sin(tLat) -
|
||||
Math.sin(fLat) * Math.cos(tLat) * Math.cos(tLng - fLng))) * 180.0 / Math.PI;
|
||||
if (degree >= 0) {
|
||||
return degree;
|
||||
} else {
|
||||
return 360 + degree;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据角度获取指定距离点的经纬度
|
||||
*/
|
||||
public static MogoLatLng getNewLocation(MogoLatLng st, double distance, double angle) {
|
||||
mRadLo = st.getLon() * Math.PI / 180.;
|
||||
mRadLa = st.getLat() * Math.PI / 180.;
|
||||
Ec = radius_s + (radius_b - radius_s) * (90. - st.lat) / 90;
|
||||
Ed = Ec * Math.cos(mRadLa);
|
||||
|
||||
double dx = distance * Math.sin(Math.toRadians(angle));
|
||||
double dy = distance * Math.cos(Math.toRadians(angle));
|
||||
double lon_new = (dx / Ed + mRadLo) * 180. / Math.PI;
|
||||
double lat_new = (dy / Ec + mRadLa) * 180. / Math.PI;
|
||||
return new MogoLatLng(lat_new, lon_new);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user