Pass custom parameter in web-api to FlagEncoder

Hi,

Is it possible to pass custom parameters via the web-api to a custom FlagEncoder? For example, I’d like to pass parameters like this: http://mygraphhopper:8989/route?point=12.3456789,9.87654321&point=21.3456789,10.87654321&routing.ch.disable=true**&max_speed=80&rain=1**

In my custom FlagEncoder I’d then calculate the time using the max_speed value and for example add some penalty because of rain=1.
The reason behind this is that I want to allow passing differnt speeds to Graphhopper for different vehicles and can’t create a new profile for every possible scenario as I will probably end up with more than just two additional URL parameters. Is there a way to achieve this? Thanks!

It is already automatically done and you just need to pass a map to the constructor of your custom weighting. See the GenericWeighting and the usage of the PMap. Maybe this weighting and the DataFlagEncoder are already good for your other requirements?

BTW: your own parameters are in the GHRequest.getHints().

Thank you both very much for the answers!

I have to admit that I’m not that proficient with Java and my last Java project was a few years ago but I’m eager to look into the GenericWeighting. Once, I figured out how it exactly works I’m happy to report back and also ask about the requirements I have problems with. But this might take me a few days.

Have a nice weekend!!