Hello all,
I'm rather new here so very sorry if there are posts on similar types of searches. I'm working on a project for a delivery company what wants to be able to search for deliveries with a 500 mile radius of point A, that end up with in a 500 mile radius of point B.
I have a simple radius search working, a user can type in a zip code and get all the other zip codes with in a radius of up to 500 miles (the max required distance).
(The zip code table is listed below)*
I am using a php function to calculate locations with in the radius specified by the user (start and end point.)
Basically it's a function that returns all the zip codes with in the radius specified. And example of the search is here:
http://www.zensomedia.com/truckboard/
So what I end up with is 2 arrays of zip codes. However at a 500 mile radius sometimes there can be 16,000 zip codes. So I would have 16,000 start point zips and 16,000 end point zip.
In a second table I have all the loads that need to be delivered. For the sake of argument lets say it has
LoadID
StartZip
EndZip
What I was going to do is in php select all the loads where “StartZIP” matches my starting zip codes array. So I know all my start points match, then I would take my possible end points zip code array and see if there are any matches on that array.
I’m not sure if this is the best way to go about doing this, and how the performance will be. Can any one give me any suggestions on how to improve this?
Thank you,
Steven
************************************************** **
CREATE TABLE `zip_code` (
`id` int(11) unsigned NOT NULL auto_increment,
`zip_code` varchar(5) collate utf8_bin NOT NULL,
`city` varchar(50) collate utf8_bin default NULL,
`county` varchar(50) collate utf8_bin default NULL,
`state_name` varchar(50) collate utf8_bin default NULL,
`state_prefix` varchar(2) collate utf8_bin default NULL,
`area_code` varchar(3) collate utf8_bin default NULL,
`time_zone` varchar(50) collate utf8_bin default NULL,
`lat` float NOT NULL,
`lon` float NOT NULL,
PRIMARY KEY (`id`),
KEY `zip_code` (`zip_code`)
)
************************************************** **