Php > Miscellaneous
Calculate distance based on lat. long
Calculate distance based on lat. long
Document
\n"; die; } if(ereg("\.",$name)){ $dot = "."; $pos = strpos($name, $dot); //echo $pos."
\n"; if($pos > 3){ echo "The input cannot exceed more than 3 digits left of the decimal
\n"; die; } } if($name > 365){ echo "The input cannot exceed 365 degrees
\n"; die; } } $A = $Aa/57.29577951; $B = $Ba/57.29577951; $C = $Ca/57.29577951; $D = $Da/57.29577951; //convert all to radians: degree/57.29577951 if ($A == $C && $B == $D ){ $dist = 0; } else if ( (sin($A)* sin($C)+ cos($A)* cos($C)* cos($B-$D)) > 1){ $dist = 3963.1* acos(1);// solved a prob I ran into. I haven't fully analyzed it yet } else{ $dist = 3963.1* acos(sin($A)*sin($C)+ cos($A)* cos($C)* cos($B-$D)); } return ($dist); } ?>
Point one Lat
Long
Point two Lat
Long
echo "
distance = ".$distance." miles (as the crow flies)
"; ?>
Php Codes
Algorithms
Arrays
Authentication
Calendar
Code Snippets
Programs
Content Manage
Contest Related
Cookies
Credit Cards
DBase Related
Databases
Date Time
Directories
E-Mail
Errors
File
File System
Forms
Handling
Graphics
HTML and PHP
Informix
Ingres
InterBase
LDAP
Look and Feel
Miscellaneous
MySQL
Other
PHP Classes
Searching
Navigation
Statistics
Strings
User Manage