I am trying to create a routing application with OSM data. What I am working with is an almost square area of about 30x30 kilometers, so nothing too big. But when I do something like

SELECT the_geom FROM dijkstra_sp_directed('roads_clip','6','2','true','true');

It does not select anything. Both the table and the source and target vertices exist, as well as a possible path between them. This code is a part of a larger block that is about to insert the selected path into a new table, here's what it looks like:

DROP TABLE IF EXISTS shortest_path_table;
CREATE TABLE shortest_path_table(gid int4) with oids;
SELECT AddGeometryColumn( 'shortest_path_table', 'the_geom', -1, 'MULTILINESTRING', 2 );
INSERT INTO shortest_path_table(the_geom) SELECT the_geom FROM dijkstra_sp_directed('roads_clip','6','2','true','true');

All I get after running this is an empty shortest_path_table.

I have already used this code before and every time (until now) it worked like a swiss watch, so this time the problem seems to be in the data. When I run

SELECT assign_vertex_id('roads_clip', 0.00001, 'the_geom', 'gid');

I get a nice and useable network of vertices, but dijkstra_sp_directed does not return any result. When I modify the tolerance to 0,001 it can find a way. The problem is, that the vertex network is a mess (I need a lot more vertices) and the route pgRouting returns is an even bigger mess (see picture: http://imageshack.us/photo/my-images/89/pgrouting.png/ )

As you can see, not only the returned route (in purple) is a complete nonsense, but also many streets have no vertices assigned, and that is not very useful.

I also tried this: http://www.pgrouting.org/docs/howto/validation.html and the result, (if I set the tolerance in assign_vertex_id to 0,00001) is pretty much the same as the image displayed at the bottom of the page.

So I know something is wrong with the data, the question is: What it is? And how can I fix it?

Thanks for your help

Your Answer

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

Browse other questions tagged or ask your own question.