Hi Tim, Yes I need to work out the area size of a rectangular (bounding box) on a geographical map given a Southwest latitude/longitude and a Northeast latitude/longitude geographic coordinate.
If the size of the bounding box is <= 20 kilometres than I retrieve all the rows from the database that are within that bounding box but if the bounding box is larger than 20 Kilometres than I display an error message (i.e. Area too large) Thank you for everyone's help so far On Tue, Apr 30, 2013 at 4:57 PM, Tim Oliver <[email protected]> wrote: > Area/size of the bounding box may not be distance between the two points - > do you mean a bounding box that's aligned with edges parallel to latitude > and longitude? And did you want distance less than 20km, area less than 20 > square kilometers or some dimension less than 20km? This gets pretty hairy > if the box can be large since the area of a 'rectangular' region on the > sphere is larger than on a flat surface. > > > http://www.lunarpedia.org/index.php?title=Area_of_regions_on_the_lunar_spheremight > be handy. > > > On Tue, Apr 30, 2013 at 4:49 PM, Jason Kang <[email protected]> wrote: > >> 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. >> >> >> > > -- > -- > 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 a topic in the > Google Groups "NZ PHP Users Group" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/nzphpug/CxLD69RZC-Y/unsubscribe?hl=en. > To unsubscribe from this group and all its topics, 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.
