[Mapbender-commits] r10216 - in trunk/mapbender/http: classes php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Aug 23 21:41:55 PDT 2019


Author: armin11
Date: 2019-08-23 21:41:55 -0700 (Fri, 23 Aug 2019)
New Revision: 10216

Modified:
   trunk/mapbender/http/classes/class_cswClient.php
   trunk/mapbender/http/php/mod_callCswMetadata.php
Log:
Code cleaning and option to do different combined text searches via csw

Modified: trunk/mapbender/http/classes/class_cswClient.php
===================================================================
--- trunk/mapbender/http/classes/class_cswClient.php	2019-08-23 14:05:32 UTC (rev 10215)
+++ trunk/mapbender/http/classes/class_cswClient.php	2019-08-24 04:41:55 UTC (rev 10216)
@@ -494,20 +494,17 @@
 	}
 
 	private function getResult($url, $postData, $auth=false) {
-			//$e = new mb_exception("postdata: ".$postData);
 			$cswInterfaceObject = new connector();
 			$cswInterfaceObject->set('httpType','POST');
 			$postData = stripslashes($postData);
-			//$e = new mb_exception("classes/class_cswClient.php: post xml: ".$postData);
+//$e = new mb_exception("classes/class_cswClient.php: post xml: ".$postData);
 			$dataXMLObject = new SimpleXMLElement($postData);
 			$postData = $dataXMLObject->asXML();
-			//$e = new mb_exception($postData);
 			$cswInterfaceObject->set('curlSendCustomHeaders',true);
 			$cswInterfaceObject->set('httpPostData', $postData);
 			$cswInterfaceObject->set('httpContentType','text/xml');
 			$cswInterfaceObject->load($url);
-			//$file = $cswInterfaceObject->file;
-			//$e = new mb_exception($cswInterfaceObject->file);
+//$e = new mb_exception("classes/class_cswClient.php: result xml: ".$cswInterfaceObject->file);
 			return $cswInterfaceObject->file;
 	}
 	//insert or update - depends if record with same fileidentifier already exists in catalog and if timestamp is not newer than the timestamp of the new record

Modified: trunk/mapbender/http/php/mod_callCswMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callCswMetadata.php	2019-08-23 14:05:32 UTC (rev 10215)
+++ trunk/mapbender/http/php/mod_callCswMetadata.php	2019-08-24 04:41:55 UTC (rev 10216)
@@ -474,54 +474,56 @@
 $searchResourcesArray = explode(",",$searchResources);
 $searchPages = explode(",",$searchPages);
 //************************************************************************************
-//begin main program
+//build query - one solution is combining all textfilter with single <And> tags, other solution maybe like filter as "*searchText1*searchText2*searchText3*"
+//single leads to a lower amount of results ! - mmh - how does the filter will be evaluated?
+//example: "*wald*baum*" on anytext -> 3 results in 1 sec || <And> combined "*wald*" and "*baum*" -> 102 results in 2.1 sec (geonetwork 3.6.0)
 //************************************************************************************
 //$queryString  = $searchText;
 $searchTextArray = explode(",",$searchText);
-
-//$queryText = $queryStringArray[0];
-
-//if ($queryText == '*') {
-//	$queryText = '';
-//} else {
-
-if (count($searchTextArray) > 1) {
-	$fullTextFilter = "<ogc:And>";
-} else {
-	$fullTextFilter = "";
-}
-//$fullTextFilter = "";
-
-//$e = new mb_exception($searchTextArray[0]."".gettype($searchTextArray));
-foreach($searchTextArray as $queryString) {
-//$e = new mb_exception("querystring: ".$queryString);
-	$fullTextFilter .= '<ogc:PropertyIsLike wildCard="*" singleChar="_" escapeChar="">';
+$combineTextOption = "multiple"; //"multiple","single"
+switch ($combineTextOption) {
+    case "single":
+        $fullTextFilter .= '<ogc:PropertyIsLike wildCard="*" singleChar="_" escapeChar="">';
 	$fullTextFilter .= '<ogc:PropertyName>AnyText</ogc:PropertyName>';
-	/*if($queryString != '*'){
-		$queryString = '*' . explode($queryString) . '*';
-	}*/
-	//$queryString = '*' . implode("*", $searchTextArray) . '*';
-	if ($queryString == "*") {
-	    $fullTextFilter .= '<ogc:Literal>*</ogc:Literal>';
+	if (count($searchTextArray) > 1) {
+	    $fullTextFilter .= '<ogc:Literal>*'.implode('*', $searchTextArray).'*</ogc:Literal>';
 	} else {
-	    $fullTextFilter .= '<ogc:Literal>'.$queryString.'*</ogc:Literal>';
+	    $fullTextFilter .= '<ogc:Literal>*'.$searchTextArray[0].'*</ogc:Literal>';
 	}
+	//$fullTextFilter .= '<ogc:Literal>%'.implode('%', $searchTextArray).'%</ogc:Literal>';
 	$fullTextFilter .= '</ogc:PropertyIsLike>';
+	break;
+    case "multiple":
+	if (count($searchTextArray) > 1) {
+	    $fullTextFilter = "<ogc:And>";
+	} else {
+	    $fullTextFilter = "";
+	}
+	//$e = new mb_exception($searchTextArray[0]."".gettype($searchTextArray));
+	foreach($searchTextArray as $queryString) {
+	    //$e = new mb_exception("querystring: ".$queryString);
+	    $fullTextFilter .= '<ogc:PropertyIsLike wildCard="*" singleChar="_" escapeChar="">';
+	    $fullTextFilter .= '<ogc:PropertyName>AnyText</ogc:PropertyName>';
+	    /*if($queryString != '*'){
+		$queryString = '*' . explode($queryString) . '*';
+	    }*/
+	    //$queryString = '*' . implode("*", $searchTextArray) . '*';
+	    if ($queryString == "*") {
+	        $fullTextFilter .= '<ogc:Literal>*</ogc:Literal>';
+	    } else {
+	        $fullTextFilter .= '<ogc:Literal>*'.$queryString.'*</ogc:Literal>';
+	    }
+	    $fullTextFilter .= '</ogc:PropertyIsLike>';
+	}
+	if (count($searchTextArray) > 1) {
+	    $fullTextFilter .= "</ogc:And>";
+	}
+	break;
 }
-
-
-if (count($searchTextArray) > 1) {
-	$fullTextFilter .= "</ogc:And>";
-}
 //$e = new mb_exception("fulltextfilter: ".$fullTextFilter);
-/*
-	$fullTextFilter .= '<ogc:PropertyIsLike wildCard="%" singleChar="_" escapeChar="">';
-	$fullTextFilter .= '<ogc:PropertyName>AnyText</ogc:PropertyName>';
-	$fullTextFilter .= '<ogc:Literal>%'.implode('%', $searchTextArray).'%</ogc:Literal>';
-	$fullTextFilter .= '</ogc:PropertyIsLike>';*/
-//$e = new mb_exception("fulltextfilter: ".$fullTextFilter);
-//}
 $existsSpatialFilter = false;
+//$e = new mb_exception("searchBbox: ".$searchBbox);
+//$e = new mb_exception("searchTypeBbox: ".$searchTypeBbox);
 $searchBboxArray = explode(",", $searchBbox);
 //TODO: test the right filter! - inspire has other ones and no logical option!
 if ($searchBbox !== NULL) {
@@ -567,20 +569,27 @@
     }
 }
 //combine filter
-//$e = new mb_exception("fullTextFilter: ".$fullTextFilter);
-
-if ($existsSpatialFilter == true && $searchText !== '' && $searchText !== '*'){
-    $additionalFilter = "<ogc:And>".$fullTextFilter.$spatialFilter."</ogc:And>";
+//$e = new mb_exception("spatialFilter: ".$spatialFilter);
+//TODO: inspire spatial filter only supported, if no other filter is set!!!! see https://ies-svn.jrc.ec.europa.eu/issues/3658
+//if spatial filter and some text filter is set, combine them with and
+if ($existsSpatialFilter == true) {
+    //some textfilter is given
+    if ($searchText !== '' && $searchText !== '*') {
+    	$additionalFilter = "<ogc:And>".$fullTextFilter.$spatialFilter."</ogc:And>";
+    } else {
+	//no textfilter is given
+	$additionalFilter = $spatialFilter;
+    }
 } else {
-    if ($searchText == '') {
-        $additionalFilter = $spatialFilter;
+    //no spatial filter is given
+    if ($searchText !== '' && $searchText !== '*') {
+        $additionalFilter = $fullTextFilter;
     } else {
-	$additionalFilter = $fullTextFilter;
+	$additionalFilter = false;
     }
 }
 //$e = new mb_exception("additionalFilter: ".$additionalFilter);
 
-//csw Id = catalogueId
 $csw = new csw();
 $csw->createCatObjFromDB($catalogueId);
 



More information about the Mapbender_commits mailing list