I am facing a subproblem, where I got database (with postgis, pgrouting) of my city.
I need to make a path / route from point A to B. If this path is longer than xx kilometres then this path has to visit one of given "stop point" (lets call it C). If the path from C to B is longer than xx kilometres then we have to visit one more intermediate "stop point" somewhere between C and B etc.
Asked
Active
Viewed 152 times
0

user3613919
- 777
- 1
- 7
- 17
-
In future, please do not cross-post questions (https://gis.stackexchange.com/questions/241829/function-algorithm-to-find-intermediate-points-if-path-is-too-long). For more information, see [here](http://meta.stackexchange.com/q/64068). – Matt Jun 08 '17 at 09:13
1 Answers
1
This sounds like a loop like this pseudo-code, I would convert it to a plpgsql stored procedure:
A = start
S = stop
B = S
while true {
r = getRoute(A, B)
if length(r) > limit then
B = selectIntermediatepoint(A, B)
else if B == S then
break
else
A = B
B = S
}

Stephen Woodbridge
- 1,100
- 1
- 8
- 16
-
Thanks, I had something common in mind but the point is I don't know how to find that intermediatepoint (selectIntermediatepoint(A, B)). – user3613919 May 27 '17 at 23:22
-
what are your requirements for selecting an intermediate point? Why do you need this intermediate point? Can you just compute the full route then sub-divide that into multiple segments? Or pick a node just short of your limit. This is all going to add to the compute time for the routes. – Stephen Woodbridge May 29 '17 at 00:50