NYCPHP Meetup

[nycphp-talk] Radial Zip Code Search

Steve Solomon sjmci at optonline.net
Tue Jan 23 09:54:53 EST 2007


In the real world most of these applications involve finding locations
(i.e., "stores") closest to a given zip code (or city and state which is
then translated to a zip code).  The standard solutions are not very
efficient here because they are redoing calculations that only have to
be done once.  That is, for every zip code, the distances to the closest
locations is static and changes only when there are new locations or
locations cease to exist.

A more efficient algorithm is to generate offline a table which looks
something like 

Zip,Location#1,Distance1,Location#2,Distance2...

Up to the maximum no. of locations that you would ever want to display
(typically 5-25).  Of course this is time consuming since it has to be
done for all the 40,000+ zip codes, but it only has to be done
completely once.  When locations change only the records in the file
that are affected must be changed.

Once this table has been generated finding the closest locations is a
simple one record read.  The location details are then displayed by
reading the location information from a 'location' file for each one
found.


-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.8/648 - Release Date:
1/23/2007 11:04 AM
 




More information about the talk mailing list