opt
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user