I need to create a page (in PHP and MySQL) that allows you to find the distance (in miles) between two UK postcodes, by entering either the postcodes or the names of the places.
I have an existing database of postcodes with place names, which was obtained from the following link:
[login to view URL]
(click on the link titled "[login to view URL]")
I have set this up with a function that calculates the distance, however the results are not accurate enough. The data appears to be OK, so it must be the calculation that is inaccurate. So, we need to either create a new function that provides accurate results, OR start from scratch with new data.
The current database contains the first part of each postcode only, for example "DH1" instead of "DH1 2YZ", and each postcode has latitude/longitude values as well as the place name. Example record:
"DH1", "54.781", "-1.566", "Durham"
There is an official database of postcode geo-location data (called "Code-Point Open") that is available in CSV format from here:
[login to view URL]
However, this data does not contain place names. If we were to use this data, we would need to add a field for the place name and somehow populate it with a value for each postcode - possibly by scraping a site like Google Maps? Example record:
"DH1 1AB",10,"X",-99,-99,-99,-99,-99,-99,-99,430317,543630,064,"Y51","Q30","00","EJ","MG","X"
Another issue with this data is that it only contains *full* postcodes. So, if we were to search for a city by name, it would return many, many postcodes - we would need a mechanism for selecting which one of the postcodes to use (possibly the first alphabetically, as this is usually quite central).
I am open to suggestions for the best possible method. I hope all the above makes sense! If you have any questions, please don't hesitate to ask me.
Thanks for your time,
Adam