1: <?php
2:
3: namespace Mapbender\CoreBundle\Component;
4:
5: /**
6: * BoundingBox class.
7: *
8: * @author Paul Schmidt
9: */
10: class BoundingBox
11: {
12:
13: /**
14: * @var srs Spatial reference system
15: *
16: * ORM\Column(type="string", nullable=false)
17: */
18: //@TODO Doctrine bug: "protected" replaced with "public"
19: public $srs;
20:
21: /**
22: * @var minx Minimum X of the Bounding Box
23: * ORM\Column(type="float", nullable=false)
24: */
25: //@TODO Doctrine bug: "protected" replaced with "public"
26: public $minx;
27:
28: /**
29: * @var miny Minimum Y of the Bounding Box
30: * ORM\Column(type="float", nullable=false)
31: */
32: //@TODO Doctrine bug: "protected" replaced with "public"
33: public $miny;
34:
35: /**
36: * @var maxx Maximum X of the Bounding Box
37: * ORM\Column(type="float", nullable=false)
38: */
39: //@TODO Doctrine bug: "protected" replaced with "public"
40: public $maxx;
41:
42: /**
43: * @var maxy Maximum Y of the Bounding Box
44: * ORM\Column(type="float", nullable=false)
45: */
46: //@TODO Doctrine bug: "protected" replaced with "public"
47: public $maxy;
48:
49: /**
50: * Creates a BoundingBox from parameters
51: *
52: * @param array $parameters
53: */
54: public static function create(array $parameters)
55: {
56: try
57: {
58: return new BoundingBox(
59: isset($parameters["srs"]) ? $parameters["srs"] : null,
60: isset($parameters["minx"]) ? $parameters["minx"] : null,
61: isset($parameters["miny"]) ? $parameters["miny"] : null,
62: isset($parameters["maxx"]) ? $parameters["maxx"] : null,
63: isset($parameters["maxy"]) ? $parameters["maxy"] : null
64: );
65: } catch(\Exception $e)
66: {
67: return null;
68: }
69: }
70:
71: /**
72: * Creates a BoundingBox
73: *
74: * @param type $srs srs
75: * @param type $minx minx
76: * @param type $miny miny
77: * @param type $maxx maxx
78: * @param type $maxy maxy
79: */
80: public function __construct($srs = null, $minx = null, $miny = null,
81: $maxx = null, $maxy = null)
82: {
83: $this->srs = $srs;
84: $this->minx = $minx;
85: $this->miny = $miny;
86: $this->maxx = $maxx;
87: $this->maxy = $maxy;
88: }
89:
90: /**
91: * Get srs
92: *
93: * @return string
94: */
95: public function getSrs()
96: {
97: return $this->srs;
98: }
99:
100: /**
101: * Set srs
102: * @param string $value
103: * @return BoundingBox
104: */
105: public function setSrs($value)
106: {
107: $this->srs = $value;
108: return $this;
109: }
110:
111: /**
112: * Get minx
113: *
114: * @return float
115: */
116: public function getMinx()
117: {
118: return $this->minx;
119: }
120:
121: /**
122: * Set minx
123: * @param float $value
124: * @return BoundingBox
125: */
126: public function setMinx($value)
127: {
128: $this->minx = $value;
129: return $this;
130: }
131:
132: /**
133: * Get miny
134: *
135: * @return float
136: */
137: public function getMiny()
138: {
139: return $this->miny;
140: }
141:
142: /**
143: * Set miny
144: * @param float $value
145: * @return BoundingBox
146: */
147: public function setMiny($value)
148: {
149: $this->miny = $value;
150: return $this;
151: }
152:
153: /**
154: * Get maxx
155: *
156: * @return float
157: */
158: public function getMaxx()
159: {
160: return $this->maxx;
161: }
162:
163: /**
164: * Set maxx
165: * @param float $value
166: * @return BoundingBox
167: */
168: public function setMaxx($value)
169: {
170: $this->maxx = $value;
171: return $this;
172: }
173:
174: /**
175: * Get maxy
176: *
177: * @return float
178: */
179: public function getMaxy()
180: {
181: return $this->maxy;
182: }
183:
184: /**
185: * Set maxy
186: * @param float $value
187: * @return BoundingBox
188: */
189: public function setMaxy($value)
190: {
191: $this->maxy = $value;
192: return $this;
193: }
194:
195: /**
196: * Get object as array
197: *
198: * @return array
199: */
200: public function toArray()
201: {
202: return array(
203: "srs" => $this->srs,
204: "minx" => $this->minx,
205: "miny" => $this->miny,
206: "maxx" => $this->maxx,
207: "maxy" => $this->maxy
208: );
209: }
210:
211: }