Considering Vehicle Parameters at Waypoint
This article discusses the usecase of calculating a route 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. by taking into account the changes of vehicle 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. parameters at waypoint A waypoint is a geographic location used to specify start, destination and possible stopovers for a route..
Benefits
Calculates the best route and returns accurate emission and toll values, considering some structural changes on the vehicle. For example, the route is dependent of the loading weight of the vehicle ; this weight can change during a route when delivering or picking goods.
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_TruckAttributes.
Concepts
During a route with intermediate waypoints, some parameters of the vehicle can change. For example, the fact that the vehicle picks or delivers goods, changes the loadWeight of the vehicle.
The consequences of changing some vehicle parameters are multiples.
- These changes could affect the best calculated route, making a detour or on the opposite, don't do this detour anymore.
- These changes may affect also the calculation of the emissions, tolls,... without changing the route.
For each waypoint of the route request, it is possible to specify some vehicle parameters. For the list of parameters, please refers to VehicleParametersAtWaypoint.
Please note that if a parameter is changed at an intermediate waypoint, it remains changed until the end of the route, or until the parameter is changed again at another waypoint.
Programming Guide
The example below shows the calculation of a route with an intermediate waypoint, in conjunction with the Feature Layer PTV_TruckAttributes, using the capability to change vehicle parameters at waypoint. Therefore the JavaScript bindings to the xRoute service API is used:
var featureLayerProfile = { "themes": [{"enabled": true, "id": "PTV_TruckAttributes"}] } var A = { "$type": "OffRoadWaypoint", "location": {"offRoadCoordinate": {"x": 5.986546188502945, "y": 49.57593339522088}} }; var B = { "$type": "OffRoadWaypoint", "location": {"offRoadCoordinate": {"x": 5.98467037156937, "y": 49.587011000678885}} }; var B_changed = { "$type": "OffRoadWaypoint", "location": {"offRoadCoordinate": {"x": 5.98467037156937, "y": 49.587011000678885}}, "vehicleParameters": {"weight": {"loadWeight": 0}} }; var C = { "$type": "OffRoadWaypoint", "location": {"offRoadCoordinate": {"x": 5.991911482913518, "y": 49.61590725276622}} }; var map = new L.Map('map', { center: [49.587, 6.220], zoom: 13 }); // Add tile layer to map new L.tileLayer.xserver(xServerUrl + '/services/rest/XMap/experimental/tile/{z}/{x}/{y}' + '?layers=background,transport,labels,PTV_TruckAttributes' + '&contentType=JSON', { pane: "overlayPane", maxZoom: 20, }).addTo(map); var outputString = ""; //----- Route ----- function calculateSpecificRoute(modified) { let wps = modified ? [A, B_changed, C] : [A, B, C]; xroute.calculateRoute({ "storedProfile": "truck7_49t", "requestProfile": { "featureLayerProfile": featureLayerProfile, "vehicleProfile": {"weight": {"emptyWeight":3000}} }, "waypoints": wps, "resultFields": {"polyline": true}, "geometryOptions": {"responseGeometryTypes": ["GEOJSON"]} }, function(route, exception) { var geoJson = route.polyline.geoJSON; if(!modified) { displayGeoJson(geoJson, '#ffa225'); outputString += ' orange route => '+ Math.trunc(route.distance/1000) +' km in ' + Math.trunc(route.travelTime/60) + ' min'; } else { displayGeoJson(geoJson, '#2882C8'); outputString += ' || blue route => '+ Math.trunc(route.distance/1000) +' km in ' + Math.trunc(route.travelTime/60) + ' min'; } print(outputString); }); } function displayGeoJson(geoJson,color) { var jsonObject = JSON.parse(geoJson); var geoJsonLayer = new L.GeoJSON(jsonObject, { style: {color: color, weight: 4, dashArray: "4,10", lineCap: 'square'} }).addTo(map); map.fitBounds(geoJsonLayer.getBounds()); }; function displayWaypoints() { new L.circleMarker([A.location.offRoadCoordinate.y, A.location.offRoadCoordinate.x], {color: 'green', fillOpacity: 0.7, radius: 7}).addTo(map); new L.circleMarker([B.location.offRoadCoordinate.y, B.location.offRoadCoordinate.x], {color: 'orange', fillOpacity: 0.7, radius: 7}).addTo(map); new L.circleMarker([C.location.offRoadCoordinate.y, C.location.offRoadCoordinate.x], {color: 'red', fillOpacity: 0.7, radius: 7}).addTo(map); } calculateSpecificRoute(false); calculateSpecificRoute(true); displayWaypoints();In the example above, a route with one intermediate stop is calculated twice.
The goal is to demonstrate that changing some vehicle parameters at the intermediate point, changes the route. For that we will use the PTV_TruckAttributes restrictions.
- the full-loading route (orange line)
If the vehicle is fully loaded, its weight is over 3500kg. The route should avoid all the restrictions and a detour is computated. - the empty-loading route (blue line)
At the intermediate waypoint, the vehicle is emptied. The final route contains two legs. The first leg try to avoid the restrictions as much as possible (like the orange line). The second leg can pass through the restrictions, as the weight of the vehicle is now below the 3500kg.