2

This is the first time I post a question here. I was following the tutorial from Anita Graser http://anitagraser.com/2013/07/06/pgrouting-2-0-for-windows-quick-guide/ , on a roads table which contains only 2 columns ( id , geom ). I added the columns ( source and target ) and ran the :

select pgr_createTopology('roads', 0.0001, 'geom', 'id');

the result was OK and the columns were populated. I ran the :

SELECT seq, id1 AS node, id2 AS edge, cost, geom
FROM pgr_dijkstra(
'SELECT id, source, target, st_length(geom) as cost FROM roads',
2, 52, false, false
) as di
JOIN roads r
ON di.id2 = r.id ;

and the results were far from satisfying, none of the exemples I tried gave me the shortest path.

Can someone please explain to me where is the problem ?

2

I think your roads table is not "noded" correctly.

In the pgRouting topology model, each row of the roads table is an edge, that connects two (and only two) nodes. Source and target columns are filled with the id of the roads_vertices_pgr table accordingly.

If your roads table is not noded, pgRouting cannot "turn" on non-noded intersections.

If I'm right, you could solve running pgr_nodenetwork.

Be aware that pgr_nodenetwork will create a node on each intersection and this can lead to "false intersections" (for example, bridges, tunnels and so on..).

  • thanks I tried it but it somehow deforms my vertexes and creates new ones. I solved the problem check on the answers – Hicham Zouarhi Mar 11 '16 at 12:19
1

thanks for your help, the problem was that my vertexes weren't correctly connected so I reconnected them in geojson.io and relaunched the algorithm and it worked perfectly.

I tried the pgr_nodenetwork solution but it created many nodes that I don't need plus it somehow deformed my vertexes, the other problem is that it creates the target and source columns as bigint while pgr_Dijkstra uses these columns as int.

So the problem is solved thanks for helping

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.