Overview

Namespaces

  • Mapbender
    • Component
      • HTTP
    • CoreBundle
      • Command
      • Component
        • Exception
      • Controller
      • DataFixtures
        • ORM
      • DependencyInjection
      • Element
        • Type
      • Entity
      • EventListener
      • Extension
      • Form
        • DataTransformer
        • EventListener
        • Type
      • Security
      • Template
    • 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
        • Type
    • WmsBundle
      • Component
        • Exception
      • Controller
      • DependencyInjection
      • Element
        • Type
      • Entity
      • Event
      • Form
        • EventListener
        • Type
    • WmtsBundle
      • Component
        • Exception
      • Controller
      • Entity
      • Form
        • Type
  • None
  • PHP

Classes

  • MapbenderWMC
  • WmcParser
  • WmcParser110
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  • Download
  1: <?php
  2: 
  3: namespace Mapbender\WmcBundle\Component;
  4: 
  5: /**
  6:  * Class that Parses WMS 1.3.0 GetCapabilies Document 
  7:  * @package Mapbender
  8:  * @author Paul Schmidt
  9:  */
 10: class WmcParser110 extends WmcParser
 11: {
 12: 
 13:     /**
 14:      * Creates an instance
 15:      * @param \DOMDocument $doc
 16:      */
 17:     public function __construct(\DOMDocument $doc)
 18:     {
 19:         parent::__construct($doc);
 20:         $this->xpath->registerNamespace("cntxt",
 21:                                         "http://www.opengis.net/context");
 22:     }
 23: 
 24:     /**
 25:      * Parses the GetCapabilities document
 26:      * 
 27:      * @return \Mapbender\WmsBundle\Entity\WmsSource
 28:      */
 29:     public function parse()
 30:     {
 31:         $wmc = array();
 32:         $root = $this->doc->documentElement;
 33: 
 34:         $wmc["version"] = $this->getValue("./@version", $root);
 35:         $wmc["id"] = $this->getValue("./@id", $root);
 36:         $wmc["general"] = array();
 37:         $genEl = $this->getValue("./cntxt:General", $root);
 38:         $wmc["general"]["window"] = array(
 39:             "width" => $this->getValue("./cntxt:Window/@width", $genEl),
 40:             "height" => $this->getValue("./cntxt:Window/@height", $genEl)
 41:         );
 42:         $wmc["general"]["bbox"] = array(
 43:             "srs" => $this->getValue("./cntxt:BoundingBox/@srs", $genEl),
 44:             "minx" => $this->getValue("./cntxt:BoundingBox/@minx", $genEl),
 45:             "miny" => $this->getValue("./cntxt:BoundingBox/@miny", $genEl),
 46:             "maxx" => $this->getValue("./cntxt:BoundingBox/@maxx", $genEl),
 47:             "maxy" => $this->getValue("./cntxt:BoundingBox/@maxy", $genEl)
 48:         );
 49: 
 50:         $wmc["general"]["title"] = $this->getValue("./cntxt:Title/text()", $genEl);
 51: 
 52:         $keywordList = $this->xpath->query("./cntxt:KeywordList/cntxt:Keyword",
 53:                                            $genEl);
 54:         if($keywordList !== null)
 55:         {
 56:             foreach($keywordList as $keywordElt)
 57:             {
 58:                 $wmc["general"]["keywords"][] = $this->getValue("./text()", $keywordElt);
 59:             }
 60:         }
 61:         if($this->getValue("./cntxt:Abstract", $genEl) !== null)
 62:         {
 63:             $wmc["general"]["abstract"] = $this->getValue("./cntxt:Abstract/text()",
 64:                                                    $genEl);
 65:         }
 66:         if($this->getValue("./cntxt:LogoURL", $genEl) !== null)
 67:         {
 68:             $logoEl = $this->getValue("./cntxt:LogoURL", $genEl);
 69:             $wmc["general"]["logourl"] = array(
 70:                 "width" => $this->getValue("./@width", $logoEl),
 71:                 "height" => $this->getValue("./@height", $logoEl),
 72:                 "format" => $this->getValue("./@format", $logoEl),
 73:                 "url" => $this->getValue("./cntxt:OnlineResource/@xlink:href",
 74:                                          $logoEl));
 75:         }
 76:         if($this->getValue("./cntxt:DescriptionURL", $genEl) !== null)
 77:         {
 78:             $descrEl = $this->getValue("./cntxt:DescriptionURL", $genEl);
 79:             $wmc["general"]["descriptionurl"] = array(
 80:                 "format" => $this->getValue("./@format)", $descrEl),
 81:                 "url" => $this->getValue("./cntxt:OnlineResource/@xlink:href",
 82:                                          $descrEl));
 83:         }
 84:         if($this->getValue("./cntxt:ContactInformation", $genEl) !== null)
 85:         {
 86:             $contactEl = $this->getValue("./cntxt:ContactInformation", $genEl);
 87:             $wmc["general"]["contactinfo"] = array();
 88:             if($this->getValue("./cntxt:ContactPersonPrimary", $contactEl) !== null)
 89:             {
 90:                 $wmc["general"]["contactinfo"]["person"] = $this->getValue("./cntxt:ContactPersonPrimary/cntxt:ContactPerson/text()",
 91:                                                      $contactEl);
 92:                 $wmc["general"]["contactinfo"]["organization"] = $this->getValue("./cntxt:ContactPersonPrimary/cntxt:ContactOrganization/text()",
 93:                                                            $contactEl);
 94:             }
 95:             if($this->getValue("./cntxt:ContactPosition", $contactEl) !== null)
 96:             {
 97:                 $wmc["general"]["contactinfo"]["position"] = $this->getValue("./cntxt:ContactPosition/text()",
 98:                                                        $contactEl);
 99:             }
100:             if($this->getValue("./cntxt:ContactAddress", $contactEl) !== null)
101:             {
102:                 $addrEl = $this->getValue("./cntxt:ContactAddress", $contactEl);
103:                 $wmc["general"]["contactinfo"]["address"] = array(
104:                     "type" => $this->getValue("./cntxt:AddressType/text()",
105:                                               $addrEl),
106:                     "address" => $this->getValue("./cntxt:Address/text()",
107:                                                  $addrEl),
108:                     "city" => $this->getValue("./cntxt:City/text()", $addrEl),
109:                     "state" => $this->getValue("./cntxt:StateOrProvince/text()",
110:                                                $addrEl),
111:                     "postcode" => $this->getValue("./cntxt:PostCode/text()",
112:                                                   $addrEl),
113:                     "country" => $this->getValue("./cntxt:Country/text()",
114:                                                  $addrEl)
115:                 );
116:             }
117:             if($this->getValue("./cntxt:ContactVoiceTelephone", $contactEl) !== null)
118:             {
119:                 $wmc["general"]["contactinfo"]["phone"] = $this->getValue("./cntxt:ContactVoiceTelephone/text()",
120:                                                     $contactEl);
121:             }
122:             if($this->getValue("./cntxt:ContactFacsimileTelephone", $contactEl) !== null)
123:             {
124:                 $wmc["general"]["contactinfo"]["fax"] = $this->getValue("./cntxt:ContactFacsimileTelephone/text()",
125:                                                   $contactEl);
126:             }
127:             if($this->getValue("./cntxt:ContactElectronicMailAddress",
128:                                $contactEl) !== null)
129:             {
130:                 $wmc["general"]["contactinfo"]["email"] = $this->getValue("./cntxt:ContactElectronicMailAddress/text()",
131:                                                     $contactEl);
132:             }
133:         }
134:         $layerList = $this->xpath->query("./cntxt:LayerList/cntxt:Layer", $root);
135:         $wmc["layerlist"] = array();
136: //        $layerlist = $wmc["layerlist"];
137:         foreach($layerList as $layerElm)
138:         {
139:             $wmc["layerlist"][] = $this->parseLayer($layerElm);
140:         }
141:         return $wmc;
142:     }
143: 
144:     /**
145:      * Parses the Service section of the GetCapabilities document
146:      * 
147:      * @param \Mapbender\WmsBundle\Entity\WmsSource $wmc the WmsSource
148:      * @param \DOMElement $contextElm the element to use as context for
149:      * the Service section
150:      */
151:     private function parseLayer(\DOMElement $layerElm)
152:     {
153:         $layer = array(
154:             "queryable" => $this->getValue("./@queryable", $layerElm),
155:             "hidden" => $this->getValue("./@hidden", $layerElm),
156:             "server" => array(
157:                 "service" => $this->getValue("./cntxt:Server/@service",
158:                                              $layerElm),
159:                 "version" => $this->getValue("./cntxt:Server/@version",
160:                                              $layerElm),
161:                 "title" => $this->getValue("./cntxt:Server/@title", $layerElm),
162:                 "url" => $this->getValue("./cntxt:Server/cntxt:OnlineResource/@xlink:href",
163:                                          $layerElm)),
164:             "name" => $this->getValue("./cntxt:Name/text()", $layerElm),
165:             "title" => $this->getValue("./cntxt:Title/text()", $layerElm),
166:         );
167:         if($this->getValue("./cntxt:Abstract", $layerElm) !== null)
168:         {
169:             $layer["abstract"] = $this->getValue("./cntxt:Abstract/text()",
170:                                                  $layerElm);
171:         }
172:         if($this->getValue("./SRS", $layerElm) !== null)
173:         {
174:             $layer["srs"] = $this->getValue("./cntxt:SRS/text()", $layerElm);
175:         }
176:         $formatList = $this->xpath->query("./cntxt:FormatList/cntxt:Format",
177:                                           $layerElm);
178:         $layer["formats"] = array();
179:         foreach($formatList as $formatElm)
180:         {
181:             $layer["formats"][] = array(
182:                 "current" => $this->getValue("./@current", $formatElm),
183:                 "format" => $this->getValue("./text()", $formatElm),
184:             );
185:         }
186: 
187:         $styleList = $this->xpath->query("./cntxt:StyleList/cntxt:Style",
188:                                          $layerElm);
189:         $layer["styles"] = array();
190:         foreach($formatList as $styleElm)
191:         {
192:             $style = array(
193:                 "current" => $this->getValue("./@current", $styleElm),
194:                 "name" => $this->getValue("./cntxt:Name/text()", $styleElm),
195:                 "title" => $this->getValue("./cntxt:Title/text()", $styleElm),
196:             );
197:             if($this->getValue("./LegendURL", $styleElm) !== null)
198:             {
199:                 $style["legend"] = array(
200:                     "width" => $this->getValue("./cntxt:LegendURL/@width",
201:                                                $styleElm),
202:                     "height" => $this->getValue("./cntxt:LegendURL/@height",
203:                                                 $styleElm),
204:                     "url" => $this->getValue("./cntxt:LegendURL/cntxt:OnlineResource/@xlink:href",
205:                                              $styleElm)
206:                 );
207:             }
208:             $layer["styles"][] = $style;
209:         }
210: 
211:         return $layer;
212:     }
213: 
214: }
215: 
216: 
Mapbender3 API documenation API documentation generated by ApiGen 2.8.0