public BelgiumHubSuggester() {
   graphHopper = new GraphHopper().forServer();
   String osmPath = "local/osm/belgium-latest.osm.pbf";
   if (!new File(osmPath).exists()) {
     throw new IllegalStateException(
         "The osmPath ("
             + osmPath
             + ") does not exist.\n"
             + "Download the osm file from http://download.geofabrik.de/ first.");
   }
   graphHopper.setOSMFile(osmPath);
   graphHopper.setGraphHopperLocation("local/graphhopper");
   graphHopper.setEncodingManager(new EncodingManager(EncodingManager.CAR));
   graphHopper.importOrLoad();
   logger.info("GraphHopper loaded.");
 }
示例#2
0
  public void startup(String dataDir, boolean loadElevationData)
      throws NoDataException, StartupException {
    if (dataDir == null) {
      Log.e(TAG, "No external storage available, cannot load GraphHopper data");
      throw new NoDataException();
    }

    gh = new GraphHopper().forMobile();
    boolean result;
    try {
      gh.setEncodingManager(EncodingManager.create(FlagEncoderFactory.DEFAULT, dataDir));
      gh.getCHFactoryDecorator().setDisablingAllowed(true);
      result = gh.setElevation(loadElevationData).setCHEnabled(true).load(dataDir);
    } catch (Exception e) {
      Log.e(TAG, "GraphHopper initialization failed", e);
      throw new StartupException(e);
    }

    if (!result) {
      Log.e(TAG, "GraphHopper initialization failed");
      throw new StartupException(null);
    }
  }