|
29 | 29 | import com.graphhopper.storage.GraphBuilder;
|
30 | 30 | import com.graphhopper.storage.index.LocationIndex;
|
31 | 31 | import com.graphhopper.storage.index.QueryResult;
|
| 32 | +import com.graphhopper.util.GHUtility; |
32 | 33 | import com.graphhopper.util.Helper;
|
33 | 34 | import com.graphhopper.util.StopWatch;
|
34 | 35 | import java.io.File;
|
@@ -78,9 +79,18 @@ List<OneRun> createMonacoCar()
|
78 | 79 | @Test
|
79 | 80 | public void testMonaco()
|
80 | 81 | {
|
81 |
| - runAlgo(testCollector, "files/monaco.osm.gz", "target/monaco-gh", |
| 82 | + Graph g = runAlgo(testCollector, "files/monaco.osm.gz", "target/monaco-gh", |
82 | 83 | createMonacoCar(), "CAR", true, "CAR", "shortest", false);
|
| 84 | + |
83 | 85 | assertEquals(testCollector.toString(), 0, testCollector.errors.size());
|
| 86 | + |
| 87 | + // When OSM file stays unchanged make static edge and node IDs a requirement |
| 88 | + assertEquals(GHUtility.asSet(9, 111, 182), GHUtility.getNeighbors(g.createEdgeExplorer().setBaseNode(10))); |
| 89 | + assertEquals(GHUtility.asSet(19, 21), GHUtility.getNeighbors(g.createEdgeExplorer().setBaseNode(20))); |
| 90 | + assertEquals(GHUtility.asSet(478, 84, 83), GHUtility.getNeighbors(g.createEdgeExplorer().setBaseNode(480))); |
| 91 | + |
| 92 | + assertEquals(43.736989, g.getNodeAccess().getLat(10), 1e-6); |
| 93 | + assertEquals(7.429758, g.getNodeAccess().getLon(201), 1e-6); |
84 | 94 | }
|
85 | 95 |
|
86 | 96 | @Test
|
@@ -178,9 +188,17 @@ List<OneRun> createMonacoFoot()
|
178 | 188 | @Test
|
179 | 189 | public void testMonacoFoot()
|
180 | 190 | {
|
181 |
| - runAlgo(testCollector, "files/monaco.osm.gz", "target/monaco-gh", |
| 191 | + Graph g = runAlgo(testCollector, "files/monaco.osm.gz", "target/monaco-gh", |
182 | 192 | createMonacoFoot(), "FOOT", true, "FOOT", "shortest", false);
|
183 | 193 | assertEquals(testCollector.toString(), 0, testCollector.errors.size());
|
| 194 | + |
| 195 | + // see testMonaco for similar ID test |
| 196 | + assertEquals(GHUtility.asSet(2, 906, 570), GHUtility.getNeighbors(g.createEdgeExplorer().setBaseNode(10))); |
| 197 | + assertEquals(GHUtility.asSet(443, 952, 739), GHUtility.getNeighbors(g.createEdgeExplorer().setBaseNode(440))); |
| 198 | + assertEquals(GHUtility.asSet(909, 580, 912), GHUtility.getNeighbors(g.createEdgeExplorer().setBaseNode(911))); |
| 199 | + |
| 200 | + assertEquals(43.743705, g.getNodeAccess().getLat(100), 1e-6); |
| 201 | + assertEquals(7.426362, g.getNodeAccess().getLon(701), 1e-6); |
184 | 202 | }
|
185 | 203 |
|
186 | 204 | @Test
|
@@ -421,7 +439,7 @@ public void testNeudrossenfeld()
|
421 | 439 | * @param testAlsoCH if true also the CH algorithms will be tested which needs preparation and
|
422 | 440 | * takes a bit longer
|
423 | 441 | */
|
424 |
| - void runAlgo( TestAlgoCollector testCollector, String osmFile, |
| 442 | + Graph runAlgo( TestAlgoCollector testCollector, String osmFile, |
425 | 443 | String graphFile, List<OneRun> forEveryAlgo, String importVehicles,
|
426 | 444 | boolean testAlsoCH, String vehicle, String weightStr, boolean is3D )
|
427 | 445 | {
|
@@ -463,6 +481,8 @@ void runAlgo( TestAlgoCollector testCollector, String osmFile,
|
463 | 481 | testCollector.assertDistance(algoEntry, list, oneRun);
|
464 | 482 | }
|
465 | 483 | }
|
| 484 | + |
| 485 | + return hopper.getGraph(); |
466 | 486 | } catch (Exception ex)
|
467 | 487 | {
|
468 | 488 | if (algoEntry == null)
|
|
0 commit comments