11

We are currently working with pgRouting and found that there's no way of implementing turn restrictions (e.g. banned right or left turns). While it is possible to assign "to_cost" and "rule" in Shooting * algorithm... I couldn't find a way of implementing these restrictions using A star and Dijktra algorithms.

Is there a way of implementing special turn restrictions in A star and Dijkstra methods ?

3

Yes, we have just implemented a turn restricted shortest path (trsp). I think it has been checked into a git branch at origin/trsp. It is not documented yet. If you have questions or need help ask on the pgrouting list, because that is where I hangout.

-Steve

1

Are you looking up this?

7.2. Restricted access¶

Another possibility is to restrict access to roads of a certain type by either setting a very high cost for road links with a certain attribute or by not selecting certain road links at all:

UPDATE classes SET cost=100000 WHERE name LIKE 'motorway%';

Through subqueries you can “mix” your costs as you like and this will change the results of your routing request immediately. Cost changes will affect the next shortest path search, and there is no need to rebuild your network.

Of course certain road classes can be excluded in the WHERE clause of the query as well, for example exclude “living_street” class:

SELECT * FROM shortest_path_shooting_star(
        'SELECT gid as id, class_id, source, target, length*c.cost as cost,
                x1, y1, x2, y2, rule, to_cost, reverse_cost*c.cost as reverse_cost
        FROM ways w, classes c
        WHERE class_id=c.id AND class_id != 111', 6585, 8247, true, true);

Of course pgRouting allows you all kind of SQL that is possible with PostgreSQL/PostGIS.

It's a fragment from workshop.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.