# Routing problem finding shortest route to line

inspiration on how to solve this problem. (Ascii art, I don't have points to insert picture)

I need to find Z

Z = Shortest route from X Using Road (no point exists here)

O = The points that makes the line

X = Start point

Y = Closest point on line (Can't be used)

The problem right now is: The nearest point (Y) from X will give a long route.

Route from X to Points (O) on line also returns a long route.

Any idea on how I can find Z ??

``````    O(Point)
| ||
Line| ||       O2----------O2 (closer line but no road to this line so this can't be used)
| ||
| ||
|Y||         X (Start point)
| ||         ||
| ||    ||   ||
| ||    ||   ||
| ||    ||
| ||
| ||
| ||
O (Point)
``````

Is there anyway I can take the line and add more points to it on every 5 meters? So the Line would look like O-O-O-O-O-O instead of O---------O

Setup: I have a postgres 9.3 with postgis 2 The database has all X (points) All Lines (linestring) And all roads (Export from openstreet)

(can't get pgrouting to work right now) And a local osrm server running.

• I had a similar problem and instead of creating "psuedo nodes", I ended up using a function that would calculate the portions (whole or partial) reachable along the edges of the network. Have a look at this thread - gis.stackexchange.com/questions/154826/… Commented Oct 8, 2015 at 15:31
• For adding more points to linestrings, see my answer here: gis.stackexchange.com/a/88199/15459! Commented Nov 9, 2015 at 14:47
• You say that no point exists at Z. But if there is no node there, then there's no route from X to either end of the O-O edge. Do you just need to add nodes at line intersections? Commented Apr 30, 2016 at 22:34

To add more points on the line use `ST_Segmentize`.
The easiest solution using pgRouting would be calculating shortest part from X to middle of O and then all alternate paths where the distance is within `shortest path length + half of the length of line o` (which can be done by disabling the last edge used in the route).