Retrieving Features in the Route Response

This article discusses the usecase of calculating 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. and retrieving features in RouteResponse.

Benefits

Retrieves the features from the Feature Layers of every segment in the route list. This can be used for example to get information on traffic incidents on the route.

Prerequisites

Check if the following prerequisites are fulfilled before you start with the use case.

  • Installed and licensed PTV xRoute service.

  • Installed map includes Luxembourg by HERE with the Feature Layer theme PTV_TrafficIncidents.

Concepts

In this scenario different elements in the request are filled and all the features of route segments are returned.

For this purpose, in the request the SegmentResultFields of ResultFields is used.

In this SegmentResultFields

  • The boolean field enabled should be set to true

  • featureThemeIds contains a list of the Feature Layer themes for which the features are to be returned. These themes should belong to the feature layers declared in featureLayerProfile of RequestProfile.

The features are returned in SegmentAttributes with a list of features.

This last contains the themeId and attributes in key value pair form can be retrieved. This last lists all attributes of a segment. For each attribute its type (key) and value is provided via key-value pairs. See the documentation of the layer-specific attributes for more information on the type and the range of available attributes.

Restrictions

Only the themeId and feature descriptions of already declared Feature Layer in the featureLayerProfile of RequestProfile can be used.

Programming Guide

The example below shows how to get the segment features in conjunction with the Feature Layer PTV_TrafficIncidents. Therefor the JavaScript bindings to the xRoute service API is used:

In the example above, a route is calculated and goes through the Traffic Incidents. The message of Traffic Incidents is displayed.