NameSilo

Distance between longitudes and latitudes

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
Watch

Dan

Buy my domains.VIP Member
Impact
108
PHP:
<?php

// Example points
$lat1 = '117.1216';
$lon1 = '32.69460';
$lat2 = '117.0516';
$lon2 = '32.70614';

function deg_to_rad($deg) {
     $radians = 0.0;
     $radians = $deg * M_PI/180.0;
     return($radians);
}

$distance = 3956 * 2 * atan2(sqrt(pow(sin((deg_to_rad($lat2) - deg_to_rad($lat1))/2.0),2) + cos($lat1) * cos($lat2) * pow(sin((deg_to_rad($lon2) - deg_to_rad($lon1))/2.0),2)),sqrt(1-(pow(sin((deg_to_rad($lat2) - deg_to_rad($lat1))/2.0),2) + cos($lat1) * cos($lat2) * pow(sin((deg_to_rad($lon2) - deg_to_rad($lon1))/2.0),2))));

echo $distance; // Miles between the points.

?>
I'm working on a script related to this and I found this pretty amazing, so I thought I'd post it.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Wow...thanks for the share.
 
0
•••
This is basically Maths.
You just got know how Longitudes and Latitudes are calculated.
The programming part is easy.
 
0
•••
bbalegere said:
This is basically Maths.
You just got know how Longitudes and Latitudes are calculated.
The programming part is easy.
Did anyone say anything had to be hard to be posted? I highly doubt you could figure that out anyways.
 
0
•••
Anybody have good sources for location databases ? :cy:
 
0
•••
0
•••
thanks for the share Dan.. was wondering how they figure that out.
 
0
•••
DomainEasy: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
URLs.com
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back