RE: [PHP] lat lon function

From: Date: Tue, 08 Apr 2003 18:15:50 +0000
Subject: RE: [PHP] lat lon function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-142935@lists.php.net to get a copy of this message
On 08-Apr-2003 Edward Peloke wrote: > > Don, > > How would I get distance? If my search is for a place with a lat of 30 > and > long of 87 and I see a place with a lat of 31 and long of 88, how do you > get > the rough distance? > Forgot Pythagoras ? c^2 = a^2 + b^2 mysql> set @a:=31-30; Query OK, 0 rows affected (0.00 sec) mysql> set @b:=88-87; Query OK, 0 rows affected (0.00 sec) mysql> set @d:=SQRT(POW(@a,2) + POW(@b,2)); Query OK, 0 rows affected (0.00 sec) mysql> SELECT @d * 69; +-----------------+ | @d * 69 | +-----------------+ | 97.580735803744 | +-----------------+ 1 row in set (0.00 sec) 97.6 miles assuming a flat earth. To get a true distance, google 'spherical trig' or 'law of cosines'. Regards, -- Don Read dread@texas.net -- It's always darkest before the dawn. So if you are going to steal the neighbor's newspaper, that's the time to do it.

« previous php.general (#142935) next »