| 
	
 | 
 Posted by Jerry Stuckle on 10/11/05 00:44 
Nel wrote: 
> "Jerry Stuckle" <jstucklex@attglobal.net> wrote in message  
> news:kuadnX9eZvJdKNfeRVn-ug@comcast.com... 
>  
>> 
>>Nel, 
>> 
>>First of all, you have a problem with your equation.  It assumes 1 degree  
>>if longitude has the same distance as 1 degree of latitude - which only  
>>occurs at the equator.  Everywhere else, 1 degree of longitude is less  
>>than 1 degree of latitude.  I don't have the correct equation handy, but I  
>>found it one time quite easily with a google search. 
>  
>  
> The figures are in metres, not degrees so hopefully this will not be a  
> problem. 
>  
> 
 
Metres from where?  Some central point (i.e. Greenwich Observatory)?  
For a (relatively) small country like GB, it probably wouldn't be that  
much of a problem.  But for Russia or Canada it could be a problem :-) 
 
>  
>>For instance, say you want everything within 25 miles.  In your program,  
>>define a 50x50 mi. square with the "from" point in the center.  That is,  
>>find the longitude 25 mi. east and west with no change in latitude. Then  
>>find the maximum and minimum latitude with no change in longitude. 
>  
>  
> Using a square would make it easier.  I had visioned calculating the  
> hypotinuse for each member. 
>  
 
You will have to do that eventually (not all locations in the 25km.  
square will be within a 25 km. circle). 
 
>  
>  
>>This now gives you a range that all the target post codes must be in. Now  
>>let the database do the work for you.  Search the database for all  
>>postcodes where the longitude is between the min and max above, and the  
>>latitude is within the min and max. 
>  
>  
> Genius.  So I can narrow down the processor work to a limited few. 
> 
 
Definitely.  Calculations such as this are very CPU intensive.  You want  
to perform the calculation on as few items as necessary. 
 
>  
>>Once you have this (much smaller) set of postcodes, you can run your  
>>equation again against every one to determine if it is within the 25 mile  
>>radius circle. 
>  
>  
> One final question, once I have narrowed down the sqlresult to those 25, and  
> I calculate the distance, how do I sort the sql results in the order of the  
> distance calculation? 
>  
 
You really can't, because you can't determine the actual distance until  
you perform the final calculations.  I'd suggest placing them in an  
array of postalcode=>distance and use asort to perform the sort. 
 
> Thanks, 
>  
> Nel.  
>  
>  
 
 
--  
================== 
Remove the "x" from my email address 
Jerry Stuckle 
JDS Computer Training Corp. 
jstucklex@attglobal.net 
==================
 
[Back to original message] 
 |