Code Snippet:
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.setEncodingManager(EncodingManager.create(new CustomEncoder(4,2,0)));
//tmpHopp.setEncodingManager(EncodingManager.create(FlagEncoderFactory.CUSTOM));
//tmpHopp.setEncodingManager(new EncodingManager( “custom” ));
//EncodingManager encodingManager = EncodingManager.create(new CustomEncoder());
//tmpHopp.setEncodingManager(encodingManager);
tmpHopp.load(new File(mapsFolder, currentArea).getAbsolutePath() + “-gh”);
//tmpHopp.init(new CmdArgs().put(“graph.flag_encoders”, “custom”).put(Parameters.CH.PREPARE + “weightings”, “no”));
//tmpHopp.importOrLoad();
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.");
}
finishPrepare();
}
}.execute();
}
Update:
Where can i change the default profile to my custom profile or how do i change the code above to use my profile. The commented lines are different tries but every time another exception appears. For example “FlagEncoder not yet initialzed”, “FlagEncoder does not match” or “No configuration changes are possible after loading the graph”. If I should be more specific about anything just ask and i’ll try to answer properly.
Kind regards
Chamflo