Repository navigation
Description
The main OHM website should integrate a routing service that calculates routes over the historical road network in OHM.
Background
openstreetmap-website integrates with several routing services to help mappers visualize and debug the routing implications of their navigation mapping. Users can access this functionality by pressing a button beside the search bar, or by visiting the /directions page. Most mappers go for years without ever noticing the Directions button; it’s one reason why discussions about navigation mapping can sometimes be a bit ungrounded from reality.
OHM has yet to set up a routing service. OpenHistoricalMap/ohm-website@c3b40d9 removes the button, but it remains possible to access the built-in OSM routing integration by visiting /directions. #506 tracks removing this endpoint.
Rationale
From a modern perspective, it can be difficult to appreciate reductions in travel time enabled by road development or by the opening of a specific thoroughfare. For this reason, historians often mention how long it used to take to travel from one place to another as context when explaining a sequence of events. Sometimes these estimates factor into important world events. These estimates are often based on records and historical accounts mentioning departure and arrival times. However, these records only cover rare, exceptional occasions. An OHM-based router could improve spatial understanding based on how humans actually navigate on the ground, not just from a bird’s eye view.
Historical routing can also potentially help to model future epidemics of communicable diseases based on understanding the spread of previous epidemics.1
Feasibility
Temporal routing graphs are algorithmically significantly more complex than conventional routing graphs.2 However, several OSM-based routing engines already support a limited form of time-dependent routing based on the conditional restrictions tagging scheme. Each router skirts algorithmic complexity by taking strategic shortcuts. For example, OSRM and Openrouteservice only resolve conditional restrictions at the time they build the routing graph. None of these routers dynamically recomputes the available edges after completing each step. Some routers only compute accessibility with daily precision.
These are severe limitations when it comes to OSM data, but it should generally be fine when working with OHM data that’s less precise from a navigation perspective. In fact, the only reason I bring up OSM’s conditional restriction tagging scheme is to suggest that we co-opt it for storing start and end dates, which are more important in the grand scheme of things. The idea is to configure one of these routing engines to translate start_date=1950-10-14 end_date=1940-11-07 into access=no access:conditional=yes @ (1950 Oct 14 - 1940 Nov 7).3 Both GraphHopper and Valhalla appear to support full date ranges in access:conditional=*, though GraphHopper doesn’t support time ranges: graphhopper/graphhopper#374. Time ranges would only be necessary if we attempt to support start_date:edtf=* and end_date:edtf=*.
Both GraphHopper and Valhalla come with walking profiles, but we might also want to develop profiles for riding on horseback or driving cattle. We’d be writing a custom profile anyways to handle the tag transformation from start_date=* and end_date=* to access:conditional=*.
Footnotes
-
Michail, Othon (2015). “An Introduction to Temporal Graphs: An Algorithmic Perspective.” Patras: Computer Technology Institute & Press “Diophantus”. ↩
-
Michail, Othon; Spirakis, Paul G. (2014). “Traveling Salesman Problems in Temporal Graphs.” Budapest: International Symposium on Mathematical Foundations of Computer Science. ↩
-
The infamous original span of the Tacoma Narrows Bridge, if you’re wondering. ↩
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsIn Production
Activity
1ec5 commentedon Feb 15, 2024
Based on some cursory code inspection, in GraphHopper, we’d need to modify the core codebase to check the date keys. In Valhalla, the tag rewriting can happen in Lua without needing to recompile the engine. Another possibility would be to transform the tags ahead of time in the PBF.
ianthetechie commentedon Feb 20, 2024
A few random notes after giving this a read through...
This is clever. I think it'll work. I don't think
access:conditionalitself is explicitly tested as such today, but there is a great test for mode-specific restrictions here.Yeah, that makes sense. Unfortunately, making a new profile in Valhalla isn't exactly easy, but it's certainly possible. This unfortunately requires writing oodles of C++. I'm not sure how much better that is than grokking 2500 lines of Lua spaghetti, but just FYI ;)
Another thing to be aware of are that, while Valhalla should be quite extensible in terms of costing modes, there are some limits at the moment re: number of modes of travel, and my open PR will use the last bit.
While you won't need to touch C++ code per se just to change the lua scripts, these do actually get compiled down. This is probably splitting hairs, but at a high level, the pipeline goes something like 1) prepare data, 2) build graph tiles, and 3) run the Valhalla service pointed at the graph tiles. This has a few interesting properties that might not be obvious.
valhalla_build_tilestarget (Lua gets compiled into a C++ header which is invoked by C++ code using the LuaJIT runtime). You don't need to recompile the engine here unless you are adding new info to the tiles. If you're just using existing fields and remapping, then you're good. (Also note that while the first pass of stuff happens in Lua, some C++ is involved to transfer properties into into internal structures; you can see my PR for details, but this probably isn't a concern unless you are adding new fields).Finally, re: feasibility, this feels like it's scopable for a motivated student. For context, I wrote the golf cart profile in about a week and a half (sans present effort to upstream the changes for general public use, which is going to take almost as many dev hours haha). I started with a pretty understanding of the domain and Valhalla itself (had hacked on it on and off for ~5 years prior). Multiply that a few times for unfamiliarity and uncertainty, and I think it's a reasonable summer project.
Hope this helps!
1ec5 commentedon Feb 25, 2024
This idea pretty much assumes that any change to a street is mapped as a separate way. Fortunately, this is how most streets are being mapped in OHM presently.
By contrast, #94 proposes to map most attributes as relations on a shared way instead. Some mappers would like that approach because it would keep them from having to untangle a mess of overlapping ways in the editor. However, it would greatly complicate any routing solution, since we’d have to either synthesize edges during postprocessing or somehow modify the core routing engine to assign weights and other attributes conditionally, not just access restrictions. Valhalla’s guidance engine would probably be heavily affected too.
For now, I’d ignore the relation-based approach since there are too many open questions about how to even render it, let alone route over it.
1ec5 commentedon Mar 3, 2024
For completeness, there is some prior art: in 2014, @SK53 experimented with setting up OHM-powered instances of GraphHopper, OpenTripPlanner, and Routino in Buenos Aires.
1ec5 commentedon Oct 28, 2025
Some of the feedback about Viabundus 2 on Metafilter suggests that a routing profile in medieval times would need to route over waterways in order to be useful. OmnesViae and ORBIS are cited as examples of routers that support waterway routing.
The routing engines mentioned earlier only have support for nominal multimodal routing (like assuming you can just show up with a bike at a railway track and ride a train), but it might be enough for this use case.
1ec5 commentedon Nov 6, 2025
itiner-e also has routing over roads and waterways in Roman times.
Rub21 commentedon Oct 16, 2026
I looked into the alternatives and it's not that hard to set up, here is a example https://routing.ohmstaging.org, repo: https://github.com/OpenHistoricalMap/ohm-routing
I used GraphHopper with a small plugin that reads
start_date/end_date, so the route only uses ways that existed on the selected date. Valhalla doesn't work for this because its date rules don't store the year, the main problem is the data, many ways don't connect to each other.1ec5 commentedon Oct 17, 2026
Fantastic! I’m having a lot of fun finding gaps in my own mapping, as have others in the community who have discovered the demo. I’m confident we’ll see more buildout of roads and connectivity once there’s a way to visualize its impact.
What’s next? I could think of endless enhancements to the routing experience, but mostly I’m looking forward to being able to integrate a router into the website so mappers and users can access it.
Does GraphHopper feel like it’ll give us the flexibility we need for things like OHM-specific relation types (such as
street) and modes of transportation (such ashorse)? Does it try to infer anything from boundaries; if so, will it be confused by time-dependent boundaries? How is load and performance looking? How frequently will we be able to update the routing graph?1ec5 commentedon Oct 30, 2026
Fixed in OpenHistoricalMap/ohm-deploy#893.