I've found a good answer for you! :-D

http://bit.ly/11SaJ04



Or

$southwest_lat = $_GET['swlat'];
$southwest_lng = $_GET['swlng'];
$northeast_lat =  $_GET['nelat'];
$northeast_lng = $_GET['nelng'];

$result = distance($southwest_lat, $southwest_lng, $northeast_lat,
$northeast_lng, "K");

if($result > 20) {

  echo "over 20!";

} else {

  echo "over 20!";

}

function distance($lat1, $lon1, $lat2, $lon2, $unit) {

  $theta = $lon1 - $lon2;
  $dist = sin(deg2rad($lat1)) * sin(deg2rad($lat2)) +
cos(deg2rad($lat1)) * cos(deg2rad($lat2)) * cos(deg2rad($theta));
  $dist = acos($dist);
  $dist = rad2deg($dist);
  $miles = $dist * 60 * 1.1515;
  $unit = strtoupper($unit);

  if ($unit == "K") {
    return ($miles * 1.609344);
  } else if ($unit == "N") {
      return ($miles * 0.8684);
    } else {
        return $miles;
      }
}



On Tue, Apr 30, 2013 at 4:30 PM, Olivia <[email protected]> wrote:

> Hi all,
>
> I am using PHP 5.3.9 and I am trying to figure out how to calculate the
> size of a bounding box based on the passed in coordinates of the 4 corners
> of a geographical map.
> The reason for this is that I need to check that the size/area of the
> bounding box is not larger than 20 Kilometres.
>
> The bounding box format is defined as:
>
> $southwest_lat = $_GET['swlat'];
> $southwest_lng = $_GET['swlng'];
> $northeast_lat =  $_GET['nelat'];
> $northeast_lng = $_GET['nelng'];
>
> Your help is much appreciated.
>
> Kind regards,
> Olivia
>
>
>
> --
> --
> NZ PHP Users Group: http://groups.google.com/group/nzphpug
> To post, send email to [email protected]
> To unsubscribe, send email to
> [email protected]
> ---
> You received this message because you are subscribed to the Google Groups
> "NZ PHP Users Group" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
--- 
You received this message because you are subscribed to the Google Groups "NZ 
PHP Users Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to