1: <?php
2:
3: namespace Mapbender\WmsBundle\Entity;
4:
5: use Doctrine\Common\Collections\ArrayCollection;
6: use Doctrine\ORM\Mapping as ORM;
7: use Mapbender\CoreBundle\Component\BoundingBox;
8: use Mapbender\CoreBundle\Entity\Keyword;
9: use Mapbender\WmsBundle\Entity\WmsLayerSource;
10: use Mapbender\WmsBundle\Component\IdentifierAuthority;
11: use Mapbender\WmsBundle\Component\Attribution;
12: use Mapbender\WmsBundle\Component\Authority;
13: use Mapbender\WmsBundle\Component\Dimension;
14: use Mapbender\WmsBundle\Component\Extent;
15: use Mapbender\WmsBundle\Component\Identifier;
16: use Mapbender\WmsBundle\Component\MetadataUrl;
17: use Mapbender\WmsBundle\Component\MinMax;
18: use Mapbender\WmsBundle\Component\OnlineResource;
19: use Mapbender\WmsBundle\Component\Style;
20: use Mapbender\CoreBundle\Component\Utils;
21:
22: /**
23: * @ORM\Entity
24: * @ORM\Table(name="mb_wms_wmslayersource")
25: */
26: class WmsLayerSource
27: {
28:
29: /**
30: * @var integer $id
31: * @ORM\Id
32: * @ORM\Column(type="integer")
33: * @ORM\GeneratedValue(strategy="AUTO")
34: */
35: protected $id;
36:
37: /**
38: * @ORM\ManyToOne(targetEntity="WmsSource",inversedBy="layers")
39: * @ORM\JoinColumn(name="wmssource", referencedColumnName="id")
40: */
41: protected $source;
42:
43: /**
44: * @ORM\ManyToOne(targetEntity="WmsLayerSource",inversedBy="sublayer")
45: * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", nullable=true)
46: */
47: protected $parent = null;
48:
49: /**
50: * @ORM\OneToMany(targetEntity="WmsLayerSource",mappedBy="parent")
51: * @ORM\OrderBy({"id" = "asc"})
52: */
53: protected $sublayer;
54:
55: /**
56: * @ORM\Column(type="string", nullable=true)
57: */
58: protected $name = null;
59:
60: /**
61: * @ORM\Column(type="string", nullable=true)
62: */
63: protected $title = "";
64:
65: /**
66: * @ORM\Column(type="text", nullable=true)
67: */
68: protected $abstract = "";
69:
70: /**
71: * @ORM\Column(type="boolean", nullable=true)
72: */
73: protected $queryable;
74:
75: /**
76: * @ORM\Column(type="integer", nullable=true)
77: */
78: protected $cascaded = 0;
79:
80: /**
81: * @ORM\Column(type="boolean", nullable=true)
82: */
83: protected $opaque = false;
84:
85: /**
86: * @ORM\Column(type="boolean", nullable=true)
87: */
88: protected $noSubset = false;
89:
90: /**
91: * @ORM\Column(type="integer", nullable=true)
92: */
93: protected $fixedWidth;
94:
95: /**
96: * @ORM\Column(type="integer", nullable=true)
97: */
98: protected $fixedHeight;
99:
100: /**
101: * @ORM\Column(type="object", nullable=true)
102: */
103: //@TODO Doctrine bug: "protected" replaced with "public"
104: public $latlonBounds;
105:
106: /**
107: * @ORM\Column(type="array", nullable=true)
108: */
109: //@TODO Doctrine bug: "protected" replaced with "public"
110: public $boundingBoxes;
111:
112: /**
113: * @ORM\Column(type="array", nullable=true)
114: */
115: protected $srs;
116:
117: /**
118: * @ORM\Column(type="array", nullable=true)
119: */
120: protected $styles;
121:
122: /**
123: * @ORM\Column(type="object",nullable=true)
124: */
125: //@TODO Doctrine bug: "protected" replaced with "public"
126: public $scale;
127:
128: /**
129: * @ORM\Column(type="object",nullable=true)
130: */
131: //@TODO Doctrine bug: "protected" replaced with "public"
132: public $scaleHint;
133:
134: /**
135: * @ORM\Column(type="object", nullable=true)
136: */
137: //@TODO Doctrine bug: "protected" replaced with "public"
138: public $attribution;
139:
140: /**
141: * @ORM\Column(type="array",nullable=true)
142: */
143: //@TODO Doctrine bug: "protected" replaced with "public"
144: public $identifier;
145:
146: /**
147: * @ORM\Column(type="array",nullable=true)
148: */
149: //@TODO Doctrine bug: "protected" replaced with "public"
150: public $authority;
151:
152: /**
153: * @ORM\Column(type="array", nullable=true)
154: */
155: protected $metadataUrl;
156:
157: /**
158: * @ORM\Column(type="array", nullable=true)
159: */
160: protected $dimension;
161:
162: /**
163: * @ORM\Column(type="array", nullable=true)
164: */
165: protected $extent;
166:
167: /**
168: * @ORM\Column(type="array", nullable=true)
169: */
170: protected $dataUrl;
171:
172: /**
173: * @ORM\Column(type="array", nullable=true)
174: */
175: protected $featureListUrl;
176: // FIXME: keywords cascade remove ORM\OneToMany(targetEntity="Mapbender\CoreBundle\Entity\Keyword",mappedBy="id", cascade={"persist","remove"})
177: /**
178: * @var array $keywords the source keyword list
179: * @ORM\OneToMany(targetEntity="Mapbender\CoreBundle\Entity\Keyword",mappedBy="id", cascade={"persist"})
180: */
181: protected $keywords;
182:
183: public function __construct()
184: {
185: $this->sublayer = new ArrayCollection();
186: $this->keywords = new ArrayCollection();
187: $this->boundingBoxes = array();
188: $this->metadataUrl = array();
189: $this->dimension = array();
190: $this->extent = array();
191: $this->dataUrl = array();
192: $this->featureListUrl = array();
193: $this->styles = array();
194: $this->srs = array();
195: $this->identifier = array();
196: $this->authority = array();
197: }
198:
199: /**
200: * Get id
201: *
202: * @return integer
203: */
204: public function getId()
205: {
206: return $this->id;
207: }
208:
209: /**
210: * Set wmssource
211: * @param $wmssource
212: * @return WmsSource
213: */
214: public function setSource(WmsSource $wmssource)
215: {
216: $this->source = $wmssource;
217: return $this;
218: }
219:
220: /**
221: * Get wmssource
222: *
223: * @return WmsSource
224: */
225: public function getSource()
226: {
227: return $this->source;
228: }
229:
230: /**
231: * Set parent
232: *
233: * @param Object $parent
234: * @return WmsLayerSource
235: */
236: public function setParent(WmsLayerSource $parent)
237: {
238: $this->parent = $parent;
239: return $this;
240: }
241:
242: /**
243: * Get parent
244: *
245: * @return Object
246: */
247: public function getParent()
248: {
249: return $this->parent;
250: }
251:
252: /**
253: *
254: * @return ArrayCollection
255: */
256: public function getSublayer()
257: {
258: return $this->sublayer;
259: }
260:
261: /**
262: *
263: * @return ArrayCollection
264: */
265: public function setSublayer($sublayer)
266: {
267: $this->sublayer = $sublayer;
268: }
269:
270: /**
271: * Add sublayer
272: *
273: * @param WmsLayerSource $sublayer
274: * @return WmsLayerSource
275: */
276: public function addSublayer(WmsLayerSource $sublayer)
277: {
278: $this->sublayer->add($sublayer);
279:
280: return $this;
281: }
282:
283: //
284: // /**
285: // * Remove sublayer
286: // *
287: // * @param WmsLayerSource $sublayer
288: // */
289: // public function removeSublayer(WmsLayerSource $sublayer)
290: // {
291: // $this->sublayer->removeElement($sublayer);
292: // }
293:
294: /**
295: * Set name
296: *
297: * @param string $name
298: * @return WmsLayerSource
299: */
300: public function setName($name)
301: {
302: $this->name = $name;
303: return $this;
304: }
305:
306: /**
307: * Get name
308: *
309: * @return string
310: */
311: public function getName()
312: {
313: return $this->name;
314: }
315:
316: /**
317: * Set title
318: *
319: * @param string $title
320: * @return WmsLayerSource
321: */
322: public function setTitle($title)
323: {
324: $this->title = $title;
325: return $this;
326: }
327:
328: /**
329: * Get title
330: *
331: * @return string
332: */
333: public function getTitle()
334: {
335: return $this->title;
336: }
337:
338: /**
339: * Set abstract
340: *
341: * @param string $abstract
342: * @return WmsLayerSource
343: */
344: public function setAbstract($abstract)
345: {
346: $this->abstract = $abstract;
347: return $this;
348: }
349:
350: /**
351: * Get abstract
352: *
353: * @return string
354: */
355: public function getAbstract()
356: {
357: return $this->abstract;
358: }
359:
360: /**
361: * Set queryable
362: *
363: * @param boolean $queryable
364: * @return WmsLayerSource
365: */
366: public function setQueryable($queryable)
367: {
368: $this->queryable = Utils::getBool($queryable);
369: return $this;
370: }
371:
372: /**
373: * Get queryable
374: *
375: * @return boolean
376: */
377: public function getQueryable()
378: {
379: return $this->queryable;
380: }
381:
382: /**
383: * Set cascaded
384: *
385: * @param integer $cascaded
386: * @return WmsLayerSource
387: */
388: public function setCascaded($cascaded)
389: {
390: $this->cascaded = $cascaded;
391: return $this;
392: }
393:
394: /**
395: * Get cascaded
396: *
397: * @return integer
398: */
399: public function getCascaded()
400: {
401: return $this->cascaded;
402: }
403:
404: /**
405: * Set opaque
406: *
407: * @param boolean $opaque
408: * @return WmsLayerSource
409: */
410: public function setOpaque($opaque)
411: {
412: $this->opaque = $opaque;
413: return $this;
414: }
415:
416: /**
417: * Get opaque
418: *
419: * @return boolean
420: */
421: public function getOpaque()
422: {
423: return $this->opaque;
424: }
425:
426: /**
427: * Set noSubset
428: *
429: * @param boolean $noSubset
430: * @return WmsLayerSource
431: */
432: public function setNoSubset($noSubset)
433: {
434: $this->noSubset = $noSubset;
435: return $this;
436: }
437:
438: /**
439: * Get noSubset
440: *
441: * @return boolean
442: */
443: public function getNoSubset()
444: {
445: return $this->noSubset;
446: }
447:
448: /**
449: * Set fixedWidth
450: *
451: * @param integer $fixedWidth
452: * @return WmsLayerSource
453: */
454: public function setFixedWidth($fixedWidth)
455: {
456: $this->fixedWidth = $fixedWidth;
457: return $this;
458: }
459:
460: /**
461: * Get fixedWidth
462: *
463: * @return integer
464: */
465: public function getFixedWidth()
466: {
467: return $this->fixedWidth;
468: }
469:
470: /**
471: * Set fixedHeight
472: *
473: * @param integer $fixedHeight
474: * @return WmsLayerSource
475: */
476: public function setFixedHeight($fixedHeight)
477: {
478: $this->fixedHeight = $fixedHeight;
479: return $this;
480: }
481:
482: /**
483: * Get fixedHeight
484: *
485: * @return integer
486: */
487: public function getFixedHeight()
488: {
489: return $this->fixedHeight;
490: }
491:
492: /**
493: * Set latlonBounds
494: *
495: * @param BoundingBox $latlonBounds
496: * @return WmsLayerSource
497: */
498: public function setLatlonBounds(BoundingBox $latlonBounds)
499: {
500: $this->latlonBounds = $latlonBounds;
501: return $this;
502: }
503:
504: /**
505: * Get latlonBounds
506: *
507: * @return Object
508: */
509: public function getLatlonBounds()
510: {
511: // //@TODO check layer inheritance if layer->latlonBounds === null
512: if($this->latlonBounds === null && $this->getParent() !== null)
513: {
514: return $this->getParent()->getLatlonBounds();
515: } else
516: {
517: return $this->latlonBounds;
518: }
519: // return $this->latlonBounds;
520: }
521:
522: /**
523: * Add boundingBox
524: *
525: * @param BoundingBox $boundingBoxes
526: * @return WmsLayerSource
527: */
528: public function addBoundingBox(BoundingBox $boundingBoxes)
529: {
530: $this->boundingBoxes[] = $boundingBoxes;
531: return $this;
532: }
533:
534: /**
535: * Set boundingBoxes
536: *
537: * @param array $boundingBoxes
538: * @return WmsLayerSource
539: */
540: public function setBoundingBoxes($boundingBoxes)
541: {
542: $this->boundingBoxes = $boundingBoxes;
543: return $this;
544: }
545:
546: /**
547: * Get boundingBoxes
548: *
549: * @return array
550: */
551: public function getBoundingBoxes()
552: {
553: // //@TODO check layer inheritance if count(layer->boundingBoxes) === 0
554: // if(count($this->boundingBoxes) === 0 && $this->getParent() !== null){
555: // return $this->getParent()->getBoundingBoxes();
556: // } else {
557: // return $this->boundingBoxes;
558: // }
559: return $this->boundingBoxes;
560: }
561:
562: /**
563: * Set srs
564: *
565: * @param array $srs
566: * @return WmsLayerSource
567: */
568: public function setSrs($srs)
569: {
570: $this->srs = $srs;
571: return $this;
572: }
573:
574: /**
575: * Add srs
576: *
577: * @param string $srs
578: * @return WmsLayerSource
579: */
580: public function addSrs($srs)
581: {
582: $this->srs[] = $srs;
583: return $this;
584: }
585:
586: /**
587: * Get srs incl. from parent WmsLayerSource (OGC WMS
588: * Implemantation Specification)
589: *
590: * @return array
591: */
592: public function getSrs()
593: {
594: // return $this->srs;
595: if($this->getParent() !== null)
596: { // add crses from parent
597: return array_merge(
598: $this->getParent()->getSrs(), $this->srs);
599: } else
600: {
601: return $this->srs;
602: }
603: }
604:
605: /**
606: * Add style
607: *
608: * @param Style $style
609: * @return WmsLayerSource
610: */
611: public function addStyle(Style $style)
612: {
613: $this->styles[] = $style;
614: return $this;
615: }
616:
617: /**
618: * Set styles
619: *
620: * @param array $styles
621: * @return WmsLayerSource
622: */
623: public function setStyles($styles)
624: {
625: $this->styles = $styles;
626: return $this;
627: }
628:
629: /**
630: * Get styles incl. from parent WmsLayerSource (OGC WMS
631: * Implemantation Specification)
632: *
633: * @return array
634: */
635: public function getStyles()
636: {
637: if($this->getParent() !== null)
638: { // add styles from parent
639: return array_merge(
640: $this->getParent()->getStyles(), $this->styles);
641: } else
642: {
643: return $this->styles;
644: }
645: }
646:
647: /**
648: * Set scale
649: *
650: * @param MinMax $scale
651: * @return WmsLayerSource
652: */
653: public function setScale(MinMax $scale)
654: {
655: $this->scale = $scale;
656: return $this;
657: }
658:
659: /**
660: * Get scale
661: *
662: * @return MinMax
663: */
664: public function getScale()
665: {
666: return $this->scale;
667: }
668:
669: /**
670: * Get scale
671: *
672: * @return MinMax
673: */
674: public function getScaleRecursive()
675: {
676: if($this->scale === null && $this->getParent() !== null){
677: return $this->getParent()->getScale();
678: } else {
679: return $this->scale;
680: }
681: }
682:
683: /**
684: * Set scaleHint
685: *
686: * @param MinMax $scaleHint
687: * @return WmsLayerSource
688: */
689: public function setScaleHint(MinMax $scaleHint)
690: {
691: $this->scaleHint = $scaleHint;
692: return $this;
693: }
694:
695: /**
696: * Get scaleHint
697: *
698: * @return MinMax
699: */
700: public function getScaleHint()
701: {
702: return $this->scaleHint;
703: }
704:
705: /**
706: * Set attribution
707: *
708: * @param Attribution $attribution
709: * @return WmsLayerSource
710: */
711: public function setAttribution(Attribution $attribution)
712: {
713: $this->attribution = $attribution;
714: return $this;
715: }
716:
717: /**
718: * Get attribution
719: *
720: * @return Object
721: */
722: public function getAttribution()
723: {
724: return $this->attribution;
725: }
726:
727: /**
728: * Add identifier
729: *
730: * @param Identifier $identifier
731: * @return WmsLayerSource
732: */
733: public function addIdentifier(Identifier $identifier)
734: {
735: $this->identifier[] = $identifier;
736: return $this;
737: }
738:
739: /**
740: * Set identifier
741: *
742: * @param array $identifier
743: * @return WmsLayerSource
744: */
745: public function setIdentifier($identifier)
746: {
747: $this->identifier = $identifier;
748: return $this;
749: }
750:
751: /**
752: * Get identifier
753: *
754: * @return Identifier
755: */
756: public function getIdentifier()
757: {
758: return $this->identifier;
759: }
760:
761: /**
762: * Get identifier
763: *
764: * @return array
765: */
766: public function getIdentifierAuthority()
767: {
768: $result = array();
769: $authorities = $this->getAuthority();
770: if(count($this->identifier) != 0 && count($authorities) != 0)
771: {
772: foreach($this->identifier as $identifier)
773: {
774: foreach($authorities as $authority)
775: {
776: if($authority->getName() == $identifier->getAuthority())
777: {
778: $ident_auth = new IdentifierAuthority();
779: $ident_auth->setAuthority($authority);
780: $ident_auth->setIdentifier($identifier);
781: $result[] = $ident_auth;
782: }
783: }
784: }
785: }
786: return $result;
787: }
788:
789: /**
790: * Add authority
791: *
792: * @param Authority $authority
793: * @return WmsLayerSource
794: */
795: public function addAuthority(Authority $authority)
796: {
797: $this->authority[] = $authority;
798: return $this;
799: }
800:
801: /**
802: * Set authority
803: *
804: * @param array $authority
805: * @return WmsLayerSource
806: */
807: public function setAuthority($authority)
808: {
809: $this->authority = $authority;
810: return $this;
811: }
812:
813: /**
814: * Get authority
815: *
816: * @return Authority
817: */
818: public function getAuthority()
819: {
820: if($this->getParent() !== null)
821: { // add crses from parent
822: return array_merge(
823: $this->getParent()->getAuthority(), $this->authority);
824: } else
825: {
826: $this->authority;
827: }
828: }
829:
830: /**
831: * Add metadataUrl
832: *
833: * @param array $metadataUrl
834: * @return WmsLayerSource
835: */
836: public function addMetadataUrl(MetadataUrl $metadataUrl)
837: {
838: $this->metadataUrl[] = $metadataUrl;
839: return $this;
840: }
841:
842: /**
843: * Set metadataUrl
844: *
845: * @param array $metadataUrl
846: * @return WmsLayerSource
847: */
848: public function setMetadataUrl($metadataUrl)
849: {
850: $this->metadataUrl = $metadataUrl;
851: return $this;
852: }
853:
854: /**
855: * Get metadataUrl
856: *
857: * @return array
858: */
859: public function getMetadataUrl()
860: {
861: return $this->metadataUrl;
862: }
863:
864: /**
865: * Add dimension
866: *
867: * @param Dimension $dimension
868: * @return WmsLayerSource
869: */
870: public function addDimensionl(Dimension $dimension)
871: {
872: $this->dimension[] = $dimension;
873: return $this;
874: }
875:
876: /**
877: * Set dimension
878: *
879: * @param array $dimension
880: * @return WmsLayerSource
881: */
882: public function setDimension($dimension)
883: {
884: $this->dimension = $dimension;
885: return $this;
886: }
887:
888: /**
889: * Get dimension
890: *
891: * @return array
892: */
893: public function getDimension()
894: {
895: return $this->dimension;
896: }
897:
898: /**
899: * Add extent
900: *
901: * @param Extent $extent
902: * @return WmsLayerSource
903: */
904: public function addExtent(Extent $extent)
905: {
906: $this->extent[] = $extent;
907: return $this;
908: }
909:
910: /**
911: * Set extent
912: *
913: * @param array $extent
914: * @return WmsLayerSource
915: */
916: public function setExtent($extent)
917: {
918: $this->extent = $extent;
919: return $this;
920: }
921:
922: /**
923: * Get extent
924: *
925: * @return array
926: */
927: public function getExtent()
928: {
929: return $this->extent;
930: }
931:
932: /**
933: * Add dataUrl
934: *
935: * @param array $dataUrl
936: * @return WmsLayerSource
937: */
938: public function addDataUrl(OnlineResource $dataUrl)
939: {
940: $this->dataUrl[] = $dataUrl;
941: return $this;
942: }
943:
944: /**
945: * Set dataUrl
946: *
947: * @param array $dataUrl
948: * @return WmsLayerSource
949: */
950: public function setDataUrl($dataUrl)
951: {
952: $this->dataUrl = $dataUrl;
953: return $this;
954: }
955:
956: /**
957: * Get dataUrl
958: *
959: * @return array
960: */
961: public function getDataUrl()
962: {
963: return $this->dataUrl;
964: }
965:
966: /**
967: * Add featureListUrl
968: *
969: * @param array $featureListUrl
970: * @return WmsLayerSource
971: */
972: public function addFeatureListUrl(OnlineResource $featureListUrl)
973: {
974: $this->featureListUrl[] = $featureListUrl;
975: return $this;
976: }
977:
978: /**
979: * Set featureListUrl
980: *
981: * @param array $featureListUrl
982: * @return WmsLayerSource
983: */
984: public function setFeatureListUrl($featureListUrl)
985: {
986: $this->featureListUrl = $featureListUrl;
987: return $this;
988: }
989:
990: /**
991: * Get featureListUrl
992: *
993: * @return array
994: */
995: public function getFeatureListUrl()
996: {
997: return $this->featureListUrl;
998: }
999:
1000: /**
1001: * Set keywords
1002: *
1003: * @param array $keywords
1004: * @return Source
1005: */
1006: public function setKeywords($keywords)
1007: {
1008: $this->keywords = $keywords;
1009: return $this;
1010: }
1011:
1012: /**
1013: * Get keywords
1014: *
1015: * @return string
1016: */
1017: public function getKeywords()
1018: {
1019: return $this->keywords;
1020: }
1021:
1022: /**
1023: * Add keyword
1024: *
1025: * @param Keyword $keyword
1026: * @return Source
1027: */
1028: public function addKeyword(Keyword $keyword)
1029: {
1030: $this->keywords->add($keyword);
1031: return $this;
1032: }
1033:
1034: /**
1035: * Remove keywords
1036: *
1037: * @param Mapbender\CoreBundle\Entity\Keyword $keywords
1038: */
1039: public function removeKeyword(\Mapbender\CoreBundle\Entity\Keyword $keywords)
1040: {
1041: $this->keywords->removeElement($keywords);
1042: }
1043:
1044: /**
1045: * @inheritdoc
1046: */
1047: public function getType()
1048: {
1049: return "WMS";
1050: }
1051:
1052: /**
1053: * @inheritdoc
1054: */
1055: public function getManagerType()
1056: {
1057: return "wms";
1058: }
1059:
1060: /**
1061: * @inheritdoc
1062: */
1063: public function getClassname()
1064: {
1065: return get_class();
1066: }
1067:
1068: /**
1069: * @inheritdoc
1070: */
1071: public function __toString()
1072: {
1073: return (string) $this->id;
1074: }
1075:
1076: }