\n". "getVersion() . "\" " . "service=\"WFS\" xmlns=\"http://www.opengis.net/wfs\" "; if ($featuretype_name != $this->sepNameSpace($featureTypeName)) { $key = "xmlns:" . $this->getNameSpace($featureTypeName); $postData .= $key . "=\"" . $featureTypeNsArray[$key] . "\" "; } $postData .= ">" . $featureTypeName . "" . ""; $xml = $this->post($aWfs->describeFeatureType, $postData); return $this->createFeatureTypeFromXml ($xml, $aWfs); } protected function createFeatureTypeFromXml ($xml, $myWfs) { $newFeatureType = new WfsFeatureType($myWfs); $admin = new administration(); $values = $admin->parseXml($xml); foreach ($values as $element) { if ($this->sepNameSpace($element[tag]) == "schema" && $element[type] == "open") { $section = "namespace"; } if ($section == "namespace" && is_array($element[attributes])) { while (list($k, $val) = each ($element[attributes])) { if (substr($k, 0, 5) == "xmlns") { $key = $this->sepNameSpace($k); $newFeatureType->addNamespace($key, $val); } } } if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "open"){ $section = "complexcontent"; } if($section == "complexcontent" && $this->sepNameSpace($element[tag]) == "element" && $element[attributes][name]){ $newFeatureType->addElement( $element[attributes]["name"], $this->sepNameSpace($element[attributes]["type"]) ); } if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "close"){ $section = ""; } } return $newFeatureType; } /** * Creates WFS 1.0 objects from a capabilities documents. * * @return Wfs_1_1 * @param $xml String */ public function createFromXml ($xml) { try { $myWfs = new Wfs_1_1(); $admin = new administration(); $values = $admin->parseXml($xml); $myWfs->getCapabilitiesDoc = $admin->char_encode($xml); $myWfs->id = $this->createId(); foreach ($values as $element) { $tag = $this->sepNameSpace(strtoupper($element[tag])); if($tag == "WFS_CAPABILITIES" && $element[type] == "open"){ $myWfs->version = $element[attributes][version]; if ($myWfs->version !== "1.1.0") { throw new Exception("Not a WFS 1.1.0 capabilities document."); } } if($tag == "NAME" && $element[level] == '3'){ $myWfs->name = $element[value]; } if($tag == "TITLE" && $element[level] == '3'){ $myWfs->title = $this->stripEndlineAndCarriageReturn($element[value]); } if($tag == "ABSTRACT" && $element[level] == '3'){ $myWfs->summary = $this->stripEndlineAndCarriageReturn($element[value]); } if($tag == "FEES"){ $myWfs->fees = $element[value]; } if($tag == "ACCESSCONSTRAINTS"){ $myWfs->accessconstraints = $element[value]; } if($tag == "OPERATION" && $element[type] == "open"){ switch ($element[attributes][name]) { case "GetCapabilities" : $section = "getcapabilities"; break; case "DescribeFeatureType" : $section = "describefeaturetype"; break; case "GetFeature" : $section = "getfeature"; break; case "Transaction" : $section = "transaction"; break; } } # getCapabilities if($section == "getcapabilities" && $tag == "GET"){ $myWfs->getCapabilities = html_entity_decode($element[attributes]["xlink:href"]); } # descriptFeatureType if($section == "describefeaturetype" && $tag == "POST"){ $myWfs->describeFeatureType = html_entity_decode($element[attributes]["xlink:href"]); } # getFeature if($section == "getfeature" && $tag == "POST"){ $myWfs->getFeature = html_entity_decode($element[attributes]["xlink:href"]); } # transaction if($section == "transaction" && $tag == "POST"){ $myWfs->transaction = html_entity_decode($element[attributes]["xlink:href"]); } if($tag == "OPERATION" && $element[type] == "close"){ $section = ""; } if($tag == "FEATURETYPE" && $element[type] == "open"){ $section = "featuretype"; $featureTypeNsArray = $element[attributes]; } if($section == "featuretype" && $tag == "NAME"){ $featuretype_name = $element[value]; } if($section == "featuretype" && $tag == "TITLE"){ $featuretype_title = $this->stripEndlineAndCarriageReturn($element[value]); } if($section == "featuretype" && $tag == "ABSTRACT"){ $featuretype_abstract = $element[value]; } if($section == "featuretype" && $tag == "DEFAULTSRS"){ $featuretype_srs = $element[value]; $currentFeatureType = $this->createFeatureTypeFromUrl($myWfs, $featuretype_name, $featureTypeNsArray); if ($currentFeatureType !== null) { $currentFeatureType->name = $featuretype_name; $currentFeatureType->title = $featuretype_title; $currentFeatureType->summary = $featuretype_abstract; $currentFeatureType->srs = $featuretype_srs; $myWfs->addFeatureType($currentFeatureType); } } } return $myWfs; } catch (Exception $e) { $e = new mb_exception($e); return null; } } public function createFromDb ($id) { $myWfs = new Wfs_1_1(); return parent::createFromDb($id, $myWfs); } } ?>