Optimizing Bing Maps Geocode and RouteMapping requests Optimizing Bing Maps Geocode and RouteMapping requests ajax ajax

Optimizing Bing Maps Geocode and RouteMapping requests


I am planning to do something similar in the very near future, so I have a few suggestions, but no actual code to share yet. I hope it is useful.

I expect to store the lat/lon for each item in my db (so it is geocoded only once). To select items within a certain distance from a point, I will calculate the lat/lon numbers which are 'x' miles north/south/east/west of my center point. Then the selection becomes a simple matter of picking records where the lat/lon values fall between the values of my square.

And yes, I know that technically I should use a circle to precisely control the distance, but this is so much easier and faster. If you really need to use a circle for a more precise limit, use this method first, then use more complex calculations to weed out the items outside the circle in the corners.

I am not familiar with Bing's licensing, but if I remember correctly about google, you need to have a paid (commercial) license to store the results of geocoding. And it ain't cheap. So that may negate any value my suggestion might have had :(

Edit; I just read the question a little more carefully, and I see that it is talking about driving miles, not linear miles. So, my answer isn't really applicable, unless you want to use it as a way to narrow down the number of driving distance calculcations you have to do.

Also, on the subject of geocoding and licenses, you could look at geocoder.us which is pretty cheap.


What you probably want to do is create a minimum spanning tree assuming you have the same destination location for the user. The MST still is O(V^2), but you're effectively caching many of the shortest paths since a lot of them will reuse the same roads.

Another option is to estimate using linear distances first as a substitute for road miles, but that all depends on what you're sending back to the user.

Good luck !