root/g-map/files/lib/util/BoundsUtil.class.php @ 763

Revision 763, 1.1 kB (checked in by d0nut, 4 years ago)

moved g-map to wcf repository

Line 
1<?php
2
3/**
4 * gets several positions and builds the bounding box
5 *
6 * @package     de.gmap.wcf.util
7 * @author      Michael Senkler, Torben Brodt
8 * @license     GNU General Public License <http://opensource.org/licenses/gpl-3.0.html>
9 */
10class BoundsUtil {
11        public $left, $right, $bottom, $top;
12
13        /**
14         * Constructor
15         */
16        public function __construct() {
17                $this->left = -180;
18                $this->right = 180;
19                $this->bottom = -180;
20                $this->top = 180;
21        }
22
23        /**
24         * adds Position to group
25         * @param lat -> latitude
26         * @param lng -> longitude
27         */
28        public function add($lat, $lng) {
29                $lat = floatval($lat);
30                $lng = floatval($lng);
31
32                if($this->left == -180 || $lat < $this->left) {
33                        $this->left = $lat;
34                }
35                if($this->right == 180 || $lat > $this->right) {
36                        $this->right = $lat;
37                }
38                if($this->bottom == -180 || $lng < $this->bottom) {
39                        $this->bottom = $lng;
40                }
41                if($this->top == 180 || $lng > $this->top) {
42                        $this->top = $lng;
43                }
44        }
45
46        /*
47         * Overwrites the toString method
48         */
49        public function __toString() {
50                return implode(",",array($this->left,$this->top,$this->right,$this->bottom));
51        }
52}
53?>
Note: See TracBrowser for help on using the browser.