Given this the scenario:
- We have the order of 1,000,000 points around the world, specified by longitude and latitude;
- We have a circle c based on a point pc (specified by longitude and latitude) and a radius rc
- We want to efficiently determine which of the points are in the circle
I'm developing in C# and the locations stored in SQL server 2008.
So as I see it I have these 3 options:
Store the locations as longitude latitude floats and perform the calculations in C#.
Store the locations as geographical data types and perform the calculations in SQL server 2008 like this:
CREATE TABLE UserLocations [UserId] [bigint] NOT NULL, [CurrentLocation] [geography] NOT NULL ALTER PROCEDURE sp_GetCurrentUsersInRange @userPoint geography, @RangeInMeters int AS BEGIN select UserId from UserLocations where @userPoint.STDistance(CurrentLocation) <= @RangeInMeters and UserId <> @userId END
Disadvantages: problems using geographical data with LinqToSQL and LinqToEntities.
Advantages: using dbms processing power over large data, and usage of the SQL Server spatial index.
3.Using some web service such as google's geolocation and calculation services. So far I didn't find such web service.
Which is the most efficient in your opinion? Please justify your answer.
Thank you