This commit is contained in:
tongchenfei
2021-03-10 17:06:23 +08:00
parent f85a5b9e6a
commit 394ee6eb33
3 changed files with 34 additions and 10 deletions

View File

@@ -1045,6 +1045,7 @@ public class AMapViewWrapper implements IMogoMapView,
if(roadCache == null){
SinglePointRoadInfo singlePointRoadInfo = MapDataApi.INSTANCE.getSinglePointMatchRoad( ( ( float ) wgs[0] ), ( ( float ) wgs[1] ), ( ( float ) angle ), isGpsLocation, isRTK );
if (singlePointRoadInfo != null && singlePointRoadInfo.getCoords() != null && !singlePointRoadInfo.getCoords().isEmpty()) {
Log.i("timer-matchRoad-4", "cost " + (System.currentTimeMillis() - start) + "ms roadId: " + singlePointRoadInfo.getRoadId());
roadCache = new RoadCacheWrapper(singlePointRoadInfo.getCoords());
}
}
@@ -1055,21 +1056,21 @@ public class AMapViewWrapper implements IMogoMapView,
&& !roadCache.getRoad().isEmpty() ) {
start = System.currentTimeMillis();
double matchedPoint[] = PointInterpolatorUtil.mergeToRoad( wgs[0], wgs[1], roadCache.getRoad() );
if(matchedPoint[2]<1) {
double diff = CoordinateUtils.calculateLineDistance(lon, lat, roadCache.getLastLon(), roadCache.getLastLon());
if ((roadCache.getLastDistanceDiff() == 0 || roadCache.getLastDistanceDiff() > diff)) {
roadCache.setLastDistanceDiff(diff);
if(matchedPoint[2]<1.5) {
if (roadCache.inCache(matchedPoint[0], matchedPoint[1])) {
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");
Log.i("timer-matchRoad-2", "cost " + (System.currentTimeMillis() - start) + "ms roadId: "+roadCache.getLastLat());
return matchRoad(id, lon, lat, angle, isGpsLocation, isRTK);
}else{
roadCacheMap.put(id, null);
return matchedPoint;
}
}
roadCacheMap.put(id, null);
return null;
}

View File

@@ -15,7 +15,7 @@ public class RoadCacheWrapper {
private int roadLength = -1;
public RoadCacheWrapper(List<LonLatPoint> road) {
this.road = road;
setRoad(road);
}
public List<LonLatPoint> getRoad() {
@@ -51,4 +51,27 @@ public class RoadCacheWrapper {
return 0;
}
public boolean inCache(double lon, double lat) {
if (roadLength > 0) {
LonLatPoint start = road.get(0);
LonLatPoint end = road.get(roadLength - 1);
boolean latInRoad = false;
boolean lonInRoad = false;
if (start.getLatitude() > end.getLatitude()) {
latInRoad = lat <= start.getLatitude() && lat >= end.getLatitude();
}else{
latInRoad = lat >= start.getLatitude() && lat <= end.getLatitude();
}
if (start.getLongitude() > end.getLongitude()) {
lonInRoad = lon <= start.getLongitude() && lon >= end.getLongitude();
}else{
lonInRoad = lon >= start.getLongitude() && lon <= end.getLongitude();
}
return latInRoad && lonInRoad;
}
return false;
}
}

View File

@@ -560,9 +560,9 @@ 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, 0L );
// mLocationMockHandler.sendEmptyMessageDelayed( 3, 0L );
// mLocationMockHandler.sendEmptyMessageDelayed( 5, 0L );
break;
case 48:
@@ -728,7 +728,7 @@ public class MockIntentHandler implements IntentHandler {
private boolean handleMockSnapshotIntent() throws Exception {
if ( br2 == null ) {
br2 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "snapshot2.txt" ) ) );
br2 = new BufferedReader( new InputStreamReader( AbsMogoApplication.getApp().getAssets().open( "snapshot.txt" ) ) );
}
String line = br2.readLine();
if ( line == null ) {
@@ -756,7 +756,7 @@ public class MockIntentHandler implements IntentHandler {
delay = cloudRoadData.getSystemTime() - last;
}
last = cloudRoadData.getSystemTime();
mLocationMockHandler.sendEmptyMessageDelayed( 2, delay );
mLocationMockHandler.sendEmptyMessageDelayed( 2, 100L );
return true;
}