Okies... here we go.. it's 10 years since I left school, so I had to do a lil hunting around for calcultion formulas, but I think I got it right...
1 Mile basically works out to a 0.015 diference in latitude or longitude...
http://mathforum.org/dr.math/faq/formul ... angle.html
There's the URL I used for the calculation, and here's an image I was working to try and sort of demonstrate how I arrived at a 0.015:1 scale (Btw, all numbers ended up being rounded off to 2dp, except for latitude & longitude coordinates & differences).
So, in this example, if you lived in zip code 94950, and you wanted all stores in a 50m radius, you'd first work out the difference...
50 * 0.015 = 0.75
So, if your zip code coords are 38.054433 x -122.777625
Your box would be...
Top left : 37.304433 x -122.027625
Top right : 38.804433 x -122.027625
Bottom left : 37.304433 x -123.527625
Bottom right : 38.804433 x -123.527625
So, you would search for all zip codes that had...
Latitude > 37.304433 AND
Latitude < 38.804433 AND
Longitude > -123.527625 AND
Longitude < -122.027625
Which would give all zip codes in that 100x100 mile square.
Then you look for all stores in those zip codes. Do each individual distance calculation on each store found. Anything found under 50m, add it to the array, anything over 50m, forget it and move onto the next one. Once all results are in, spew out the contents of the array.
Bear in mind, it's 4am now, and my head was already hurtin' before I started this, so I could be a lil bit off, hehe.
There's also a probably much more optimized way of doing this (actually getting the list of stores with fewer SQL queries), but this was the first logical method that struck me.
As I said, it was kinda left on the backburner for a while, but now I've actually gone n' done the calculations, I think I might go ahead and work on that part of my script a bit after this weekend's over (working all weekend, heh).
Have a play anyways, and let me know how you get along with it.