Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit69ccaf6

Browse files
committed
misc - fixed
1 parent95ab0bb commit69ccaf6

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

‎core/src/main/java/com/graphhopper/util/GHUtility.java‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ public static JsonFeature createRectangle(String id, double minLat, double minLo
573573
returnresult;
574574
}
575575

576-
publicstaticList<String>comparePaths(PathrefPath,Pathpath,intsource,inttarget,longseed) {
576+
publicstaticList<String>comparePaths(PathrefPath,Pathpath,intsource,inttarget,booleancheckNodes,longseed) {
577577
if (path.getGraph() !=refPath.getGraph())
578578
fail("path and refPath graphs are different");
579579
List<String>strictViolations =newArrayList<>();
@@ -591,15 +591,15 @@ public static List<String> comparePaths(Path refPath, Path path, int source, int
591591
if (Math.abs(path.getTime() -refPath.getTime()) >50) {
592592
strictViolations.add("wrong time " +source +"->" +target +", expected: " +refPath.getTime() +", given: " +path.getTime());
593593
}
594-
IntIndexedContainerrefNodes =refPath.calcNodes();
595-
IntIndexedContainerpathNodes =path.calcNodes();
596-
if (!refNodes.equals(pathNodes)) {
597-
// sometimes there are paths including an edge a-c that has the same distance as the two edges a-b-c. in this
598-
//case both optionsarevalid best paths. we only check for this most simple and frequent case here...
599-
if (path.getGraph() !=refPath.getGraph())
600-
fail("path and refPath graphs are different");
601-
if (!pathsEqualExceptOneEdge(path.getGraph(),refNodes,pathNodes))
602-
strictViolations.add("wrong nodes " +source +"->" +target +"\nexpected: " +refNodes +"\ngiven: " +pathNodes);
594+
if (checkNodes) {
595+
IntIndexedContainerrefNodes =refPath.calcNodes();
596+
IntIndexedContainerpathNodes =path.calcNodes();
597+
if (!refNodes.equals(pathNodes)) {
598+
//sometimes therearepaths including an edge a-c that has the same distance as the two edges a-b-c. in this
599+
// case both options are valid best paths. we only check for this most simple and frequent case here...
600+
if (!pathsEqualExceptOneEdge(path.getGraph(),refNodes,pathNodes))
601+
strictViolations.add("wrong nodes " +source +"->" +target +"\nexpected: " +refNodes +"\ngiven: " +pathNodes);
602+
}
603603
}
604604
returnstrictViolations;
605605
}

‎core/src/test/java/com/graphhopper/GraphHopperTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,8 +1828,8 @@ public void testCompareAlgos(boolean turnCosts) {
18281828
assertEquals(path.hasErrors(),pathLM.hasErrors(),failMessage);
18291829

18301830
if (!path.hasErrors()) {
1831-
assertEquals(path.getRouteWeight(),pathCH.getRouteWeight(),failMessage);
1832-
assertEquals(path.getRouteWeight(),pathLM.getRouteWeight(),failMessage);
1831+
assertEquals(path.getRouteWeight(),pathCH.getRouteWeight(),1.e-1,failMessage);
1832+
assertEquals(path.getRouteWeight(),pathLM.getRouteWeight(),1.e-1,failMessage);
18331833

18341834
assertEquals(path.getDistance(),pathCH.getDistance(),0.1,failMessage);
18351835
assertEquals(path.getDistance(),pathLM.getDistance(),0.1,failMessage);

‎core/src/test/java/com/graphhopper/routing/RandomCHRoutingTest.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ private void runRandomTest(Fixture f, Random rnd, long seed) {
151151
continue;
152152
}
153153

154-
strictViolations.addAll(comparePaths(refPath,path,from,to,seed));
154+
// todo: to check nodes as well we would have to ignore intermediate virtual nodes
155+
strictViolations.addAll(comparePaths(refPath,path,from,to,false,seed));
155156
}
156157
if (numPathsNotFound >0.9 *numQueries) {
157158
fail("Too many paths not found: " +numPathsNotFound +"/" +numQueries);

‎core/src/test/java/com/graphhopper/routing/RandomizedRoutingTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public void randomGraph(FixtureSupplier fixtureSupplier) {
243243
.calcPath(source,target);
244244
Pathpath =f.createAlgo()
245245
.calcPath(source,target);
246-
strictViolations.addAll(GHUtility.comparePaths(refPath,path,source,target,seed));
246+
strictViolations.addAll(GHUtility.comparePaths(refPath,path,source,target,true,seed));
247247
}
248248
if (strictViolations.size() >3) {
249249
for (StringstrictViolation :strictViolations) {
@@ -283,7 +283,7 @@ public void randomGraph_withQueryGraph(FixtureSupplier fixtureSupplier) {
283283

284284
PathrefPath =newDijkstraBidirectionRef(queryGraph,queryGraph.wrapWeighting(f.weighting),f.traversalMode).calcPath(source,target);
285285
Pathpath =f.createAlgo(queryGraph).calcPath(source,target);
286-
strictViolations.addAll(GHUtility.comparePaths(refPath,path,source,target,seed));
286+
strictViolations.addAll(GHUtility.comparePaths(refPath,path,source,target,true,seed));
287287
}
288288
// we do not do a strict check because there can be ambiguity, for example when there are zero weight loops.
289289
// however, when there are too many deviations we fail

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp