Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • DrupalIntegrationBundle
      • DependencyInjection
      • Security
        • Authentication
          • Provider
          • Token
        • Authorization
          • Voter
        • Factory
        • Firewall
        • User
      • Session
    • KmlBundle
      • Element
    • ManagerBundle
      • Controller
      • Form
        • DataTransformer
        • Type
    • MonitoringBundle
      • Command
      • Component
      • Controller
      • DependencyInjection
      • Entity
      • EventListener
      • Form
    • PrintBundle
      • Component
      • Controller
    • WmcBundle
      • Component
        • Exception
      • Element
        • Type
      • Entity
      • Form
        • EventListener
        • Type
    • WmsBundle
      • Component
        • Exception
      • Controller
      • DependencyInjection
      • Element
        • Type
      • Entity
      • Event
      • Form
        • EventListener
        • Type
    • WmtsBundle
      • Component
        • Exception
      • Controller
      • Entity
      • Form
        • Type
  • None
  • PHP

Classes

  • WmsInstance
  • WmsInstanceLayer
  • WmsLayerSource
  • WmsSource
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
   1: <?php
   2: 
   3: namespace Mapbender\WmsBundle\Entity;
   4: 
   5: use Doctrine\Common\Collections\ArrayCollection;
   6: use Doctrine\ORM\EntityManager;
   7: use Doctrine\ORM\Mapping as ORM;
   8: use Mapbender\CoreBundle\Component\Utils;
   9: use Mapbender\CoreBundle\Entity\Contact;
  10: use Mapbender\CoreBundle\Entity\Keyword;
  11: use Mapbender\CoreBundle\Entity\Source;
  12: use Mapbender\WmsBundle\Component\RequestInformation;
  13: use Mapbender\WmsBundle\Entity\WmsLayerSource;
  14: use Symfony\Component\Validator\Constraints as Assert;
  15: 
  16: /**
  17:  * A WmsSource entity presents an OGC WMS.
  18:  * @ORM\Entity
  19:  * @ORM\Table(name="mb_wms_wmssource")
  20:  * ORM\DiscriminatorMap({"mb_wms_wmssource" = "WmsSource"})
  21:  */
  22: class WmsSource extends Source
  23: {
  24: 
  25:     /**
  26:      * @var string An origin WMS URL
  27:      * @ORM\Column(type="string", nullable=true)
  28:      * @Assert\NotBlank()
  29:      * @Assert\Url()
  30:      */
  31:     protected $originUrl = "";
  32: 
  33:     /**
  34:      * @var string A WMS name
  35:      * @ORM\Column(type="string", nullable=true)
  36:      */
  37:     protected $name = "";
  38: 
  39:     /**
  40:      * @var string A WMS version
  41:      * @ORM\Column(type="string", nullable=true)
  42:      */
  43:     protected $version = "";
  44: 
  45:     /**
  46:      * @var string A WMS online resource
  47:      * @ORM\Column(type="string",nullable=true)
  48:      */
  49:     protected $onlineResource;
  50: 
  51:     /**
  52:      * @var Contact A contact.
  53:      * @ORM\OneToOne(targetEntity="Mapbender\CoreBundle\Entity\Contact", cascade={"persist","remove"})
  54:      */
  55:     protected $contact;
  56: 
  57:     /**
  58:      * @var string A fees.
  59:      * @ORM\Column(type="text", nullable=true)
  60:      */
  61:     protected $fees = "";
  62: 
  63:     /**
  64:      * @var string An access constraints.
  65:      * @ORM\Column(type="text",nullable=true)
  66:      */
  67:     protected $accessConstraints = "";
  68: 
  69:     /**
  70:      * @var integer A limit of the layers
  71:      * @ORM\Column(type="integer",nullable=true)
  72:      */
  73:     protected $layerLimit;
  74: 
  75:     /**
  76:      * @var integer A maximum width of the GetMap image
  77:      * @ORM\Column(type="integer",nullable=true)
  78:      */
  79:     protected $maxWidth;
  80: 
  81:     /**
  82:      * @var integer A maximum height of the GetMap image
  83:      * @ORM\Column(type="integer",nullable=true)
  84:      */
  85:     protected $maxHeight;
  86: 
  87:     /**
  88:      * @var array A list of supported exception formats
  89:      * @ORM\Column(type="array",nullable=true)
  90:      */
  91:     protected $exceptionFormats = array();
  92: 
  93:     /**
  94:      * @var boolean A SLD support
  95:      * @ORM\Column(type="boolean", nullable=true)
  96:      */
  97:     protected $supportSld = false;
  98: 
  99:     /**
 100:      * @var boolean A user layer
 101:      * @ORM\Column(type="boolean", nullable=true)
 102:      */
 103:     protected $userLayer = false;
 104: 
 105:     /**
 106:      * @var boolean A user layer
 107:      * @ORM\Column(type="boolean", nullable=true)
 108:      */
 109:     protected $userStyle = false;
 110: 
 111:     /**
 112:      * @var boolean A remote WFS
 113:      * @ORM\Column(type="boolean", nullable=true)
 114:      */
 115:     protected $remoteWfs = false;
 116: 
 117:     /**
 118:      * @var boolean A inline feature
 119:      * @ORM\Column(type="boolean", nullable=true)
 120:      */
 121:     protected $inlineFeature = false;
 122: 
 123:     /**
 124:      * @var boolean A remote WCS
 125:      * @ORM\Column(type="boolean", nullable=true)
 126:      */
 127:     protected $remoteWcs = false;
 128: 
 129:     /**
 130:      * @var RequestInformation A request information for the GetCapabilities operation
 131:      * @ORM\Column(type="object", nullable=true)
 132:      */
 133:     //@TODO Doctrine bug: "protected" replaced with "public"
 134:     public $getCapabilities = null;
 135: 
 136:     /**
 137:      * @var RequestInformation A request information for the GetMap operation
 138:      * @ORM\Column(type="object", nullable=true)
 139:      */
 140:     //@TODO Doctrine bug: "protected" replaced with "public"
 141:     public $getMap = null;
 142: 
 143:     /**
 144:      * @var RequestInformation A request information for the GetFeatureInfo operation
 145:      * @ORM\Column(type="object", nullable=true)
 146:      */
 147:     //@TODO Doctrine bug: "protected" replaced with "public"
 148:     public $getFeatureInfo = null;
 149: 
 150:     /**
 151:      * @var RequestInformation A request information for the DescribeLayer operation
 152:      * @ORM\Column(type="object", nullable=true)
 153:      */
 154:     //@TODO Doctrine bug: "protected" replaced with "public"
 155:     public $describeLayer = null;
 156: 
 157:     /**
 158:      * @var RequestInformation A request information for the GetLegendGraphic operation
 159:      * @ORM\Column(type="object", nullable=true)
 160:      */
 161:     //@TODO Doctrine bug: "protected" replaced with "public"
 162:     public $getLegendGraphic = null;
 163: 
 164:     /**
 165:      * @var RequestInformation A request information for the GetStyles operation
 166:      * @ORM\Column(type="object", nullable=true)
 167:      */
 168:     //@TODO Doctrine bug: "protected" replaced with "public"
 169:     public $getStyles = null;
 170: 
 171:     /**
 172:      * @var RequestInformation A request information for the PutStyles operation
 173:      * @ORM\Column(type="object", nullable=true)
 174:      */
 175:     //@TODO Doctrine bug: "protected" replaced with "public"
 176:     public $putStyles = null;
 177: 
 178:     /**
 179:      * @var RequestInformation A request information for the PutStyles operation
 180:      * @ORM\Column(type="string", nullable=true);
 181:      */
 182:     protected $username = null;
 183: 
 184:     /**
 185:      * @var string A password
 186:      * @ORM\Column(type="string", nullable=true);
 187:      */
 188:     protected $password = null;
 189: 
 190:     /**
 191:      * @var ArrayCollections A list of WMS layers
 192:      * @ORM\OneToMany(targetEntity="WmsLayerSource",mappedBy="source", cascade={"persist","remove"})
 193:      * @ORM\OrderBy({"id" = "asc"})
 194:      */
 195:     protected $layers;
 196: 
 197:     // FIXME: keywords cascade remove RM\OneToMany(targetEntity="Mapbender\CoreBundle\Entity\Keyword",mappedBy="id", cascade={"persist","remove"})
 198: 
 199:     /**
 200:      * @var ArrayCollections A list of WMS keywords
 201:      * @ORM\OneToMany(targetEntity="Mapbender\CoreBundle\Entity\Keyword",mappedBy="id", cascade={"persist"})
 202:      */
 203:     protected $keywords;
 204: 
 205:     /**
 206:      * @var ArrayCollections A list of WMS instances
 207:      * @ORM\OneToMany(targetEntity="WmsInstance",mappedBy="source", cascade={"persist","remove"})
 208:      * 
 209:      */
 210:     protected $wmsinstance;
 211: 
 212:     public function __construct()
 213:     {
 214:         $this->keywords = new ArrayCollection();
 215:         $this->layers = new ArrayCollection();
 216:         $this->exceptionFormats = array();
 217:     }
 218: 
 219:     public function getType()
 220:     {
 221:         return "WMS";
 222:     }
 223: 
 224:     public function getManagertype()
 225:     {
 226:         return "wms";
 227:     }
 228: 
 229:     /**
 230:      * Set originUrl
 231:      *
 232:      * @param string $originUrl
 233:      * @return WmsSource
 234:      */
 235:     public function setOriginUrl($originUrl)
 236:     {
 237:         $this->originUrl = $originUrl;
 238:         return $this;
 239:     }
 240: 
 241:     /**
 242:      * Get originUrl
 243:      *
 244:      * @return string 
 245:      */
 246:     public function getOriginUrl()
 247:     {
 248:         return $this->originUrl;
 249:     }
 250: 
 251:     /**
 252:      * Set name
 253:      *
 254:      * @param string $name
 255:      * @return WmsSource
 256:      */
 257:     public function setName($name)
 258:     {
 259:         $this->name = $name;
 260:         return $this;
 261:     }
 262: 
 263:     /**
 264:      * Get name
 265:      *
 266:      * @return string 
 267:      */
 268:     public function getName()
 269:     {
 270:         return $this->name;
 271:     }
 272: 
 273:     /**
 274:      * Set version
 275:      *
 276:      * @param string $version
 277:      * @return WmsSource
 278:      */
 279:     public function setVersion($version)
 280:     {
 281:         $this->version = $version;
 282:         return $this;
 283:     }
 284: 
 285:     /**
 286:      * Get version
 287:      *
 288:      * @return string 
 289:      */
 290:     public function getVersion()
 291:     {
 292:         return $this->version;
 293:     }
 294: 
 295:     /**
 296:      * Set onlineResource
 297:      *
 298:      * @param string $onlineResource
 299:      * @return WmsSource
 300:      */
 301:     public function setOnlineResource($onlineResource)
 302:     {
 303:         $this->onlineResource = $onlineResource;
 304:         return $this;
 305:     }
 306: 
 307:     /**
 308:      * Get onlineResource
 309:      *
 310:      * @return string 
 311:      */
 312:     public function getOnlineResource()
 313:     {
 314:         return $this->onlineResource;
 315:     }
 316: 
 317:     /**
 318:      * Set contact
 319:      *
 320:      * @param string $contact
 321:      * @return WmsSource
 322:      */
 323:     public function setContact($contact)
 324:     {
 325:         $this->contact = $contact;
 326:         return $this;
 327:     }
 328: 
 329:     /**
 330:      * Get contact
 331:      *
 332:      * @return string 
 333:      */
 334:     public function getContact()
 335:     {
 336:         return $this->contact;
 337:     }
 338: 
 339:     /**
 340:      * Set fees
 341:      *
 342:      * @param text $fees
 343:      * @return WmsSource
 344:      */
 345:     public function setFees($fees)
 346:     {
 347:         $this->fees = $fees;
 348:         return $this;
 349:     }
 350: 
 351:     /**
 352:      * Get fees
 353:      *
 354:      * @return text 
 355:      */
 356:     public function getFees()
 357:     {
 358:         return $this->fees;
 359:     }
 360: 
 361:     /**
 362:      * Set accessConstraints
 363:      *
 364:      * @param text $accessConstraints
 365:      * @return WmsSource
 366:      */
 367:     public function setAccessConstraints($accessConstraints)
 368:     {
 369:         $this->accessConstraints = $accessConstraints;
 370:         return $this;
 371:     }
 372: 
 373:     /**
 374:      * Get accessConstraints
 375:      *
 376:      * @return text 
 377:      */
 378:     public function getAccessConstraints()
 379:     {
 380:         return $this->accessConstraints;
 381:     }
 382: 
 383:     /**
 384:      * Set layerLimit
 385:      *
 386:      * @param integer $layerLimit
 387:      * @return WmsSource
 388:      */
 389:     public function setLayerLimit($layerLimit)
 390:     {
 391:         $this->layerLimit = $layerLimit;
 392:         return $this;
 393:     }
 394: 
 395:     /**
 396:      * Get layerLimit
 397:      *
 398:      * @return integer 
 399:      */
 400:     public function getLayerLimit()
 401:     {
 402:         return $this->layerLimit;
 403:     }
 404: 
 405:     /**
 406:      * Set maxWidth
 407:      *
 408:      * @param integer $maxWidth
 409:      * @return WmsSource
 410:      */
 411:     public function setMaxWidth($maxWidth)
 412:     {
 413:         $this->maxWidth = $maxWidth;
 414:         return $this;
 415:     }
 416: 
 417:     /**
 418:      * Get maxWidth
 419:      *
 420:      * @return integer 
 421:      */
 422:     public function getMaxWidth()
 423:     {
 424:         return $this->maxWidth;
 425:     }
 426: 
 427:     /**
 428:      * Set maxHeight
 429:      *
 430:      * @param integer $maxHeight
 431:      * @return WmsSource
 432:      */
 433:     public function setMaxHeight($maxHeight)
 434:     {
 435:         $this->maxHeight = $maxHeight;
 436:         return $this;
 437:     }
 438: 
 439:     /**
 440:      * Get maxHeight
 441:      *
 442:      * @return integer 
 443:      */
 444:     public function getMaxHeight()
 445:     {
 446:         return $this->maxHeight;
 447:     }
 448: 
 449:     /**
 450:      * Set exceptionFormats
 451:      *
 452:      * @param array $exceptionFormats
 453:      * @return WmsSource
 454:      */
 455:     public function setExceptionFormats($exceptionFormats)
 456:     {
 457:         $this->exceptionFormats = $exceptionFormats;
 458:         return $this;
 459:     }
 460: 
 461:     /**
 462:      * Add exceptionFormat
 463:      *
 464:      * @param array $exceptionFormat
 465:      * @return WmsSource
 466:      */
 467:     public function addExceptionFormat($exceptionFormat)
 468:     {
 469:         $this->exceptionFormats[] = $exceptionFormat;
 470:         return $this;
 471:     }
 472: 
 473:     /**
 474:      * Get exceptionFormats
 475:      *
 476:      * @return array 
 477:      */
 478:     public function getExceptionFormats()
 479:     {
 480:         return $this->exceptionFormats;
 481:     }
 482: 
 483:     /**
 484:      * Set supportSld
 485:      *
 486:      * @param boolean $supportSld
 487:      * @return WmsSource
 488:      */
 489:     public function setSupportSld($supportSld)
 490:     {
 491:         $this->supportSld = $supportSld;
 492:         return $this;
 493:     }
 494: 
 495:     /**
 496:      * Get supportSld
 497:      *
 498:      * @return boolean 
 499:      */
 500:     public function getSupportSld()
 501:     {
 502:         return $this->supportSld;
 503:     }
 504: 
 505:     /**
 506:      * Set userLayer
 507:      *
 508:      * @param boolean $userLayer
 509:      * @return WmsSource
 510:      */
 511:     public function setUserLayer($userLayer)
 512:     {
 513:         $this->userLayer = $userLayer;
 514:         return $this;
 515:     }
 516: 
 517:     /**
 518:      * Get userLayer
 519:      *
 520:      * @return boolean 
 521:      */
 522:     public function getUserLayer()
 523:     {
 524:         return $this->userLayer;
 525:     }
 526: 
 527:     /**
 528:      * Set userStyle
 529:      *
 530:      * @param boolean $userStyle
 531:      * @return WmsSource
 532:      */
 533:     public function setUserStyle($userStyle)
 534:     {
 535:         $this->userStyle = $userStyle;
 536:         return $this;
 537:     }
 538: 
 539:     /**
 540:      * Get userStyle
 541:      *
 542:      * @return boolean 
 543:      */
 544:     public function getUserStyle()
 545:     {
 546:         return $this->userStyle;
 547:     }
 548: 
 549:     /**
 550:      * Set remoteWfs
 551:      *
 552:      * @param boolean $remoteWfs
 553:      * @return WmsSource
 554:      */
 555:     public function setRemoteWfs($remoteWfs)
 556:     {
 557:         $this->remoteWfs = $remoteWfs;
 558:         return $this;
 559:     }
 560: 
 561:     /**
 562:      * Get remoteWfs
 563:      *
 564:      * @return boolean 
 565:      */
 566:     public function getRemoteWfs()
 567:     {
 568:         return $this->remoteWfs;
 569:     }
 570: 
 571:     /**
 572:      * Set inlineFeature
 573:      *
 574:      * @param boolean $inlineFeature
 575:      * @return WmsSource
 576:      */
 577:     public function setInlineFeature($inlineFeature)
 578:     {
 579:         $this->inlineFeature = $inlineFeature;
 580:         return $this;
 581:     }
 582: 
 583:     /**
 584:      * Get inlineFeature
 585:      *
 586:      * @return boolean 
 587:      */
 588:     public function getInlineFeature()
 589:     {
 590:         return $this->inlineFeature;
 591:     }
 592: 
 593:     /**
 594:      * Set remoteWcs
 595:      *
 596:      * @param boolean $remoteWcs
 597:      * @return WmsSource
 598:      */
 599:     public function setRemoteWcs($remoteWcs)
 600:     {
 601:         $this->remoteWcs = $remoteWcs;
 602:         return $this;
 603:     }
 604: 
 605:     /**
 606:      * Get remoteWcs
 607:      *
 608:      * @return boolean 
 609:      */
 610:     public function getRemoteWcs()
 611:     {
 612:         return $this->remoteWcs;
 613:     }
 614: 
 615:     /**
 616:      * Set getCapabilities
 617:      *
 618:      * @param Object $getCapabilities
 619:      * @return WmsSource
 620:      */
 621:     public function setGetCapabilities(RequestInformation $getCapabilities)
 622:     {
 623:         $this->getCapabilities = $getCapabilities;
 624:         return $this;
 625:     }
 626: 
 627:     /**
 628:      * Get getCapabilities
 629:      *
 630:      * @return Object 
 631:      */
 632:     public function getGetCapabilities()
 633:     {
 634:         return $this->getCapabilities;
 635:     }
 636: 
 637:     /**
 638:      * Set getMap
 639:      *
 640:      * @param RequestInformation $getMap
 641:      * @return WmsSource
 642:      */
 643:     public function setGetMap(RequestInformation $getMap)
 644:     {
 645:         $this->getMap = $getMap;
 646:         return $this;
 647:     }
 648: 
 649:     /**
 650:      * Get getMap
 651:      *
 652:      * @return Object 
 653:      */
 654:     public function getGetMap()
 655:     {
 656:         return $this->getMap;
 657:     }
 658: 
 659:     /**
 660:      * Set getFeatureInfo
 661:      *
 662:      * @param RequestInformation $getFeatureInfo
 663:      * @return WmsSource
 664:      */
 665:     public function setGetFeatureInfo(RequestInformation $getFeatureInfo)
 666:     {
 667:         $this->getFeatureInfo = $getFeatureInfo;
 668:         return $this;
 669:     }
 670: 
 671:     /**
 672:      * Get getFeatureInfo
 673:      *
 674:      * @return Object 
 675:      */
 676:     public function getGetFeatureInfo()
 677:     {
 678:         return $this->getFeatureInfo;
 679:     }
 680: 
 681:     /**
 682:      * Set describeLayer
 683:      *
 684:      * @param RequestInformation $describeLayer
 685:      * @return WmsSource
 686:      */
 687:     public function setDescribeLayer(RequestInformation $describeLayer)
 688:     {
 689:         $this->describeLayer = $describeLayer;
 690:         return $this;
 691:     }
 692: 
 693:     /**
 694:      * Get describeLayer
 695:      *
 696:      * @return Object 
 697:      */
 698:     public function getDescribeLayer()
 699:     {
 700:         return $this->describeLayer;
 701:     }
 702: 
 703:     /**
 704:      * Set getLegendGraphic
 705:      *
 706:      * @param RequestInformation $getLegendGraphic
 707:      * @return WmsSource
 708:      */
 709:     public function setGetLegendGraphic(RequestInformation $getLegendGraphic)
 710:     {
 711:         $this->getLegendGraphic = $getLegendGraphic;
 712:         return $this;
 713:     }
 714: 
 715:     /**
 716:      * Get getLegendGraphic
 717:      *
 718:      * @return Object 
 719:      */
 720:     public function getGetLegendGraphic()
 721:     {
 722:         return $this->getLegendGraphic;
 723:     }
 724: 
 725:     /**
 726:      * Set getStyles
 727:      *
 728:      * @param RequestInformation $getStyles
 729:      * @return WmsSource
 730:      */
 731:     public function setGetStyles(RequestInformation $getStyles)
 732:     {
 733:         $this->getStyles = $getStyles;
 734:         return $this;
 735:     }
 736: 
 737:     /**
 738:      * Get getStyles
 739:      *
 740:      * @return Object 
 741:      */
 742:     public function getGetStyles()
 743:     {
 744:         return $this->getStyles;
 745:     }
 746: 
 747:     /**
 748:      * Set putStyles
 749:      *
 750:      * @param RequestInformation $putStyles
 751:      * @return WmsSource
 752:      */
 753:     public function setPutStyles(RequestInformation $putStyles)
 754:     {
 755:         $this->putStyles = $putStyles;
 756:         return $this;
 757:     }
 758: 
 759:     /**
 760:      * Get putStyles
 761:      *
 762:      * @return Object 
 763:      */
 764:     public function getPutStyles()
 765:     {
 766:         return $this->putStyles;
 767:     }
 768: 
 769:     /**
 770:      * Set username
 771:      *
 772:      * @param text $username
 773:      * @return WmsSource
 774:      */
 775:     public function setUsername($username)
 776:     {
 777:         $this->username = $username;
 778:         return $this;
 779:     }
 780: 
 781:     /**
 782:      * Get username
 783:      *
 784:      * @return text 
 785:      */
 786:     public function getUsername()
 787:     {
 788:         return $this->username;
 789:     }
 790: 
 791:     /**
 792:      * Set password
 793:      *
 794:      * @param text $password
 795:      * @return WmsSource
 796:      */
 797:     public function setPassword($password)
 798:     {
 799:         $this->password = $password;
 800:         return $this;
 801:     }
 802: 
 803:     /**
 804:      * Get password
 805:      *
 806:      * @return text 
 807:      */
 808:     public function getPassword()
 809:     {
 810:         return $this->password;
 811:     }
 812: 
 813:     /**
 814:      * Set layers
 815:      *
 816:      * @param array $layers
 817:      * @return WmsSource
 818:      */
 819:     public function setLayers($layers)
 820:     {
 821:         $this->layers = $layers;
 822:         return $this;
 823:     }
 824: 
 825:     /**
 826:      * Get layers
 827:      *
 828:      * @return array 
 829:      */
 830:     public function getLayers()
 831:     {
 832:         return $this->layers;
 833:     }
 834: 
 835:     /**
 836:      * Add layer
 837:      *
 838:      * @param WmsLayerSource $layer
 839:      * @return WmsSource
 840:      */
 841:     public function addLayer(WmsLayerSource $layer)
 842:     {
 843:         $this->layers->add($layer);
 844:         return $this;
 845:     }
 846: 
 847:     /**
 848:      * Get root layer
 849:      *
 850:      * @return WmsLayerSource 
 851:      */
 852:     public function getRootlayer()
 853:     {
 854:         foreach($this->layers as $layer)
 855:         {
 856:             if($layer->getParent() === null)
 857:             {
 858:                 return $layer;
 859:             }
 860:         }
 861:         return null;
 862: //        if($this->layers !== null && $this->layers->count() > 0){
 863: //            return $this->layers->get(0);
 864: //        } else {
 865: //            return null;
 866: //        }
 867:     }
 868: 
 869:     /**
 870:      * Set keywords
 871:      *
 872:      * @param array $keywords
 873:      * @return Source
 874:      */
 875:     public function setKeywords($keywords)
 876:     {
 877:         $this->keywords = $keywords;
 878:         return $this;
 879:     }
 880: 
 881:     /**
 882:      * Get keywords
 883:      *
 884:      * @return string 
 885:      */
 886:     public function getKeywords()
 887:     {
 888:         return $this->keywords;
 889:     }
 890: 
 891:     /**
 892:      * Add keyword
 893:      *
 894:      * @param Keyword $keyword
 895:      * @return Source
 896:      */
 897:     public function addKeyword(Keyword $keyword)
 898:     {
 899:         $this->keywords->add($keyword);
 900:         return $this;
 901:     }
 902: 
 903:     /**
 904:      * Remove layers
 905:      *
 906:      * @param WmsLayerSource $layers
 907:      */
 908:     public function removeLayer(WmsLayerSource $layers)
 909:     {
 910:         $this->layers->removeElement($layers);
 911:     }
 912: 
 913:     /**
 914:      * Remove keywords
 915:      *
 916:      * @param Keyword $keywords
 917:      */
 918:     public function removeKeyword(Keyword $keywords)
 919:     {
 920:         $this->keywords->removeElement($keywords);
 921:     }
 922: 
 923:     public function __toString()
 924:     {
 925:         return (string) $this->getId();
 926:     }
 927: 
 928:     /**
 929:      * @inheritdoc
 930:      */
 931:     public function createInstance()
 932:     {
 933:         $instance = new WmsInstance();
 934:         $instance->setSource($this);
 935:         $instance->setTitle($this->getTitle());
 936:         $formats = $this->getGetMap()->getFormats();
 937:         $instance->setFormat(count($formats) > 0 ? $formats[0] : null);
 938:         $infoformats = $this->getGetFeatureInfo() !== null ?
 939:                 $this->getGetFeatureInfo()->getFormats() : array();
 940:         $instance->setInfoformat(count($infoformats) > 0 ? $infoformats[0] : null);
 941:         $excformats = $this->getExceptionFormats();
 942:         $instance->setExceptionformat(count($excformats) > 0 ? $excformats[0] : null);
 943: //        $instance->setOpacity(100);
 944:         $num = 0;
 945:         $wmslayer_root = $this->getRootlayer();
 946:         $instLayer_root = new WmsInstanceLayer();
 947:         $instLayer_root->setWmsinstance($instance);
 948:         $instLayer_root->setWmslayersource($wmslayer_root);
 949:         $instLayer_root->setTitle($wmslayer_root->getTitle());
 950:         // @TODO min max from scaleHint
 951:         $instLayer_root->setMinScale(
 952:                 $wmslayer_root->getScaleRecursive() !== null ?
 953:                         $wmslayer_root->getScaleRecursive()->getMin() : null);
 954:         $instLayer_root->setMaxScale(
 955:                 $wmslayer_root->getScaleRecursive() !== null ?
 956:                         $wmslayer_root->getScaleRecursive()->getMax() : null);
 957:         $queryable = $wmslayer_root->getQueryable();
 958:         $instLayer_root->setInfo(Utils::getBool($queryable));
 959:         $instLayer_root->setAllowinfo(Utils::getBool($queryable));
 960: 
 961:         $instLayer_root->setToggle(true);
 962:         $instLayer_root->setAllowtoggle(true);
 963:         
 964:         $instLayer_root->setPriority($num);
 965:         $instance->addLayer($instLayer_root);
 966:         $this->addSublayer($instLayer_root, $wmslayer_root, $num, $instance);
 967:         return $instance;
 968:     }
 969: 
 970:     /**
 971:      * Adds sublayers
 972:      * 
 973:      * @param WmsInstanceLayer $instlayer
 974:      * @param WmsLayerSource $wmslayer
 975:      * @param integer $num
 976:      * @param WmsIstance $instance
 977:      */
 978:     private function addSublayer($instlayer, $wmslayer, $num, $instance)
 979:     {
 980:         foreach($wmslayer->getSublayer() as $wmssublayer)
 981:         {
 982:             $num++;
 983:             $instsublayer = new WmsInstanceLayer();
 984:             $instsublayer->setWmsinstance($instance);
 985:             $instsublayer->setWmslayersource($wmssublayer);
 986:             $instsublayer->setTitle($wmssublayer->getTitle());
 987:             // @TODO min max from scaleHint
 988:             $instsublayer->setMinScale(
 989:                     $wmssublayer->getScaleRecursive() !== null ?
 990:                             $wmssublayer->getScaleRecursive()->getMin() : null);
 991:             $instsublayer->setMaxScale(
 992:                     $wmssublayer->getScaleRecursive() !== null ?
 993:                             $wmssublayer->getScaleRecursive()->getMax() : null);
 994:             $queryable = $wmssublayer->getQueryable();
 995:             $instsublayer->setInfo(Utils::getBool($queryable));
 996:             $instsublayer->setAllowinfo(Utils::getBool($queryable));
 997: 
 998:             $instsublayer->setPriority($num);
 999:             $instsublayer->setParent($instlayer);
1000:             $instance->addLayer($instsublayer);
1001:             if($wmssublayer->getSublayer()->count() > 0){
1002:                 $instsublayer->setToggle(true);
1003:                 $instsublayer->setAllowtoggle(true);
1004:             }
1005:             $this->addSublayer($instsublayer, $wmssublayer, $num, $instance);
1006:         }
1007:     }
1008:     
1009:     /**
1010:      * @inheritdoc
1011:      */
1012:     public function remove(EntityManager $em)
1013:     {
1014:         $this->removeSourceRecursive($em, $this->getRootlayer());
1015:         $em->remove($this);
1016:     }
1017:     
1018:     /**
1019:      * Recursively remove a nested Layerstructure
1020:      * @param WmsLayerSource
1021:      * @param EntityManager
1022:      */
1023:     private function removeSourceRecursive(EntityManager $em, WmsLayerSource $wmslayer)
1024:     {
1025:         foreach($wmslayer->getSublayer() as $sublayer)
1026:         {
1027:             $this->removeSourceRecursive($em, $sublayer);
1028:         }
1029:         $em->remove($wmslayer);
1030:         $em->flush();
1031:     }
1032: 
1033: }
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0