| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- class GeolocationBounds {
- protected $minLat = 180;
- protected $minLng = 180;
- protected $maxLat = -180;
- protected $maxLng = -180;
- public function __construct() {
- }
- public function extend($lat, $lng) {
- if($lat > $this->maxLat) $this->maxLat = $lat;
- if($lng > $this->maxLng) $this->maxLng = $lng;
- if($lat < $this->minLat) $this->minLat = $lat;
- if($lng < $this->minLng) $this->minLng = $lng;
- }
- public function getCenter() {
- return $this->getCentre();
- }
- public function getCentre() {
- return [
- ($this->minLat + $this->maxLat) / 2,
- ($this->minLng + $this->maxLng) / 2,
- ];
- }
- public function getSouthWest() {
- return [$this->minLat, $this->minLng];
- }
- public function getNorthEast() {
- return [$this->maxLat, $this->maxLng];
- }
- }
- ?>
|