[GraphHopper] Testing a simple graph

Andreas Fischer fischer.andreas.atf at googlemail.com
Fri Feb 14 11:12:39 UTC 2014


Hi There,

I want to test an algorithm which i wrote on a very simple graph (like the
test.osm in the storage test cases).
My algorithm uses location indexes. My algo first gets all nodes nearby by
calling findNetworkEntries(lat, lon).
This usually works on my external built graph (e.g. on my smart phone) but
it does not work if i just load an OSM file with GraphHopper via
setInMemory(true, false)

My code is equivalent to the GraphHopper test case:

private static final String testOsm3 =
"./src/test/resources/com/graphhopper/reader/test-osm3.xml";
private static final String ghLoc = "./target/tmp/ghosm";
private GraphHopper gh;

@Before
public void setUp(){
  Helper.removeDir(new File(ghLoc));
}

@After
public void tearDown(){
  gh.close();
  Helper.removeDir(new File(ghLoc));
}

@Test
public void myAlgoTest(){
  gh = new GraphHopper().setInMemory(true, false).setEncodingManager(new
EncodingManager("CAR"))

.setGraphHopperLocation(ghLoc).setOSMFile(testOsm3);
  gh.importOrLoad();

  myAlgoDoesFancyStuff();
}

The problem is, that it seems that it didn't create any location indexes
and findNetworkEntries() returns 0 entries.
What is the easiest way to create the location indexes that i get
findNetworkEntries() working?

Thanks in advance,
Andreas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/graphhopper/attachments/20140214/c3880d53/attachment.html>


More information about the GraphHopper mailing list