UrbanAnalyst / dodgr

Distances on Directed Graphs in R
https://urbananalyst.github.io/dodgr/
127 stars 16 forks source link

Add function to "uncompound" junctions #190

Closed mpadge closed 1 year ago

mpadge commented 1 year ago

Weighted street networks with turn penalties create and rely on compound junctions. To allow flow aggregation and centrality calculations on these networks, there needs to be an additional function to re-map flows along these compound edges back on to the original "uncompounded" network edges.

mpadge commented 1 year ago

This has already been implemented in dodgr_uncontract_graph(), but that function is not called by default within centrality and flow functions. Just need to modify those to ensure that it is called to uncompound and remove those junction edges.

mpadge commented 1 year ago

The uncompounding code is now in a separate function which is called at the end of centrality. Now also have to call that at the end of the flow functions, plus ensure that a tidy workflow can be explained especially when using single graphs between different sessions. This will mostly reduce to ensuring that compound junctions are removed from the main graph prior to saving, and that it is then possible to re-insert the compound junctions through exporting the current join_junctions_to_graph() function: https://github.com/ATFutures/dodgr/blob/4c78bb57e813929e2bc4b43a8ebe129e347d6975/R/weight-streetnet-times.R#L551-L552

mpadge commented 1 year ago

An even cleaner way is to always return a standard graph from all functions, and to create and insert compound junctions on-the-fly within individual functions which need them. The only problem with that is that, while turn penalties are entirely possible, turn restrictions can only be implemented with the original sc-class data used to create the graph. The solution is to store those as an two extra data.frame attributes of the graph. The next commits will implement that.

mpadge commented 1 year ago

closed via #191