0
votes

I am building an application where I am using osmdroid with its bonus pack and mapnik for tiles. I want to be able to output shortest path between multiples points, and as a next step build paths considering time-frames. From my research it looks like Graphhopper Routing Optimization API is exactly what I need, but I can't figure out how to use it in my project properly. Since I am using os OSMBonusPack it looks like my only option is to set up Road Manager properly to be able to use routing optimization. Following tutorial for OSMBonusPack I am able to create Road manager and draw paths from one point to another, but not sure how to add optimization to find shortest path to it as well as set the road type to be "pedestrian" not a car. Any help will be highly appreciated. That's the code I am using to build a path between my points, pretty much exactly the same as tutorial:

 ArrayList<GeoPoint> waypoints = new ArrayList<GeoPoint>();
                    for (int i = 0; i < chosenAttractions.size(); i++) {
                        GeoPoint point = new GeoPoint(chosenAttractions.get(i).latitude, chosenAttractions.get(i).longitude);
                        waypoints.add(point);
                    }

                if (count > 1) {
                    StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
                    StrictMode.setThreadPolicy(policy);
                    RoadManager roadManager = new GraphHopperRoadManager("fae5bf0a-402a-48b2-96ac-324e138f53dc", true);

                  //  roadManager.addRequestOption("routeType=bicycle");
                    Road road = roadManager.getRoad(waypoints);
                    Polyline roadOverlay = RoadManager.buildRoadOverlay(road);
                    map.getOverlays().add(roadOverlay);
                    map.invalidate();

                }
            }
1
I think GraphHopperRoadManager is using the Routing API under the hood and not the Route Optimization API. You can still just "sort" the order of the locations via optimize=true, but more advanced features like multiple vehicles, time windows etc are not possible with the Routing API - Karussell
@Karussell you are very likely to be correct, so if you could give me a hint which function do I need to call to set optimize option, that will be greatly appreciated. - user_9
@Karussell nvm I figured out where the call is made from and how to add the request option to it. Thanks for pointing me in the right direction thou - user_9
Please add this as answer and accept it - Karussell

1 Answers

0
votes

Turns out to use optimization or vehicle option of Routing API one has to pass it as an argument to addRequestOption function, for example:

roadManager.addRequestOption("vehicle=foot");
roadManager.addRequestOption("optimize=true");