Piotr Labudda 9 лет назад
Родитель
Сommit
bfde6cc4e2
1 измененных файлов с 17 добавлено и 15 удалено
  1. 17 15
      SE/se-lib/Api/WfsServerBase.php

+ 17 - 15
SE/se-lib/Api/WfsServerBase.php

@@ -110,8 +110,8 @@ class Api_WfsServerBase {
 			// BBOX may have EPSG at then end - example: ",EPSG:4326"
 			$num = "\d+.?\d*?";// "\d+(.\d+)?"
 			if (!preg_match("/^({$num}),({$num}),({$num}),({$num})(\,EPSG:\d+)?$/", $args['bbox'], $matches)) throw new Exception("Illegal BBOX format");
-			// QGIS may send BBOX in wrong order: 54.23580872176457,18.46844302390853,54.25220902538883,18.492990600812696
-			// first number should be smaller then second
+			// QGIS send BBOX in correct order: 54.23580872176457,18.46844302390853,54.25220902538883,18.492990600812696
+			// first number should not be smaller then second
 			// example $matches:
 			//     [0] => 18.492990600812696,54.23580872176457,18.46844302390853,54.25220902538883
 			//     [1] => 18.492990600812696
@@ -120,10 +120,10 @@ class Api_WfsServerBase {
 			//     [4] => 54.25220902538883
 			// (optional) EPGS
 			$bboxPoints = ($matches[1] > $matches[2])
-				? [ $matches[2], $matches[3], $matches[4], $matches[1] ]
-				: [ $matches[1], $matches[2], $matches[3], $matches[4] ];
+				? [ $matches[1], $matches[2], $matches[3], $matches[4] ]
+				: [ $matches[2], $matches[3], $matches[4], $matches[1] ];
 
-			$searchParams['f_the_geom'] = "BBOX:" . implode(",", $bboxPoints);
+			$args['bbox'] = implode(",", $bboxPoints);
 		}
 
 		$args['wfs:featureID'] = V::get('featureid', null, $lowerArgs);// TODO: allow multiply feature id (csv)
@@ -1413,6 +1413,16 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 			if ($acl->hasSimpleSchema()) {
 				$simpleSchema = $acl->getSimpleSchema();
 
+				foreach ($simpleSchema as $ssName => $schema) {
+					if ('root' == $ssName) $ssName = $objectName;
+					list($nsUri, $prefix, $name) = Api_WfsNs::parseObjectNsUri($schema['@namespace']);
+					if (!array_key_exists($nsUri, $nsMap)) $nsMap[$nsUri] = $prefix;
+				}
+
+				foreach ($nsMap as $uri => $prefix) {
+					$rootNode->setAttributeNS('http://www.w3.org/2000/xmlns/', "xmlns:{$prefix}", $uri);
+				}
+
 				$aliasRefMap = array();// fieldName => namespace uri
 				foreach ($simpleSchema as $ssName => $schema) {
 					if ('root' == $ssName) $ssName = $objectName;
@@ -1433,7 +1443,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 						$elNode = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:import');
 						$rootNode->appendChild($elNode);
 						$elNode->setAttribute('namespace', $nsUri);
-						$elNode->setAttribute('schemaLocation', "{$name}.xsd");// TODO: real file url -> DescribeFeatureType[Advanced]
+						$elNode->setAttribute('schemaLocation', "{$nsUri}.xsd");// TODO: real file url -> DescribeFeatureType[Advanced]
 					}
 				}
 
@@ -1441,15 +1451,6 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 					{// code from Code_AclSimpleSchema
 						if ('root' == $ssName) $ssName = $objectName;
 
-				    if (empty($schema['@namespace'])) throw new Exception("Missing @namespace in schema for '{$ssName}'");
-				    $ns = explode('/', $schema['@namespace']);
-				    $name = end($ns);
-				    if (count($ns) < 2) throw new Exception("Wrong @namespace syntax in schema for '{$ssName}'");
-				    $rootTableName = $ns[1];
-
-						$aclNamespaceUri = Api_WfsNs::getNsUri("default_db__x3A__{$rootTableName}");
-						if (!array_key_exists($aclNamespaceUri, $nsMap)) $nsMap[$aclNamespaceUri] = "default_db__x3A__{$rootTableName}";
-
 						// <xsd:complexType name="ZaliczkaPozycjaType">
 				    //     <xsd:complexContent>
 				    //         <xsd:extension base="gml:AbstractFeatureType">
@@ -1491,6 +1492,7 @@ if($DBG){echo 'L.' . __LINE__ . ' $validateConvertedTransactionXsdString:';print
 							} else if (!empty($field['@ref'])) {
 								if (false !== strpos($field['@ref'], '/')) {// @ref_uri
 									$elNode->setAttribute('ref', "{$tnsPrefix}:{$ssName}_{$fieldName}");
+									$elNode->setAttributeNS($rootWfsNsUri, "{$rootWfsNs}:name", $fieldName);
 								} else {
 									$elNode->setAttribute('ref', "{$tnsPrefix}:{$field['@ref']}");
 								}