1
  • Does someone know how the cost field in PgRouting is calculated?
  • What are 'source' and 'target' good for? 'osm_source_id' and 'osm_target_id' contain the same information using different numbers.
  • Is there a good reason to use 'cost' and 'r_cost'? Every cost in my table is smaller than 1. So, 0.00045... could mean both directions and 1.00045 oneway.
  • When it comes to routing what are 'clazz', 'flags' and the line string good for?
  • 1
    Are you talking about pgRouting or the way osm2pgrouting loads data? You need r_cost (reverse cost) for 1 ways etc. costs are all relative, they mean what you want them to mean. So you can have big numbers or small numbers. osm2pgrouting is based on road length (note new version measures in meters (old in units of road - degrees) – LR1234567 Aug 16 '15 at 8:44
  • I am just trying to figure out what a good database design is for routing. (And still think getting rid of one cost column is possible...) Do you also know something about clazz, flags, the line string and what the source and target column are good for? – user54586 Aug 16 '15 at 15:26
  • The source and target are node ids of the start and end points of the edges. When you run pgr_createTopology on an edge table, these get populated and a side line table your_table_vertices_pgr gets created with node ids and corresponding point geometries. – LR1234567 Aug 17 '15 at 9:05
1

I guess it's better to answer here than comments on your question:

1) As mentioned source and target are integers that are unique identifiers for starting and ending points of your edge. So if an edge joins with another they share a point in common and you'll see the id repeated. This is a very fundamental piece of routing since travel stops are at the source /target nodes. Anyway a lot of functions in pgRouting expect your edge table (or query to have a source and target column)

Just repeating what I wrote in comments:

When you run pgr_createTopology on an edge table, these get populated and a side line table your_table_vertices_pgr gets created with node ids and corresponding point geometries.

2) Linestring is needed for a couple of reasons, In certain routing, you don't want to have to stop and start at a node. So the pgRouting functions will find you the path from say node 1 to node 2 alonge edge a, and then your final solution might involve doing linear interpolation along the final edge.

The other purpose for the linestring is if you have a large network, you don't want to have to analyze the whole thing, so using proximity PostGIS functions, you can select with a bounding region the edges you need to inspect.

3) Clazz and flags that is an implementation detail of how osm2po loads data and not something specific about pgRouting. I think this link might answer your question:

What does the values in column clazz (osm2po) mean?

| improve this answer | |
  • Thanks, I didn't know that Linestrings are good for solving that problem. Very interesting and good news. As far as the source and target thing is concerned, there are two columns: source and osm_source_id. And every source is an integer mapped to and osm_source_id. Which is also an integer. So you could use just the original node ids for routing. At least that is what I am going to do... – user54586 Aug 17 '15 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy