优化他车道路吸附变道突兀问题

This commit is contained in:
tongchenfei
2021-03-04 19:45:32 +08:00
parent 6ba2e5eeea
commit 6d5e0d952b
4 changed files with 36 additions and 12 deletions

View File

@@ -1031,9 +1031,10 @@ public class AMapViewWrapper implements IMogoMapView,
&& !singlePointRoadInfo.getCoords().isEmpty() ) {
double matchedPoint[] = PointInterpolatorUtil.mergeToRoad( wgs[0], wgs[1], singlePointRoadInfo.getCoords() );
// return CoordinateUtils.transformWgsToGcj( matchedPoint[1], matchedPoint[0] );
double[] trans = CoordinateUtils.transformWgsToGcj(matchedPoint[1], matchedPoint[0]);
matchedPoint = CoordinateUtils.transformWgsToGcj( matchedPoint[1], matchedPoint[0] );
matchedPoint[0] = trans[0];
matchedPoint[1] = trans[1];
// MarkerOptions options
// = new MarkerOptions();
// options.markerIcon( R.drawable.red )

View File

@@ -24,11 +24,10 @@ public class PointInterpolatorUtil {
* n in 1 .. a-1
* n == 0 时xn = x1
* n == a 时xn = x2
*
* <p>
* 将xn依次插入x1到x2之间
*
* @param points 待插值点集
*
* @deprecated 这个方法有问题,并不能算出来想要的值
*/
@Deprecated
@@ -63,7 +62,11 @@ public class PointInterpolatorUtil {
LonLatPoint end = road.get(closeEnd);
Logger.d(TAG, "mergeToRoad start: " + closeStart + " end: " + closeEnd);
// return getMid(start, end);
return getFoot(lon, lat, start, end);
double[] foot = getFoot(lon, lat, start, end);
float d = CoordinateUtils.calculateLineDistance(foot[0], foot[1], lon, lat);
Logger.d(TAG, "distance to mid line==" + d);
return new double[]{foot[0], foot[1], d};
}
private static int closeStart = 0;

View File

@@ -31,6 +31,7 @@ public class SimpleHandlerThreadPool {
private static final String TAG = "SimpleHandlerThreadPool";
private HandlerThread renderThread = new HandlerThread("one-frame-render-thread");
private Handler renderHandler;
private SimpleHandlerThreadPool() {
renderThread.start();
renderHandler = new Handler(renderThread.getLooper());
@@ -108,6 +109,7 @@ public class SimpleHandlerThreadPool {
private final Map<String, IMogoMarker> markerCache = new ArrayMap<>();
private final Map<String, CloudRoadData> roadDataCache = new ArrayMap<>();
private final Map<String, Long> lastExecutionTimeCache = new ArrayMap<>();
private final Map<String, Boolean> isMatchStatusCache = new ArrayMap<>();
private void rendCarOneFrame(CloudRoadData cloudRoadData) {
if (cloudRoadData == null) {
@@ -127,6 +129,7 @@ public class SimpleHandlerThreadPool {
|| AdasRecognizedResultDrawer.getInstance().hasCached(uniqueKey)) {
return;
}
IMogoMarker marker = markerCache.get(uniqueKey);
CloudRoadData lastPosition = roadDataCache.put(uniqueKey, cloudRoadData);
if (marker == null || marker.isDestroyed()) {
@@ -140,22 +143,39 @@ public class SimpleHandlerThreadPool {
}
}
if(cloudRoadData.getFromType() == CloudRoadData.FROM_MY_LOCATION) {
if (cloudRoadData.getFromType() == CloudRoadData.FROM_MY_LOCATION) {
double[] matchedPoint = SnapshotSetDataDrawer.getInstance().matchRoad(cloudRoadData.getLon(),
cloudRoadData.getLat(),
cloudRoadData.getHeading(),
true
);
Boolean isMathch = isMatchStatusCache.get(uniqueKey);
if (matchedPoint != null) {
cloudRoadData.setLon(matchedPoint[0]);
cloudRoadData.setLat(matchedPoint[1]);
if ((isMathch == null || !isMathch)) {
if (matchedPoint[2] < 0.5) {
isMathch = true;
}
} else {
if (matchedPoint[2] > 1) {
isMathch = false;
}
}
if (isMathch == null) {
isMathch = false;
}
isMatchStatusCache.put(uniqueKey, isMathch);
if (isMathch) {
cloudRoadData.setLon(matchedPoint[0]);
cloudRoadData.setLat(matchedPoint[1]);
}
}
}
final IMogoMarker finalMarker = marker;
Logger.d(TAG, "work in " + Thread.currentThread().getName());
renderHandler.post(()->{
renderHandler.post(() -> {
// 由于地图现在不支持addDynamicAnchorPosition并发所以工作线程仅做相关计算真正绘制发送到另外一条绘制线程中做
if (lastPosition != null && !lastPosition.equals(cloudRoadData)) {
long interval = SnapshotSetDataDrawer.getInstance().computeAnimDuration(lastPosition.getSystemTime(), cloudRoadData.getSystemTime(), lastPosition.getSatelliteTime(), cloudRoadData.getSatelliteTime());
@@ -176,11 +196,11 @@ public class SimpleHandlerThreadPool {
public void removeDirtyMarker(Collection<String> keys) {
Map<String, IMogoMarker> result = new ArrayMap<>(keys.size());
for (String key : keys) {
if(markerCache.containsKey(key)) {
if (markerCache.containsKey(key)) {
result.put(key, markerCache.remove(key));
}
}
SnapshotSetDataDrawer.getInstance().sendMessage( MSG_REMOVE_DIRTY_MARKERS, result );
SnapshotSetDataDrawer.getInstance().sendMessage(MSG_REMOVE_DIRTY_MARKERS, result);
}
}
}

View File

@@ -557,7 +557,7 @@ public class MockIntentHandler implements IntentHandler {
break;
case 47:
mLocationMockHandler.sendEmptyMessageDelayed( 1, 200L );
// mLocationMockHandler.sendEmptyMessageDelayed( 2, 0 );
mLocationMockHandler.sendEmptyMessageDelayed( 2, 0 );
// mLocationMockHandler.sendEmptyMessageDelayed( 21, 200 );
// mLocationMockHandler.sendEmptyMessageDelayed( 3, 300L );
break;