0
SELECT id FROM table ORDER BY st_distance(the_geom, st_setsrid(st_makepoint($slng,$slat), 4326)) limit 1
; get source and similar for target
; and then apply in dijkstra algo
SELECT pgr_a('SELECT id AS id, source, target,length AS cost, x1, x2, y1, y2 FROM ways',$source,$target,false,false))
SELECT id_0, st_AsText(geom) FROM table w, a a WHERE w.id = (a.pgr_a).id2

and getting linestring but it is not perfect up to staring point and ending point...enter image description here

it is display up to node not up to point b

1

This is how pg_routing works. If you want to have route from specified points not from start or end of edge you have to perform some post-processing. I've answered similar question here. I think this could be what you're looking for.

|improve this answer|||||

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