The link you post is good, but there is a simpler way (usually).
Typically this kind of request is, as the OP mentioned, for "... near
me" type operations. In which case they're zip-code to zip-code based.
The long/lat of a zip-code is usually based on the center of the
rhomboid the zip-code covers. As such, the distance is only accurate if
you happen to be at the exact center of the from-zip-rhomboid and you
happen to be going to the exact center of the to-zip-rhomboid, and even
then, it's an as-the-crow-flies distance, not a driving distance. All
that is to say, the calculation is an approximation anyway. Therefore,
if you're into approximations...
Distance = sqrt(x * x + y * y)
where x = 69.1 * (lat2 - lat1)
and y = 53.0 * (lon2 - lon1)
This can be off by 10%, but if you're looking for stuff in a 50 mile
radius, what's 5 miles? Especially since the center of the zip is
probably more than 5 miles from where I am anyway, and I need to add 10
miles for the trip since the roads don't go directly.
-Walden
--
Walden H Leverich III
Tech Software
(516) 627-3800 x3051
WaldenL@xxxxxxxxxxxxxxx
http://www.TechSoftInc.com
Quiquid latine dictum sit altum viditur.
(Whatever is said in Latin seems profound.)
As an Amazon Associate we earn from qualifying purchases.