I am self-taught in html, css, javascript, arcmap, qgis, leaflet, mapbox gl api, over the past four years. I have been studying and reviewing the documentation for teaching myself how to make a custom bicycle routing algorithm for graphhopper. While the documentation is extensive, it is very far from straight forward.
Can someone just put out a 15 minute video or something or anything that walks through the process of implementing a customized routing profile? Or just write up a detailed reply here and please ELi5 it (Explain it like Iâm 5 years old).
What Iâm trying to do⌠Iâve built an interactive webmap with data initially downloaded from OpenStreetMap, modified in QGIS, Uploaded to mapbox, and a webpage built in github pages that visualizes the data layers in the mapbox API⌠(See image below)
I want to implement my own customized bicycle routing profile that more heavy weights my curated road network and can provide AtoB directions.
As I understand broadly I need to:
Setup my own local graphhopper playground to make my changes to the code
change the code - specifically the weights based on the documentation here. And this is where it begins to be extremely unclear⌠That link says " Create a subclass of GraphHopper and overwrite createWeighting" There is no createWeighting file⌠Also All the files I do try to modify in intellij are read-only (even though I clicked File > Make File Writable, and Tools > Vim Emulator box is not checked)âŚ
I am starting to feel very overwhelmed by the process⌠Please if there was more video documentation, I (and I imagine others would find it very helpful).
Iâm certainly no GraphHopper expert, but Iâve recently built trailrouter.com which uses custom weightings and a custom flag encoder quite heavily, so maybe I can give you some pointers. My app biases towards roads/paths surrounded by natural features (e.g. parks, forests, rivers, etc), so it sounds like it could be similar to what youâre doing. Iâm actually using Openrouteservice rather than GraphHopper, but since Openrouteservice is built on top of GraphHopper, I know GraphHopper pretty well.
My suggestion on how to proceed would be as follows:
It sounds like youâre not sure on the difference between a FlagEncoder and a Weighting, which is very understandable. The way I understand it, the FlagEncoder is used to either âacceptâ or ârejectâ an edge (e.g. a road) or alternatively give it some high/low weight based upon some of the OSM attributes associated with it. For example, an edge that has âbicycle=noâ as an attribute on it would be rejected by the cycling FlagEncoder. It might also give an edge with âhighway=cyclewayâ a higher weight than an edge without it.
Conversely, a Weighting allows you to make weighting decisions on an individual edge by edge basis, rather than relying on the attributes associated with the edge. For example, you might want to weight towards the shortest road, or maybe the fastest, or maybe the one with least elevation gain.
Now to your actual task: You said you wanted to create your own cycling profile that more heavily weights towards your curated road network. What is your input data?
If your list of preferred roads is derived purely from OSM attributes (e.g. âhighway=cycleway means I want to give it a really high preference!â) then you can just modify the existing cycling FlagEncoder and you should achieve what you want. I donât think you need a custom Weighting really.
PS. That âCreate a subclass of GraphHopper and overwrite createWeightingâ bit in the documentation is a typo. It should say âoverride createWeightingâ. âoverrideâ means the same in Java as JS, which it sounds like youâre familiar with.
Thank you so much for your reply! Your website is incredible! The user interface, the analytics that pop up, the customization, and variation in length of route, along with the customized route generation alone! It goes to show how much more I have to learnâŚ
Anyway your trailrouter website is in many ways very similar to what Iâm trying to do bicycle commuting routes in my website www.tucsonpathways.org . What you must have coded off the OpenRouteService to automatically generate the trails you do is awesome⌠Iâm going to unpack this message and do my best to understand what you wrote over the next week or so, and I may post a more specific question in this thread later this week.