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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Sep 25 07:10:38 PDT 2012


Author: armin11
Date: 2012-09-25 07:10:36 -0700 (Tue, 25 Sep 2012)
New Revision: 8495

Modified:
   trunk/mapbender/http/classes/class_metadata_new.php
   trunk/mapbender/http/php/mod_callMetadata.php
Log:
Extent json search interface for getmap urls and all filters/categories/keywords - if wished. Parameter resultTarget=webclient. This is uesed to have a simple searchInterface for ol based applications.

Modified: trunk/mapbender/http/classes/class_metadata_new.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata_new.php	2012-09-21 06:45:22 UTC (rev 8494)
+++ trunk/mapbender/http/classes/class_metadata_new.php	2012-09-25 14:10:36 UTC (rev 8495)
@@ -90,11 +90,6 @@
 		$this->maxWeight = 0;
 		$this->scale = 'linear';
 		$this->minFontSize = 10;
-	
-
-
-
-
 		$this->tempFolder = TMPDIR; //TODO define another path - maybe the one which is given in mapbender.conf
 		if ($this->outputFormat == 'json'){
 			$this->json = new Mapbender_JSON;
@@ -242,7 +237,7 @@
 				$this->databaseTableName = 'layer';
 				//$this->keywordRelation = 'layer_keyword';
 				$this->searchView = 'wms_search_table';
-				//$this->searchView = 'wms_search_view';
+				//$this->searchView = 'search_wms_view';
 				$this->whereStrCatExtension = " AND custom_category.custom_category_hidden = 0";
 				switch ($this->orderBy) {
 					case "rank":
@@ -594,6 +589,7 @@
 				#$this->wmsJSON->wms->srv[$j]->respOrg = "test";
 				$this->wmsJSON->wms->srv[$j]->loadCount = (integer)$subLayers[$rootIndex]['load_count'];
 				#$this->wmsJSON->wms->srv[$j]->mdLink = "http://".$_SERVER['HTTP_HOST']."/mapbender/geoportal/mod_layerMetadata.php?id=".(integer)$subLayers[$rootIndex]['layer_id'];
+				$this->wmsJSON->wms->srv[$j]->getMapUrl = $this->getMapUrlfromWMSId((integer)$subLayers[$rootIndex]['wms_id']);
 				$spatialSource = "";
 				$stateOrProvince = $subLayers[$rootIndex]['stateorprovince']; 
 				#echo $stateOrProvince."<br>";
@@ -717,6 +713,23 @@
 			if ($this->resultTarget == 'web' or $this->resultTarget == 'debug') {
 				echo $this->wmsJSON;
 			}
+			if ($this->resultTarget == 'webclient') {
+				$this->allJSON = new stdClass;
+				$this->allJSON->categories = $this->json->decode($this->keyJSON);
+				$this->allJSON->keywords =  $this->json->decode($this->catJSON);
+				//load filter from file 
+				$filename = $this->tempFolder."/".$this->searchId."_filter.json";
+				if (!file_exists($filename)) {
+					$e = new mb_exception("class_metadata_new.php: No filter json exists!");
+				} else {
+					$filterJSON = file_get_contents($filename);
+					$filterJSON = $this->json->decode($filterJSON);
+					$this->allJSON->filter = $filterJSON;
+				}
+				$this->allJSON->wms = $this->json->decode($this->wmsJSON);
+				echo  $this->json->encode($this->allJSON);
+				//echo "test";
+			}
 		}
 		$usedTime2 = $this->microtime_float() - $starttime;
 		//echo "<br>used time: ".$usedTime."<br>";
@@ -1267,6 +1280,18 @@
 		return $return_permission;
 	}
 
+	private function getMapUrlfromWMSId($wmsId) {
+			$sql = "SELECT wms_getmap FROM wms WHERE wms_id = $1 AND (wms_owsproxy IS NULL OR wms_owsproxy ='')";
+			$v = array($wmsId);
+			$t = array('i');
+			$res = db_prep_query($sql, $v, $t);
+			while($row = db_fetch_array($res)){
+				$getMap = $row['wms_getmap'];
+			}
+			return $getMap; 
+
+	}
+
 	private function getPermissionValueForLayer($layerId,$wmsId){
 		//TODO: Set Email of owner into view for ressource - so it don't have to be searched?
 		$return_permission="";

Modified: trunk/mapbender/http/php/mod_callMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callMetadata.php	2012-09-21 06:45:22 UTC (rev 8494)
+++ trunk/mapbender/http/php/mod_callMetadata.php	2012-09-25 14:10:36 UTC (rev 8495)
@@ -14,7 +14,7 @@
 #http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wa&searchText=e&outputFormat=json&languageCode=de&resultTarget=debug&searchResources=wms&maxResults=99&registratingDepartments=44,31,52&inspireThemes=11&isoCategories=5,10&searchBbox=7,48,9,51&regTimeBegin=2001-12-24&regTimeEnd=2020-10-10
 #http://www.geoportal.rlp.de/mapbender/php/mod_callMetadata.php?searchId=wa&outputFormat=json&languageCode=de&resultTarget=debug&searchResources=wms&maxResults=99&registratingDepartments=44,31,52&inspireThemes=11&isoCategories=5,10&searchBbox=7,48,9,51&regTimeBegin=2001-12-24&regTimeEnd=2020-10-10
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
-require_once(dirname(__FILE__)."/../../conf/geoportal.conf");#???
+//require_once(dirname(__FILE__)."/../../conf/geoportal.conf");#???
 require_once(dirname(__FILE__)."/../classes/class_metadata_new.php");
 require_once(dirname(__FILE__)."/../classes/class_json.php");
 
@@ -305,7 +305,7 @@
 if (isset($_REQUEST["resultTarget"]) & $_REQUEST["resultTarget"] != "") {
 	//validate to web,debug,file
 	$testMatch = $_REQUEST["resultTarget"];	
- 	if (!($testMatch == 'web' or $testMatch == 'debug' or $testMatch == 'file')){ 
+ 	if (!($testMatch == 'web' or $testMatch == 'debug' or $testMatch == 'file'  or $testMatch == 'webclient')){ 
 		echo 'resultTarget: <b>'.$testMatch.'</b> is not valid.<br/>'; 
 		die(); 		
  	}
@@ -359,7 +359,7 @@
 }
 
 
-if ($resultTarget == 'file') {
+if ($resultTarget == 'file' or $resultTarget == 'webclient') {
 	if (!isset($searchResources) OR ($searchResources == "")) {
 		$searchResources = "wms,wfs,wmc";
 		$searchPages = "1,1,1";
@@ -834,7 +834,7 @@
 	echo "<br>DEBUG: filter: ".$queryFilter."<br>";
 	#echo "<br>DEBUG: searchTypeBbox: ".$searchTypeBbox."<br>";
 }
-if ($resultTarget == 'file') {
+if ($resultTarget == 'file' or $resultTarget == 'webclient') {
 	$filename = $tempFolder."/".$searchId."_filter.json";
 	if (file_exists($filename)) {
     		$e = new mb_notice("php/callMetdata.php: The file $filename exists - it will not be overwritten!");
@@ -881,9 +881,9 @@
 		//remove last comma
 		$objectList = rtrim($objectList, ",");
 		$str2search = $paramName."=".$queryList;
-		echo "string to search: ".$str2search."<br>";
+		//echo "string to search: ".$str2search."<br>";
 		$str2exchange = $paramName."=".$objectList;
-		echo "string to exchange: ".$str2exchange."<br>";
+		//echo "string to exchange: ".$str2exchange."<br>";
 		$queryStringNew = str_replace($str2search, $str2exchange, urldecode($queryString));
 	}
 	return $queryStringNew;
@@ -944,7 +944,7 @@
 		exec($str);
 	}
 }
-if ($resultTarget == 'web' or $resultTarget == 'debug') {
+if ($resultTarget == 'web' or $resultTarget == 'debug' or $resultTarget == 'webclient') {
 	if (count($searchResources) == 1) {
 		$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources[0], $searchPages[0], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy);
 		#if ($outputFormat == 'xml') {



More information about the Mapbender_commits mailing list