When setting vehicle restriction parameters via TravelMode.AttributeParameterValues, method RouteTask.CreateAsync throws an Exception with the following message.
Invalid attribute parameter attribute name "Height Restriction".
Invalid attribute parameter attribute name "Weight Restriction".
Invalid attribute parameter attribute name "Width Restriction".
I've been unable to find documentation for the values in the .Net or UWP section of the API reference, here:
Class AttributeParameterValue (arcgis.com)
However, there is explanation of these values in the REST services documentation here:
Direct request—ArcGIS REST APIs | ArcGIS Developers
Please advise if there is something incorrect in the code or parameters and how I can set vehicle restrictions to apply to SolveRouteAsync, specifically height, width and weight restrictions. And if there is a documentation page I can refer to.
Sample code:
RouteTask offlineRouteTask = await RouteTask.CreateAsync(Convert.ToString(dataPath), networkName);
RouteParameters routeParams = await offlineRouteTask.CreateDefaultParametersAsync();
List<Stop> routeStops = new List<Stop> { new Stop(fromPoint), new Stop(toPoint) };
routeParams.SetStops(routeStops);
routeParams.TravelMode.Type = "Driving";
routeParams.ReturnDirections = true;
routeParams.ReturnStops = true;
routeParams.DirectionsStyle = DirectionsStyle.Navigation;
routeParams.TravelMode.UTurnPolicy = UTurnPolicy.NotAllowed;
var attributes = routeParams.TravelMode.AttributeParameterValues;
attributes.Add(new AttributeParameterValue { AttributeName = "Height Restriction", ParameterName = "Vehicle Height (meters)", ParameterValue = 3.3 });
attributes.Add(new AttributeParameterValue { AttributeName = "Weight Restriction", ParameterName = "Vehicle Weight (kilograms)", ParameterValue = 12500 });
attributes.Add(new AttributeParameterValue { AttributeName = "Width Restriction", ParameterName = "Vehicle Width (meters)", ParameterValue = 2.5 });
Graphic routeGraphic = null;
try
{
RouteResult solvedRouted = await offlineRouteTask.SolveRouteAsync(routeParams);
}
catch (Exception ex)
{
// Log Exception
}