Forex miner

Personal blog about forex trading. Automated trading strategy for VT TRADER, TRADERSTATION, METATRADER. Trading strategy fx reviews

Gps distance - php and math formula (working)

Maybe, you will be insituation when you need compute distance from two GPS coordinates (points).

So here is formula and PHP code:


$lat1=00.0000;
$lon1=00.0000;

$lat2=00.0000;
$lon2=00.0000;

$dlat = ($lat2-$lat1)*pi() / 180;
$dlon = ($lon2-$lon1)*pi() / 180;
$a= sin($dlat/2)*sin($dlat/2)+cos($lat1 * pi()/180) * cos($lat2 *pi()/180) * sin($dlon/2) * sin ($dlon/2);

$c=2 * atan2(sqrt($a),sqrt(1-$a));
$distance=6371000*$c;
echo round ($distance/1000,1) ;