Project-OSRM / osrm-backend

Open Source Routing Machine - C++ backend
http://map.project-osrm.org
BSD 2-Clause "Simplified" License
6.18k stars 3.28k forks source link

weights what are they good for? node vs edge vs segment #5066

Open swilinsky opened 6 years ago

swilinsky commented 6 years ago

Hi,

I'm very new to routing software and am getting confused but the different types of weights and what they can and should be used for.

We currently have a 10 square meter map of my city with a number from 1 to 5 where the higher the number the less we want our users to pass through that square.

I'm using a connection to a DB and retrieving the value based on the longitude and latitude for each segment in the process_segment function. But we are looking to expand to a larger area and increase out update frequency from daily to hourly.

Using the data base query for each segment will take far to long (>5 hours with the expanded area).

I've been doing a lot of reading on the site and was wondering if the OSRM-CONTRACT would be able to speed things up. But I'm not sure if it will allow me to change the weight without changing the rate / speed. Also from the documentation it says that it change the edge weight,

So my questions are....

What is the difference between the three different types of weights ( Node, Edge & Segment )

How much does the weight effect the choice of the segment? Is there a formula for determining the relationship between speed / duration and weight when routes are being calculated?

Are they being used for anything in the supplied walking and cycling ( ie to stop people walking on highways? )

If the OSRM-CONTRACT would allow me to update just the weight, how do you create the OSRM-CONTRACT input file? not sure where to get the to / from node ids or how to work out a latitude and longitude for them?

Any help or advice would be appreciated.

Thanks Steve

emiltin commented 6 years ago

You can import a raster file of values, see https://github.com/Project-OSRM/osrm-backend/wiki/Integrating-third-party-raster-data. It sounds like your data fits this format well. In your lua routing prifle, you load the file initially,, then when setting weights you can query the data quickly based on lat/lon.

You will need to first create this datafile based on database lookups, or some other method, based on where the original data comes from.

swilinsky commented 6 years ago

Hi Emiltin,

Thanks for the suggestion, the Data comes as a GEOTIFF so converting to Raster was quite easy, unfortunately, the extract process is still taking far too long. Even without adding the weights the time for the extraction is > 3 hours, not quite fast enough if they want to do hourly updates.

That's why I was interested in the CONTRACT.

Is there any documentation out there about how segment weights relates to the edge weights and node weights?

Also how to generate the input file for the CONTRACT? I read the post 'How do I create the segment-speed-file that can be fed to the contraction phase.i #2648' but it sounds like he gave up on it and decided to use the database method.

Thanks Steve

TheMarex commented 6 years ago

@swilinsky using the speed file is primarily targeted at traffic updates where you want to update the duration/weight of an edge segment that is addressed by a pair of OSM Node IDS.

If computing the actual weight is no problem for you could try the following thing:

{from_id},{to_id},{duration},{rate}
swilinsky commented 6 years ago

@Marex I think that's what I want to do but I can't find anything that shows how to get a lat / lon pair for an OSRM ID.

Currently I'm setting a weight on every segment, Is there any documentation that explains how that value gets factored into the route selection? All I can find is a comment that a higher weight makes a way less likely to be selected but there is no information about how this is implemented.

Is this the formula that is implemented : rate = distance / weight

Does changing the rate effect the overall reported distance or time for a route?

Would there be any difference in setting the rate in the customize file using that formula and setting the weight on each segment during the extract?

If In the I think my processing would be : 1) run extract with --generate-edge-lookup 2) run osrm-partition 3) convert all the from and to node id's to lat long pairs ( don't know how to do this! ) 4) load into a database. 5) load 3rd party weight data into the database 6) extract customize CSV file from database ( I already have code that can do this ) . 7) run osrm-customize using CSV file as input 8) restart osrm-routed

each time I receive a new input file repeat from step 5

Hopefully running step 5 to 9 will be minutes rather than hours.

Thanks in advance for all your help.