I need to find the best way for a “circles overlapping given point” system.
I have a lot of points e.g. restaurants, and every item has a point of the place, and a radius for e.g. “bringing out food”. The radius differ, some have 3 km, others 10 km.
I am searching from a point. e.g. “My position” latitude/longitude.
I need to find the best way to find all restaurants that overlaps my point. (Will bring food to me). (Not is point in circle, but what circles are overlapping my point.)
I am thinking of storing lat/lng as geography type in SQLServer 2008. Is this the way to do it?
Can I query directly on top of sqlserver? Or do I need to do it in code?
And what is the way to do it?
Yes, this is exactly the kind of thing that
geographyand spatial methods are good at. Here is a short example:Note that here to construct the
geographyvalues I am using an implicit conversion from string, which behind the scenes callsgeography::Parse.