[add] 预警目标物底层的红色圆圈位置-未完成
This commit is contained in:
@@ -12,6 +12,7 @@ import com.mogo.map.overlay.IMogoPolyline;
|
||||
import com.mogo.module.common.MogoApisHandler;
|
||||
import com.mogo.module.common.drawer.V2XWarnDataDrawer;
|
||||
import com.mogo.module.common.entity.V2XWarningEntity;
|
||||
import com.mogo.module.common.utils.Trigonometric;
|
||||
import com.mogo.module.service.MarkerServiceHandler;
|
||||
import com.mogo.module.service.receiver.MogoReceiver;
|
||||
import com.mogo.module.v2x.MoGoV2XServicePaths;
|
||||
@@ -19,7 +20,6 @@ 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.manager.IMoGoV2XCloundDataManager;
|
||||
import com.mogo.module.v2x.utils.LocationUtils;
|
||||
import com.mogo.utils.UiThreadHandler;
|
||||
import com.mogo.utils.WorkThreadHandler;
|
||||
|
||||
@@ -39,7 +39,10 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
private boolean isSelfLineClear;
|
||||
private List fillPoints = new ArrayList();//停止线经纬度合集
|
||||
private boolean isFirstLocation = false;
|
||||
private MogoLatLng carLocation;
|
||||
private MogoLatLng carLocation = new MogoLatLng(
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLat(),
|
||||
MogoApisHandler.getInstance().getApis().getAdasControllerApi().getLastLon()
|
||||
);
|
||||
|
||||
private static long showTime = 0;
|
||||
|
||||
@@ -63,7 +66,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
isFirstLocation = false;
|
||||
|
||||
if (cloundWarningInfo.getDirection() == 1) { //前方
|
||||
MogoLatLng newLocation = LocationUtils.getNewLocation((MogoLatLng) fillPoints.get(0), 80, cloundWarningInfo.getAngle());
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation((MogoLatLng) fillPoints.get(0), 80, cloundWarningInfo.getAngle());
|
||||
//停止线前方画线
|
||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||
//二轮车和行人的渲染和移动
|
||||
@@ -126,7 +129,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
Log.d(V2XConst.LOG_NAME_WARN, " drawStopLine endLatlng lon =" + endLatlng.lon + "--lat =" + endLatlng.lat
|
||||
+ "--startLatlng lon = " + startLatlng.lon + "-lat = " + startLatlng.lat);
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
MogoLatLng addMiddleLoc = LocationUtils.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
if (polyLine != null) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawStopLine polyLine != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
@@ -158,7 +161,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
MogoLatLng startLatlng = new MogoLatLng(info.getLat(), info.getLon());
|
||||
MogoLatLng endLatlng = new MogoLatLng(info.getCollisionLat(), info.getCollisionLon());
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
MogoLatLng addMiddleLoc = LocationUtils.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
MogoLatLng addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
if (polyLine != null) {
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "polyLine != null");
|
||||
polyLine.setPoints(Arrays.asList(startLatlng, addMiddleLoc, endLatlng));
|
||||
@@ -225,7 +228,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
endLatlng = new MogoLatLng(mCloundWarningInfo.getDirection() == 1 ? carLocation.lat : mCloundWarningInfo.getCollisionLat(),
|
||||
mCloundWarningInfo.getDirection() == 1 ? carLocation.lon : mCloundWarningInfo.getCollisionLon());
|
||||
float distance = CoordinateUtils.calculateLineDistance(startLatlng.lon, startLatlng.lat, endLatlng.lon, endLatlng.lat);
|
||||
addMiddleLoc = LocationUtils.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
addMiddleLoc = Trigonometric.getNewLocation(startLatlng, distance / 2, mCloundWarningInfo.getAngle());
|
||||
Log.d(V2XConst.LOG_NAME_WARN, "drawSlefCarLine lon = " + carLocation.lon + "---lat = " + carLocation.lat);
|
||||
isFirstLocation = true;
|
||||
}
|
||||
@@ -265,11 +268,11 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
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);
|
||||
double angle = Trigonometric.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);
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(x, average * i, angle);
|
||||
fillPoints.add(newLocation);
|
||||
}
|
||||
fillPoints.add(y);
|
||||
@@ -280,7 +283,7 @@ public class MoGoV2XCloundDataManager implements IMoGoV2XCloundDataManager, IMog
|
||||
}
|
||||
|
||||
private MogoLatLng getMogoLat(MogoLatLng latlng) {
|
||||
MogoLatLng newLocation = LocationUtils.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getDirection());
|
||||
MogoLatLng newLocation = Trigonometric.getNewLocation(latlng, mCloundWarningInfo.getStopLineDistance(), mCloundWarningInfo.getDirection());
|
||||
return newLocation;
|
||||
}
|
||||
|
||||
|
||||
@@ -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.v2x.R;
|
||||
import com.mogo.module.v2x.V2XConst;
|
||||
import com.mogo.module.v2x.V2XServiceManager;
|
||||
@@ -99,7 +100,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
||||
carlo = new MogoLatLng(lat, lon);
|
||||
}
|
||||
//自车行驶方向的前方*米的经纬度,该经纬度在停止线上
|
||||
MogoLatLng drawStopLineLon = LocationUtils.getNewLocation(carlo, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
|
||||
MogoLatLng drawStopLineLon = Trigonometric.getNewLocation(carlo, mMarkerEntity.getStopLineDistance(), mMarkerEntity.getAngle());
|
||||
Log.d(TAG, "2D资源绘" + drawStopLineLon);
|
||||
MogoMarkerOptions optionsRipple = new MogoMarkerOptions()
|
||||
.latitude(drawStopLineLon.getLat())
|
||||
|
||||
@@ -27,12 +27,6 @@ import com.mogo.utils.network.utils.GsonUtil;
|
||||
*/
|
||||
public class LocationUtils {
|
||||
private static final String TAG = "LocationUtils";
|
||||
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 void geoCodeSearch(MogoLocation location, IMogoGeoSearchListener listener) {
|
||||
MogoRegeocodeQuery mogoRegeocodeQuery = new MogoRegeocodeQuery();
|
||||
@@ -93,42 +87,6 @@ public class LocationUtils {
|
||||
return latLon;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算两点间的角度
|
||||
*/
|
||||
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