[pgrouting-users] pgRouting and traffic congestion

On 3/3/2013 7:14 AM, Muhammad Iqnaul Haq wrote:

Hello Mr. Stephen

I'm iqnaul who asked about pgrouting and road traffic congestion in
pgrouting lists. I'm really thank you for your explanation. I want to
ask you is it possible to identify the traffic jam/congestion as a
barrier in pgrotuing table? so that when there is a jam the system will
automatically suggest another road segment to avoid the jam.
Do you have the websites that you made for your clients about this system?

thank you

warm regards

Hi Iqnaul,

This link is to a reference site I set up for one of my clients. It shows just a simple pgRouting installation but I have added an enhancement for the driving direction. The sites that I added traffic too are not publicly accessible sites.


You can add general area avoidances by using some SQL on how you select edges. Say you have a table of lines and/or polygon that you do not want your routes to cross over, ie you have to route around these obstructions. Then you could modify my previous SQL to look like this:

select a.gid, coalesce(b.speed, a.speed), a.the_geom
   from streets a
        left outer join traffic b on a.gid=b.gid
  where mytime between b.time1 and b.time2
        and a.gid not in (
            select a.gid
              from streets a, avoid b
             where st_dwithin(a.the_geom, b.the _geom, 0.0));

There may be more efficient ways to do this but basically you want to eliminate the edges for the areas that you want to avoid.