valhalla / valhalla

Open Source Routing Engine for OpenStreetMap
https://valhalla.github.io/valhalla/
Other
4.46k stars 677 forks source link

Allow for crowdsourcing in costing #3420

Open kungfu303 opened 2 years ago

kungfu303 commented 2 years ago

I have question with regards to dynamic costing (Sif).

We want to be able to take in crowdsourced data (external to Valhalla) that should be used to modify certain edge costs. However, it seems like Valhalla only takes in osm extract files (such as .pbf files) that save no information on the cost of edges. These files only contain information about nodes, ways, and relations (and thus, nothing about edge weights or path-costs).

After reading through Valhalla’s architecture, it seems like the dynamic costing occurs after the .pbf input is processed.

We do not want to change the costing methodology or option (‘auto’), but we do want the crowdsourced data to affect the edge weights/costs. What would you suggest to best achieve this?

Appreciate the help.

nilsnolde commented 2 years ago

I had a very similar idea, I wanted (eventually, many PRs from that goal) to be able to allow for „popularity weighting“. Depending on the setup, you can have a look at the live traffic or incident loading. They provide smth very similar: support for a third party service to update edge weights on a regular basis without rebuilding any graph things.

kungfu303 commented 2 years ago

Great, will have a look at that. Do you have a specific link or page in mind to the live traffic solution that you recommended?

kevinkreiser commented 2 years ago

@kungfu303 back in 2016 or so Mapillary implemented this using spare bits in the DirectedEdge structure. Because we saw this coming we added the DirectedEdgeExt extension for this purpose. We are still lackign the ability for a costing to be able to detect and make use of data there though, that would need to be written, as you said, in an external repo. It would be interesting to support this stuff out of the box though addmitedly we haven't spent any time on it (originally we wanted people to pass lua in for the costing).

@nilsnolde using the traffic data architecture is also interesting, but in my opinion, only if you need the weights to change in real time.

ChenW12 commented 4 months ago

Hi @kevinkreiser, I'm quite curious about, for now, if it is possible to use DirectedEdgeExt for using external data in cost calculation. I have spent some time reading the source code, but I'm not sure if we can use it now. Thank you in advance

kevinkreiser commented 4 months ago

if by 'can' you mean automatically without code changes the answer is no. it was created to really show how one could extend the edge structure. just what one would put in there is not defined and so it's not possible to do that without a definition. but adding a definition would presuppose a person's use case and that would be too prescriptive. what we need I think is a howto probably

ChenW12 commented 4 months ago

Thank you so much for the quick response! I'm quite confused about how to access DirectedEdgeExt in EdgeCost(). I think I can't use tile->ext_directededge() because I can't access the GraphId of edge in EdgeCost(). Thank you again