Planning a Tour for Close-by Warehouses and Subcontractor Delivery

In this use case there are several types of goods to be delivered, which are stored in different, but close-by warehouses. Customers often order products from different warehouses. The execution of the tours is done by a subcontracting carrier which leaves the aspect of empty route legsClosed A route leg is a part of a route between two consecutive waypoints. when returning to the vehicleClosed The term vehicle describes what is being routed or planned for. Vehicles are used in route calculation, distance matrix calculation and effectively also in tour planning. In route calculation, vehicle properties like overall size, weight and speed are in focus. In tour planning, it is vehicle properties like capacity and availability. Commonly a vehicle is motorized, like a truck - including its trailer or a car. However also a bike or even a pedestrian are included in this definition. location of no interest to the dispatcher.

Example | The following picture shows an example of the desired tour structure

Geographical tour structure and stop sequence for several warehouses and subcontractor delivery.


  • Users learn how to parametrize the current use-case.
  • Basic insight into how to influence the course of a tour.


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

  • Installed and licensed PTV xTour service
  • License for as many vehicles as the plan should contain


Programming Guide

This example explains how the request should look like in order to influence the tour structure as mentioned in the use-case description above.

First we define our locations as OffRoadRouteLocations in the default EPSG:4326 format (see RequestBase.coordinateFormat). You could also use OnRoadRouteLocations, see the technical concept on waypoints and route legs for more information on the different types of route locationsClosed A route location is the position of an object to be routed to or from, which contains additional information on how to link this position to the road network and whether or or not this position is actually reached. Route locations are used as the input for route calculation and optimization throughout PTV xServer.. Since the use case describes deliveries from several depots, we define some locations as depot and some as customer sites, see Orders, Locations, and Stops for more details.

The fleet in this example consists of one type of vehicle, containing one available vehicle instance (defined by the number of vehicle ids). This vehicle has unspecified start and end locations since the return to the carrier location before and after delivering all goods is of no importance for the further planning. To simplify the example code, we assume that the vehicle uses direct distance (can be set in the distance mode of the request).

In this example we do not want to return to the depot(s) in between stops at customers, so we need to activate the tour restriction singleTripPerTour. This restriction could be omitted if other tour structures should be allowed.

The last part of the example request are the orders, in this case only consisting of pickup and delivery orders.

We pass the request on to planTours. Once xTour has processed the request a callback is invoked which gives us access to the result of the calculation in form of a ToursResponse object.

The customer sites of the request are displayed in gray, the depot sites in orange. Since the ToursResponse only contains references to the given locations, the corresponding coordinates are taken from the request. The tour of the result is displayed in gray.

The vehicle starts at the first depot (DepotA), carries out all pick-up tasks at the three depots and the delivers everything to the customers. The tour ends at the last customer, in this case Customer4, because the return to the carriers vehicle location is of no interest for this kind of trip planning.