Results from the most recent live auction are here .
27 members in the live chat room. Join Chat !
09-27-2006, 08:44 PM
· #1 Buy my domains.
Name: Dan
Join Date: Feb 2006
Posts: 2,801
NP$: 54.00 (
Donate )
Distance between longitudes and latitudes
PHP Code:
<?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.
09-27-2006, 08:48 PM
· #2 Senior Member
Name: Josh Evans
Location: Ohio
Join Date: Aug 2005
Posts: 1,704
NP$: 149.75 (
Donate )
Wow...thanks for the share.
__________________
"If PHP is peanut butter...then...MySQL would be the jelly. Together they can make one heck of a good sandwich." --- Netzilla 9/14/08
09-30-2006, 04:15 AM
· #3 Senior Member
Name: Bharat Balegere
Location: Bangalore
Join Date: Jul 2005
Posts: 1,178
NP$: 9.25 (
Donate )
This is basically Maths.
You just got know how Longitudes and Latitudes are calculated.
The programming part is easy.
09-30-2006, 09:54 AM
· #4 Buy my domains.
Name: Dan
Join Date: Feb 2006
Posts: 2,801
NP$: 54.00 (
Donate )
Originally Posted by bbalegere 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.
09-30-2006, 09:58 AM
· #5 Law and disorder
Name: Kate
Location: Expat
Join Date: Aug 2005
Posts: 5,129
NP$: 890.11 (
Donate )
Anybody have good sources for location databases ?
09-30-2006, 10:03 AM
· #6 Buy my domains.
Name: Dan
Join Date: Feb 2006
Posts: 2,801
NP$: 54.00 (
Donate )
10-01-2006, 09:14 AM
· #7 NamePros Regular
Join Date: Apr 2006
Posts: 252
NP$: 2110.00 (
Donate )
thanks for the share Dan.. was wondering how they figure that out.
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off