[Mapbender-commits] r7139 - trunk/mapbender/http/classes
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Nov 18 06:01:48 EST 2010
Author: christoph
Date: 2010-11-18 03:01:48 -0800 (Thu, 18 Nov 2010)
New Revision: 7139
Modified:
trunk/mapbender/http/classes/class_wfs_1_1_factory.php
Log:
#722
Modified: trunk/mapbender/http/classes/class_wfs_1_1_factory.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs_1_1_factory.php 2010-11-16 14:37:08 UTC (rev 7138)
+++ trunk/mapbender/http/classes/class_wfs_1_1_factory.php 2010-11-18 11:01:48 UTC (rev 7139)
@@ -1,7 +1,7 @@
<?php
# $Id: class_wfs.php 3094 2008-10-01 13:52:35Z christoph $
# http://www.mapbender.org/index.php/class_wfs.php
-# Copyright (C) 2002 CCGIS
+# Copyright (C) 2002 CCGIS
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -26,61 +26,69 @@
/**
* Creates WFS 1.1 objects from a capabilities documents.
- *
+ *
* @return Wfs_1_1
*/
class Wfs_1_1_Factory extends WfsFactory {
protected function createFeatureTypeFromUrl ($aWfs, $featureTypeName, $featureTypeNsArray) {
$postData = "<?xml version=\"1.0\"?>\n".
- "<DescribeFeatureType version=\"" . $aWfs->getVersion() . "\" " .
+ "<DescribeFeatureType version=\"" . $aWfs->getVersion() . "\" " .
"service=\"WFS\" xmlns=\"http://www.opengis.net/wfs\" ";
-
+
+ $nsUrl = $featureTypeNsArray["xmlns:" . $key];
+ if (!$nsUrl) {
+ $nsUrl = $featureTypeNsArray[$key];
+ }
+
if ($featuretype_name != $this->sepNameSpace($featureTypeName)) {
$key = "xmlns:" . $this->getNameSpace($featureTypeName);
- $postData .= $key . "=\"" . $featureTypeNsArray[$key] . "\" ";
+ $postData .= $key . "=\"" . $nsUrl . "\" ";
}
- $postData .= "><TypeName>" . $featureTypeName . "</TypeName>" .
+ $postData .= "><TypeName>" . $featureTypeName . "</TypeName>" .
"</DescribeFeatureType>";
$xml = $this->post($aWfs->describeFeatureType, $postData);
- return $this->createFeatureTypeFromXml ($xml, $aWfs);
+ return $this->createFeatureTypeFromXml ($xml, $aWfs, $featureTypeName);
}
+
protected function createFeatureTypeFromUrlGet ($aWfs, $featureTypeName, $featureTypeNsArray) {
$key = $this->getNameSpace($featureTypeName);
-
+ $nsUrl = $featureTypeNsArray["xmlns:" . $key];
+ if (!$nsUrl) {
+ $nsUrl = $featureTypeNsArray[$key];
+ }
$paramArray = array(
"SERVICE=WFS",
"VERSION=1.1.0",
"REQUEST=DescribeFeatureType",
"TYPENAME=" . urlencode($featureTypeName),
"NAMESPACE=" . urlencode(
- "xmlns(" . $key . "=" . $featureTypeNsArray[$key] . ")"
- )
- );
+ "xmlns(" . $key . "=" . $nsUrl . ")"
+ ));
$url = $aWfs->describeFeatureType .
$aWfs->getConjunctionCharacter($aWfs->describeFeatureType) .
implode("&", $paramArray);
$xml = $this->get($url);
- return $this->createFeatureTypeFromXml ($xml, $aWfs);
+ return $this->createFeatureTypeFromXml ($xml, $aWfs, $featureTypeName);
}
- protected function createFeatureTypeFromXml ($xml, $myWfs) {
+ protected function createFeatureTypeFromXml ($xml, $myWfs, $featureTypeName) {
$newFeatureType = new WfsFeatureType($myWfs);
$admin = new administration();
$values = $admin->parseXml($xml);
- foreach ($values as $element) {
+ foreach ($values as $element) {
if ($this->sepNameSpace($element[tag]) == "schema" && $element[type] == "open") {
$section = "namespace";
}
-
- if ($section == "namespace" && is_array($element[attributes])) {
-
+
+ if ($section == "namespace" && is_array($element[attributes])) {
+
while (list($k, $val) = each ($element[attributes])) {
if (substr($k, 0, 5) == "xmlns") {
$key = $this->sepNameSpace($k);
@@ -88,42 +96,42 @@
}
}
}
- if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "open"){
- $section = "complexcontent";
+ if($this->sepNameSpace($element[tag]) == "complexType" && $element[type] == "open" && $element[attributes]["name"] === $featureTypeName . "Type"){
+ $section = "complexType";
}
- if($section == "complexcontent" && $this->sepNameSpace($element[tag]) == "element" && $element[attributes][name]){
+ if($section == "complexType" && $this->sepNameSpace($element[tag]) == "element" && $element[attributes][name]){
$newFeatureType->addElement(
- $element[attributes]["name"],
+ $element[attributes]["name"],
$this->sepNameSpace($element[attributes]["type"])
- );
+ );
}
- if($this->sepNameSpace($element[tag]) == "complexContent" && $element[type] == "close"){
+ if($this->sepNameSpace($element[tag]) == "complexType" && $element[type] == "close"){
$section = "";
}
- }
- return $newFeatureType;
+ }
+ 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") {
@@ -145,7 +153,7 @@
if($tag == "ACCESSCONSTRAINTS"){
$myWfs->accessconstraints = $element[value];
}
-
+
if($tag == "OPERATION" && $element[type] == "open"){
switch ($element[attributes][name]) {
case "GetCapabilities" :
@@ -166,7 +174,7 @@
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"]);
@@ -176,7 +184,7 @@
if($section == "describefeaturetype" && $tag == "GET"){
$myWfs->describeFeatureType = html_entity_decode($element[attributes]["xlink:href"]);
}
-
+
# getFeature
if($section == "getfeature" && $tag == "POST"){
$myWfs->getFeature = html_entity_decode($element[attributes]["xlink:href"]);
@@ -188,7 +196,7 @@
}
if($tag == "OPERATION" && $element[type] == "close"){
- $section = "";
+ $section = "";
}
if($tag == "FEATURETYPE" && $element[type] == "open"){
@@ -207,7 +215,7 @@
if($section == "featuretype" && $tag == "DEFAULTSRS"){
$featuretype_srs = $element[value];
- $currentFeatureType = $this->createFeatureTypeFromUrl($myWfs, $featuretype_name, $featureTypeNsArray);
+ $currentFeatureType = $this->createFeatureTypeFromUrlGet($myWfs, $featuretype_name, $featureTypeNsArray);
if ($currentFeatureType !== null) {
$currentFeatureType->name = $featuretype_name;
$currentFeatureType->title = $featuretype_title;
@@ -229,7 +237,7 @@
return null;
}
}
-
+
public function createFromDb ($id) {
$myWfs = new Wfs_1_1();
return parent::createFromDb($id, $myWfs);
More information about the Mapbender_commits
mailing list