Changing Stored Tours

This use case describes how to manipulate parts of a calculated tour in a user-defined way.

Benefits

  • Users learn how to use a ChangeToursRequest.
  • Users can adapt tour plans created by the PTV xTour service according to their personal needs.

Prerequisites

Please ensure following prerequisites are fulfilled before you start with the use case:

Concepts

Programming Guide

This example provides the information on how to manipulate parts of a calculated tour according to your preferences.

First, we store tours by passing a PlanToursRequest to the planTours operation of the xTour service.

In order to focus on changing the tour in a second step, the request is kept simple: just visit orders, no opening interval restrictions, just one vehicle using direct distance, and so on. Have a look at other Integration Samples (e.g. Planning a Round Trip) for more realistic scenarios.

Since we want to manipulate the initial tour plan later on, we set the field storeRequest to true. Once xTour has processed the request, a callback is invoked which gives us access the the calculation result in form of a ToursResponse object. The PlanToursRequest (including the current tour plan as input plan) is stored in a session storage and the storedRequestId can be found in the response. This storedRequestId can be used in a ChangeToursRequest to change the current tour plan according to own preferences.

In the comments at the end of the sample code below you find some hints on how to modify the code to apply and observe changes in the displayed tour. Set the local boolean variable applyChangeToursRequest of function planAndChangeSpecificTours() to true to activate the changeTours call. In function getChangeToursRequest() two sample ChangeToursActions are prepared. You can switch between both actions, modify them and add new ones. Note that each change action requires a new ChangeToursRequest. The changeTours operation used to process the ChangeToursRequest also returns a ToursResponse. The modified tour plan is automatically stored in the session storage and can be the basis for further modifications. If you want to further modify the already changed tour, copy the current storedRequestId to the ChangeToursAction. Have a look at Change Tours for details.