NYCPHP Meetup

[nycphp-talk] Radial Zip Code Search

Donald J Organ IV dorgan at optonline.net
Fri Jan 19 16:14:09 EST 2007


WEll i am assuming you have a postal zipcodes database with longitude 
and latitude here is the queries you want to use, first you need to get 
long and lat for zipcode

SELECT longitutde,latitude
FROM usa
WHERE zipcode=$zip


SELECT distinct zipcode,
ROUND((ACOS((SIN($lat/57.2958) * SIN(latitude/57.2958)) +
(COS($lat/57.2958) * COS(latitude/57.2958) *
COS(longitude/57.2958 - $long/57.2958)))) * 3963, 3) AS distance
FROM usa
WHERE (latitude >= $lat - ($miles/111))
AND (latitude <= $lat + ($miles/111))
AND (longitude >= $long - ($miles/111))
AND (longitude <= $long + ($miles/111))
ORDER BY distance



Baer, Jon wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> You might want to try a new GIS topic search @ MySQL ...
>
> Here is an old one from 2004 -
> http://forums.mysql.com/read.php?23,3868,3868
>
> An inexpensive solution ... http://www.myzipdb.com/zipcode_locator.php
>
> - - Jon 
>
> - -----Original Message-----
> From: talk-bounces at lists.nyphp.org [mailto:talk-bounces at lists.nyphp.org]
> On Behalf Of Donna Marie Vincent
> Sent: Friday, January 19, 2007 3:45 PM
> To: talk at lists.nyphp.org
> Subject: [nycphp-talk] Radial Zip Code Search
>
> Hi, all.  I am looking for a script, or a tutorial on how to create a
> script, that will perform a radial zip code search.  I Googled this
> "radial zip code" and "radial postcode" and have found nothing about how
> to do this.  Can anyone point me in the right direction?
> Thanks in advance!
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (MingW32)
>
> iD8DBQFFsTAE99e5DI8C/rsRAmC/AKDq1EOwQO1WHnfXcXBDgmcPr3WPYwCcDrum
> 8bFq8+ciezOt432+x/zgDCI=
> =9lks
> -----END PGP SIGNATURE-----
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>
>   



More information about the talk mailing list