Re: Re: Google Maps Distance Between UK Postcodes

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

 



At 8:31 AM -0700 9/11/08, mike wrote:
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.

I dunno.

But I do know that knowing the latitude and longitude of two points on the surface of the Earth and then trying to calculate the actual distance between each is not a trivial task

Take a look at:

http://en.wikipedia.org/wiki/Latitude#Degree_length

In that table you can see that for every degree north-south there is a change -- likewise, for every degree east-west AND those changes are not equal.

This has been a problem for map makers for a long time.

I remember surveying ancient playas (i.e., lake-beds) in the Mohave desert where my rod man would travel away and I would see his boots disappear beneath the curvature of the Earth. Now, what's the distance between me and my rod man? Is it the distance I see in my survey instrument or the distance of my rod chain? One is a straight line while the other isn't -- which is the correct one?

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
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