Bing Map API vs Bing Map manual RouteRequest. Is the API inaccurate?

I tried to check the accuracy of the Bing Map API. I tried to figure out the distance and time between Chicago O'Hare International Airport and Chicago Midway Airport . It seems that the Bing Map API is completely inaccurate. I double and triple checked it manually using bing cards. 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 a link to the JAR


As a result, I got

 Bing Distance : 42.898 miles Driving Time : 34 minutes 

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

When I tried to use different addresses, the driving time in most cases would be calculated perfectly. However, the distance is almost always higher than the one that I would type in the addresses manually on the Bing Map.,

Is this a problem with the Bing API? Maybe I should use the getDistance method differently?


Although the distances are close to what the Bing Map shows manually, it’s not exactly the same. Why aren't they the same?

Thanks!

+8
java bing-api
source share
1 answer

If you use the actual coordinates manually, the driving time seems the same, if you round the seconds, see the test link . I get 35 minutes, and your result is 34 minutes.

Now, about the distance. In the test link, you can see this 26.7 miles, while your code gives the result 42.898 (you yourself added the β€œmiles”!). Now, if you convert your 26.7 miles to kilometers , you will get 42.9695. Thus, I argue that the result .getDistance () is actually kilometers, not miles.

Looking at Route api seems to confirm this:

distanceUnit

du

Additionally. The units used for the distance in the response.

One of the following values:

  • Mile or mi
  • Kilometer or km [default]

So the numbers you get are pretty accurate IMO.

+7
source share

All Articles