Hello everyone,
I am working on a Flutter application and am trying to implement dynamic routing, allowing users to choose options like “avoid motorways” without creating a separate profile for each choice on the server. I want to pass these routing preferences from the app to the GraphHopper API using a custom_model .
I have defined the following profile in my config.yml :
- name: mycustom
custom_model: {
"speed": [
{ "if": "true", "limit_to": "car_average_speed" }
]
}
weighting: custom
routing.ch.disabling_allowed: true
From my Flutter app, I am attempting to generate a route with the following URL, which includes a custom_model to avoid motorways:
https://localhost:8989/route?point=51.67734,5.0612677&point=52.0907006,5.1215634&profile=mycustom&custom_model=%7B%22priority%22%3A%5B%7B%22if%22%3A%22road_class%3D%3DMOTORWAY%22%2C%22multiply_by%22%3A%220.0%22%7D%5D%7D
My issue is that this custom_model seems to be ignored. The route calculation still uses motorways, as if the custom rules are not being applied. I have tried clearing the graph cache and restarting the server, but the behavior remains unchanged.
This leads me to a few questions:
- What is the best practice for a client-side application (like Flutter) to dynamically send routing rules?
- How can I ensure that the
custom_modelparameter in my API request successfully overrides the default rules of mymycustomprofile? - Are there specific examples of this use case, or perhaps a more reliable method for achieving this?
Any insights into why my custom_model might be ignored and how to fix it would be greatly appreciated.
Thank you in advance for your help!