# ST_intersects and shortest_path to optimize routing in respect to (de-)acceleration

Is there a way to consider a more complex cost field in the PG_Routing algorithm?

I am currently trying to get more realistic routing costs. I have a map based on the German ATKIS standard with road types given. I have also the max. speed on those roads. @Editors: Can someone add a tag "ATKIS" for the German standard?

Idea:

1. Based on Identifying road intersections using PostGIS I am able to identify all junctions.

2. Now, combine the junction information with the vehicle acceleration to estimate the max. speed on the edge.

3. Would yield the indvidual costs for every edge

Can someone help me to solve issue 2.?

Or, is this impossible (or not necessary)? Maybe I am on the wrong track to get realistic traveling times!?

EDIT:

I successfully combined the junction information with the routing information. However, I might still have an error since I neglected the direction of the graph and thus which junction to take (start or endpoint of the edge).

Here's the code. Nervertheless, leave me a message if sth. can be solved better:

``````SELECT a.vertex_id, a.edge_id, a.cost, b.crossing, b.array_agg,
b.count, c.length, "WDM"
FROM shortest_path('
SELECT gid AS id,
start_id::int4 AS source,
end_id::int4 AS target,
length::float8 AS cost
FROM network',
2302,
1496,
false,
false) as a, junctions as b, network as c
WHERE c.st_endpoint = b.crossing AND c.gid = a.edge_id
``````
-
just an idea. How about calculating all turns on route as change of azimuth and classify those to 2-4 different class and add some educated quess to totaltime. –  simplexio Feb 25 at 10:49