Hi Group, I'm trying to use the longitude and latitude to do a radius
search but I'm getting some inaccurate results, below is the code and I
was wondering if anyone knows weather or not I'm doing the calculations any
feed back is much appreciated. Thanks Todd
class RadiusAssistant {
var $maxLat;
var $minLat;
var $maxLong;
var $minLong;
function RadiusAssistant($Latitude, $Longitude, $Miles) {
global $maxLat,$minLat,$maxLong,$minLong;
$EQUATOR_LAT_MILE = 69.172;
$maxLat = $Latitude + $Miles / $EQUATOR_LAT_MILE;
$minLat = $Latitude - ($maxLat - $Latitude);
$maxLong = $Longitude + $Miles / (cos($minLat * M_PI / 180) *
$EQUATOR_LAT_MILE);
$minLong = $Longitude - ($maxLong - $Longitude);
}
function MaxLatitude() {
return $GLOBALS["maxLat"];
}
function MinLatitude() {
return $GLOBALS["minLat"];
}
function MaxLongitude() {
return $GLOBALS["maxLong"];
}
function MinLongitude() {
return $GLOBALS["minLong"];
}
}