|
Posted by Jerry Stuckle on 09/28/63 11:41
Michael Trausch wrote:
> noone wrote:
>
>>if Decatur GA is at [longitude] => -084.2511710 where is the range in
>>your query .. should it not be somwhere between -70 and -122
>>
>>[longitude <= -122.70422048692 AND longitude >= -122.70422048692] =
>>-122.70422048692
>>
>
>
> Yeah, the problem was something along the lines of how I implemented the
> hunting algorithm to deduce the valid range to look in. for a 20 mile
> radius, it works out differently - vastly, actually:
>
> for a five mi radius it works:
>
>
>>./zip_test.php 30034 5
>
>
> Query SELECT * FROM dataZipCode WHERE latitude <= 33.763122891528 AND
> latitude >= 33.618391108472 AND longitude <= -84.211503845018 AND
> longitude >= -84.290838154982 ORDER BY abbr,city
> Returned 3 rows
> City: Atlanta State: GA ZIP: 31132 Dist: 3.1496162946772
> City: Decatur State: GA ZIP: 30032 Dist: 4.2562533102956
> City: Decatur State: GA ZIP: 30034 Dist: 0
>
>
> As well as a 20 mile radius:
>
> Query SELECT * FROM dataZipCode WHERE latitude <= 33.980220566111 AND
> latitude >= 33.401293433889 AND longitude <= -84.092501398957 AND
> longitude >= -84.409840601043 ORDER BY abbr,city
> Returned 65 rows
> City: Atlanta State: GA ZIP: 30307 Dist: 7.8779054595022
> City: Atlanta State: GA ZIP: 30340 Dist: 13.988388086945
> City: Atlanta State: GA ZIP: 30338 Dist: 19.540119063232
> City: Atlanta State: GA ZIP: 30335 Dist: 9.0276794496919
> City: Atlanta State: GA ZIP: 30315 Dist: 7.6332861615796
> City: Atlanta State: GA ZIP: 30332 Dist: 10.300183017737
> City: Atlanta State: GA ZIP: 30329 Dist: 10.293572217837
> City: Atlanta State: GA ZIP: 30328 Dist: 18.716589259417
> City: Atlanta State: GA ZIP: 30326 Dist: 12.656176679345
> City: Atlanta State: GA ZIP: 30309 Dist: 10.784558977204
> City: Atlanta State: GA ZIP: 30324 Dist: 11.123997032003
> City: Atlanta State: GA ZIP: 30322 Dist: 8.3657588395676
> City: Atlanta State: GA ZIP: 30319 Dist: 13.608382045463
> City: Atlanta State: GA ZIP: 30317 Dist: 7.1986920468663
> City: Atlanta State: GA ZIP: 30342 Dist: 15.071788907405
> City: Atlanta State: GA ZIP: 30345 Dist: 10.838995754932
> City: Atlanta State: GA ZIP: 30306 Dist: 9.1595992448634
>
> [... cutting more of the stuff out]
>
> It doesn't do a perfect radius yet, but I don't think I need it to
> unless I start looking at distances > 30 miles... using a square can get
> to be covering a bit of a too broad area when dealing with things larger
> then that.
>
> thanks for the help guys,
> ] mike
I did something like this not too long ago.
It would be nice if you could search the database for something within a
circle :-). Unfortunately, it just doesn't work that way.
I did it similar to how you did - created a square and got everything
within it. Then I recalculated the distance and manually filtered out
anything not within the required radius. Worked fine and was quite quick.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
[Back to original message]
|