How to avoid road based on list of latitude & longitude

I’m using the Android file for offline routing. Link

and I’m trying to make a condition to avoid certain road using list of latitude & longitude. This is like there’s a unexpected road blockage or accident.

Thank you in advance. I do I appreciate more if there’s a complete code to study. Sorry for being newbie.

See the custom weighting example or in the master branch we’ve developed a more integrated solution for that (currently limited to changes that you know up-front or single thread applications)

Sorry for being newbie.

No problem. You can find getting started material in the documentation and if something is unclear we should improve this docs.

Sorry sir, I really need help following the instruction.

I just follow to test the weighting. Please see the screenshot

There are red in the code.

WeightingMap wMap,

String weighting = wMap.getWeighting();

I cant fix or make solution how it will be. Or i just missing something. The documentation is good, I just making a hard time doin it for the first time.

Another thing, am I doing it right declaring a GPS point

forbiddenEdges = 52.492999, 13.387924;

You can’t do this in Java :slight_smile: … create instances of GHPoint and then look them up using the LocationIndex (hopper.getLocationIndex), where you then get the edge IDs to be added to the forbiddenEdges.

Sorry sir, I can’t figure out how it will done. Is there any sample source code available to look on? My goal is just to have a offline routing that can set to avoid specific road (using gps point). Thank you in advance

Hi, I have a requirements like yours, which avoid road using latitude and longitude.
After looking a custom weight, it’s quite unclear about that. But I got this documentation
[Documentation - GraphHopper Directions API],

You can code like this


Hopefully help !!

Cheers,
Malvin
(Documentation - GraphHopper Directions API)

The recommended way is now via custom profiles where you can define polygons that you cannot only exclude but also avoid or prefer: Examples For Customizable Routing - GraphHopper Directions API

2 Likes
Powered by Discourse