Route Request Time out
-
terça-feira, 17 de julho de 2012 08:00
Hi,
can anyone suggest me over these condition....
1. i have 2000 OR more Points(Locations) from database
2. i m passing the each location from 2000 Points to the method having RouteRequest object.OBJECTIVE: trying to achieve the location for each point(which is passed from database) on the nearest Road.
GETTING EXCEPTION :The HTTP request to 'http://dev.virtualearth.net/webservices/v1/RouteService/RouteService.svc' has exceeded the allotted timeout. The time allotted to this operation may have been a portion of a longer timeout.
//calling the function to add pushpin for nearest road location foreach (Location item in _elementsLocationsInCircle2) { GetLocationOnTheNearestRoad(item); } .................................................................................................................... private void GetLocationOnTheNearestRoad(Location location) { bool httpsUriScheme = !Application.Current.IsRunningOutOfBrowser && HtmlPage.Document.DocumentUri.Scheme.Equals(Uri.UriSchemeHttps); BasicHttpBinding binding = new BasicHttpBinding(httpsUriScheme ? BasicHttpSecurityMode.Transport : BasicHttpSecurityMode.None); binding.MaxReceivedMessageSize = int.MaxValue; binding.MaxBufferSize = int.MaxValue; UriBuilder serviceUri = new UriBuilder("http://dev.virtualearth.net/webservices/v1/RouteService/RouteService.svc"); if (httpsUriScheme) { //For https, change the UriSceheme to https and change it to use the default https port. serviceUri.Scheme = Uri.UriSchemeHttps; serviceUri.Port = -1; } //Create the Service Client RouteService.RouteServiceClient routeClient = new RouteService.RouteServiceClient(binding, new EndpointAddress(serviceUri.Uri)); routeClient.CalculateRouteCompleted += new EventHandler<RouteService.CalculateRouteCompletedEventArgs>(routeService_CalculateRouteCompleted); // Set the token. RouteService.RouteRequest routeRequest = new RouteService.RouteRequest(); routeRequest.Credentials = new RouteService.Credentials(); routeRequest.Credentials.ApplicationId = ((ApplicationIdCredentialsProvider)this.MainMap.CredentialsProvider).ApplicationId; // Return the route points so the route can be drawn. routeRequest.Options = new RouteService.RouteOptions(); routeRequest.Options.RoutePathType = RouteService.RoutePathType.Points; // Set the waypoints of the route to be calculated using the Geocode Service results stored in the geocodeResults variable. routeRequest.Waypoints = new System.Collections.ObjectModel.ObservableCollection<RouteService.Waypoint>(); //waypoints RouteService.Waypoint firstPoint = new RouteService.Waypoint(); firstPoint.Location = new RouteService.Location(); firstPoint.Location.Latitude = location.Latitude; firstPoint.Location.Longitude = location.Longitude; RouteService.Waypoint copyOfFirstPoint = new RouteService.Waypoint(); copyOfFirstPoint.Location = new RouteService.Location(); copyOfFirstPoint.Location.Latitude = location.Latitude; copyOfFirstPoint.Location.Longitude = location.Longitude; routeRequest.Waypoints.Add(firstPoint); routeRequest.Waypoints.Add(copyOfFirstPoint); routeClient.CalculateRouteAsync(routeRequest); } private void routeService_CalculateRouteCompleted(object sender, RouteService.CalculateRouteCompletedEventArgs e) { try { // If the route calculate was a success and contains a route, then draw the route on the map. if ((e.Result.ResponseSummary.StatusCode == RouteService.ResponseStatusCode.Success) & (e.Result.Result.Legs.Count != 0)) { Location pointonNearestRoad = new Location(e.Result.Result.Legs[0].Itinerary[0].Location.Latitude, e.Result.Result.Legs[0].Itinerary[0].Location.Longitude); _collectionOfPointsOnRoad.Add(pointonNearestRoad); _mapDrawLayer.Children.Add(new Pushpin() { Location = pointonNearestRoad }); } } catch (Exception) { throw; } }
Thanks & Regards
prakash kumar
Todas as Respostas
-
terça-feira, 17 de julho de 2012 08:34Proprietário
Are you passing these in a loop or something? Or are you just manually passing in one point at a time? It looks like you are just trying to geocode. Note the start and end points must be different. If you want the nearest point on the road then use the geocoding method, there is no need to use the routing service. The geocoding service will be much faster than the routing service and give you the same information you are looking for. Going a step further I highly recommend using the REST geocoding service as it will be significantly faster and more accurate than the SOAP services. The SOAP services should be avoided for all new development. Take a look at this document for using the REST services in .NET: http://rbrundritt.wordpress.com/2012/01/06/bing-maps-rest-service-net-libraries/
Also, you should be using the GetCrednetials method on the Map's Credentials provider so that you create a session key. A session key will mark these requests as non-billable. The way you are currently doing it every request is a billable transaction against your account.
http://rbrundritt.wordpress.com
- Sugerido como Resposta Richard_BrundrittMicrosoft Employee, Owner terça-feira, 17 de julho de 2012 08:34
- Marcado como Resposta Richard_BrundrittMicrosoft Employee, Owner quarta-feira, 25 de julho de 2012 08:40
-
terça-feira, 17 de julho de 2012 09:37
yes m passing these in a loop
foreach (Location item in _elementsLocations) { GetLocationOnTheNearestRoad(item); }...............................................
in Geocoding how can i get the Location on the nearest for a point which is not on the road.is it possible????if yes plz sugget me...
using route services it is taking 40 seconds for 250 points.
-
terça-feira, 17 de julho de 2012 10:04Proprietário
The geocoding service (in REST) returns a value called the UsageType, this will say routable for points which are on the road. Also, all addresses have points on the road. This is usually also the default coordinate. Basically you are over complicating things. If you just use the default functionality of the Geocoding service and the standard coordinates returned you would be getting the points that are on the road.http://rbrundritt.wordpress.com
- Marcado como Resposta Richard_BrundrittMicrosoft Employee, Owner quarta-feira, 25 de julho de 2012 08:40
-
sexta-feira, 27 de julho de 2012 11:53
//increasing time interval for routerequest
TimeSpan ts=new TimeSpan(2,30,0);
binding.ReceiveTimeout = ts;
binding.OpenTimeout = ts;
binding.SendTimeout = ts;Thanks
- Marcado como Resposta prakash_light sexta-feira, 27 de julho de 2012 11:53
- Não Marcado como Resposta Richard_BrundrittMicrosoft Employee, Owner sexta-feira, 27 de julho de 2012 18:44

