1: <?php
2: namespace Mapbender\WmtsBundle\Entity;
3:
4: use Doctrine\Common\Collections\ArrayCollection;
5:
6: /**
7: * TileMatrixSet class
8: *
9: * @author Paul Schmidt
10: */
11: class TileMatrixSet {
12: /** @var string title */
13: protected $title;
14: /** @var string abstract */
15: protected $abstract;
16: /** @var string identifier */
17: protected $identifier;
18: /** @var string keyword ??? */
19: protected $keyword;
20: /** @var array supportedsrs */
21: protected $supportedsrs = array();
22: /** @var string wellknowscaleset */
23: protected $wellknowscaleset;
24: /** @var array $tilematrixes */
25: protected $tilematrixes;
26: /**
27: * Create an instance of TileMatrixSet
28: *
29: * @param type $tilematrixset
30: */
31: public function __construct($tilematrixset = null){
32: $this->tilematrixes = new ArrayCollection();
33: if($tilematrixset!=null && is_array($tilematrixset)){
34: $this->setTitle($tilematrixset["title"]);
35: $this->setAbstract($tilematrixset["abstract"]);
36: $this->setIdentifier($tilematrixset["identifier"]);
37: $this->setKeyword($tilematrixset["keyword"]);
38: $this->setSupportedSRS($tilematrixset["supportedsrs"]);
39: $this->setWellknowscaleset($tilematrixset["wellknowscaleset"]);
40: foreach($tilematrixset["tilematrixes"] as $tilematrix){
41: $this->tilematrixes->add(new TileMatrix($tilematrix));
42: }
43: }
44: }
45:
46: /**
47: * Get title
48: *
49: * @return string
50: */
51: public function getTitle() {
52: return $this->title;
53: }
54: /**
55: * Set title
56: * @param string $value
57: */
58: public function setTitle($value) {
59: $this->title = $value;
60: }
61: /**
62: * Get abstract
63: * @return string
64: */
65: public function getAbstract() {
66: return $this->abstract;
67: }
68: /**
69: * Set abstract
70: * @param string $value
71: */
72: public function setAbstract($value) {
73: $this->abstract = $value;
74: }
75: /**
76: * Get identifier
77: *
78: * @return string
79: */
80: public function getIdentifier() {
81: return $this->identifier;
82: }
83: /**
84: * Set identifier
85: *
86: * @param string $value
87: */
88: public function setIdentifier($value) {
89: $this->identifier = $value;
90: }
91: /**
92: * Get keyword
93: *
94: * @return string
95: */
96: public function getKeyword() {
97: return $this->keyword;
98: }
99: /**
100: * Set keyword
101: *
102: * @param string $value
103: */
104: public function setKeyword($value) {
105: $this->keyword = $value;
106: }
107: /**
108: * Get suppertedsrs
109: *
110: * @return string
111: */
112: public function getSupportedSRS() {
113: return $this->supportedsrs;
114: }
115: /**
116: * Set supportedsrs
117: *
118: * @param string $value
119: */
120: public function setSupportedSRS($value) {
121: $this->supportedsrs = $value;
122: }
123: /**
124: * Add supportedsrs
125: *
126: * @param string $value
127: */
128: public function addSupportedSRS($value) {
129: if($this->supportedsrs === null) {
130: $this->supportedsrs = array();
131: }
132: if(!in_array($value, $this->supportedsrs)){
133: $this->supportedsrs[] = $value;
134: }
135: }
136: /**
137: * Get simple supportedsrs
138: *
139: * return array
140: */
141: public function getSRS() {
142: if($this->supportedsrs === null) {
143: return array();
144: } else {
145: $array = array();
146: foreach($this->supportedsrs as $srs) {
147: $newsrs = strripos($srs, "EPSG") !== FALSE ? substr($srs, strripos($srs, "EPSG")) : $srs;
148: $array[] = str_replace("::" , ":" , $newsrs);
149: }
150: return $array;
151: }
152: }
153: /**
154: * Get wellknowscaleset
155: *
156: * @return string
157: */
158: public function getWellknowscaleset() {
159: return $this->wellknowscaleset;
160: }
161: /**
162: * Set wellknowscaleset
163: *
164: * @param string $value
165: */
166: public function setWellknowscaleset($value) {
167: $this->wellknowscaleset = $value;
168: }
169: /**
170: * Get Tilematrix as ArrayCollection of Tilematrix
171: *
172: * @return array
173: */
174: public function getTilematrix(){
175: return $this->tilematrixes;
176: }
177: /**
178: * Set tilematrix: ArrayCollection of Tilematrix
179: *
180: * @param ArrayCollection $tilematrixes
181: */
182: public function setTilematrix($tilematrixes){
183: $this->tilematrixes = $tilematrixes;
184: }
185: /**
186: * Add to tilematrix TileMatrix or Tilematrix as array
187: *
188: * @param $tilematrix
189: */
190: public function addTilematrix($tilematrix){
191: if($tilematrix instanceof TileMatrix) {
192: $this->tilematrixes->add($tilematrix);
193: } else if(is_array($tilematrix)) {
194: $this->tilematrixes->add(new TileMatrix($tilematrix));
195: }
196: }
197: /**
198: * Get TilematrixSet as array of string inc. TileMatrixes
199: *
200: * @return array
201: */
202: public function getAsArray() {
203: $tilematrixset = array();
204: $tilematrixset["title"] = $this->getTitle();
205: $tilematrixset["abstract"] = $this->getAbstract();
206: $tilematrixset["identifier"] = $this->getIdentifier();
207: $tilematrixset["keyword"] = $this->getKeyword();
208: $tilematrixset["supportedsrs"] = $this->getSupportedSRS();
209: $tilematrixset["wellknowscaleset"] = $this->getWellknowscaleset();
210: $tilematrix = array();
211: foreach($this->getTilematrix() as $tilematrixObj){
212: $tilematrix[] = $tilematrixObj->getAsArray();
213: }
214: $tilematrixset["tilematrixes"] = $tilematrix;
215: return $tilematrixset;
216: }
217: }
218: