Hi,
I need to prepare CH periodically like every 15 minutes as the live traffic comes in and the generated routes need to be optimal
Is this possible right now?
I did this:
Do you make use of profiles here? The GraphHopper server assumes the profiles are never changed while it is running (and not even changed after the initial import). The CH preparations simply provide the index data for these profiles (that never change). So the easiest you can do in this case would be restarting the server with your updated configuration. Another approach would be keeping the profiles constant but modifying some encoded values you use for traffic. In this case they need to be stored outside of the (constant) BaseGraph (see ExternalBooleanEncodedValue.java). If you do not use profiles and the GraphHopper server at all but only the low-level CH code technically you should be able to create any CH with whatever weighting you like. Did you try this yet? What error do you run into exactly?
Hi,
Thanks for your response, i’ll explain my some more details below:
I have created an external storage called live_traffic and a speed calculator that has this function: getSpeed(EdgeIteratorState edge, boolean reverse, long time), this speed calculator is a field in the Weighting object and uses the the live_traffic storage to calculate weights; I simply want a thread that periodically re-prepares CH(as the underlying traffic storage gets updated so weighting algo uses that) and overwrites the already existing “shortcuts_ch_car_ors_fastest” and “nodes_ch_car_ors_fastest” files or in new files; i then compress and push these files and reuse them in the server instances;
Now when i want to re-prepare the existing preparation i get errors that you can not prepare twice; when i delete flags tracking if preparation has run twice, close the CHStorage, recreate it and prepare again the files end up corrupted; The only solution i have right now is to create new preparation, but without creating the new profile in PrepareContractionHierarchies it says that the profile is already prepared. now what i want to do is to add another constructor to PreparationContractionHierarchies.java that does not extract the CHStore from ghStorage and takes it in as an arg. Is there a cleaner way to achieve this? Am i missing some other Obvious and easy solution?
Do you use GraphHopper or Open Route Service. I’m wondering where this _ors_ is coming from.
If you use a recent (vanilla) GraphHopper version you should be able to simply delete the previous nodes/shortcut files and restart the server (or re-run the import). If the files aren’t there they will be created again. So if you make sure your time parameter is updated the second time you run the import you should end up with the files you need.
Thanks @easbar for your response, i managed to do what i wanted and i appreciate your fast and helpful response.
So i did this by introducing Graphhopper’s latest ImportOrLoad in my project.
I am doing this now periodically:
There’s a problem though, i think this is problematic when new requests arrive as we are in the middle of this re-preparing and re-assigning storages; even if i have the files ready already how can i switch them seamlessly in a way that while switching the requests don’t face a problem? (besides restarting the deployments)