Error while creating Graph

Hi…
i am currently working on a web application that is intended to enable navigation as a feature. For graphical use, I use leaflet in combination with leaflet routing machine and graphhopper is to serve as a routing engine.

It is now about the offline navigation on an Android device.

I have followed the instructions and have taken the following steps.

  1. I have downloaded the OpenStreetMap data:
    rheinland-pfalz-latest.osm.pbf

  2. I have run ./graphhopper.sh import rheinland-pfalz-latest.osm.pbf

  3. I have copied the folder rheinland-pfalz-gh to the Android device

  4. I have the following code, which I run to create the graph.

    public class WebAppInterface {
    private Context mContext;
    private GraphHopper hopper;
    private File mapsFolder = new
    File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
    “/graphhopper/maps/”);
    private String currentArea = “europe_germany_rheinland-pfalz”;

     /**
      * Instantiate the interface and set the context
      */
     WebAppInterface(Context c) {
         mContext = c;
         loadGraphStorage();
     }
    
     @JavascriptInterface
     void loadGraphStorage() {
         logUser("loading graph (" + Constants.VERSION + ") ... ");
         new GHAsyncTask<Void, Void, Path>() {
             protected Path saveDoInBackground(Void... v) throws Exception {
                 GraphHopper tmpHopp = new GraphHopper().forMobile();
                 tmpHopp.load(new File(mapsFolder, currentArea).getAbsolutePath() + "-gh");
                 log("found graph " + tmpHopp.getGraphHopperStorage().toString() + ", nodes:" + 
                 tmpHopp.getGraphHopperStorage().getNodes());
                 hopper = tmpHopp;
                 return null;
             }
    
             protected void onPostExecute(Path o) {
                 if (hasError()) {
                     logUser("An error happened while creating graph:"
                             + getErrorMessage());
                 } else {
                     logUser("Finished loading graph. Long press to define where to start and end the route.");
                 }
             }
         }.execute();
     }
    

When I now run the application, i get the following error:

I have tried the data from Berlin, which I created with the example application, but the error still exists.

graph.flag_encoders=car|speed_factor=5.0|speed_bits=5|turn_costs=false|version=1
graph.byte_order=LITTLE_ENDIAN
graph.dimension=2
nodes.version=5
edges.version=14
geometry.version=4
location_index.version=3
name_index.version=3
shortcuts.version=2
graph.ch.weightings=[fastest|car]
datareader.import.date=2017-05-20T16:34:35Z
datareader.data.date=2017-05-10T20:43:18Z
prepare.ch.date.fastest_car=2017-05-20T16:36:38Z
prepare.ch.done=true

What’s wrong with the properties file and why Graphhopper didnt accept it?

Have someone an idea, where the problem is and how i can fix it?

What exactly is the stacktrace? Can you try graphHopper.setAllowWrites(false) as some external storages are read-only.

Hi,

thanks for your answer.

I found the mistake. I forgot to request permissions at run time .

Thank you anyway

1 Like