I'm trying to implement pgrouting with MapServer. It works right now but I have to enter the number of the source and target nodes in my mapfile by myself. What I want to do, is being able to use a click on the map and select start and end points. So the tutorial I'm following suggests that I create a VIEW in postgresql which is the following:
CREATE VIEW shortest_path AS SELECT min(r.seq) AS seq, e.old_id AS id, e.street, e.district, sum(e.time) AS time, sum(e.distance) AS distance, ST_Collect(e.geom) AS geom FROM pgr_dijkstra( 'SELECT id, source::INT4, target::INT4, %cost% AS cost, FROM roads_noded', %source%, %target%, false) AS r, roads_noded AS e WHERE r.id2 = e.id GROUP BY e.old_id, e.street, e.district;
but I get the following error:
ERROR: syntax error at or near "%" LINE 17: FROM roads_noded', %source%, %target%, false) AS r, ^ ********** Error ********** ERROR: syntax error at or near "%" SQL state: 42601 Character: 302
In the beginning I assumed it because of the percentage symbol so I put %source% in quotes like '%source%'. But then I got another error:
ERROR: function pgr_dijkstra(unknown, unknown, unknown, boolean) is not unique SQL state: 42725 Hint: Could not choose a best candidate function. You might need to add explicit type casts. Character: 192
So, I'm quite new to this. Am I going the right way? What is wrong here?