Jump to content

Recommended Posts

you need to look for 2 things:

 

1, a UK postcode database which also holds the longitude/latitude of the postcode. Getting a database with a full collection of the first part of the postcode (ie, B27) is a pretty straightforward google search. If you want the full postcode (ie, SE1 4XU) then you may have to do a bit more digging or pay for it (if you find it via the former, let me know :) )

 

2, another google search that converts 2 longitude/latitude pairs to a straight line distance. again, there are many different implementations but finding one shouldnt be too tricky.

 

Then it's simply a case of storing the location of each car and making the calcs as you go.

Link to comment
https://forums.phpfreaks.com/topic/46551-uk-postcode/#findComment-226613
Share on other sites

You could try to get a 4 digit zipcode from googlemaps or yahoo maps and translate that to latitude longitude coordinates. After you stored that in your database you can search on distance.

 

Hope this link will get you futher:

http://ben.milleare.com/2006/09/03/calculating-distance-with-latitude-and-longitude/

 

Link to comment
https://forums.phpfreaks.com/topic/46551-uk-postcode/#findComment-226615
Share on other sites

and here's a postcode resource I mentioned, which gives longitude/latitude for the first part of the postcode.

 

http://www.jibble.org/ukpostcodes/

edit: you might find some good references here too: http://en.wikipedia.org/wiki/UK_postcodes#References

 

edit 2: this one seems to do the lot: http://www.pjenkins.co.uk/blog/index.php/2007/04/04/uk_post_code_distance_calculation/

 

b83s, from my experience, both google and yahoo have rubbish support for UK postcodes, but the link you provided is a good one ;)

Link to comment
https://forums.phpfreaks.com/topic/46551-uk-postcode/#findComment-226623
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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