Re: Re: Google Maps Distance Between UK Postcodes

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

 



On Thu, Sep 11, 2008 at 8:17 AM, tedd <tedd.sperling@xxxxxxxxx> wrote:

> Considering that my other profession is Geophysicist, I'm kind of up on
> those sort of things. The Earth is an oblate spheroid and the computation to
> include the curvature of the earth would be a bit more involved.

what do you think of the code i mentioned earlier?

$distance = number_format(ceil(69*rad2deg(acos(sin(deg2rad($ulat)) *
sin(deg2rad($vlat)) + cos(deg2rad($ulat)) * cos(deg2rad($vlat)) *
cos(deg2rad($ulong - $vlong))))));

where:

$ulat = latitude of user #1
$ulong = longitude of user #1

$vlat = latitude of user #2
$vlong = longitude of user #2

I took the very popular mysql query (at the time) that supposedly
works with a sphere and mapped it to php functions and it has appeared
to work very well. I have only tested with US zip codes, but the
concept should be the same as long as lat/long are centered properly.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.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