Thx Joost and Bernd for your quick answers.
Yes, I understand that the speed values have a lot of influences. It makes sense that if the route is calculated for a car that the quicker route is via A7.
For the speed values I take the default values in 'truck11_99t'. I also use 'PTV_TruckAttributes' as theme.
I dont not understand why the penalties (default ones of truck11_99t: [0, 20, 30, 35, 40, 90, 100, 100]) do influence the route for distanceTimeWeighting = 100 and not for values below ~80.
I thought the route is punished the same way (not depending on distanceTimeWeighting).
So for example if the direct route in my example is bad because of the penalties -> for both values of distanceTimeWeighting the result route should be via a7.
@Joost: I tried distanceTimeWeighting = 65. I got kind of the same route as for distanceTimeWeighting = 0. It is also quicker then the distanceTimeWeighting = 100 route (via A7). I dont get any violations of the route. I could not find any details in the API for "aStarAggressiveness". (We are using PTV2).
Do you have a recommendation how we can get the shortest and the fastes route. It doesnt have to be the global minumum, but the fastest route should be not slower than the shortest.
My full request including the json which I used for this example in Integration Samples/Calculating the Shortest or the Fastest Route is:
Code: Select all
var A = {
"$type": "OffRoadWaypoint",
"location": {
"offRoadCoordinate": {
"x": 9.94179,
"y": 50.93384
}
}
};
var B = {
"$type": "OffRoadWaypoint",
"location": {
"offRoadCoordinate": {
"x": 9.9040498475,
"y": 51.530239138
}
}
};
var map = new L.Map('map', {
center: [49.61, 6.125],
zoom: 13
});
// Add tile layer to map
var tileUrl = xServerUrl + '/services/rest/XMap/tile/{z}/{x}/{y}';
var tileLayer = new L.TileLayer(tileUrl, {
minZoom: 3,
maxZoom: 18,
noWrap: true
}).addTo(map);
var outputString = '';
function calculateSpecificRoute(dtw) {
xroute.calculateRoute({
"waypoints": [A, B],
"resultFields": {
"polyline": true
},
"requestProfile": {
"featureLayerProfile": {
"themes": [{
"enabled": true,
"id": "PTV_TruckAttributes"
}]
},
"routingProfile": {
"searchSpace": {
"heuristicAggressiveness": 0,
},
"course": {
"distanceTimeWeighting": dtw,
"violations": {
"enabled": false
},
"network": {
"rampPenalty": 0,
//taken from the default
//"penaltiesByNetworkClass": {
// "penalties": [0, 0, 0, 0, 40, 90, 100, 100]
//}
},
"maneuver": {
"uTurnCost": 0
}
}
}
},
"geometryOptions": {
"responseGeometryTypes": ["GEOJSON"]
},
"storedProfile": 'truck11_99t'
}, function(route, exception) {
var geoJson = route.polyline.geoJSON;
if (dtw < 70) {
displayGeoJson(geoJson, '#ffa225');
outputString += 'shortest route: ' + route.distance + ' m in ' + route.travelTime + ' s violated:' + route.violated + ' ';
} else {
displayGeoJson(geoJson, '#2882C8');
outputString += '|fastest route: ' + route.distance + ' m in ' + route.travelTime + ' s violated:' + route.violated + ' ';
}
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(65);
calculateSpecificRoute(100);