两点之间补点
This commit is contained in:
@@ -163,6 +163,10 @@ public class V2XWarningEntity implements Serializable {
|
|||||||
this.warningContent = warningContent;
|
this.warningContent = warningContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setStopLines(List<MogoLatLng> stopLines) {
|
||||||
|
this.stopLines = stopLines;
|
||||||
|
}
|
||||||
|
|
||||||
public int getType() {
|
public int getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -199,18 +203,6 @@ public class V2XWarningEntity implements Serializable {
|
|||||||
return speed;
|
return speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTargetColor() {
|
|
||||||
return targetColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRoadId() {
|
|
||||||
return roadId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getLaneId() {
|
|
||||||
return laneId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
@@ -219,10 +211,6 @@ public class V2XWarningEntity implements Serializable {
|
|||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCarId() {
|
|
||||||
return carId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWarningContent() {
|
public String getWarningContent() {
|
||||||
if (this.warningContent == null) {
|
if (this.warningContent == null) {
|
||||||
setTipContent(type);
|
setTipContent(type);
|
||||||
@@ -254,6 +242,10 @@ public class V2XWarningEntity implements Serializable {
|
|||||||
return stopLineDistance;
|
return stopLineDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<MogoLatLng> getStopLines() {
|
||||||
|
return stopLines;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "V2XWarningEntity{" +
|
return "V2XWarningEntity{" +
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.mogo.module.v2x.scenario.scene.warning;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.mogo.cloud.commons.utils.CoordinateUtils;
|
||||||
import com.mogo.map.MogoLatLng;
|
import com.mogo.map.MogoLatLng;
|
||||||
import com.mogo.map.marker.IMogoMarker;
|
import com.mogo.map.marker.IMogoMarker;
|
||||||
import com.mogo.map.marker.MogoMarkerOptions;
|
import com.mogo.map.marker.MogoMarkerOptions;
|
||||||
@@ -15,11 +16,11 @@ import com.mogo.module.v2x.V2XConst;
|
|||||||
import com.mogo.module.v2x.V2XServiceManager;
|
import com.mogo.module.v2x.V2XServiceManager;
|
||||||
import com.mogo.module.v2x.entity.model.DrawLineInfo;
|
import com.mogo.module.v2x.entity.model.DrawLineInfo;
|
||||||
import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
import com.mogo.module.v2x.scenario.view.IV2XMarker;
|
||||||
|
import com.mogo.module.v2x.utils.LocationUtils;
|
||||||
import com.mogo.utils.WorkThreadHandler;
|
import com.mogo.utils.WorkThreadHandler;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Handler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author liujing
|
* @author liujing
|
||||||
@@ -45,7 +46,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
|||||||
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
if (MogoApisHandler.getInstance().getApis().getStatusManagerApi().isVrMode()) {
|
||||||
clearPOI();
|
clearPOI();
|
||||||
WorkThreadHandler.getInstance().postDelayed(() -> {
|
WorkThreadHandler.getInstance().postDelayed(() -> {
|
||||||
IMogoMarker marker = drawMarker(markerShowEntity);
|
IMogoMarker marker = drawMarkerAndReturn(markerShowEntity);
|
||||||
//如果有预警碰撞点,识别物与预警碰撞点之间连线,并执行平移动画
|
//如果有预警碰撞点,识别物与预警碰撞点之间连线,并执行平移动画
|
||||||
if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() != 0) {
|
if (mMarkerEntity.getCollisionLat() > 0 && mMarkerEntity.getCollisionLon() != 0) {
|
||||||
drawLine();
|
drawLine();
|
||||||
@@ -62,7 +63,32 @@ public class V2XWarningMarker implements IV2XMarker {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMogoMarker drawMarker(MarkerShowEntity markerShowEntity) {
|
public void pointsBetween() {
|
||||||
|
try {
|
||||||
|
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);
|
||||||
|
//根据距离和角度获取下个点的经纬度
|
||||||
|
List replenish = new ArrayList();
|
||||||
|
for (int i = 1; i < 3; i++) {
|
||||||
|
MogoLatLng newLocation = LocationUtils.getNewLocation(x, average * i, angle);
|
||||||
|
replenish.add(newLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//绘制marker
|
||||||
|
public IMogoMarker drawMarkerAndReturn(MarkerShowEntity markerShowEntity) {
|
||||||
MogoMarkerOptions options = new MogoMarkerOptions()
|
MogoMarkerOptions options = new MogoMarkerOptions()
|
||||||
.object(markerShowEntity)
|
.object(markerShowEntity)
|
||||||
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
.latitude(markerShowEntity.getMarkerLocation().getLat())
|
||||||
@@ -76,6 +102,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
|||||||
return marker;
|
return marker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//绘制线
|
||||||
public void drawLine() {
|
public void drawLine() {
|
||||||
DrawLineInfo drawLineInfo = new DrawLineInfo();
|
DrawLineInfo drawLineInfo = new DrawLineInfo();
|
||||||
MogoLatLng slatLng = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon());
|
MogoLatLng slatLng = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon());
|
||||||
@@ -85,6 +112,7 @@ public class V2XWarningMarker implements IV2XMarker {
|
|||||||
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, drawLineInfo);
|
V2XServiceManager.getMoGoWarnPolylineManager().drawWarnPolyline(mContext, drawLineInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//平移
|
||||||
public void smooth(IMogoMarker marker) {
|
public void smooth(IMogoMarker marker) {
|
||||||
List<MogoLatLng> latLngs = new ArrayList<>();
|
List<MogoLatLng> latLngs = new ArrayList<>();
|
||||||
MogoLatLng sLocation = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon());
|
MogoLatLng sLocation = new MogoLatLng(mMarkerEntity.getLat(), mMarkerEntity.getLon());
|
||||||
|
|||||||
@@ -28,8 +28,14 @@ import com.mogo.utils.network.utils.GsonUtil;
|
|||||||
*/
|
*/
|
||||||
public class LocationUtils {
|
public class LocationUtils {
|
||||||
private static final String TAG = "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) {
|
public static void geoCodeSearch(MogoLocation location, IMogoGeoSearchListener listener) {
|
||||||
MogoRegeocodeQuery mogoRegeocodeQuery = new MogoRegeocodeQuery();
|
MogoRegeocodeQuery mogoRegeocodeQuery = new MogoRegeocodeQuery();
|
||||||
mogoRegeocodeQuery.setPoint(new MogoLatLng(location.getLatitude(), location.getLongitude()));
|
mogoRegeocodeQuery.setPoint(new MogoLatLng(location.getLatitude(), location.getLongitude()));
|
||||||
|
|
||||||
@@ -83,6 +89,39 @@ public class LocationUtils {
|
|||||||
return latLon;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,12 @@
|
|||||||
"collisionLon": 116.417634,
|
"collisionLon": 116.417634,
|
||||||
"stopLines":[
|
"stopLines":[
|
||||||
{
|
{
|
||||||
"stopLineLat": 39.977082,
|
"lat": 39.977082,
|
||||||
"stopLineLon": 116.417553
|
"lon": 116.417553
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"stopLineLat": 39.977078,
|
"lat": 39.977078,
|
||||||
"stopLineLon": 116.417666
|
"lon": 116.417666
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"from": 1,
|
"from": 1,
|
||||||
|
|||||||
Reference in New Issue
Block a user