[thelist] determine radius of zips

Will Lynch wlynch at powerprinting.net
Mon Mar 15 12:49:01 CST 2004


This is an old subject, but one I saw a long time ago discussed here.
Eventually this will be incorporated in a web page but first I must make
it run using Foxpro and sql. What I have is below. What I end up having
returned is not right at all. For instance, no matter what distance I
enter as radius, I always have returned the same records from the
Automaster database. I'm not a math wizard so I don't know if my problem
lies in that logic or if my statements are way off base. Anyone know
where I might be going wrong with the following code? I've been beating
my head against a wall for over a week now on this. Thanks for any
hints.
 
 
SELECT latitude_, longitude_;
FROM automaster WHERE zip = '45403';
 
lat= latitude_
lon= longitude_
 
RADIUS = 10
 
miles_per_lat = 69.09
miles_per_lon = Abs(69.09 * Cos(Val(lat) * Pi() / 180))
 
deg_latitude = radius / miles_per_lat
deg_longitude = radius / miles_per_lon
 
SELECT zip,ROUND(SQRT((miles_per_lat * (val(automaster.latitude_) -
Val(automaster.latitude_)))^2 ;
                   +(miles_per_lon * (val(automaster.longitude_) -
Val(automaster.longitude_)))^2),1);
                   as distance;
FROM automaster WHERE val(lat) BETWEEN Val(automaster.latitude_) -
deg_latitude;
AND val(automaster.latitude_) + deg_latitude;
AND val(lon) BETWEEN Val(automaster.longitude_) - deg_longitude AND
Val(automaster.longitude_) + deg_longitude
 
 
 
***************
 
 
 

Power Printing and Direct Mail Services, Inc.

Phone: (937)254-7355

Toll Free: (800)225-9655

Fax: (937)258-5495

420 Davis Ave.

Dayton, OH 45403

 


More information about the thelist mailing list