[GraphHopper] (no subject)
Bruno Carle
bruno.carle at gmail.com
Mon Aug 25 08:00:11 UTC 2014
Hi Alvin
there are 2 APIs in graphhopper. the higher level one is accessed thru the
Graphhoper class. The lower one has some doc here:
https://github.com/graphhopper/graphhopper/blob/master/docs/core/low-level-api.md
AFAIK If you need to instanciate the graph storage by yourself then you can
not call Graphhoper.,importorload, you would have to use the lower api.
Now, if you don't need to instanciate the graphstorage by yourself then you
might use simply the graphhoper higher api:
GraphHopper tmpHopp = new GraphHopper().forServer();
EncodingManager encMan = new EncodingManager(new CarFlagEncoder());
String tmpDir="...india";
tmpHopp.setCHShortcuts("fastest");
GHRequest req = new GHRequest(50,14,50.1,14.1)
.setAlgorithm("dijkstrabi")
.putHint("instructions", true)
.putHint("douglas.minprecision", 1);
tmpHopp.setGraphHopperLocation(tmpDir);
tmpHopp.setOSMFile(....india.osm.pbf");
tmpHopp.setEncodingManager(encMan);
tmpHopp.setMemoryMapped(); // will use dataaccesstype MMAP
tmpHopp.importOrLoad();
GHResponse resp = tmpHopp.route(req);
Regards
Bruno
On Mon, Aug 25, 2014 at 7:14 AM, Alvin Varghese <alvinvarghese092 at gmail.com>
wrote:
> Hi,
> I had a problem while routing with graphhopper. When I run, it terminates
> with an error on the following code.
>
> GraphHopper tmpHopp = new GraphHopper().forServer();
> EncodingManager encMan = new EncodingManager("CAR:"
> + CarFlagEncoder.class.getCanonicalName());
> GraphStorage gs = new GraphHopperStorage(new
> GHDirectory("/sdcard/downloads/india_maps-gh", DAType.MMAP), encMan, false);
> OSMReader reader = new OSMReader(gs);
> reader.setEncodingManager(encMan);
> File f = new File("/sdcard/downloads/india.osm.pbf");
> if (f.exists() && f.isFile()) {
> reader.setOSMFile(f);
> reader.readGraph();
> }
> tmpHopp.setGraph(gs);
> tmpHopp.setCHShortcuts("fastest");
> GHRequest req = new GHRequest(fromLat, fromLon, toLat, toLon)
> .setAlgorithm("dijkstrabi")
> .putHint("instructions", true)
> .putHint("douglas.minprecision", 1);
> gh.importOrLoad();
> GHResponse resp = gh.route(req);
>
> I am attaching my logcat statements below:
>
> 08-25 10:36:43.377: E/AndroidRuntime(9276): FATAL EXCEPTION: AsyncTask #2
> 08-25 10:36:43.377: E/AndroidRuntime(9276): Process: com.example.testmap,
> PID: 9276
> 08-25 10:36:43.377: E/AndroidRuntime(9276): java.lang.RuntimeException: An
> error occured while executing doInBackground()
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> android.os.AsyncTask$3.done(AsyncTask.java:300)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> java.util.concurrent.FutureTask.setException(FutureTask.java:222)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> java.util.concurrent.FutureTask.run(FutureTask.java:242)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> java.lang.Thread.run(Thread.java:841)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): Caused by:
> java.lang.IllegalStateException: graphHopperLocation is not specified. call
> init before
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> com.graphhopper.GraphHopper.load(GraphHopper.java:637)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> com.graphhopper.GraphHopper.importOrLoad(GraphHopper.java:557)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> com.example.testmap.activities.GraphhopperRouteActivity$6.doInBackground(GraphhopperRouteActivity.java:351)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> com.example.testmap.activities.GraphhopperRouteActivity$6.doInBackground(GraphhopperRouteActivity.java:1)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> android.os.AsyncTask$2.call(AsyncTask.java:288)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): at
> java.util.concurrent.FutureTask.run(FutureTask.java:237)
> 08-25 10:36:43.377: E/AndroidRuntime(9276): ... 4 more
>
> Hope you can help me.
> Thank you.
> Alvin
>
>
> _______________________________________________
> GraphHopper mailing list
> GraphHopper at openstreetmap.org
> https://lists.openstreetmap.org/listinfo/graphhopper
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/graphhopper/attachments/20140825/bb0f0326/attachment.html>
More information about the GraphHopper
mailing list