I have been developing an android application for a gas station company. The application uses google map.
The user selects two points on the map and i show the route between selected points.
The application needs to show nearest(in 2 miles radius) gas stations on the selected route.
The route is a coordinate array like:
Route[5000] = {“lon1,lat1″,”lon2,lat2″,”lon3,lat3”,”lon4,lat5″… }
And i have a gas stations list which consists of coordinates.
GasStations[200] = {“lon1,lat1″,”lon2,lat2″,”lon3,lat3”,”lon4,lat5″… }
Can you suggest me a high performance algorithm for calculating the nearest gas stations on the route.
Thanks.
I am not familiar with android. Here the C# method to calculate the distance between two pairs of location. If distance is within 2 miles radius, pick that station.
Yes, you will have to loop through 5000×200 = 1,000,000, but it is quite fast.
I hope that will help.