You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When using the suggested motorcycle profile, the resulting route duration is incorrect. In my opinion, this line { "if": "true", "multiply_by": "0.9 * car_average_speed" } produces a wrong result (the base speed is multiplied by 90% of the car_average_speed). However, the main bug is that if I change the speed section to { "if": "true", "limit_to": "car_average_speed" }, the resulting route time does not change. Meanwhile, if I append another custom_model_files with only the speed section, it works correctly.
To Reproduce
Steps to reproduce the behavior.
checkout recent and stable version of GraphHopper v8
Expected behavior
I expect that I can change the speed section of the motorcycle.json file. It seems that the speed section of the first custom model file is ignored.
However, the main bug is that if I change the speed section to { "if": "true", "limit_to": "car_average_speed" }, the resulting route time does not change. Meanwhile, if I append another custom_model_files with only the speed section, it works correctly.
Can you explain what you did in detail to solve this?
In general the custom model for motorcycle is not yet production-ready. E.g. motorcycle access restrictions are not considered yet.
but it does not work. It seems that the speed section of the first custom model is ignored. If I send the same json as custom model json at runtime, it works.
What you see is that the (still) incorrect motorcycle.json is picked from the 8.0 jar and the limitation is basically only done from the statement if:true,limit_to:120.
You can either use the latest master (where this is already fixed due to your request) or a correct motorcycle-fixed.json (don't forget to specify custom_models.directory: xy) and this should no longer happen.
And yes, in general if you define a server-side custom model there is no need to send the custom model in the request and you are right that in the second case the query with "if": "true", "limit_to": "0.9 * car_average_speed" should result in the same time, because the statement already exists on the server-side.
Please note that the statement order still can be important. So it matters if you first limit to X and multiply by Y or if you first do the multiplication and after that the limitation.
Thank you, so I suppose that if I set a motorcycle.json in the custom_model_files it takes the file picked from the jar, even if there exists a file with the same name in the folder specified by custom_models.directory: xy. I didn't know that.
Maybe, it may be better to use the file defined by the user, if it is present. Or, it can be useful to write that in the documentation, but it is just a suggestion.
Activity
[-]Motorcycle profile has wrong time duration[/-][+]Motorcycle profile speed section is ignored[/+]karussell commentedon Nov 20, 2023
Can you explain what you did in detail to solve this?
In general the custom model for motorcycle is not yet production-ready. E.g. motorcycle access restrictions are not considered yet.
NicholasRasi commentedon Nov 20, 2023
I append another custom model file (i.e.
motorcycle_speed.json) to the config file, as follow:And set the speed in the
motorcycle_speed.jsonfilekarussell commentedon Nov 20, 2023
Hm, the correct way would be if the model starts with
Here it is indeed the bug you mentioned ( multiply->limit_to ).
Can you retry without motorcycle_speed.json and you make sure that you remove the graph folder before you try again?
NicholasRasi commentedon Nov 20, 2023
Yes, I already removed the cache and tried with
motorcycle.json
but it does not work. It seems that the speed section of the first custom model is ignored. If I send the same json as custom model json at runtime, it works.
karussell commentedon Nov 20, 2023
What exactly does not work? I just tried it and it "worked" as expected and is e.g. 90% of the car speed.
You can see the now lower average_speed in the widget in the bottom right corner:
Also the route time increased compared to car in my example.
fix bug, reported by @NicholasRasi, #2908
NicholasRasi commentedon Nov 20, 2023
The traveling time is wrong.
Look, I define
motorcycle.jsonasThen, I make a request for this route

I get a traveling time of 8 min (that is wrong). If I send this custom model
that is the same rule defined in

motorcycle.jsonI get the following:And the traveling time is 18 min (correct).
The profile is defined as already mentioned
(curvature.json does not add any speed rule)
Shouldn't it be the same?
karussell commentedon Nov 21, 2023
What you see is that the (still) incorrect motorcycle.json is picked from the 8.0 jar and the limitation is basically only done from the statement
if:true,limit_to:120.You can either use the latest master (where this is already fixed due to your request) or a correct motorcycle-fixed.json (don't forget to specify
custom_models.directory: xy) and this should no longer happen.And yes, in general if you define a server-side custom model there is no need to send the custom model in the request and you are right that in the second case the query with
"if": "true", "limit_to": "0.9 * car_average_speed"should result in the same time, because the statement already exists on the server-side.Please note that the statement order still can be important. So it matters if you first limit to X and multiply by Y or if you first do the multiplication and after that the limitation.
NicholasRasi commentedon Nov 21, 2023
Thank you, so I suppose that if I set a
motorcycle.jsonin thecustom_model_filesit takes the file picked from the jar, even if there exists a file with the same name in the folder specified bycustom_models.directory: xy. I didn't know that.Maybe, it may be better to use the file defined by the user, if it is present. Or, it can be useful to write that in the documentation, but it is just a suggestion.
karussell commentedon Nov 21, 2023
Yes and we should probably throw an exception to avoid the same name.
NicholasRasi commentedon Nov 21, 2023
Ok, in my opinion there are two ways to solve the problem:
This should be the interested code section
graphhopper/core/src/main/java/com/graphhopper/GraphHopper.java
Lines 1546 to 1570 in 3f741a7