August 8, 2005 at 4:33 pm
I have a table filled with zipcodes and longitude and latitude of the zipcode location.
I'm trying to write a SQL Server T-SQL statement to pull all the zipcodes within a 2 mile radius. Can anyone help with this query?
SELECT *, SQRT(POWER((38.492497-latitude),2)+POWER((-121.404807-Longitude),2)) AS distance FROM location WHERE distance < .016 ORDER BY distance
The error I keep getting is that distance is not a valid column.
TIA,
-Dewayne
August 8, 2005 at 4:47 pm
Distance is a derived column, and you cannot use it in the where clause, It is okay in the order by though.
Your code has some parsing error, but the example below illustrates your problem
use pubs
-- This does not work in where clause because sales is a derived column
select price * ytd_Sales as sales
from titles
where sales > 777.0000
order by sales
-- this does work because calculation used in where clause
select price * ytd_Sales as sales
from titles
where price * ytd_Sales > 777.0000
order by sales
August 8, 2005 at 6:03 pm
try something like this...
select * from
(
SELECT *, SQRT(POWER((38.492497-latitude),2)+POWER((-121.404807-Longitude),2)) AS distance FROM location
)q
where q.distance < .16
order by q.distance asc
HTH
Mathew J Kulangara
sqladventures.blogspot.com
August 8, 2005 at 8:42 pm
Or like this:
SELECT SQRT(POWER((38.492497-latitude),2)+POWER((-121.404807-Longitude),2)) AS distance, *
FROM location
WHERE SQRT(POWER((38.492497-latitude),2)+POWER((-121.404807-Longitude),2)) < .016
ORDER BY 1
August 9, 2005 at 7:45 am
ok i have that same zipcode database , and this SQL seems to work:
select SQRT(POWER((38.492497 - latitude),-2) + POWER((-121.404807 - Longitude),2) ) as distance ,zipcodes.* from zipcodes
where SQRT(POWER((38.492497 - latitude),-2) + POWER((-121.404807 - Longitude),2) ) < 0.16
and seems to report items withing a radius: however, i'd like to know the conversion for distance to miles, or distance to kilometers; if .16 = 2 miles, then if i multiply distance * 12.5, is that the miles? (2 / 0.16)? it seems like an awful lot of cities within that 2 mile radius. i thought Washingtion would be a bit more spread out than as it appears below. that "radius" covers 3 counties and an additional town in oregon...is that right?
distance | ZIPCODE | LATITUDE | LONGITUDE | ZIP_CLASS | PONAME | STATEFIPS | COUNTY | STATE |
------- | ----------- | ----------- | --------- | ------------------ | --------- | ------ | ----- | |
0.12114454176726247 | 98267 | +48.537813 | -121.473840 | NULL | MARBLEMOUNT | 53 | 057 | WA |
0.14205984654363105 | 97040 | +45.650790 | -121.379020 | NULL | MOSIER | 41 | 065 | OR |
0.1000949549178179 | 98246 | +48.558127 | -121.417034 | NULL | BOW | 53 | 057 | WA |
0.1322535443759448 | 98224 | +47.767103 | -121.481395 | P | BARING | 53 | 033 | WA |
0.114 | 98288 | +47.722245 | -121.369352 | P | SKYKOMISH | 53 | 033 | WA |
0.15986244086714052 | 98623 | +45.807631 | -121.487682 | P | HUSUM | 53 | 039 | WA |
0.11473883387938018 | 98068 | +47.445171 | -121.431033 | P | SNOQUALMIE PASS | 53 | 033 | WA |
0.13631580979475566 | 98672 | +45.828588 | -121.405863 | NULL | WHITE >SALMON | 53 | 039 | WA |
0.14472042012100436 | 98605 | +45.721519 | -121.447323 | NULL | BINGEN | 53 | 039 | WA |
Lowell
August 9, 2005 at 7:56 am
August 9, 2005 at 8:01 am
sorry; i wanted the conversion for the distance calculation to miles; the "distance" column is a value, but i don't know what kind of units it's supposed to be.
i don't think .16 units of the distance calculation above is 2 miles; once i have that conversion value, converting to other units of measure is a snap.
also DOH! i had a negative power in my calculation, which put my data in washington....when the correct formula is used, it lists a bunc of post offices in sacramento:
select SQRT(POWER((38.492497 - latitude),2) + POWER((-121.404807 - Longitude),2) ) as distance ,zipcodes.* from zipcodes
where SQRT(POWER((38.492497 - latitude),2) + POWER((-121.404807 - Longitude),2) ) < .16
distance | ZIPCODE | LATITUDE | LONGITUDE | ZIP_CLASS | PONAME | STATEFIPS | COUNTY | STATE |
0.12171688461343397 | 94234 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94244 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94248 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94268 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94278 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94296 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94205 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94230 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94232 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94250 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94262 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94273 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94204 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94245 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94253 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94254 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94261 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94274 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94279 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94283 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94207 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94246 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94267 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94290 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94257 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94284 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94287 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94209 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94280 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.1479155164274526 | 95608 | +38.621360 | -121.332191 | NULL | CARMICHAEL | 06 | 067 | CA |
6.0638271743182127E-2 | 95820 | +38.536606 | -121.446414 | NULL | SACRAMENTO | 06 | 067 | CA |
9.3343451832466534E-2 | 95825 | +38.585804 | -121.402213 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94295 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94229 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94243 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94249 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94258 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94259 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94282 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
9.4805063155930652E-2 | 95822 | +38.511356 | -121.497716 | NULL | SACRAMENTO | 06 | 067 | CA |
3.8897300677553447E-2 | 95823 | +38.481354 | -121.442071 | NULL | SACRAMENTO | 06 | 067 | CA |
0.05843800133474792 | 95826 | +38.547639 | -121.385459 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95853 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94206 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94263 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94297 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95812 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
1.8867962264113206E-2 | 95828 | +38.488446 | -121.423245 | NULL | SACRAMENTO | 06 | 067 | CA |
0.1088806686239573 | 95832 | +38.435014 | -121.497276 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94235 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94239 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94240 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94269 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94293 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94299 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.11525189803209317 | 95814 | +38.579055 | -121.480905 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95851 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94277 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94291 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95743 | +38.377411 | -121.444429 | U | RANCHO CORDOVA | 06 | 067 | CA |
0.12171688461343397 | 95873 | +38.377411 | -121.444429 | U | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94294 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95611 | +38.377411 | -121.444429 | P | CITRUS HEIGHTS | 06 | 067 | CA |
0.12171688461343397 | 95894 | +38.377411 | -121.444429 | U | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94252 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94289 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95813 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.08390470785361212 | 95819 | +38.568305 | -121.440764 | NULL | SACRAMENTO | 06 | 067 | CA |
0.15003999466808843 | 95834 | +38.584193 | -121.523566 | NULL | SACRAMENTO | 06 | 067 | CA |
0.15661736813010235 | 95838 | +38.645103 | -121.440015 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94208 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94236 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94237 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.1472412985544477 | 95758 | +38.347205 | -121.428681 | NULL | ELK GROVE | 06 | 067 | CA |
0.13872634933566155 | 95821 | +38.627204 | -121.437964 | NULL | SACRAMENTO | 06 | 067 | CA |
0.10188228501560023 | 95827 | +38.552752 | -121.322653 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95887 | +38.377411 | -121.444429 | U | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94211 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94247 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94256 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94285 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94288 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94298 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.10089103032480143 | 95816 | +38.571505 | -121.467549 | NULL | SACRAMENTO | 06 | 067 | CA |
8.3330666623998628E-2 | 95829 | +38.495328 | -121.321524 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95867 | +38.377411 | -121.444429 | U | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94271 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 94286 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95759 | +38.377411 | -121.444429 | P | ELK GROVE | 06 | 067 | CA |
4.3657759905886148E-2 | 95824 | +38.517256 | -121.440764 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95852 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.11018620603324175 | 95624 | +38.441480 | -121.307142 | NULL | ELK GROVE | 06 | 067 | CA |
0.13848465618977432 | 95630 | +38.594181 | -121.310796 | NULL | FOLSOM | 06 | 067 | CA |
0.13769894698217558 | 95655 | +38.554406 | -121.281810 | NULL | MATHER | 06 | 067 | CA |
0.1486875919503709 | 95830 | +38.490022 | -121.256140 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95840 | +38.377411 | -121.444429 | U | SACRAMENTO | 06 | 067 | CA |
9.7411498294605853E-2 | 95864 | +38.586554 | -121.379467 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95865 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95857 | +38.377411 | -121.444429 | U | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95899 | +38.377411 | -121.444429 | U | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95671 | +38.377411 | -121.444429 | U | REPRESA | 06 | 067 | CA |
0.12171688461343397 | 95741 | +38.377411 | -121.444429 | P | RANCHO CORDOVA | 06 | 067 | CA |
0.10646595700034824 | 95815 | +38.589505 | -121.448665 | NULL | SACRAMENTO | 06 | 067 | CA |
7.3966208500909389E-2 | 95817 | +38.549232 | -121.452264 | NULL | SACRAMENTO | 06 | 067 | CA |
0.11178103595869918 | 95818 | +38.557255 | -121.495915 | NULL | SACRAMENTO | 06 | 067 | CA |
0.1266412255152326 | 95831 | +38.497863 | -121.531332 | NULL | SACRAMENTO | 06 | 067 | CA |
0.12171688461343397 | 95866 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
5.6133768802744753E-2 | 95673 | +38.478399 | -121.459135 | NULL | RIO LINDA | 06 | 067 | CA |
0.12171688461343397 | 95763 | +38.377411 | -121.444429 | P | FOLSOM | 06 | 067 | CA |
0.12171688461343397 | 95860 | +38.377411 | -121.444429 | P | SACRAMENTO | 06 | 067 | CA |
Lowell
August 9, 2005 at 8:41 am
Sorry Lowell. The .016 is very very close to 1 mile. I should have put .032 for two miles. My bad. Also, please note that the radius we're getting is for a flat circle and we'll be off because we're not taking into consideration the curvature of the earth. For my application that's acceptable. More accurately the latitude is .014 and the longitude is .018. I was cutting corners and just went with the median for one calculation. Hope that helps.
And thanks to all that helped. This community ROCKS!
-Dewayne
August 9, 2005 at 9:12 am
You can't use simple geometry for latitudes & longitudes. To begin with, latitude is constant anywhere but the size of a degree of longitude changes with latitude. A better approximation (near 40 deg latitude) might be SQRT(SQUARE(lat1-lat2) + 0.5867 * SQUARE(lon1-lon2)).
You should be using spherical geometry, but the problem is that a two-mile distance represents a very small angle when measured from the center of the earth and the SINE function gets flaky. You could have errors of as much as 10 miles for any distance under 10 miles.
If you check with your friendly neighborhood ancient mariner, he'd tell you to use the haversine formula. His parrot might explain that is short for "half of the versed sine", but you probably don't want the details. Translated into T-SQL it is:
CREATE FUNCTION dbo.fn_latlondistance (@lat1 float, @lon1 float, @lat2 float, @lon2 float)
RETURNS float
AS
BEGIN
DECLARE @rlat1 float, @rlon1 float, @rlat2 float, @rlon2 float
DECLARE @a float, @C float, @d float
SELECT @rlat1 = RADIANS(@lat1), @rlon1 = RADIANS(@lon1), @rlat2 = RADIANS(@lat2), @rlon2 = RADIANS(@lon2)
SET @C = SQUARE(SIN((@rlat2 - @rlat1) / 2.0)) + COS(@rlat1) * COS(@rlat2) * SQUARE(SIN((@rlon2 - @rlon1) / 2.0))
SET @a = 2.0 * ATN2(SQRT(@c), SQRT(1.0 - @C))
SET @d = 3956.088331329 * @a
RETURN @d
END
This function returns the distance in miles for any two sets of lat-long. Admittedly this does not correct for altitude or radius variations from a perfect sphere, but it is pretty accurate.
There is a lot of number crunching involved, so I try to avoid running this on my entire zipcode database. I use simpler approximations to select all locations near the target, then this formula to get the exact distance only for that subset.
August 9, 2005 at 9:30 am
I'll tell you, i love this distraction; Scott's function works well, but I seem to get a much smaller result set than Dewaynes.
I used this SQL to find items within 4 miles; within two miles produced just a single record(the 4th item in the result set below,1.03 miles?)
select dbo.fn_latlondistance(38.492497,-121.404807,latitude,Longitude) as distance, zipcodes.* from zipcodes
where dbo.fn_latlondistance(38.492497,-121.404807,latitude,Longitude) < 4
3.7852856283453051 | 95820 | +38.536606 | -121.446414 | NULL | SACRAMENTO | 06 | 067 | CA |
2.1559427759904617 | 95823 | +38.481354 | -121.442071 | NULL | SACRAMENTO | 06 | 067 | CA |
3.9482373179432209 | 95826 | +38.547639 | -121.385459 | NULL | SACRAMENTO | 06 | 067 | CA |
1.034971122521227 | 95828 | +38.488446 | -121.423245 | NULL | SACRAMENTO | 06 | 067 | CA |
2.5878945649878804 | 95824 | +38.517256 | -121.440764 | NULL | SACRAMENTO | 06 | 067 | CA |
3.0934375334839963 | 95673 | +38.478399 | -121.459135 | NULL | RIO LINDA | 06 | 067 | CA |
would anyone like to take a guess at the discrepancy between the two calculations ? i don't think the curvature of the earth would make that big of a difference in the results.
Lowell
August 9, 2005 at 9:40 am
Thanks Scott! Great function! You are 100% correct, but I'm just wanting to return zipcodes within an approximation of one set of coordinates. For me I only need an accuracy of about 10 miles, and if two or more zipcodes are returned within that distance I'm only using the first zipcode in the result set. In this case it's like horseshoes or hand-grenades. Close enough is good enough. Thank God I don't have to be spot-on accurate for this application. At least for now.
Thanks for your help Scott. I'm pigeonholing this code just in case!
-Dewayne
August 9, 2005 at 9:52 am
You probably don't need the full accuracy, especially since you're talking about some location (geometric center?) in the middle of a zipcode and not individual lat/lon for 9-digit zips.
But you could still use the function to help you convert the latitude and longitude degrees to miles, then use your simple distance function:
DECLARE @MilesPerLatDegree FLOAT, @MilesPerLonDegree FLOAT
DECLARE @Lat FLOAT, @Lon FLOAT
SELECT @Lat = 38.492497, @Lon = -121.404807
SET @MilesPerLatDegree = fn_latlondistance(@Lat, @Lon, @Lat+1, @Lon)
SET @MilesPerLonDegree = fn_latlondistance(@Lat, @Lon, @Lat, @Lon+1)
SELECT * FROM zipcodes
WHERE SQRT(SQUARE(@MilesPerLatDegree*(Latitude-@Lat))
+ SQUARE(@MilesPerLonDegree*(Longitude-@Lon))) <= 4
Even better would be to drop the SQRT function and use WHERE SQUARE() + SQUARE() <= 16.
August 9, 2005 at 11:42 am
Scott: Good call on the SQRT. Comparing the square of the distance to the square of the desired distance is a great way to speed up the query. I was just about to mention that.
Now, there's another way to speed this up as well. As it stands, the query must calculate the distance for every point in the table. This can be worked around by using a minimum bounding rectangle. (Or its spherical equivalent). To do this, you would calculate the max and min lat & long that could possibly satisfy the result set. This could be thought of as the "flat-land" square in which the search circle is circumscribed.
Adding the minimum bounds to the where clause would allow SQL server to use indexes to narrow the set of values upon which it would have to perform the expensive spatial calcs.
Sql server may not figure this out, so it might require the use of an inline view or temp table.
hth jg
August 9, 2005 at 12:36 pm
I use a zipcode table with a clustered primary key on zip5+zip4, and secondary indexes on latitude and longitude. A properly-constructed query with BETWEEN conditions is the fastest, but you have to check the execution plan to make sure that it is using index seek operations to limit the rows before it starts calculating. Sometimes it seems to assume that all the heavy-duty calculations occur in zero time.
The simple distance calculation is probably close enough for small distances, but I sometimes have to go out to 50 or 100 miles. This is enough to significantly distort a circle drawn with flat geometry, but the area of uncertainty is only around the edge of the circle. I might use a simple distance approximation to get all points inside 55 miles and use the precise calculation to recheck points in the 45-55 mile ring.
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply