Reputation: 397
I am currently working in Android Studio on a GPS app that will route me from my current location to a set destination. Beforehand, along this road I want to make some of the streets and routes unusable forcing the GPS to guide me the shortest distance NOT using these unusable routes.
For example, I am driving from A towards B. In between the shortest normal route takes me over a bridge. This bridge has collapsed and is being marked with a MapOverlayItem in the shape of a big red cross. I want the GPS to know the bridge is out and guide me to an alternative route.
I am using OSMdroid for map and OSMBonusPack for routing. I know that OSM have exactly what I need but I am not sure on how to use them together.
Upvotes: 1
Views: 957
Reputation: 397
A friend of mine solved it.
@Override
protected Integer doInBackground(GeoPoint... geoPoints) {
String url = getRoadUrl(geoPoints[0]);
HttpConnection connection = new HttpConnection();
connection.doGet(url);
String s = connection.getContentAsString();
String[] split = s.split("\"linkId\":");
split = split[1].split(",");
return Integer.parseInt(split[0]);
}
By finding the route's ID you can explicitly ask it not to calculate by that road. The above code is just a snippet to show how we ask a road not to be used. Ask if you need a more describing version of this.
Upvotes: 0
Reputation: 21469
I don't think this is possible, unfortunately. As far as I can see, OSMBonusPack doesn't do the routing itself (offline routing) but uses MapQuest instead (online routing). Consequently you can't add arbitrary barriers yourself. The only solution is to use an offline router for android.
Upvotes: 2