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