How to make route calculations work?

1088
1
02-08-2017 02:44 AM
ThomasGustafsson1
New Contributor

Hi,

I have had this functionality to work perfectly.

But now recieve a 403 or 404 error whem I try to calculate the shortest driving distance for a firetruck to the fire in order to choose the most suitable toalarm.

I am using ArcGis onlie with the URLs:

"https://webadaptor.domain.com/arcgis/rest/services/folder/servicename/NAServer/Route"

or

"http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World". please advice.

Btw. Is it possible to make the map calculate the route for a firetruck and not a nomal car? (not the same restriction in trafic..)

Kind regards

Thomas Gustafsson

0 Kudos
1 Reply
ThomasGustafsson1
New Contributor

The exact error returned are e.g. this:

Find distance error:Error code '403':'User doesnot have permissions to access 'world/route.mapserver'.'

I get the errortext, but this has worked before.

My code is here:

      double totalMiles = 0;//double.MaxValue;
      try
      {
        MapPoint fromPoint = new MapPoint(fromLon, fromLat, SpatialReferences.Wgs84);
        MapPoint toPoint = new MapPoint(selected.lon, selected.lat, SpatialReferences.Wgs84);
        var fromSym = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.X, Size = 50, Color = Colors.Green };
        var toSym = new SimpleMarkerSymbol { Style = SimpleMarkerStyle.X, Size = 50, Color = Colors.GreenYellow };
        var fromMapGraphic = new Graphic { Geometry = fromPoint, Symbol = fromSym };getLayer("graphicsLayer").Graphics.Add(fromMapGraphic);
        var toMapGraphic = new Graphic { Geometry = toPoint, Symbol = toSym }; getLayer("graphicsLayer").Graphics.Add(toMapGraphic);
        //var uri = new Uri("https://webadaptor.domain.com/arcgis/rest/services/folder/servicename/NAServer/Route");
        var uri = new Uri("http://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World");
        var routeTask = new OnlineRouteTask(uri);
        var routeParams = await routeTask.GetDefaultParametersAsync(); //MessageBox.Show(routeParams.ToString());
        routeParams.OutSpatialReference = ihmMapView.SpatialReference;
        routeParams.DirectionsLengthUnit = LinearUnits.Kilometers;
        routeParams.DirectionsLanguage = new System.Globalization.CultureInfo("EN");
        routeParams.ReturnDirections = true;
        routeParams.OutputLines = Esri.ArcGISRuntime.Tasks.NetworkAnalyst.OutputLine.Default;
        routeParams.FindBestSequence = true;

        var stopGraphics = new List<Graphic>();
        //stopGraphics.Add(fromMapGraphic);
        //stopGraphics.Add(toMapGraphic);
        routeParams.SetStops(stopGraphics);

        var routeResult = await routeTask.SolveAsync(routeParams);

I (and the Danish firetrucks) would really apreciate some help here.

0 Kudos