3

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)
    | ||         ||
    | ||    ||   ||Road
    | ||    ||   ||
    | ||    ||   ||
    |Z||----||----Road
    | ||    ||
    | ||    ||------------- Road
    | ||
    | ||Road
    | ||
    | ||
    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.

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
dk_nls
  • 83
  • 1
  • 4
  • 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 - http://gis.stackexchange.com/questions/154826/return-nodes-along-portions-of-edges-with-pgrouting – Brent Edwards Oct 08 '15 at 15:31
  • For adding more points to linestrings, see my answer here: http://gis.stackexchange.com/a/88199/15459! – Stefan Nov 09 '15 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? – alphabetasoup Apr 30 '16 at 22:34

1 Answers1

1

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).

Jakub Kania
  • 2,814
  • 15
  • 20