From 5dea7b6b13ec02f3ce57685d6548a04965d4889b Mon Sep 17 00:00:00 2001 From: tongchenfei Date: Tue, 9 Mar 2021 16:16:34 +0800 Subject: [PATCH] opt --- .../mogo/map/impl/custom/AMapViewWrapper.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java index 442391396f..0c85d32f38 100644 --- a/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java +++ b/libraries/map-custom/src/main/java/com/mogo/map/impl/custom/AMapViewWrapper.java @@ -1055,16 +1055,20 @@ public class AMapViewWrapper implements IMogoMapView, && !roadCache.getRoad().isEmpty() ) { start = System.currentTimeMillis(); double matchedPoint[] = PointInterpolatorUtil.mergeToRoad( wgs[0], wgs[1], roadCache.getRoad() ); - double diff = CoordinateUtils.calculateLineDistance(lon, lat, roadCache.getLastLon(), roadCache.getLastLon()); - if ( (roadCache.getLastDistanceDiff() == 0 || roadCache.getLastDistanceDiff() > diff)) { - roadCache.setLastDistanceDiff(diff); - roadCacheMap.put(id, roadCache); - Log.i("timer-matchRoad-3", "cost " + (System.currentTimeMillis() - start) + "ms"); + if(matchedPoint[2]<1) { + double diff = CoordinateUtils.calculateLineDistance(lon, lat, roadCache.getLastLon(), roadCache.getLastLon()); + if ((roadCache.getLastDistanceDiff() == 0 || roadCache.getLastDistanceDiff() > diff)) { + roadCache.setLastDistanceDiff(diff); + roadCacheMap.put(id, roadCache); + Log.i("timer-matchRoad-3", "cost " + (System.currentTimeMillis() - start) + "ms"); + return matchedPoint; + } + roadCacheMap.put(id, null); + Log.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms"); + return matchRoad(id, lon, lat, angle, isGpsLocation, isRTK); + }else{ return matchedPoint; } - roadCacheMap.put(id, null); - Log.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms"); - return matchRoad(id, lon, lat, angle, isGpsLocation, isRTK); } return null; }