While working with PostGIS pgrouting
, for calculating the distance between two roads (lines) I'm using the shortest_path
function.
The logic is based on start_point(Start_id)
and end_point(end_id)
but in my data the line string contains many internal points like (linestring(1 1,2 2,3 3,4 4,5 5)
for example.)
So it is taking the start point as (1 1)
and the endpoint as (5 5)
. If another line starts with (5 5)
it shows as route like linestring(5 5,6 6)
.
But a line which has a crossing point inside the linestring like (2 2,3 3,4 4)
is not considered connected.
For example, using this roads table:
id name way
1 A linestring(1 1,2 2,3 3,4 4,5 5)
2 B linestring(5 5,6 6)
3 c linestring(2 1,2 2,2 3)
If I apply the shortest_path
function from point (1 1)
to (6 6)
, it does determine a path. But for (1 1)
to (2 3)
it doesn't find anything. It does not find the (1 1,2 2,2 3)
route.
What do I need to do so that the function considers each segments internal points rather than only the start and end points of the lines?