[GraphHopper] Testing a simple graph

Peter K peathal at yahoo.de
Fri Feb 14 22:49:34 UTC 2014


Try setInMemory(true, true) instead of setInMemory(true, false)

Regards,
Peter.

BTW: This was recently changed and now just reads setInMemory(true)

> 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?




More information about the GraphHopper mailing list