In a previous employment, I needed to display a "Distance to stockist" on our website. It would get your current co-ordinates (from a postcode or HTML5 geolocate) and then display a list of nearby stockists.
Because we only had about 150 stockists in our database, what I could do was:
- Get each stockist from the database
- Work out the distance to that stockist
- Order the list by distance and display it
And due to the small numbers, it was quick and worked well.
However, I'm undertaking something similar now but instead of having 150 stockists to check against, I'm working with a much larger dataset - let's call it somewhere between 10,000 and 20,000 different locations.
I don't feel I can use the same approach because of the time it would take to retrieve the data, calculate the distance to each, and sort it.
So what can I do?
Information I have to me is:
- The user's latitude/longitude co-ordinates
- The latitude/longitude of each location
- The Northings / Eastings of each location
I'm developing in C# with SQL Server 2014 Express. A solution in either C# or T/SQL will be fine.
I have just come across https://msdn.microsoft.com/en-gb/library/ff929109.aspx which I think will do what I need.