[Mapbender-commits] r9686 - trunk/mapbender/http/classes

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Feb 16 07:09:44 PST 2017


Author: armin11
Date: 2017-02-16 07:09:44 -0800 (Thu, 16 Feb 2017)
New Revision: 9686

Modified:
   trunk/mapbender/http/classes/class_iso19139.php
   trunk/mapbender/http/classes/class_wfsToDb.php
Log:
Fix bug when register WFS 2.0 and create wfs_confs for stored queries if more than one featuretype is included in the result.

Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php	2017-02-13 09:17:10 UTC (rev 9685)
+++ trunk/mapbender/http/classes/class_iso19139.php	2017-02-16 15:09:44 UTC (rev 9686)
@@ -572,7 +572,7 @@
 			}
 			//for debugging purposes
 			foreach ($interoperabilityArray as $declaredSpec) {
-				$e = new mb_exception("classes/class_iso19139.php: check conformance declaration: name: ".$declaredSpec['name']. " - date: ".$declaredSpec['date']." - pass: ".$declaredSpec['pass']);
+				$e = new mb_notice("classes/class_iso19139.php: check conformance declaration: name: ".$declaredSpec['name']. " - date: ".$declaredSpec['date']." - pass: ".$declaredSpec['pass']);
 				
 			}
 			$e = new mb_notice("classes/class_iso19139.php: sufficient declared inspire conformity: ".$this->inspireInteroperability);

Modified: trunk/mapbender/http/classes/class_wfsToDb.php
===================================================================
--- trunk/mapbender/http/classes/class_wfsToDb.php	2017-02-13 09:17:10 UTC (rev 9685)
+++ trunk/mapbender/http/classes/class_wfsToDb.php	2017-02-16 15:09:44 UTC (rev 9686)
@@ -826,10 +826,22 @@
 	 */
 	private static function insertStoredQuery ($aWfsId, $aWfsStoredQuery) {
 		$wfsFtName = $aWfsStoredQuery->description['QueryExpressionText']['returnFeatureTypes'];
+		//there may be more than one featuretype in the result. It is depending on the schema which is used. E.g. INSPIRE schemas often give back more than one featuretype. ps:ProtectedSites also may include gn:GeographicalName. Both are included in the returned result of a ListStoredQuery request.
+		//the QueryExpressionText attribute returnFeatureTypes is extracted
+		//check if blank is given in string
+		if (strpos($wfsFtName, ' ') === false) {
+			$wfsFtNameArray = array($wfsFtName);
+		} else {
+			$wfsFtNameArray = explode(' ', $wfsFtName);
+		}
+		//$typeReturnFT = gettype($wfsFtNameArray);
+		//$e = new mb_exception($typeReturnFT);
+		//$e = new mb_exception(json_encode($wfsFtNameArray));
+		//$e = new mb_exception(json_encode($aWfsStoredQuery->returnFeaturetype));
+		//try to read featuretype from ListStoredQuery Response
 		if($wfsFtName == "") {
-			$wfsFtName = $aWfsStoredQuery->returnFeaturetype;
+			$wfsFtNameArray = $aWfsStoredQuery->returnFeaturetype;
 		}
-		
 		//if returnFeaturetype is not defined for storedQuery check for default storedQuery urn:ogc:def:query:OGC-WFS::GetFeatureById 
 		if($wfsFtName == "") {
 			if($aWfsStoredQuery->description['Id'] == 'urn:ogc:def:query:OGC-WFS::GetFeatureById') {
@@ -853,28 +865,41 @@
 				
 			}
 			else {
-				$e = new mb_notice("class_wfsToDb.php: StoredQuery ".$aWfsStoredQuery->description['Id']." does not have a  returnFeaturetype, cannot be matched with featuretype.");
+				$e = new mb_exception("class_wfsToDb.php: StoredQuery ".$aWfsStoredQuery->description['Id']." does not have a  returnFeaturetype, cannot be matched with featuretype.");
 				return false;
 			}
 		}
 		else {
-			//get Featuretype ID using the returnFeaturetype name
-			$sql = "SELECT featuretype_id FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_name = $2;";
-			$v = array($aWfsId, $wfsFtName);
-			$t = array("i", "s");
+			//get Featuretype IDs for exposed featuretypes from capabilities using the returnFeaturetype names
+			$wfsFtNameArray;
+			$v = array();
+			$t = array();
+			$sql = "SELECT featuretype_id FROM wfs_featuretype WHERE fkey_wfs_id = $1 AND featuretype_name IN (";
+			$v[] = $aWfsId;
+			$t[] = "i";
+			$k = 2;
+			foreach($wfsFtNameArray as $wfsFtName) {
+				$sql .= "$".$k.",";
+				$v[] = $wfsFtName;
+				$t[] = "s";
+				$k++;
+			}
+			$sql = rtrim($sql, ",");
+			$sql .= ")";
 			$res = db_prep_query($sql, $v, $t);
 			if (!$res) {
-				$e = new mb_exception("class_wfsToDb.php: Error getting featuretype_id from DB.");
+				$e = new mb_exception("class_wfsToDb.php: Error getting featuretype_id(s) from DB.");
 				return false;
 			}
-			$row = db_fetch_array($res);
-			$ftId = $row["featuretype_id"];
-			
-			if($ftId && $ftId != "") {
-				//insert this stored query as new wfs conf
-				$insertWfsConf = WfsToDb::insertStoredQueryAsWfsConf($aWfsId, $aWfsStoredQuery, $ftId);
-				return $insertWfsConf;
-			}	
+			//maybe there are more than one featuretype
+			while ($row = db_fetch_array($res)){
+				$ftId = $row["featuretype_id"];
+				if($ftId && $ftId != "") {
+					//insert this stored query as new wfs conf
+					$insertWfsConf = WfsToDb::insertStoredQueryAsWfsConf($aWfsId, $aWfsStoredQuery, $ftId);
+					return $insertWfsConf;
+				}	
+			}
 		}
 	}
 	



More information about the Mapbender_commits mailing list