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\Mapping as ORM;
  7: use Mapbender\CoreBundle\Component\InstanceLayerIn;
  8: use Mapbender\WmsBundle\Entity\WmsInstance;
  9: use Mapbender\WmsBundle\Entity\WmsLayerSource;
 10: use Mapbender\CoreBundle\Component\Utils;
 11: 
 12: /**
 13:  * WmsInstanceLayer class
 14:  *
 15:  * @author Paul Schmidt
 16:  *
 17:  * @ORM\Entity
 18:  * @ORM\Table(name="mb_wms_wmsinstancelayer")
 19:  */
 20: class WmsInstanceLayer implements InstanceLayerIn
 21: {
 22: 
 23:     /**
 24:      * @var integer $id
 25:      * @ORM\Id
 26:      * @ORM\Column(type="integer")
 27:      * @ORM\GeneratedValue(strategy="AUTO")
 28:      */
 29:     protected $id;
 30: 
 31:     /**
 32:      * @ORM\ManyToOne(targetEntity="WmsInstance", inversedBy="layers", cascade={"refresh"})
 33:      * @ORM\JoinColumn(name="wmsinstance", referencedColumnName="id")
 34:      */
 35:     protected $wmsinstance;
 36: 
 37:     /**
 38:      * @ORM\ManyToOne(targetEntity="WmsLayerSource", inversedBy="id", cascade={"refresh"})
 39:      * @ORM\JoinColumn(name="wmslayersource", referencedColumnName="id")
 40:      */
 41:     protected $wmslayersource;
 42: 
 43:     /**
 44:      * @ORM\ManyToOne(targetEntity="WmsInstanceLayer",inversedBy="sublayer")
 45:      * @ORM\JoinColumn(name="parent", referencedColumnName="id", nullable=true)
 46:      */
 47:     protected $parent = null;
 48: 
 49:     /**
 50:      * @ORM\OneToMany(targetEntity="WmsInstanceLayer",mappedBy="parent", cascade={"remove"})
 51:      * @ORM\OrderBy({"priority" = "asc"})
 52:      */
 53:     protected $sublayer;
 54: 
 55:     /**
 56:      * @ORM\Column(type="string", nullable=true)
 57:      */
 58:     protected $title;
 59: 
 60:     /**
 61:      * @ORM\Column(type="boolean", nullable=true)
 62:      */
 63:     protected $active = true;
 64: 
 65:     /**
 66:      * @ORM\Column(type="boolean", nullable=true)
 67:      */
 68:     protected $allowselected = true;
 69: 
 70:     /**
 71:      * @ORM\Column(type="boolean", nullable=true)
 72:      */
 73:     protected $selected = true;
 74: 
 75:     /**
 76:      * @ORM\Column(type="boolean", nullable=true)
 77:      */
 78:     protected $info;
 79: 
 80:     /**
 81:      * @ORM\Column(type="boolean", nullable=true)
 82:      */
 83:     protected $allowinfo;
 84: 
 85:     /**
 86:      * @ORM\Column(type="boolean", nullable=true)
 87:      */
 88:     protected $toggle;
 89: 
 90:     /**
 91:      * @ORM\Column(type="boolean", nullable=true)
 92:      */
 93:     protected $allowtoggle;
 94: 
 95:     /**
 96:      * @ORM\Column(type="boolean", nullable=true)
 97:      */
 98:     protected $allowreorder = true;
 99: 
100:     /**
101:      * @ORM\Column(type="float", nullable=true)
102:      */
103:     protected $minScale;
104: 
105:     /**
106:      * @ORM\Column(type="float", nullable=true)
107:      */
108:     protected $maxScale;
109: 
110:     /**
111:      * @ORM\Column(type="string", nullable=true)
112:      */
113:     protected $style = "";
114: 
115:     /**
116:      * @ORM\Column(type="integer", nullable=true)
117:      */
118:     protected $priority;
119: 
120:     public function __construct()
121:     {
122:         $this->sublayer = new ArrayCollection();
123:         $this->style = "";
124:     }
125:     
126:     /**
127:      * Set id
128:      * @param integer $id
129:      * @return WmsInstanceLayer
130:      */
131:     public function setId($id)
132:     {
133:         $this->id = $id;
134:         return $this;
135:     }
136: 
137:     /**
138:      * Get id
139:      *
140:      * @return integer 
141:      */
142:     public function getId()
143:     {
144:         return $this->id;
145:     }
146: 
147:     /**
148:      * Set title
149:      *
150:      * @param string $title
151:      * @return WmsInstanceLayer
152:      */
153:     public function setTitle($title)
154:     {
155:         $this->title = $title;
156: 
157:         return $this;
158:     }
159: 
160:     /**
161:      * Get title
162:      *
163:      * @return string 
164:      */
165:     public function getTitle()
166:     {
167:         return $this->title;
168:     }
169: 
170:     /**
171:      * Set sublayer as array of string
172:      *
173:      * @param array $sublayer
174:      * @return WmsInstanceLayer
175:      */
176:     public function setSublayer($sublayer)
177:     {
178:         $this->sublayer = $sublayer;
179: 
180:         return $this;
181:     }
182: 
183:     /**
184:      * Set sublayer as array of string
185:      *
186:      * @param WmsInstanceLayer $sublayer
187:      * @return WmsInstanceLayer
188:      */
189:     public function addSublayer(WmsInstanceLayer $sublayer)
190:     {
191:         $this->sublayer->add($sublayer);
192: 
193:         return $this;
194:     }
195: 
196:     /**
197:      * Get sublayer
198:      *
199:      * @return array 
200:      */
201:     public function getSublayer()
202:     {
203:         return $this->sublayer;
204:     }
205: 
206:     /**
207:      * Set parent
208:      *
209:      * @param WmsInstanceLayer $parent
210:      * @return WmsInstanceLayer
211:      */
212:     public function setParent($parent)
213:     {
214:         $this->parent = $parent;
215: 
216:         return $this;
217:     }
218: 
219:     /**
220:      * Get parent
221:      *
222:      * @return WmsInstanceLayer 
223:      */
224:     public function getParent()
225:     {
226:         return $this->parent;
227:     }
228: 
229:     /**
230:      * Set active
231:      *
232:      * @param boolean $active
233:      * @return WmsInstanceLayer
234:      */
235:     public function setActive($active)
236:     {
237:         $this->active = $active;
238: 
239:         return $this;
240:     }
241: 
242:     /**
243:      * Get active
244:      *
245:      * @return boolean 
246:      */
247:     public function getActive()
248:     {
249:         return $this->active;
250:     }
251: 
252:     /**
253:      * Set allowselected
254:      *
255:      * @param boolean $allowselected
256:      * @return WmsInstanceLayer
257:      */
258:     public function setAllowselected($allowselected)
259:     {
260:         $this->allowselected = $allowselected;
261: 
262:         return $this;
263:     }
264: 
265:     /**
266:      * Get allowselected
267:      *
268:      * @return boolean 
269:      */
270:     public function getAllowselected()
271:     {
272:         return $this->allowselected;
273:     }
274: 
275:     /**
276:      * Set selected
277:      *
278:      * @param boolean $selected
279:      * @return WmsInstanceLayer
280:      */
281:     public function setSelected($selected)
282:     {
283:         $this->selected = $selected;
284: 
285:         return $this;
286:     }
287: 
288:     /**
289:      * Get selected
290:      *
291:      * @return boolean 
292:      */
293:     public function getSelected()
294:     {
295:         return $this->selected;
296:     }
297: 
298:     /**
299:      * Set info
300:      *
301:      * @param boolean $info
302:      * @return WmsInstanceLayer
303:      */
304:     public function setInfo($info)
305:     {
306:         $this->info = $info;
307: 
308:         return $this;
309:     }
310: 
311:     /**
312:      * Get info
313:      *
314:      * @return boolean 
315:      */
316:     public function getInfo()
317:     {
318:         return $this->info;
319:     }
320: 
321:     /**
322:      * Get toggle
323:      *
324:      * @return boolean $toggle
325:      */
326:     public function getToggle()
327:     {
328:         return $this->toggle;
329:     }
330: 
331:     /**
332:      * Set toggle
333:      *
334:      * @param string $toggle
335:      */
336:     public function setToggle($toggle)
337:     {
338:         $this->toggle = $toggle;
339:         return $this;
340:     }
341: 
342:     /**
343:      * Set allowinfo
344:      *
345:      * @param boolean $allowinfo
346:      * @return WmsInstanceLayer
347:      */
348:     public function setAllowinfo($allowinfo)
349:     {
350:         $this->allowinfo = $allowinfo;
351: 
352:         return $this;
353:     }
354: 
355:     /**
356:      * Get allowinfo
357:      *
358:      * @return boolean 
359:      */
360:     public function getAllowinfo()
361:     {
362:         return $this->allowinfo;
363:     }
364: 
365:     /**
366:      * Get allowtoggle
367:      *
368:      * @return boolean $allowtoggle
369:      */
370:     public function getAllowtoggle()
371:     {
372:         return $this->allowtoggle;
373:     }
374: 
375:     /**
376:      * Set allowtoggle
377:      *
378:      * @param boolean $allowtoggle
379:      */
380:     public function setAllowtoggle($allowtoggle)
381:     {
382:         $this->allowtoggle = $allowtoggle;
383:         return $this;
384:     }
385: 
386:     /**
387:      * Get allowreorder
388:      *
389:      * @return boolean $allowreorder
390:      */
391:     public function getAllowreorder()
392:     {
393:         return $this->allowreorder;
394:     }
395: 
396:     /**
397:      * Set allowreorder
398:      *
399:      * @param boolean $allowreorder
400:      */
401:     public function setAllowreorder($allowreorder)
402:     {
403:         $this->allowreorder = $allowreorder;
404:         return $this;
405:     }
406: 
407:     /**
408:      * Set minScale
409:      *
410:      * @param float $minScale
411:      * @return WmsInstanceLayer
412:      */
413:     public function setMinScale($minScale)
414:     {
415:         $this->minScale = $minScale;
416: 
417:         return $this;
418:     }
419: 
420:     /**
421:      * Get minScale
422:      *
423:      * @return float 
424:      */
425:     public function getMinScale()
426:     {
427:         return $this->minScale;
428:     }
429: 
430:     /**
431:      * Set maxScale
432:      *
433:      * @param float $maxScale
434:      * @return WmsInstanceLayer
435:      */
436:     public function setMaxScale($maxScale)
437:     {
438:         $this->maxScale = $maxScale;
439: 
440:         return $this;
441:     }
442: 
443:     /**
444:      * Get maxScale
445:      *
446:      * @return float 
447:      */
448:     public function getMaxScale()
449:     {
450:         return $this->maxScale;
451:     }
452: 
453:     /**
454:      * Set style
455:      *
456:      * @param string $style
457:      * @return WmsInstanceLayer
458:      */
459:     public function setStyle($style)
460:     {
461:         $this->style = $style;
462: 
463:         return $this;
464:     }
465: 
466:     /**
467:      * Get style
468:      *
469:      * @return string 
470:      */
471:     public function getStyle()
472:     {
473:         return $this->style;
474:     }
475: 
476:     /**
477:      * Set priority
478:      *
479:      * @param integer $priority
480:      * @return WmsInstanceLayer
481:      */
482:     public function setPriority($priority)
483:     {
484:         $this->priority = $priority;
485: 
486:         return $this;
487:     }
488: 
489:     /**
490:      * Get priority
491:      *
492:      * @return integer 
493:      */
494:     public function getPriority()
495:     {
496:         return $this->priority;
497:     }
498: 
499:     /**
500:      * Set wmsinstance
501:      *
502:      * @param WmsInstance $wmsinstance
503:      * @return WmsInstanceLayer
504:      */
505:     public function setWmsinstance(WmsInstance $wmsinstance = null)
506:     {
507:         $this->wmsinstance = $wmsinstance;
508: 
509:         return $this;
510:     }
511: 
512:     /**
513:      * Get wmsinstance
514:      *
515:      * @return WmsInstance 
516:      */
517:     public function getWmsinstance()
518:     {
519:         return $this->wmsinstance;
520:     }
521: 
522:     /**
523:      * Set wmslayersource
524:      *
525:      * @param WmsLayerSource $wmslayersource
526:      * @return WmsInstanceLayer
527:      */
528:     public function setWmslayersource(WmsLayerSource $wmslayersource = null)
529:     {
530:         $this->wmslayersource = $wmslayersource;
531: 
532:         return $this;
533:     }
534: 
535:     /**
536:      * Get wmslayersource
537:      *
538:      * @return WmsLayerSource 
539:      */
540:     public function getWmslayersource()
541:     {
542:         return $this->wmslayersource;
543:     }
544: 
545:     /**
546:      * @inheritdoc
547:      */
548:     public function __toString()
549:     {
550:         return (string) $this->getId();
551:     }
552: 
553:     /**
554:      * @inheritdoc
555:      */
556:     public function getConfiguration()
557:     {
558:         $configuration = array(
559:             "id" => $this->id,
560:             "name" => $this->wmslayersource->getName() !== null ? $this->wmslayersource->getName() : "",
561:             "title" => $this->title,
562:             "queryable" => $this->getInfo(),
563:             "style" => $this->style,
564:             "minScale" => $this->minScale !== null ? floatval($this->minScale) : null,
565:             "maxScale" => $this->maxScale !== null ? floatval($this->maxScale) : null
566:         );
567: 
568:         if(count($this->wmslayersource->getStyles()) > 0)
569:         {
570:             $styles = $this->wmslayersource->getStyles();
571:             $legendurl = $styles[0]->getLegendUrl(); // first style object
572:             if($legendurl !== null){
573:             $configuration["legend"] = array(
574:                 "url" => $legendurl->getOnlineResource()->getHref(),
575:                 "width" => intval($legendurl->getWidth()),
576:                 "height" => intval($legendurl->getHeight()));
577:             }
578:         } else if($this->wmsinstance->getSource()->getGetLegendGraphic() !== null)
579:         {
580:             $legend = $this->wmsinstance->getSource()->getGetLegendGraphic();
581:             $url = $legend->getHttpGet();
582:             $formats = $legend->getFormats();
583:             $params = "service=WMS&request=GetLegendGraphic"
584:                     . "&version="
585:                     . $this->wmsinstance->getSource()->getVersion()
586:                     . "&layer=" . $this->wmslayersource->getName()
587:                     . (count($formats) > 0 ? "&format=" . $formats[0] : "")
588:                     . "&sld_version=1.1.0";
589:             $legendgraphic = Utils::getHttpUrl($url, $params);
590:             $configuration["legend"] = array(
591:                 "graphic" => $legendgraphic);
592:         }
593:         $configuration["treeOptions"] = array(
594:             "info" => $this->info,
595:             "selected" => $this->selected,
596:             "toggle" => $this->toggle,
597:             "allow" => array(
598:                 "info" => $this->allowinfo,
599:                 "selected" => $this->allowselected,
600:                 "toggle" => $this->allowtoggle,
601:                 "reorder" => $this->allowreorder,
602:             )
603:         );
604:         return $configuration;
605:     }
606: 
607: }
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0