0

I cloned the Sample app from Git(Graphhopper).
And then download some Map.
But in my app it requires to have an option, either you walk or use bike
in routing.
Then i made this configuration in sample app code.

 void loadGraphStorage() {
        new GHAsyncTask<Void, Void, Path>() {
            protected Path saveDoInBackground(Void... v) throws Exception {
                GraphHopper tmpHopp = new GraphHopper().forMobile();
                tmpHopp.load(new File(mapsFolder, currentArea).getAbsolutePath());
                hopper = tmpHopp;
                return null;
            }

            protected void onPostExecute(Path o) {
                if (hasError()) {
                    err = "An error happend while creating graph:" + getErrorMessage();
                } else {
                    err = "Finished loading graph. Press long to define where to start and end the route.";
                }
                finishPrepare();
            }
        }.execute();
    }

And here.

 public void calcPath(final double fromLat, final double fromLon,
                         final double toLat, final double toLon) {
        new AsyncTask<Void, Void, GHResponse>() {
            float time;

            protected GHResponse doInBackground(Void... v) {
                StopWatch sw = new StopWatch().start();
                GHRequest req = new GHRequest(fromLat, fromLon, toLat, toLon);
                req.setAlgorithm(AlgorithmOptions.DIJKSTRA_BI);
                req.setVehicle("bike");
                req.getHints().put("instructions", "false");
                req.setWeighting("fastest");
                GHResponse resp = hopper.route(req);
                time = sw.stop().getSeconds();
                return resp;
            }

            protected void onPostExecute(GHResponse resp) {
                if (!resp.hasErrors()) {
                    log("from:" + fromLat + "," + fromLon + " to:" + toLat + ","
                            + toLon + " found path with distance:" + resp.getDistance()
                            / 1000f + ", nodes:" + resp.getPoints().getSize() + ", time:"
                            + time + " " + resp.getDebugInfo());
                    logUser("the route is " + (int) (resp.getDistance() / 100) / 10f
                            + "km long, time:" + resp.getTime() / 60000f + "min, debug:" + time);

                    mapView.getLayerManager().getLayers().add(createPolyline(resp));
                    //mapView.redraw();
                } else {
                    logUser("Error:" + resp.getErrors());
                }
                shortestPathRunning = false;
            }
        }.execute();
    }

I Used setVehicle to bike but The error message gave me only Car is supported.

Charles Galvez
  • 1,100
  • 5
  • 19
  • 41
  • 2
    See https://stackoverflow.com/questions/33897870/graphhopper-vehicle-car-works-but-foot-or-bike-dont-work – scai Dec 02 '15 at 09:38
  • 1
    Also please really avoid us duplicate work. Please post either here or on our forum: https://discuss.graphhopper.com/t/vehicle-bike-unsupported/331 – Karussell Dec 02 '15 at 12:48
  • Yes sorry. Thank you. solved this problem, and now facing a new one. – Charles Galvez Dec 02 '15 at 15:29

0 Answers0