Bing Map API vs Bing Map manual RouteRequest . Is the API inaccurate?
Asked Answered
H

1

8

I tried to test Bing Map API's accuracy . I tried to find out the distance and driving time between Chicago O'Hare International Airport and Chicago Midway Airport . It appears that Bing Map API is completely inaccurate . I double and triple checked it manually with bing maps . Here is the complete code

import net.virtualearth.dev.webservices.v1.common.Credentials;
import net.virtualearth.dev.webservices.v1.common.Location;
import net.virtualearth.dev.webservices.v1.route.BasicHttpBinding_IRouteServiceStub;
import net.virtualearth.dev.webservices.v1.route.RouteRequest;
import net.virtualearth.dev.webservices.v1.route.RouteResponse;
import net.virtualearth.dev.webservices.v1.route.RouteResult;
import net.virtualearth.dev.webservices.v1.route.RouteServiceLocator;
import net.virtualearth.dev.webservices.v1.route.RouteSummary;
import net.virtualearth.dev.webservices.v1.route.Waypoint;

public class Test {


    public static void main(String[] args) throws Exception {

         double [] address1Coordinate = {  41.97980880737305   ,   -87.88204193115234 } ; // Chicago O'Hare International Airport, IL  [I checked the coordinate . It is accurate ]
         double [] address2Coordinate = {  41.7872200012207    ,   -87.74160766601562 } ; // Chicago Midway Airport, IL  [I checked the coordinate . It is accurate ]

        BasicHttpBinding_IRouteServiceStub routeService = (BasicHttpBinding_IRouteServiceStub) (new RouteServiceLocator()).getBasicHttpBinding_IRouteService();

        RouteRequest request = new RouteRequest();
        Credentials creds = new Credentials();
        // I got my Bing map key from here http://msdn.microsoft.com/en-us/library/ff428642.aspx and entered it below : 
        creds.setApplicationId("This is my Bing App Key . . . ");
        request.setCredentials(creds);
        Waypoint[] waypoints = new Waypoint[2];
        waypoints[0] = new Waypoint();
        Location start = new Location();
        start.setLatitude(address1Coordinate[0]); 
        start.setLongitude(address1Coordinate[1]); 
        waypoints[0].setLocation(start);
        waypoints[1] = new Waypoint();
        Location end = new Location();
        end.setLatitude(address2Coordinate[0]); 
        end.setLongitude(address2Coordinate[1]) ; 
        waypoints[1].setLocation(end);
        request.setWaypoints(waypoints);

        RouteResponse response = routeService.calculateRoute(request);
        RouteResult result = response.getResult();

        RouteSummary routeSummary = result.getSummary();

        System.out.println( "Bing Distance : " + routeSummary.getDistance() + " miles ");   
        System.out.println( "Driving Time : " + routeSummary.getTimeInSeconds()/60 + " minutes ");

    }


}

This is the link to the JARs


The result that I got was

Bing Distance : 42.898 miles 
Driving Time : 34 minutes 

The above results are absolutely inaccurate . I compared manually the numbers with Bing Map Click this link to see the difference.

When I tried using different addresses , the driving time would in most cases be calculated fine . . . however the distance is almost always higher than the one that I would get typing in the addresses manually into the Bing Map . . .

Is it the issue with the Bing Map API ? Maybe I should use the getDistance method in a different way ?


Although the distances are close to what Bing Map shows manually however not exactly the same . How come they are not the same ?

Thank You !

Hawk answered 26/1, 2014 at 3:53 Comment(2)
I checked it . . . i do not have enough reputation to say this but it appears that it is a bug with the apiGlazer
Miles? Since when does bing use imperial units in it's API?Hellhound
G
7

If you use actual coordinates manually, the driving time seems to be identical given rounding of seconds, see test link. I get 35 minutes and your floored result is 34 minutes.

Now, about the distance. In the test link you can see it's 26.7 miles, whereas your code gives a result of 42.898 (you added the 'miles' unit there yourself!). Now, if you convert your 26.7 miles to kilometers, you get 42.9695. I would thus claim the result of .getDistance() is actually kilometers, not miles.

By looking at Route api seems to confirm it:

distanceUnit

du

Optional. The units to use for distance in the response.

One of the following values:

  • Mile or mi
  • Kilometer or km [default]

So the numbers you get are pretty much accurate IMO.

Gallipot answered 28/1, 2014 at 7:6 Comment(2)
I guess the "km" comment is correct. However, with all due respect, the numbers although being close are not the same as if you try the same Bing Maps manually. The question was : Where does Bing get those numbers ? Why are not they the same ?Prominence
@Prominence um, manual numbers are rounded more than what java api gives. It would not make sense to show 4 digits to end user. The difference is smaller than the amount of digits shown when using manually. How could they be 100% equal if the accuracy is not the same? What do you expect manual number be in miles, if the distance is 42.898 km? 26.7 is what it should be.Gallipot

© 2022 - 2024 — McMap. All rights reserved.