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



On Dec 21, 12:27 pm, The Natural Philosopher <a...@xxx> wrote:
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.- Hide quoted text -

- Show quoted text -

If interested, found a site that has another listing of zips, may be
newer. It also has the canadian postal codes on there also if you need
them. www.populardata.com

Bill H
.



Relevant Pages

  • 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: Could PIC handle this?
    ... Doesn't that mean comparing the distance ... magnitude of the distance, not the actual distance. ... differences between the longitude and latitude of each pair of points you ...
    (comp.arch.embedded)
  • Re: decimal longitude and latitude problem
    ... distance from a specific decimal longitude and latitude. ... latitude is 60 nautical miles, while one degree of longitude is 60*sin L ...
    (sci.math)
  • Re: decimal longitude and latitude problem
    ... distance from a specific decimal longitude and latitude. ... latitude is 60 nautical miles, while one degree of longitude is 60*sin L ...
    (sci.math)
  • Re: Questions (Space)
    ... The longitude and latitude I'd say are ... vector quantities; ... defines a distance in a particular direction. ...
    (rec.arts.sf.composition)

Loading