Re: Finding nearby zip codes (or maybe area codes) programatically



Bill H wrote:
On Dec 21, 10:32 am, sheldonlg <sheldonlg> wrote:
houghi wrote:
Bill H wrote:
Sure. It's about 5 years old so I may be missing a few zip codes but
it is better than entering everything in by hand. How would I do that
on here, it is a text file but about 1.6mb in size?
Put it on a website in zip. If you are unable to do that, just mail it
to me and I will put it on my website. That way anybody can use that
file.
I am wondering if the following would work:
1) make a list with difference in Latitude
2) make a list with difference in Longitude
This won't work! Mileage differences between the same two longitudes
are different depending upon the latitude. For example, the mileage
difference between any two longitudes is zero at a latitude of 90
degrees north or south. It works for latitude because all longitudes
are great circles. All latitudes, however, are parallel circles with
varying radii.



3) See what the code it on both list with the lowest in both lists
houghi- Hide quoted text -
- Show quoted text -

Actually it does work in this specific situation for US zip codes. If
you have a field that contains how far north of the equator a zip code
is, and the data is then sorted on this field before being placed into
the table.

Then when you get the record for the zip code you are looking at, all
data before it in the table is closer to the equator, all data after
it is farther. If you pull out a block of the data that is within 100
miles of your zips distance then you need only check the actual
distance of these records to see if they are within 100 miles of the
zip code. Using this eliminates checking zip codes that are no where
near what you are looking for and only checking those that may be.

Jerry - I went back and read your post about creating a box containing
all the zips within a certain distance and then never having to
calculate the distance again. This is a great idea if you have a fixed
distance and I was actually going to do this. But if you have multiple
distances or a variable one, I think this method works. Also I totally
understand you proint about how this should be discussed in the mysql
group, but my feelings (and I could be wrong) is that php is used so
much for database access (at least based on what I have been reading
in this group) that it should be discussed here.

Bill H
try crating an index on latitude and longitude so that enquires that are within a certain range of lat and long can be quickly accessed.


then you can process those to find a better selection.
.



Relevant Pages

  • Re: Finding nearby zip codes (or maybe area codes) programatically
    ... are different depending upon the latitude. ... difference between any two longitudes is zero at a latitude of 90 ... miles of your zips distance then you need only check the actual ... distance of these records to see if they are within 100 miles of the ...
    (comp.lang.php)
  • Re: Finding nearby zip codes (or maybe area codes) programatically
    ... Bill H wrote: ... Mileage differences between the same two longitudes ... are different depending upon the latitude. ... distance of these records to see if they are within 100 miles of the ...
    (comp.lang.php)
  • Re: latitudes and longitudes as indexes
    ... vector of latitudes and a vector of longitudes and needs the ... point pairs quantized into a indices into a grid of a ... That isn't the case for latitude and longitude coordinates: ... latitude times the distance the points would be apart if they ...
    (comp.soft-sys.matlab)
  • Re: Calculating a Distance on the Surface of the Earth
    ... latitude and longitude. ... I'd actually be above the surface of the earth due to the ... to the surface of the earth, I'd like to know the distance between ... longitude of the second point. ...
    (sci.geo.satellite-nav)
  • Re: Finding nearby zip codes (or maybe area codes) programatically
    ... are different depending upon the latitude. ... miles of your zips distance then you need only check the actual ... distance of these records to see if they are within 100 miles of the ... try crating an index on latitude and longitude so that enquires that are ...
    (comp.lang.php)

Loading