Fix tests

This commit is contained in:
Victor Shcherb 2016-08-14 00:50:07 +02:00
parent 5103a5a4c1
commit 325b024763
5 changed files with 42 additions and 55 deletions

View file

@ -32,12 +32,11 @@ public class BinaryRoutePlanner {
public static double squareRootDist(int x1, int y1, int x2, int y2) {
// translate into meters
double dy = MapUtils.convert31YToMeters(y1, y2);
double dx = MapUtils.convert31XToMeters(x1, x2);
return Math.sqrt(dx * dx + dy * dy);
// return measuredDist(x1, y1, x2, y2);
if(MapUtils.squareRootDist31(x1, y1, x2, y2) - MapUtils.measuredDist31(x1, y1, x2, y2) > 5) {
System.out.println("x1 = " + x1 + " x2" + x2 + " y1 " + y1 + " y2 " + y2);
}
return MapUtils.squareRootDist31(x1, y1, x2, y2);
// return MapUtils.measuredDist31(x1, y1, x2, y2);
}

View file

@ -30,10 +30,7 @@ public class BinaryRoutePlannerOld {
private static double squareRootDist(int x1, int y1, int x2, int y2) {
// translate into meters
double dy = MapUtils.convert31YToMeters(y1, y2);
double dx = MapUtils.convert31XToMeters(x1, x2);
return Math.sqrt(dx * dx + dy * dy);
return MapUtils.squareRootDist31(x1, y1, x2, y2);
// return measuredDist(x1, y1, x2, y2);
}

View file

@ -50,8 +50,8 @@ public class RoutePlannerFrontEnd {
private static double squareDist(int x1, int y1, int x2, int y2) {
// translate into meters
double dy = MapUtils.convert31YToMeters(y1, y2);
double dx = MapUtils.convert31XToMeters(x1, x2);
double dy = MapUtils.convert31YToMeters(y1, y2, x1);
double dx = MapUtils.convert31XToMeters(x1, x2, y1);
return dx * dx + dy * dy;
}

View file

@ -446,21 +446,39 @@ public class MapUtils {
}
public static double convert31YToMeters(double y1, double y2) {
private static double[] coefficientsY = new double[1024];
public static double convert31YToMeters(int y1, int y2, int x) {
int ind = x >> (31 - 10);
if(coefficientsY[ind] == 0) {
double md = MapUtils.measuredDist31(x, y1, x, y2);
if(md < 10) {
return md;
}
coefficientsY[ind] = md / Math.abs(y1 - y2);
}
// translate into meters
return (y1 - y2) * 0.01863d;
return (y1 - y2) * coefficientsY[ind];
}
public static double convert31XToMeters(double x1, double x2) {
private static double[] coefficientsX = new double[1024];
public static double convert31XToMeters(int x1, int x2, int y) {
int ind = y >> (31 - 10);
if(coefficientsX[ind] == 0) {
double md = MapUtils.measuredDist31(x1, y, x2, y);
if(md < 10) {
return md;
}
coefficientsX[ind] = md / Math.abs(x1 - x2);
}
// translate into meters
return (x1 - x2) * 0.011d;
return (x1 - x2) * coefficientsX[ind];
}
public static QuadPoint getProjectionPoint31(int px, int py, int st31x, int st31y, int end31x, int end31y) {
double projection = calculateProjection31TileMetric(st31x, st31y, end31x,
end31y, px, py);
double mDist = squareRootDist31(end31x, end31y, st31x,
double mDist = measuredDist31(end31x, end31y, st31x,
st31y);
int pry = end31y;
int prx = end31x;
@ -482,10 +500,9 @@ public class MapUtils {
public static double squareRootDist31(int x1, int y1, int x2, int y2) {
// translate into meters
double dy = MapUtils.convert31YToMeters(y1, y2);
double dx = MapUtils.convert31XToMeters(x1, x2);
double dy = MapUtils.convert31YToMeters(y1, y2, x1);
double dx = MapUtils.convert31XToMeters(x1, x2, y1);
return Math.sqrt(dx * dx + dy * dy);
// return measuredDist(x1, y1, x2, y2);
}
public static double measuredDist31(int x1, int y1, int x2, int y2) {
@ -494,15 +511,15 @@ public class MapUtils {
public static double squareDist31TileMetric(int x1, int y1, int x2, int y2) {
// translate into meters
double dy = convert31YToMeters(y1, y2);
double dx = convert31XToMeters(x1, x2);
double dy = convert31YToMeters(y1, y2, x1);
double dx = convert31XToMeters(x1, x2, y1);
return dx * dx + dy * dy;
}
public static double calculateProjection31TileMetric(int xA, int yA, int xB, int yB, int xC, int yC) {
// Scalar multiplication between (AB, AC)
double multiple = MapUtils.convert31XToMeters(xB, xA) * MapUtils.convert31XToMeters(xC, xA) +
MapUtils.convert31YToMeters(yB, yA) * MapUtils.convert31YToMeters(yC, yA);
double multiple = MapUtils.convert31XToMeters(xB, xA, yA) * MapUtils.convert31XToMeters(xC, xA, yA) +
MapUtils.convert31YToMeters(yB, yA, xA) * MapUtils.convert31YToMeters(yC, yA, xA);
return multiple;
}
@ -557,8 +574,6 @@ public class MapUtils {
}
}

View file

@ -90,11 +90,11 @@
{
"testName": "10.Longer route preferred? https://github.com/osmandapp/Osmand/issues/1941",
"description": "short_way строит не самый короткий путь. Транзит через MEX 261 короче.",
"ignore" : "true",
"ignore" : "false",
"params": {
"vehicle": "car",
"short_way": "true",
"planRoadDirection": "-1"
"planRoadDirection": "0"
},
"startPoint": {
"latitude": 45.9011493841283,
@ -110,7 +110,7 @@
},
{
"testName": "12.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA https://github.com/osmandapp/Osmand/issues/1743",
"ignore" : "true",
"ignore" : "false",
"params": {
"vehicle": "car",
"short_way": "true",
@ -130,32 +130,8 @@
}
},
{
"testName": "12.1.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA (transit2 point) https://github.com/osmandapp/Osmand/issues/1743",
"ignore" : "true",
"params": {
"vehicle": "car",
"short_way": "true",
"planRoadDirection": "-1"
},
"startPoint": {
"latitude": 45.84882743070033,
"longitude": 35.2621882259846
},
"transitPoint1": {
"latitude": 45.84813,
"longitude": 35.275932
},
"endPoint": {
"latitude": 45.847528944857174,
"longitude": 35.27665740251544
},
"expectedResults": {
"6335573": "false"
}
},
{
"testName": "12.2.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA (reverse) https://github.com/osmandapp/Osmand/issues/1743",
"ignore" : "true",
"testName": "12.1.Bizarre navigation at Sundance dr & Sentinel dr in Fremont, CA, USA (reverse) https://github.com/osmandapp/Osmand/issues/1743",
"ignore" : "false",
"params": {
"vehicle": "car",
"short_way": "true",