How to effectively determine n places inside a circle?

Given this scenario:

  • We have about 1,000,000 points worldwide, defined by longitude and latitude;
  • We have a circle c based on the point pc (given by longitude and latitude) and radius rc
  • We want to effectively determine which point is in the circle.

I am developing in C # and places stored on SQL Server 2008.

So, as I see it, I have these 3 options:

  • Save locations as longitude floats and do calculations in C #.

  • Store locations as geographic data types and perform calculations in SQL Server 2008 as follows:

    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 geographic data with LinqToSQL and LinqToEntities.

    Advantages: using dbms processing power on big data and using SQL Server spatial index.

3. -, Google. -.

? , .

+1
2

, lat/long pc BETWEEN . 79% , , . .

, SQL Server.

+1

( STDistance) . , , .

100 000 , , , - #, , (.. Haversine). , , -.

, ( SQL Server), SQL Server, . . SQL Server , , , .

LINQ , SqlConnection Reader. , LINQ, Spatials, .

Google, -?

0

All Articles