Considering custom Feature Layers preferring, restricting or unrestricting roads

Custom Feature Layers allow to set preference levels when computing a routeClosed A route corresponds to a path of a vehicle through the underlying transport network. The main attributes of a route are the distance and the time that the vehicle travels along the path., for instance to prefer or to avoid some roads. The process is done in 2 steps. At first, custom Feature Layer is created to assign custom road class to the segments. Then, it is also possible to choose per request the preference level to apply for each custom road class. Moreover, note that polygons are used to get segmentIds with the getSegments() operations in the following examples.

Preferring some roads

Sometimes a road should be preferred for any reasons. Preferring a route consists in favoring the passage by a route even it is not the fastest or the shortest. Thus, the access from one side of a city can be preferred without being mandatory for examples, due to best maintained roads, less traffic lights or simply because this way is more scenic. This first example shows how to mark, using the customRoadClass property, the roads that must be preferred during the route calculation.

The dashed blue route is the optimal one, the blue route is the prefer one.

Avoiding some roads

The documentation of the vehicle profile list all the other possibilities to use a custom road class. This second example shows how to mark, using the customRoadClass property, the roads that must be restricted (i.e. avoided) during the route calculation.

The dashed blue route is the shortest, but the routing restricts the access due to the using of the custom road class as 'restrictedRouteTypes'. So another route (blue) is taken.

Ignoring TruckAttributes penalties within an area

Users have the possibility to reset the penalties inherited from other Feature Layer themes (like PTV_TruckAttributes or PTV_PreferredRoutes), for certain segments.

A first route is computed (dashed blue line). This route does not take the shortest path. It makes a detour because there is a weight restriction on the optimal route (restriction from PTV_TruckAttributes layer). Then, a custom Feature Layer is created to locally override this weight restriction. As a result, the route (blue) takes the shortest path in this case.