>>Calculating the exact distance for every possible 'destination' seems like overkill?
>>If this is for the U.S. and only targets within a certain radius are required you could get a rough selection based simply on latitude and longitude.
>>There's pretty much a direct correlation for latitude (110 miles per degree) and given that the the U.S only extends from about 45-25 degrees it will always be between say 80-100 miles per degree of longitude. So grab the max by allowing an extra 20% on longitude then do the exact calculation on that result set? Not having the meridian pass through the country makes it easier as well.....
>
>So basically, we could simply rely on the Latitude and Longitude fields to apply our queries on. Is that correct? So, for example, if I want a radius of 20 km, what kind of +- formula should I calculate to allow + or - radius on the Latitude and Longitude?
http://nationalatlas.gov/articles/mapping/a_latlong.html
Degrees of latitude and longitude can be further subdivided into minutes and seconds: there are 60 minutes (') per degree, and 60 seconds (") per minute. For example, a coordinate might be written 65° 32' 15". Degrees can also be expressed as decimals: 65.5375, degrees and decimal minutes: 65° 32.25', or even degrees, minutes, and decimal seconds: 65° 32' 15.275". All these notations allow us to locate places on the Earth quite precisely – to within inches.
A degree of latitude is approximately 69 miles, and a minute of latitude is approximately 1.15 miles. A second of latitude is approximately 0.02 miles, or just over 100 feet.
A degree of longitude varies in size. At the equator, it is approximately 69 miles, the same size as a degree of latitude. The size gradually decreases to zero as the meridians converge at the poles. At a latitude of 45 degrees, a degree of longitude is approximately 49 miles. Because a degree of longitude varies in size, minutes and seconds of longitude also vary, decreasing in size towards the poles.
degree of latitude = 69 miles = 69 * 1.609 km = 111 km
degree of longitude = say the same = consider to be at the equator (
So, if I am at latHere and lonHere (consider lat and lon to be stored in degrees
select .... where
lat between latHere - 1/111 * 20 and latHere + 1/111 * 20
and lon between lonHere - 1/111 * 20 and lonHere + 1/111 * 20
and (calculatedDistance < 20 )
You may add a bit to the range to be sure, like 2 km or so
RangeAdd = 2/111
<pre>
select .... where
lat between latHere - 1/111 * 20 - RangeAdd and latHere + 1/111 * 20 +RangeAdd
and lon between lonHere - 1/111 * 20 - RangeAdd and lonHere + 1/111 * 20 + RangeAdd
and (calculatedDistance < 20 )
Gregory