One suggestion is to use the geo functionality of Postgres....

We use postgres to calculate city, state, and/or country by using the geo
functions in postgresql.

I would really suggest using postgres for your calculations.

You can pass the lat and long and have postgres give you the intersection of
these and reference a table that has the zip codes....

B i g D o g




----- Original Message -----
From: "Brandon Pearcy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 04, 2002 9:33 AM
Subject: [PHP] Postal / Zip Code Proximity Search


> 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
>   [EMAIL PROTECTED]
>
> --
> 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