Re: Re: Google Maps Distance Between UK Postcodes
| From: | mike | Date: | Thu, 11 Sep 2008 15:31:31 +0000 |
| Subject: | Re: Re: Google Maps Distance Between UK Postcodes | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-279900@lists.php.net to get a copy of this message | ||
On Thu, Sep 11, 2008 at 8:17 AM, tedd <tedd.sperling@gmail.com> 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.