Hot answers tagged pgrouting
The possible cause is what the error says: the first argument of the pgr_dijkstra(sql:text,..) function must contain an SQL statement, which returns id, source, target and cost. In your case you query for gid, but it should return id as column name. SELECT id, id1 AS node, id2 AS edge, cost, the_geom FROM pgr_dijkstra( 'SELECT gid AS id, source, ...
You can use the pgRouting function pgr_nodeNetwork, which will create nodes at intersections of linestrings. So in your case it will split the linestring into two geometries. But there is a danger that intersections, that should not be connected (ie. over- or under-passes), will also get broken into two segments.
You could do the following: Find the nearest edge to A and B Then use ST_LineLocatePoint und you get a ratio of where the nearest point lies on that edge. With ST_LineInterpolatePoint you get the coordinates of each point on their nearest edge and with ST_LineSubstring you could also get the partial geometries, but that's not necessary for the shortest ...
Only top voted, non community-wiki answers of a minimum length are eligible