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 ");
}
}
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 !