Skip to content

Commit 0d8580f

Browse files
author
Peter
committed
if input file is unchanged then edge and node IDs stay the same - make this a requirement
1 parent 62ca632 commit 0d8580f

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

core/src/main/java/com/graphhopper/reader/OSMReader.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import com.graphhopper.storage.*;
4747
import com.graphhopper.util.DistanceCalc;
4848
import com.graphhopper.util.DistanceCalc3D;
49-
import com.graphhopper.util.DistanceCalcEarth;
5049
import com.graphhopper.util.DouglasPeucker;
5150
import com.graphhopper.util.EdgeIteratorState;
5251
import com.graphhopper.util.Helper;

core/src/test/java/com/graphhopper/routing/RoutingAlgorithmIT.java

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.graphhopper.storage.GraphBuilder;
3030
import com.graphhopper.storage.index.LocationIndex;
3131
import com.graphhopper.storage.index.QueryResult;
32+
import com.graphhopper.util.GHUtility;
3233
import com.graphhopper.util.Helper;
3334
import com.graphhopper.util.StopWatch;
3435
import java.io.File;
@@ -78,9 +79,18 @@ List<OneRun> createMonacoCar()
7879
@Test
7980
public void testMonaco()
8081
{
81-
runAlgo(testCollector, "files/monaco.osm.gz", "target/monaco-gh",
82+
Graph g = runAlgo(testCollector, "files/monaco.osm.gz", "target/monaco-gh",
8283
createMonacoCar(), "CAR", true, "CAR", "shortest", false);
84+
8385
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);
8494
}
8595

8696
@Test
@@ -178,9 +188,17 @@ List<OneRun> createMonacoFoot()
178188
@Test
179189
public void testMonacoFoot()
180190
{
181-
runAlgo(testCollector, "files/monaco.osm.gz", "target/monaco-gh",
191+
Graph g = runAlgo(testCollector, "files/monaco.osm.gz", "target/monaco-gh",
182192
createMonacoFoot(), "FOOT", true, "FOOT", "shortest", false);
183193
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);
184202
}
185203

186204
@Test
@@ -421,7 +439,7 @@ public void testNeudrossenfeld()
421439
* @param testAlsoCH if true also the CH algorithms will be tested which needs preparation and
422440
* takes a bit longer
423441
*/
424-
void runAlgo( TestAlgoCollector testCollector, String osmFile,
442+
Graph runAlgo( TestAlgoCollector testCollector, String osmFile,
425443
String graphFile, List<OneRun> forEveryAlgo, String importVehicles,
426444
boolean testAlsoCH, String vehicle, String weightStr, boolean is3D )
427445
{
@@ -463,6 +481,8 @@ void runAlgo( TestAlgoCollector testCollector, String osmFile,
463481
testCollector.assertDistance(algoEntry, list, oneRun);
464482
}
465483
}
484+
485+
return hopper.getGraph();
466486
} catch (Exception ex)
467487
{
468488
if (algoEntry == null)

0 commit comments

Comments
 (0)