opt road cache
This commit is contained in:
@@ -67,7 +67,7 @@ dependencies {
|
||||
implementation project(':foudations:mogo-commons')
|
||||
}
|
||||
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.2.6'
|
||||
implementation 'com.zhidaoauto.machine:map:1.0.0-vr-8.2.9'
|
||||
// implementation 'com.zhidaoauto.machine:map:1.0.0-vr-test-3.4'
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -61,13 +61,15 @@ public class PointInterpolatorUtil {
|
||||
getCloseTwoPoint( lon, lat, road );
|
||||
LonLatPoint start = road.get( closeStart );
|
||||
LonLatPoint end = road.get( closeEnd );
|
||||
Logger.d( TAG, "mergeToRoad start: " + closeStart + " end: " + closeEnd );
|
||||
// Logger.d( TAG, "mergeToRoad start: " + closeStart + " end: " + closeEnd );
|
||||
// return getMid(start, end);
|
||||
double[] foot = 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};
|
||||
// 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};
|
||||
|
||||
return getFootAndMinDistance(lon, lat, start.getLongitude(), start.getLatitude(), end.getLongitude(), end.getLatitude());
|
||||
}
|
||||
|
||||
private static int closeStart = 0;
|
||||
@@ -99,6 +101,57 @@ public class PointInterpolatorUtil {
|
||||
return new double[]{beginPt.getLongitude() + u * dy, beginPt.getLatitude() + u * dx};
|
||||
}
|
||||
|
||||
|
||||
// un minDistance(x: Double, y: Double, x1: Double, y1: Double, x2: Double, y2: Double): Double {
|
||||
// val cross = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1)
|
||||
// println("1.cross:$cross")
|
||||
// if (cross <= 0) {
|
||||
// return Math.sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1))
|
||||
// }
|
||||
// val d2 = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)
|
||||
// println("2.d2:$cross")
|
||||
// if (cross > d2) {
|
||||
// return Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2))
|
||||
// }
|
||||
// val r = cross / d2
|
||||
// val px = x1 + (x2 - x1) * r
|
||||
// val py = y1 + (y2 - y1) * r
|
||||
// println("3.r:$r,px:$px,py:$py")
|
||||
// return Math.sqrt((x - px) * (x - px) + (py - y) * (py - y))
|
||||
// }
|
||||
|
||||
/**
|
||||
* 计算垂足以及最短距离
|
||||
*
|
||||
* @param x target point lon
|
||||
* @param y target point lat
|
||||
* @param x1 start point lon
|
||||
* @param y1 start point lat
|
||||
* @param x2 end point lon
|
||||
* @param y2 end point lat
|
||||
* @return double[]{footLon,footLat,minDistance} if(footLon == -1) => no foot or foot not in line
|
||||
*/
|
||||
private static double[] getFootAndMinDistance(double x, double y, double x1, double y1, double x2, double y2) {
|
||||
double[] result = new double[]{-1, -1, -1};
|
||||
double cross = (x2 - x1) * (x - x1) + (y2 - y1) * (y - y1);
|
||||
if (cross < 0) {
|
||||
// 垂足没有在线段内,所以也无需计算最短距离
|
||||
// result[2] = Math.sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
|
||||
return result;
|
||||
}
|
||||
double d2 = (x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1);
|
||||
if (cross > d2) {
|
||||
// 垂足没有在线段内,所以也无需计算最短距离
|
||||
// result[2] = Math.sqrt((x - x2) * (x - x2) + (y - y2) * (y - y2));
|
||||
return result;
|
||||
}
|
||||
double r = cross / d2;
|
||||
result[0] = x1 + (x2 - x1) * r;
|
||||
result[1] = y1 + (y2 - y1) * r;
|
||||
result[2] = Math.sqrt((x - result[0]) * (x - result[0]) + (result[1] - y) * (result[1] - y));
|
||||
return result;
|
||||
}
|
||||
|
||||
private static double[] getMid( LonLatPoint start, LonLatPoint end ) {
|
||||
return new double[]{( start.getLongitude() + end.getLongitude() ) / 2, ( start.getLatitude() + end.getLatitude() ) / 2};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user