I would suggest a creative solution of stealing MapQuest's distance
calculations somehow. Or maybe just do a comparison query, like try and
match all digits of the postal code and this will be closest, then match
all but the last digit, then all but the last two, and so on, this will
give you a list of address's with increasing distance.

Adam Voigt

On Thu, 2002-07-04 at 15:21, Brandon Pearcy wrote:
> Hello,
>    I have a couple of questions with respect to creating a postal / 
> zip code proximity search that is remotely accurate. The system I am 
> using now is OK for small distances, but is terrible at calculating 
> large distances.
>    What I have is a database of establishments and their corresponding 
> latitudes and longitudes, and I need to have users enter their own 
> postal / zip code, and have the system calculate which establishments 
> fall into a set range ($range) from their location. Not only does it 
> need to find the establishments, it needs to calculate the distances 
> (straight line, of course).
>    Now, I have dug through the PHP archives, but there is no single 
> clear explanation of how to do this, from beginning to end. I will 
> start by putting down what I need, and then maybe other people can 
> contribute to this and in the end we will have the solution, nice and 
> tidy, in one place.
> *** NOTE: I know doing this in PHP will be SLOW, but I do not want to 
> write a MySQL user-defined function and recompile it and blah, blah, 
> blah... (unless someone wants to cover that aspect!!! :D)
>    Step 1: Take the postal / zip code that the user entered, and 
> search the national postal / zip code database (which I already have) 
> and return its corresponding latitude and longitude ($userLat and 
> $userLong).
>    Step 2: ???
>    Step 3: Return the establishments information to the user, complete 
> with the distances to them, ordered by smallest distance to largest.
> If you can't help me out, maybe you can direct me to some online 
> tutorials on this topic!
> Thanks in Advance!
> -- 
> --------------------------
> Brandon Pearcy
>    Internet Technician
> Bowes Online
> --------------------------
>   phone: 1-780-532-1110 ext. 265
>   fax:   1-780-532-2120
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to