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

Commit95ab0bb

Browse files
committed
misc
1 parente9feea1 commit95ab0bb

File tree

6 files changed

+14
-18
lines changed

6 files changed

+14
-18
lines changed

‎core/src/main/java/com/graphhopper/routing/querygraph/QueryRoutingCHGraph.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ public double getWeight(boolean reverse) {
329329

330330
@Override
331331
publicStringtoString() {
332-
return"virtual: " +edge +": " +baseNode +"->" +adjNode +", orig: " +origEdge +", weightFwd: " +Helper.round2(weightFwd) +", weightBwd: " +Helper.round2(weightBwd);
332+
return"virtual: " +edge +": " +baseNode +"->" +adjNode +", orig: " +origEdge +", weightFwd: " +weightFwd +", weightBwd: " +weightBwd;
333333
}
334334

335335
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,6 +574,8 @@ public static JsonFeature createRectangle(String id, double minLat, double minLo
574574
}
575575

576576
publicstaticList<String>comparePaths(PathrefPath,Pathpath,intsource,inttarget,longseed) {
577+
if (path.getGraph() !=refPath.getGraph())
578+
fail("path and refPath graphs are different");
577579
List<String>strictViolations =newArrayList<>();
578580
doublerefWeight =refPath.getWeight();
579581
doubleweight =path.getWeight();

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,6 +1828,9 @@ 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);
1833+
18311834
assertEquals(path.getDistance(),pathCH.getDistance(),0.1,failMessage);
18321835
assertEquals(path.getDistance(),pathLM.getDistance(),0.1,failMessage);
18331836

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ public void randomGraph(Fixture f) {
228228
intsourceOutEdge =getSourceOutEdge(rnd,source,f.graph);
229229
inttargetInEdge =getTargetInEdge(rnd,target,f.graph);
230230
// LOGGER.info("source: " + source + ", target: " + target + ", sourceOutEdge: " + sourceOutEdge + ", targetInEdge: " + targetInEdge);
231-
PathrefPath =newDijkstraBidirectionRef(f.graph,((Graph)f.graph).wrapWeighting(f.weighting),TraversalMode.EDGE_BASED)
231+
PathrefPath =newDijkstraBidirectionRef(f.graph,f.graph.wrapWeighting(f.weighting),TraversalMode.EDGE_BASED)
232232
.calcPath(source,target,sourceOutEdge,targetInEdge);
233233
Pathpath =f.createAlgo()
234234
.calcPath(source,target,sourceOutEdge,targetInEdge);

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

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
importjava.util.Random;
3434
importjava.util.stream.Stream;
3535

36+
importstaticcom.graphhopper.util.GHUtility.comparePaths;
3637
importstaticcom.graphhopper.util.GHUtility.createRandomSnaps;
3738
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
3839
importstaticorg.junit.jupiter.api.Assertions.fail;
@@ -106,10 +107,10 @@ public void random(Fixture f) {
106107
if (f.traversalMode.isEdgeBased()) {
107108
GHUtility.addRandomTurnCosts(f.graph,seed,null,f.turnCostEnc,f.maxTurnCosts,f.graph.getTurnCostStorage());
108109
}
109-
runRandomTest(f,rnd);
110+
runRandomTest(f,rnd,seed);
110111
}
111112

112-
privatevoidrunRandomTest(Fixturef,Randomrnd) {
113+
privatevoidrunRandomTest(Fixturef,Randomrnd,longseed) {
113114
LocationIndexTreelocationIndex =newLocationIndexTree(f.graph,f.graph.getDirectory());
114115
locationIndex.prepareIndex();
115116

@@ -150,18 +151,7 @@ private void runRandomTest(Fixture f, Random rnd) {
150151
continue;
151152
}
152153

153-
doubleweight =path.getWeight();
154-
if (Math.abs(refWeight -weight) >1.e-2) {
155-
LOGGER.warn("expected: " +refPath.calcNodes());
156-
LOGGER.warn("given: " +path.calcNodes());
157-
fail("wrong weight: " +from +"->" +to +", dijkstra: " +refWeight +" vs. ch: " +path.getWeight());
158-
}
159-
if (Math.abs(path.getDistance() -refPath.getDistance()) >1.e-1) {
160-
strictViolations.add("wrong distance " +from +"->" +to +", expected: " +refPath.getDistance() +", given: " +path.getDistance());
161-
}
162-
if (Math.abs(path.getTime() -refPath.getTime()) >50) {
163-
strictViolations.add("wrong time " +from +"->" +to +", expected: " +refPath.getTime() +", given: " +path.getTime());
164-
}
154+
strictViolations.addAll(comparePaths(refPath,path,from,to,seed));
165155
}
166156
if (numPathsNotFound >0.9 *numQueries) {
167157
fail("Too many paths not found: " +numPathsNotFound +"/" +numQueries);

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
/**
5959
* This test compares different routing algorithms with {@link DijkstraBidirectionRef}. Most prominently it uses
60-
* randomlycreate graphs to create all sorts of different situations.
60+
* randomlycreated graphs to create all sorts of different situations.
6161
*
6262
* @author easbar
6363
* @see RandomCHRoutingTest - similar but only tests CH algorithms
@@ -288,7 +288,8 @@ public void randomGraph_withQueryGraph(FixtureSupplier fixtureSupplier) {
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
290290
if (strictViolations.size() >3) {
291-
LOGGER.warn(strictViolations.toString());
291+
for (StringstrictViolation :strictViolations)
292+
LOGGER.warn("strict violation: " +strictViolation);
292293
fail("Too many strict violations: " +strictViolations.size() +" / " +numQueries +", seed: " +seed);
293294
}
294295
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp