- 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?
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: