C # find all latitude and longitude in mile

Given the lat and long values, is there a way to find all the lat and longs that are at a given distance? I have a db table of lat and long values, which are points that allow street lights to be spoken, given the long lat pair, how can I find all those that are at a certain distance?

I suggest that drawing a circle from the starting point and finding all the plates and lengths contained would be the best way, however, I have no skills for this. I am a C # trading developer, but you need some pointers around the world of geocoding.

+5
source share
4 answers

(. @tdammers), (Lat, Long) . , .

, SQL Server 2008, . (, , ), SQL-:

DECLARE @Point geography = 'POINT(-83.12345 45.12345)' -- Note: Long Lat ordering required when using WKT

SELECT * 
FROM tblStreetLamps
WHERE location.STDistance(@point) < 1 * 1609.344  -- Note: 1 mile converted to meters

, SQL Spatial .NET. : http://www.microsoft.com/downloads/en/details.aspx?FamilyID=CEB4346F-657F-4D28-83F5-AAE0C5C83D52 ( Microsoft® System CLR Types SQL Server® 2008 R2).

LINQ. . Haversine , .

var yourLocation = SqlGeography.Point(Latitude, Longitude, 4326);

var query = from fac in FacilityList
            let distance = SqlGeography
                          .Point(fac.Lat, fac.Lon, 4326)
                          .STDistance(yourLocation)
                          .Value
            where distance < 1 * 1609.344
            orderby distance
            select fac;

return query.Distinct().ToList();
+3

haversine ( , ) lat/lon. ...

+1

, , , .

, . . , . 90 1 , 90 - 1/60 = 89,9833 , 1 = 1 .

, 89,9833, , , . " ". , . - , , , , " : ". pdf http://pubs.usgs.gov/pp/1395/report.pdf. 29 - 32.

+1

some time ago I was solving the problem of how to get a POI on the road. I used quadtree, which means recursion dividing the entire area into cells and subelements. Each POI belongs to only one cell. With these cells, you can easily perform high-level calculations at the cell level and after that only look for cells with intersection. This is more of a game development technique, but you can use it here. Here's something about it on the Wiki:

http://en.wikipedia.org/wiki/Quadtree

0
source

All Articles