Old 13-03-2008, 09:11   #1 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,620
postcode database

Does anyone have a complete database of UK postcodes with lat and long?

Just bought one, installed and compared to 2000 random postcodes and 50 - 100 are not listed.

Or perhaps a method of getting lat and long for a given postcode?

Does anyone know how many UK postcodes there are?
__________________
  Reply With Quote
Old 13-03-2008, 09:19   #2 (permalink)
Limbo
On yer bike...
 
Limbo's Avatar
 
Join Date: Feb 2005
Posts: 4,957
Postcodes are added & amended, like houses and roads, daily - so live data is essential.

You can buy postcode web services - it's expensive but let's you interrogate a live database - we did some work with a development agency who sorted this side and the used the royal mail...
__________________
  Reply With Quote
Old 13-03-2008, 09:25   #3 (permalink)
freelancr
Web Developer
 
freelancr's Avatar
 
Join Date: Oct 2006
Posts: 2,007
__________________
  Reply With Quote
Old 13-03-2008, 09:31   #4 (permalink)
woodss
Just another web monkey
 
woodss's Avatar
 
Join Date: Mar 2005
Location: Newcastle, UK
Posts: 216
Send a message via ICQ to woodss Send a message via MSN to woodss Send a message via Yahoo to woodss Send a message via Skype™ to woodss
Yup, we're using the postcodeanywhere XMLs
  Reply With Quote
Old 13-03-2008, 09:32   #5 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,620
Thanks very useful.
__________________
  Reply With Quote
Old 16-03-2008, 07:23   #6 (permalink)
88mph
Great Scott!!
 
88mph's Avatar
 
Join Date: Feb 2008
Posts: 223
does anyone know of a service that can return distances based on postcodes, for delivery costs?
  Reply With Quote
Old 16-03-2008, 07:40   #7 (permalink)
freelancr
Web Developer
 
freelancr's Avatar
 
Join Date: Oct 2006
Posts: 2,007
Quote:
Originally Posted by 88mph
does anyone know of a service that can return distances based on postcodes, for delivery costs?

Postcode Anywhere can... but the Google Maps API might do it for free?
__________________
  Reply With Quote
Old 16-03-2008, 08:19   #8 (permalink)
88mph
Great Scott!!
 
88mph's Avatar
 
Join Date: Feb 2008
Posts: 223
thats what i have been looking into, yet to find a definite yes or no yet
  Reply With Quote
Old 16-03-2008, 08:26   #9 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,620
From postcodes you need longitude and latitude. From this you can calc distance between two postcodes.

PHP Code:
<?php

function getDistance($lat1$long1$lat2$long2)
{
//$earth = 6371; //km change accordingly
$earth 3960//miles

//Point 1 cords
$lat1 deg2rad($lat1);
$long1deg2rad($long1);

//Point 2 cords
$lat2 deg2rad($lat2);
$long2deg2rad($long2);

//Haversine Formula
$dlong=$long2-$long1;
$dlat=$lat2-$lat1;

$sinlat=sin($dlat/2);
$sinlong=sin($dlong/2);

$a=($sinlat*$sinlat)+cos($lat1)*cos($lat2)*($sinlong*$sinlong);

$c=2*asin(min(1,sqrt($a)));

$d=round($earth*$c,2);

return 
$d;
}

?>
__________________
  Reply With Quote
Old 16-03-2008, 09:10   #10 (permalink)
freelancr
Web Developer
 
freelancr's Avatar
 
Join Date: Oct 2006
Posts: 2,007
It's not a useful distance for deliveries, better off getting how many miles it is by road from Google Maps API.
__________________
  Reply With Quote
Old 16-03-2008, 09:52   #11 (permalink)
datahound
Spare Parts
 
datahound's Avatar
 
Join Date: Jan 2005
Location: Bracknell Forest
Posts: 4,620
Sorry about that.
__________________
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8