Routing restrictions ignored with custom FlagEncoder

In order to better control speed limits and other routing prioritization I had to create my own FlagEncoder called MyHeavyVehicleFlagEncoder (a copy of HeavyVehicleFlagEncoder for the moment until restrictions work) and added a new DRIVING_MYHGV constant in RoutingProfileType (value of 77 not used before). I also adapted the code so the generation produces the graph folders.

Until here everything looks great and i was able to have two directory in my graphs folder after the generation is done:

  • hgv (default folder for heavy vehicle )
  • myhgv (new folder for my own heavy vehicle)

But after some tests I discovered that my new profile completely ignores restrictions (height, weight, etc) which is not the case for the default hgv profile.

I’ve been stuck for a month now and i did many tests but with no success.

Any help will be appreciated, thanks.


in case you didn’t do so already, you need to enable hgv-specific edge filters in RoutingProfile as well as in CoreAlgoFactoryDecorator if you intend to use CALT algorithm for routing.


Hi @andrzej , thanks for your quick reply.

As I said earlier, I’ve been stuck on the same topic for a month now therefore I duplicate the exact same code for all hgv classes in every place in the project.

I even change the docker-compose so my IntelliJ can listen to the 5005 port and perform remote debugger to figure the differences between driving-hgv and driving-myhgv.

I also went to mention that the used vehicle-type in the body of the POST request is always hgv (“vehicle_type”: “hgv”).

I can’t figure out why ONLY restrictions are ignored when routing with the new profil, is there other any places where i need to add/modify code?

I know that restrictions are retrieved from OSM. Is it possible that my code does not work because OSM tags names use hgv all the time (maxweight:hgv for weight, maxheight:hgv for height, etc) and ORS default profile is driving-hgv while mine is called driving-myhgv.

I can share all my code if that can help.

Dear @hamzarhaiem,

Thanks for your feedback! In order to be able to query ORS with an added custom hgv profile you might need to adapt parts of the API as well, such as APIEnums.

HGV-specific OSM restrictions should work out even for your custom profile as long as the corresponding HeavyVehicleEdgeFilter is active.


Dear @andrzej,

It finally works!!!

Thank you so much for your assistance.



Dear @hamzarhaiem,

I’m glad to hear that! Please don’t hesitate to reach out in case of any further questions.


1 Like