0

I need to offer user's who Live in x location in the UK.

I'm currently having users enter their postcode via a form I've built, the postcodes get submitted to the database and I use Google search to check their in a close proximity to which I can offer services.

This sometimes can take me hours to manually hack through hundreds of postcodes this way so I'm looking to automate the process; if I could have the postcodes run through a script that'll determine if postcode x is within y miles of postcode z I'll be able to die happy.

Speed is also an issue for me, so I'm looking for a solution that doesn't rely on an external web service. Does anyone know of a script that'll do the trick?

Michael Rich
  • 191
  • 1
  • 11
  • When you tried looking for scripts or libraries, did you not find what you were needing? – Jared Farrish Feb 11 '12 at 09:22
  • [This blog post](http://labs.phurix.net/posts/how-to-search-by-nearest-uk-postcode-in-php), for instance, offers several suggestions (that may be a little old), but also provides some code. – Jared Farrish Feb 11 '12 at 09:24
  • The Ordnance Survey provide a free download of mainland UK postcodes updated every 3 months... aside from the Post Office, this is surely a definitive list, yet nobody ever seems to be aware that it even exists. – Mark Baker Feb 11 '12 at 11:00

1 Answers1

0

What I would do is map postcodes to latitude and longitude and then use the distance formula between lat/lon coordinates to find out how far away they are.

Link for formula: http://www.mathforum.com/library/drmath/view/51711.html

Link for postcode -> lat/long values: http://www.freemaptools.com/download-uk-postcode-lat-lng.htm (this should be okay but haven't checked)

msgmash.com
  • 1,035
  • 5
  • 10