[VisualAngle]优化自车到终止线距离算法;道路事件场景切换逻辑

This commit is contained in:
renwj
2022-03-22 10:45:05 +08:00
parent f2307e6683
commit 8822d0865c
4 changed files with 45 additions and 35 deletions

View File

@@ -174,10 +174,10 @@ public class AMapViewWrapper implements IMogoMapView,
}
@Override
public void onRoadIdInfo(@androidx.annotation.Nullable String s) {
Log.d(TAG, "-- onRoadIdInfo --RoadId:" + s);
if (s != null) {
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnRoadIdGet(s);
public void onRoadIdInfo(@androidx.annotation.Nullable String roadId) {
if (!TextUtils.isEmpty(roadId)) {
Log.d(TAG, "-- onRoadIdInfo --RoadId:" + roadId);
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnRoadIdGet(roadId);
}
}
@@ -185,27 +185,24 @@ public class AMapViewWrapper implements IMogoMapView,
public void onStopLineInfo(@androidx.annotation.Nullable StopLine stopLine) {
Log.d(TAG, "-- onStopLineInfo -- 1 --:" + (stopLine != null ? stopLine.toString() : null) + "-> road_id:" + mRoadId);
MogoLocation carLoc = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
if (stopLine != null) {
if (stopLine != null && !TextUtils.isEmpty(stopLine.road_id) && stopLine.points != null && stopLine.points.size() > 0) {
ArrayList<LonLatPoint> points = stopLine.points;
if (points != null && carLoc != null) {
if (carLoc != null) {
MapRoadInfo.StopLine stopInfo = convert(stopLine);
LonLatPoint match = new LonLatPoint();
double ret = MapDataApi.INSTANCE.GetDisFromPointToLine(convert(carLoc), points, match, 1);
Log.d(TAG, "-- onStopLineInfo --- ret: "+ ret);
double distanceOfCarToStopLine = 0.0;
double distanceOfCarToStopLine = -1.0;
if (Double.compare(ret, -1.0) != 0) {
distanceOfCarToStopLine = MapTools.INSTANCE.distance(carLoc.getLatitude(), carLoc.getLongitude(), match.getLatitude(), match.getLongitude());
stopInfo.setDistanceOfCarToStopLine(distanceOfCarToStopLine);
} else {
LonLatPoint p1 = points.isEmpty() ? null : points.get(0);
LonLatPoint p2 = points.isEmpty() ? null : points.get(points.size() - 1);
LonLatPoint aim = p1 != null && p2 != null ? new LonLatPoint((p1.longitude + p2.longitude) / 2, (p1.altitude + p2.altitude) / 2, (p1.angle + p2.angle) / 2) : (p1 != null ? p1 : p2);
if (aim != null) {
distanceOfCarToStopLine = MapTools.INSTANCE.distance(carLoc.getAltitude(), carLoc.getLongitude(), aim.getLatitude(), aim.getLongitude());
}
LonLatPoint p1 = points.get(0);
LonLatPoint p2 = points.get(points.size() - 1);
distanceOfCarToStopLine = MapDataApi.INSTANCE.getNearstFromPointToSegment(carLoc.getLongitude(), carLoc.getLatitude(), p1.longitude, p1.latitude, p2.longitude, p2.latitude);
stopInfo.setDistanceOfCarToStopLine(distanceOfCarToStopLine);
}
Log.d(TAG, "-- onStopLineInfo --- distance: "+ distanceOfCarToStopLine);
stopInfo.setDistanceOfCarToStopLine(distanceOfCarToStopLine);
Log.d(TAG, "-- :");
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnStopLineGet(stopInfo);
}
}