Przeglądaj źródła

fixed bug in wfs when add multiple features all has the same the_geom

Piotr Labudda 10 lat temu
rodzic
commit
bdb95b0ac4
1 zmienionych plików z 13 dodań i 12 usunięć
  1. 13 12
      SE/se-lib/Api/WfsServerBase.php

+ 13 - 12
SE/se-lib/Api/WfsServerBase.php

@@ -778,13 +778,13 @@ if($DBG){echo '$convertedTransaction:';print_r($convertedTransaction);echo "\n";
 		$statusTag = '';
 		$statusIsFailed = false;
 		$statusAll = null;
-		$createdFetureId = '';
+		$createdFetureId = array();
 		foreach ($changesList as $featureId => $change) {
 			if ('FAILED' == $change['Status']) {
 				$statusIsFailed = true;
 			}
 			if ('SUCCESS' == $change['Status'] && !empty($change['fid'])) {
-				$createdFetureId = $change['fid'];
+				$createdFetureId[] = $change['fid'];
 			}
 			if (!empty($change['Message'])) $messageTag .= "Feature '{$featureId}' {$change['Status']}: {$change['Message']}\n";
 		}
@@ -809,10 +809,11 @@ if($DBG){echo '$convertedTransaction:';print_r($convertedTransaction);echo "\n";
 		// TODO: xsi:schemaLocation="http://www.opengis.net/wfs http://localhost:8080/geoserver/schemas/wfs/1.0.0/WFS-transaction.xsd"
 		$wfsInsertResult = '';
 		if (!empty($createdFetureId)) {
-			$wfsInsertResult = <<<EOF
-	<wfs:InsertResult>
-		<ogc:FeatureId fid="{$createdFetureId}" xmlns:ogc="http://www.opengis.net/ogc"/>
-	</wfs:InsertResult>
+			$wfsInsertResult = "\n<wfs:InsertResult>\n";
+			foreach ($createdFetureId as $fid) {
+				$wfsInsertResult .= '<ogc:FeatureId fid="' . $fid . '" xmlns:ogc="http://www.opengis.net/ogc"/>' . "\n";
+			}
+			$wfsInsertResult .= "\n</wfs:InsertResult>\n";
 EOF;
 		}
 		$tranRes = <<<EOF
@@ -846,19 +847,19 @@ if($DBG){echo 'sourceNsList:';print_r($sourceNsList);echo "\n";}
 			$acl = $this->getAclFromTypeName($typeName);
 			$geomType = $acl->getGeomFieldType($theGeomField);
 			if ('polygon' == $geomType) {
-				$geomCoordsUpdateXpath = "//wfs:Value/*/gml:outerBoundaryIs/gml:LinearRing/gml:coordinates";
+				$geomCoordsUpdateXpath = ".//wfs:Value/*/gml:outerBoundaryIs/gml:LinearRing/gml:coordinates";
 				$geomCoordsUpdateXpath = "((<xsl:value-of select=\"{$geomCoordsUpdateXpath}\"/>))";
-				$geomCoordsInsertXpath = "//*/gml:outerBoundaryIs/gml:LinearRing/gml:coordinates";
+				$geomCoordsInsertXpath = ".//*/gml:outerBoundaryIs/gml:LinearRing/gml:coordinates";
 				$geomCoordsInsertXpath = "((<xsl:value-of select=\"{$geomCoordsInsertXpath}\"/>))";
 			} else if ('linestring' == $geomType) {
-				$geomCoordsUpdateXpath = "//wfs:Value/*/gml:coordinates";
+				$geomCoordsUpdateXpath = ".//wfs:Value/*/gml:coordinates";
 				$geomCoordsUpdateXpath = "(<xsl:value-of select=\"{$geomCoordsUpdateXpath}\"/>)";
-				$geomCoordsInsertXpath = "//*/gml:coordinates";
+				$geomCoordsInsertXpath = ".//*/gml:coordinates";
 				$geomCoordsInsertXpath = "(<xsl:value-of select=\"{$geomCoordsInsertXpath}\"/>)";
 			} else if ('point' == $geomType) {
-				$geomCoordsUpdateXpath = "//wfs:Value/*/gml:coordinates";
+				$geomCoordsUpdateXpath = ".//wfs:Value/*/gml:coordinates";
 				$geomCoordsUpdateXpath = "(<xsl:value-of select=\"{$geomCoordsUpdateXpath}\"/>)";
-				$geomCoordsInsertXpath = "//*/gml:coordinates";
+				$geomCoordsInsertXpath = ".//*/gml:coordinates";
 				$geomCoordsInsertXpath = "(<xsl:value-of select=\"{$geomCoordsInsertXpath}\"/>)";
 			}
 			$actionXsd = <<<EOF