#### Archived

This topic is now archived and is closed to further replies.

# UK Cities....

## Recommended Posts

Besides having to pay a big subscription fee to the post office in the uk to search on post codes...

I want to be able search on UK Cities and certain proximities like 50 mile radius...

Regards and Jesus Christ's blessings,

Chris Cundill

##### Share on other sites
You can work it out from the cities grid references with a bit of Pythagoras. There are a number of databases about online with postcodes/references for free. Quick search on Google should help you out.
[code]<?php
function distance(\$na,\$ea,\$nb,\$eb) {
\$dist_n = \$na - \$nb;
\$dist_e = \$ea - \$eb;

\$hypot = sqrt((\$dist_n * \$dist_n) + (\$dist_e * \$dist_e));
return "Distance between \$na(N) \$ea(E) and \$nb(N) \$eb(E) is: ".round(\$hypot/1000,2)."kms";
}
?>[/code]

##### Share on other sites
First you need a database of

location, latitude, longitude.

Once you know where all the places are you can find them with a search. Searching in a square centered on you location is easier than radial distances. So if the bottom left corner of the square is at x1, y1 and top right is at x2, y2 then you search for

SELECT location WHERE long BETWEEN x1 and x2 AND lat BETWEEN y1 AND y2.

##### Share on other sites
I'm getting somewhere I think...

What Barand said made sense its just his sql statement is not quite what I need.

Would someone be able to elaborate on this to help me understand how to actually return the distance between two points.

Many Thanks.

Regards and Jesus Christ's blessings,

Chris Cundill

##### Share on other sites
[quote]
You can work it out from the cities grid references with a bit of Pythagoras. There are a number of databases about online with postcodes/references for free. Quick search on Google should help you out./
[/quote]

I googled and there all paid ones were can i get the postcode database free cheers.

##### Share on other sites
i dont know of any free scripts, but can i point out that uk postcodes are a trademark of royal mail and if people are found using them, u may get a hefty fine..

##### Share on other sites
So does that mean that company's and websites using the postcodes for gavering information for orders to pay are useing the royal mail post code service.

nice to know cheers.

So in reality there the ones offering the service to website users with a subcrition of some salt.

##### Share on other sites
well not really sure, i think it is only if you have a database of them, but i dont know, maybe u can use them for free, im just looking it up, see if i can come up with anything

cheers mate

##### Share on other sites
I have a few links here - not sure if it is what you are loking for but here they are:-

http://www.evoxfacilities.co.uk/index.html
http://en.wikipedia.org/wiki/List_of_postal_districts_in_the_United_Kingdom
http://en.wikipedia.org/wiki/List_of_postal_areas_in_the_United_Kingdom
http://en.wikipedia.org/wiki/Lists_of_postal_codes

##### Share on other sites
Thank you for your help cheers i try them.

##### Share on other sites
Distance Calculation

http://www.movable-type.co.uk/scripts/LatLong.html