Jump to content

UK Cities....


puritystandsout

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...

Does anyone have any idea how I'd go about this?  Has anyone done this before?

Please help.  Thanks...

Regards and Jesus Christ's blessings,

Chris Cundill
Link to comment
https://forums.phpfreaks.com/topic/14473-uk-cities/
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]
Link to comment
https://forums.phpfreaks.com/topic/14473-uk-cities/#findComment-57265
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.
Link to comment
https://forums.phpfreaks.com/topic/14473-uk-cities/#findComment-57268
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
Link to comment
https://forums.phpfreaks.com/topic/14473-uk-cities/#findComment-57877
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]

postcode database were please cheers.

I googled and there all paid ones were can i get the postcode database free cheers.
Link to comment
https://forums.phpfreaks.com/topic/14473-uk-cities/#findComment-57879
Share on other sites

Guest huey4657
I have a few links here - not sure if it is what you are loking for but here they are:-

http://www.grcdi.nl/linkspc.htm
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
Link to comment
https://forums.phpfreaks.com/topic/14473-uk-cities/#findComment-57896
Share on other sites

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.