Considering Long-term Blockings
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 only the long-term blockings.
Benefits
Calculates the best route taking into account only long-term closures for a certain period. This allows for example to determine the typical routes for a planning project.
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
The Feature Layer PTV_TruckAttributes defines specific attributes for road like maximum weight, height, etc..., but contains also information like road closure which could be time-dependent (every morning between 7h-9h near a school, for example). With the requestOption timeConsideration it is possible to define the way how this time-dependent information should be taking into account. For details see the technical concept about time consideration.
Regarding the specific usecase of long-term blockings, the TimeSpanConsideration scenario can be used.
This scenario allows to define a specific interval during which the time-dependent attributes should be considered. Typically, if a road is blocked during the whole period, it will be considered as blocked. Otherwise, the road will be considered as not blocked. Considering this period, whatever the real departure time of the 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., only these long-term attributes would be considered for the route calculation.
Programming Guide
The example below shows the calculation of a route in conjunction with the Feature Layer PTV_TruckAttributes, using TimeSpanConsideration scenario. Therefore the JavaScript bindings to the xRoute service API is used:
var referenceTime = "2017-08-23T12:00:00+01:00"; var timeSpan1 = 1; // 1 hour var timeSpan2 = 12; // 12 hours var featureLayerProfile = { "themes": [{ "enabled": true, "id": "PTV_TruckAttributes" }] } var A = { "$type": "OffRoadWaypoint", "location": { "offRoadCoordinate": { "x": 6.124995946884156, "y": 49.589077328363246 } } }; var B = { "$type": "OffRoadWaypoint", "location": { "offRoadCoordinate": { "x": 6.1227428913116455, "y": 49.58862524284309 } } }; 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' + '&timeConsideration=SNAPSHOT&referenceTime=' + encodeURIComponent(referenceTime) + '&showOnlyRelevantByTime=false' + '&contentType=JSON', { pane: "overlayPane", maxZoom: 20, }).addTo(map); var outputString = ""; //----- Route ----- function calculateSpecificRoute(ts) { xroute.calculateRoute({ "requestProfile": { "featureLayerProfile": featureLayerProfile }, "waypoints": [A, B], "routeOptions": { "timeConsideration": { "$type": "TimeSpanConsideration", "referenceTime": referenceTime, "timeSpan": ts * 3600 } }, "resultFields": { "polyline": true }, "geometryOptions": { "responseGeometryTypes": ["GEOJSON"] } }, function(route, exception) { var geoJson = route.polyline.geoJSON; if(ts == timeSpan1) { displayGeoJson(geoJson, '#ffa225'); } else { displayGeoJson(geoJson, '#2882C8'); } outputString += 'timeSpan=' + ts + ' h => route= '+ route.distance +' m in ' + route.travelTime + ' s '; print(outputString); }); } function displayGeoJson(geoJson,color) { var jsonObject = JSON.parse(geoJson); var geoJsonLayer = new L.GeoJSON(jsonObject, { style: { color: color, weight: 8 } }).addTo(map); map.fitBounds(geoJsonLayer.getBounds()); }; calculateSpecificRoute(timeSpan1); calculateSpecificRoute(timeSpan2);In the example above, a route is calculated twice with the same reference time (12 p.m.) but different time spans. The shortest route passes through a segment with a time-dependent restriction : it is blocked from Monday to Friday between 8h-17h.
- timeSpan = 1h, the orange line
The restriction is active between 8h-17h, so the route should avoid the restricted section. - timeSpan = 12h, the blue line
The restriction is not always active between 12h p.m - 12 a.m., so the route can go through the section.