none
Calculate distance with api and bing maps return different value RRS feed

  • Question

  • Hi,

    I want to calculate a distance between two points in France.

    Point A : 45,696583 -0,331795

    Point B : 48,1579836112241 -2,74889436850602

    When I use bing maps, it returns 450.1 km

    When I use my method, it returns 352 km

     BingRouteService.RouteRequest routeRequest = new RouteRequest();
            routeRequest.Credentials = new Credentials();
            routeRequest.Credentials.ApplicationId = Properties.Settings.Default.BingApplicationId;
    
            BingRouteService.UserProfile user = new UserProfile();
            user.DistanceUnit = DistanceUnit.Kilometer;
            routeRequest.UserProfile = user;
    
            // creation des points de départ et d'arrivée
            Waypoint start = new Waypoint();
            start.Location = new Location();
            start.Location.Latitude = startPoint.Latitude.TotalDegrees;
            start.Location.Longitude = startPoint.Longitude.TotalDegrees;
            Waypoint end = new Waypoint();
            end.Location = new Location();
            end.Location.Latitude = endPoint.Latitude.TotalDegrees;
            end.Location.Longitude = endPoint.Longitude.TotalDegrees;
    
            // calcul de la route
            routeRequest.Waypoints = new Waypoint[2] { start, end };
            BingRouteService.RouteServiceClient client = new RouteServiceClient();
            BingRouteService.RouteResponse routeResponse = client.CalculateRoute(routeRequest);
    
            distance = (routeResponse != null && routeResponse.Result != null && routeResponse.Result.Summary != null) ? routeResponse.Result.Summary.Distance : 0;
    

    I don't know why there is a difference like that.

    Somebody could help me please ?

    Thanks.

    Fred


    freddyboy
    • Moved by Ricky_Brundritt Friday, March 9, 2012 4:43 PM (From:Bing Maps: Map Control and Web services Development)
    Tuesday, March 22, 2011 4:02 PM

Answers

  • Are you using the same route options? There are several different routes that can be returned between points depending on which route options you are using, or not using. Something as simple as switching between shortest time and shortest distance for a route changes the total distance of the route by over 75km.
    Windows Live Developer MVP - http://rbrundritt.wordpress.com | http://inknowledge.co.uk
    • Marked as answer by freddyboy Wednesday, March 23, 2011 10:02 AM
    Tuesday, March 22, 2011 4:33 PM
  • After trying to get the route through the AJAX API, I've got 450km with default route calculation method.

    		function OnRouteReceived(e) {
    			alert(e.Distance.toFixed(1));
    		}
    		 
    		 
    		 
    		function GetDirection() {
    			var options = new VERouteOptions();
    			options.RouteCallback = OnRouteReceived;
    			options.DistanceUnit = VERouteDistanceUnit.Kilometer;
    
    			var starting = new VELatLong(45.696583, -0.331795);
    			destination = new VELatLong(48.15798361, -2.74889436);
    			map.GetDirections([starting, destination], options);
    		}
    

    Maybe you are not using the right coordinates for start or end, make sure to inspect the value of the WayPoints in the RouteRequest object.

    Or maybe it's just the calculation method that is different (MinimizeTime instead of MinimizeDistance.. and so on..).

     

     


    MVP - Bing Maps - My blog (FR): http://blogs.developpeur.org/nicoboo/ Twitter: http://twitter.com/nicolasboonaert/
    • Marked as answer by freddyboy Wednesday, March 23, 2011 10:02 AM
    Tuesday, March 22, 2011 4:35 PM
    Moderator

All replies

  • Are you using the same route options? There are several different routes that can be returned between points depending on which route options you are using, or not using. Something as simple as switching between shortest time and shortest distance for a route changes the total distance of the route by over 75km.
    Windows Live Developer MVP - http://rbrundritt.wordpress.com | http://inknowledge.co.uk
    • Marked as answer by freddyboy Wednesday, March 23, 2011 10:02 AM
    Tuesday, March 22, 2011 4:33 PM
  • After trying to get the route through the AJAX API, I've got 450km with default route calculation method.

    		function OnRouteReceived(e) {
    			alert(e.Distance.toFixed(1));
    		}
    		 
    		 
    		 
    		function GetDirection() {
    			var options = new VERouteOptions();
    			options.RouteCallback = OnRouteReceived;
    			options.DistanceUnit = VERouteDistanceUnit.Kilometer;
    
    			var starting = new VELatLong(45.696583, -0.331795);
    			destination = new VELatLong(48.15798361, -2.74889436);
    			map.GetDirections([starting, destination], options);
    		}
    

    Maybe you are not using the right coordinates for start or end, make sure to inspect the value of the WayPoints in the RouteRequest object.

    Or maybe it's just the calculation method that is different (MinimizeTime instead of MinimizeDistance.. and so on..).

     

     


    MVP - Bing Maps - My blog (FR): http://blogs.developpeur.org/nicoboo/ Twitter: http://twitter.com/nicolasboonaert/
    • Marked as answer by freddyboy Wednesday, March 23, 2011 10:02 AM
    Tuesday, March 22, 2011 4:35 PM
    Moderator
  • Thanks for your help. I use a 'home framework' that I didn't develop and that's rigth values in WayPoint weren't good. I can't fixed negative value. I have to fixe positive value and I have to affect 'N', 'W' inside our Latitude and Longitude objects...

    After I ajust values when I call bing web service and everything works fine.

    Thank you.

    Have a good day.

    freddyboy
    Wednesday, March 23, 2011 10:02 AM