Re: Re: Google Maps Distance Between UK Postcodes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2008/9/1 Tom Chubb <tomchubb@xxxxxxxxx>

> On 01/09/2008, Colin Guthrie <gmane@xxxxxxxxxxxxxx> wrote:
> >
> > Tom Chubb wrote:
> >
> >> I thought it would be easy but it seems that I need to convert each
> >> postcode
> >> to Lat/Long using Geocoding and then work it out from there.
> >>
> >
> > That's the best way: then just do something like:
> >
> > Here's how I do it in SQL, but the principle is the same in PHP, so I'm
> > sure you'll be able to convert it.
> >
> > HTHs
> >
> > Col
> >
> > <snip>
> >  public static function Distance($latA, $lngA, $latB, $lngB, $blnMiles =
> > false)
> >  {
> >    $multiplier = 6371;
> >    if ($blnMiles)
> >      $multiplier *= 1.609344;
> >
> >    $rv = <<<ESQL
> >  (ACOS(
> >    SIN(RADIANS($latA)) * SIN(RADIANS($latB))
> >    + COS(RADIANS($latA)) * COS(RADIANS($latB)) * COS(RADIANS($lngB) -
> > RADIANS($lngA)))
> >  * $multiplier)
> > ESQL;
> >    return $rv;
> >  }
> > </snip>
> >
> >
> >
> >
> > --
> >
> > Colin Guthrie
> > gmane(at)colin.guthr.ie
> > http://colin.guthr.ie/
> >
> > Day Job:
> >  Tribalogic Limited [http://www.tribalogic.net/]
> > Open Source:
> >  Mandriva Linux Contributor [http://www.mandriva.com/]
> >  PulseAudio Hacker [http://www.pulseaudio.org/]
> >  Trac Hacker [http://trac.edgewall.org/]
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> Thanks Colin,
> That's all way above my head, but I think I'll be able to understand it
> after a strong coffee!
> Any idea how you get the co-ords from the UK Postcode though?
> There seems to be a privacy factor with UK postcodes, but I'm only after
> the
> first section: eg SW11 6**
>


This address should help you. Thay have distance calculator on the page but
also you can download database with postcodes and their co-ords ->
http://www.pc-i.co.uk/postcode-distance.php

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux