Re: Zip code



News wrote:
> I have a database of zipcodes with latitude and longitude. I also have the
> method of calculating the distance between two zipcodes. What I want to
> know is if there is an efficient algorithm for obtaining the zip codes
> within a specified distance of the first zipcode without having to retrieve
> and calculate for every record in the database.

You may do that in the query itself; but the DB will definitely scan
all the records. Look at the previous discussions
<news:CWAVb.22832$VW4.3380@xxxxxxxxxxxxxxxxxxxxxxxxxx> (
http://groups-beta.google.com/group/comp.lang.php/msg/a1418b46576b2cd3
)

Indexing latitude and longitude might help.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com

.



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)