I would pursue data reduction.
One possibiliy of data reduction is that at 60 degrees north any place within 1 degree longitude of another place is less than about 30 miles away and latitude is about 60 miles per degree so a real fast first pass might just be to take for your example a subset of the places where lat > 42.5 && lat < 43.5 and lon > 70 && lon < 72. These would of course be calculated from each desired source place and give a box of about 30 x 40 miles around your source. Then do the real distanace calculation to get the actual values which will elimate a few zips from the small set, all of which can probably be in local storage in the script for speed.
Another, very accurate, way to set the bounding box would be to go 25 miles straight north for the start zip and then calculate the longitude difference needed to go 25 miles then set the box at + and - the lat and + and - the lon you calculated from the center and you have an about 25x25 mile box then use the real formula to eliminate the corner zips. If you work in lat or lon order in from the corners toward the center, you can determine as you go that all closer lat/lon (depending on your order) are inside the circle and do not need to calculate them. This way requires the real distance calculation to be done once to make up the bounding box, then simple subtractions for all other calculations in pass 1, then run the real dist calc in pass 2 for the corner cases until you are close enough in not to need them and the rest get included for zero added cost.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||