Suppose I have a database storing 1000000 geolocations of different users in a city. It will be painful for the server to execute the command SearchNearbyUsers(myLocation, 50)
if I use a list or array to hold all the geolocations and compare the distances one by one.
The server is coded in C# with Web API 2. Is there any library designed for doing such calculations with geolocations?
If there is not any library available, what data structure should be used in order to make this calculation easier? I have looked at R-tree before, but to be honest, I do not understand the logic clearly and it seems to be quite complex.
This is what the geolocation class looks like:
public class GeoLocation
{
public float latitude { get; set; }
public float longitude { get; set; }
}
Both the latitude and longitude are sent by clients. Values are obtained via navigator.geolocation.getCurrentPosition()
.