Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If accuracy is not an issue, you can plot the longitude and latitude of the center of the zip code, or a rough estimate of the center. Then, you can have a script calculate the distance between each of the centers, using the formulas listed <a href="http://en.wikipedia.org/wiki/Geographical_distance" rel="nofollow noreferrer">here</a> . There is NO need for the use of the haversine formula as illustrated <a href="http://www.movable-type.co.uk/scripts/latlong.html" rel="nofollow noreferrer">here</a>, that is for extreme accuracy, which you do not need. The trigonometric and inverse trigonometric functions drain much computational resources, and is a waste. Querying the distance every time and making MySQL run through such a complex formula for every zip code is just a waste of resources.</p> <p>If you must do this many times every day, it might be faster (space vs speed tradeoff here) to just store the distance between every zip code. The total number of entries in such a storage table is the square of the number of zip codes you have. Running through tens of thousands of zip codes each time to calculate that consumes vast amounts of computational power, not to mention be slower for the end user.</p> <p>Also, a similar question has been asked on here before, please look at the accepted answer on this question, it applies to your situation: <a href="https://stackoverflow.com/questions/3983325/calculate-distance-between-zip-codes-and-users">Calculate distance between zip codes and users</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload