[VisualAngle]实现地图sdk路口相关回调;处理十字路口视角切换逻辑
This commit is contained in:
@@ -21,10 +21,12 @@ import android.view.View;
|
||||
import com.mogo.commons.constants.SharedPrefsConstants;
|
||||
import com.mogo.commons.debug.DebugConfig;
|
||||
import com.mogo.eagle.core.data.config.HdMapBuildConfig;
|
||||
import com.mogo.eagle.core.data.map.MapRoadInfo;
|
||||
import com.mogo.eagle.core.data.map.MogoLatLng;
|
||||
import com.mogo.eagle.core.data.map.MogoLocation;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapDataCollectorManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapLocationListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapRoadListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapStyleListenerManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapUIServiceManager;
|
||||
import com.mogo.eagle.core.function.call.map.CallerVisualAngleManager;
|
||||
@@ -75,6 +77,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -173,18 +176,78 @@ public class AMapViewWrapper implements IMogoMapView,
|
||||
@Override
|
||||
public void onRoadIdInfo(@androidx.annotation.Nullable String s) {
|
||||
Log.d(TAG, "-- onRoadIdInfo --RoadId:" + s);
|
||||
mRoadId = s;
|
||||
if (s != null) {
|
||||
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnRoadIdGet(s);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStopLineInfo(@androidx.annotation.Nullable StopLine stopLine) {
|
||||
Log.d(TAG, "-- onStopLineInfo:" + (stopLine != null ? stopLine.toString() : null) + "-> road_id:" + mRoadId);
|
||||
if (stopLine != null && mRoadId != null && TextUtils.equals(mRoadId, stopLine.road_id)) {
|
||||
MogoLocation location = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
|
||||
//MapAutoApi.INSTANCE.
|
||||
Log.d(TAG, "-- onStopLineInfo -- 1 --:" + (stopLine != null ? stopLine.toString() : null) + "-> road_id:" + mRoadId);
|
||||
MogoLocation carLoc = CallerMapLocationListenerManager.INSTANCE.getCurrentLocation();
|
||||
if (stopLine != null) {
|
||||
ArrayList<LonLatPoint> points = stopLine.points;
|
||||
if (points != null && 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;
|
||||
if (Double.compare(ret, -1.0) != 0) {
|
||||
distanceOfCarToStopLine = MapTools.INSTANCE.distance(carLoc.getLatitude(), carLoc.getLongitude(), match.getLatitude(), match.getLongitude());
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
Log.d(TAG, "-- onStopLineInfo --- distance: "+ distanceOfCarToStopLine);
|
||||
stopInfo.setDistanceOfCarToStopLine(distanceOfCarToStopLine);
|
||||
Log.d(TAG, "-- :");
|
||||
CallerMapRoadListenerManager.INSTANCE.invokeListenersOnStopLineGet(stopInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private @NotNull LonLatPoint convert(MogoLocation location) {
|
||||
LonLatPoint point = new LonLatPoint();
|
||||
point.latitude = location.getLatitude();
|
||||
point.longitude = location.getLongitude();
|
||||
point.altitude = location.getAltitude();
|
||||
point.angle = location.getBearing();
|
||||
point.speed = location.getSpeed();
|
||||
point.angle = location.getBearing();
|
||||
point.provider = location.getProvider();
|
||||
return point;
|
||||
}
|
||||
|
||||
private MapRoadInfo.StopLine convert(StopLine line) {
|
||||
MapRoadInfo.StopLine ret = new MapRoadInfo.StopLine();
|
||||
ret.setDistance(line.distance);
|
||||
ret.setLaneId(line.lane_id);
|
||||
ret.setRoadId(line.road_id);
|
||||
ret.setTieId(line.tile_id);
|
||||
ArrayList<LonLatPoint> points = line.points;
|
||||
if (points != null && points.size() > 0) {
|
||||
List<MogoLatLng> newPoints = new ArrayList<>();
|
||||
for (int i = 0; i < points.size(); i++) {
|
||||
LonLatPoint lonLatPoint = points.get(i);
|
||||
MogoLatLng latLng = new MogoLatLng(lonLatPoint.latitude, lonLatPoint.longitude);
|
||||
latLng.duration = lonLatPoint.duration;
|
||||
latLng.angle = lonLatPoint.angle;
|
||||
latLng.speed = lonLatPoint.speed;
|
||||
latLng.altitude = lonLatPoint.altitude;
|
||||
latLng.provider = lonLatPoint.provider;
|
||||
newPoints.add(latLng);
|
||||
}
|
||||
ret.setPoints(newPoints);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
private Context getContext() {
|
||||
return mMapView.getContext();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user