Question
You want to calculate a route with multiple waypoints (e.g., A → B → C) using the xRoute service in PTV Developer or PTV xServer, and you also want to get alternative routes for the full journey.
Answer
When calculating a route with only two waypoints (i.e., a single origin and destination), the result is a single leg and calculating alternative routes is straightforward.
However, when you use more than two waypoints, the route is split into multiple legs, and computing alternatives for the entire route introduces challenges:
Why full-route alternatives don’t scale with multiple waypoints:
Combinatorial Complexity
Each leg may offer multiple alternatives. Combining these leads to exponential growth.
Example: 3 legs × 2 alternatives = 2³ = 8 combinationsPerformance Impact
This dramatically increases calculation time and system load.Timeout Risks
Long response times can trigger timeouts or incomplete responses.
Recommended Approach
Instead of calculating full-route alternatives over multiple waypoints, split the journey into individual legs:
Step 1: Send a route request for A → B, with alternatives.
Step 2: Send a route request for B → C, with alternatives.
Repeat for additional segments.
This approach:
Simplifies the logic
Avoids timeouts
Keeps performance optimal
Additional hints
Applicable to both PTV Developer (Routing) and PTV xServer (xRoute).
You can stitch together the individual responses manually if needed for display or navigation purposes.
Consider using a route concatenation logic on the client side if maintaining a global route context is important.