I want to build database with sql server 2008 that include columns of gps coordinate-
latitude
and
longitude
and i want to build a query that will be something like :
"Give me all rows that are within 5(for example) metres of this coordinate"
It is possible in c#??
C# really isn’t the problem, the problem is the database itself. MS SQL Server 2008 and higher has spatial support as described in this article:
http://msdn.microsoft.com/en-us/magazine/dd434647.aspx
Without using spatial extensions, you’d have to manually calculate the bounding box yourself (which would probably include points > 5 meters from the coordinate.) Then you’d have to restrict the results to make sure they are within 5 meters of the point in question.
Here’s a little pic of the manual (ie. somewhat painful) calculation:
The (
*) is the point in question. The problem with doing the calculation manually is that the points near the corners of the box are (probably) > 5 m away from the (*) point. You could calculate the bounding circle, but that’s going to increase the complexity of your SQL query.So – in short – you really need a DB with spatial support.