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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri May 6 03:48:22 PDT 2016


Author: armin11
Date: 2016-05-06 03:48:22 -0700 (Fri, 06 May 2016)
New Revision: 9444

Modified:
   trunk/mapbender/http/classes/class_metadata_new.php
   trunk/mapbender/http/php/mod_callMetadata.php
   trunk/mapbender/http/php/mod_inspireDownloadFeed.php
Log:
New search options for datasets

Modified: trunk/mapbender/http/classes/class_metadata_new.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata_new.php	2016-05-06 10:44:38 UTC (rev 9443)
+++ trunk/mapbender/http/classes/class_metadata_new.php	2016-05-06 10:48:22 UTC (rev 9444)
@@ -416,7 +416,8 @@
 				$this->wfsJSON->wfs->srv[$i-$j]->date = date("d.m.Y",$wfsMatrix[$i]['wfs_timestamp']);
 				$this->wfsJSON->wfs->srv[$i-$j]->respOrg = $wfsMatrix[$i]['mb_group_name'];
 				$this->wfsJSON->wfs->srv[$i-$j]->logoUrl = $wfsMatrix[$i]['mb_group_logo_path'];
-				$this->wfsJSON->wfs->srv[$i-$j]->mdLink = "http://".$this->hostName."/mapbender/geoportal/showWFSMetadata.php?id=".$wfsMatrix[$i]['wfs_id'];
+				$this->wfsJSON->wfs->srv[$i-$j]->mdLink = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?resource=wfs&id=".$wfsMatrix[$i]['wfs_id'];
+				//TODO: Capabilities link
 				$spatialSource = "";
 				$stateOrProvince = $wfsMatrix[$i]['administrativearea']; 
 				if ($stateOrProvince == "NULL" || $stateOrProvince == "") {
@@ -433,23 +434,31 @@
 				//TODO check the field accessconstraints - which should be presented?
 				$this->wfsJSON->wfs->srv[$i-$j]->status = NULL; //$wfsMatrix[$i][''];
 				$this->wfsJSON->wfs->srv[$i-$j]->avail = NULL; //$wfsMatrix[$i][''];
-				$this->wfsJSON->wfs->srv[$i-$j]->logged = NULL; //$wfsMatrix[$i][''];
-				$this->wfsJSON->wfs->srv[$i-$j]->price = NULL; //$wfsMatrix[$i][''];
-				$this->wfsJSON->wfs->srv[$i-$j]->nwaccess = NULL; //$wfsMatrix[$i][''];
-				$this->wfsJSON->wfs->srv[$i-$j]->bbox = array(-180.0,-90.0,180.0,90.0); //$wfsMatrix[$i][''];
+				$this->wfsJSON->wfs->srv[$i-$j]->logged = $wfsMatrix[$i]['wfs_proxylog']; //$wfsMatrix[$i][''];
+				$this->wfsJSON->wfs->srv[$i-$j]->price = $wfsMatrix[$i]['wfs_pricevolume']; //$wfsMatrix[$i][''];
+				$this->wfsJSON->wfs->srv[$i-$j]->nwaccess = $wfsMatrix[$i]['wfs_network_access']; //$wfsMatrix[$i][''];
+				$this->wfsJSON->wfs->srv[$i-$j]->bbox = "-180.0,-90.0,180.0,90.0"; //$wfsMatrix[$i][''];
 				//if featuretype hasn't been created - do it
 				if (!isset($this->wfsJSON->wfs->srv[$i-$j]->ftype)) {
 					$this->wfsJSON->wfs->srv[$i-$j]->ftype = array();
 				}
 				//fill in featuretype infos
 				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->id = (integer)$wfsMatrix[$i]['featuretype_id'];
+				//get other infos directly from database
+				$otherInformation = $this->getInfofromFeaturetypeId($this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->id);
+				
 				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->title = $wfsMatrix[$i]['featuretype_title'];
 				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->abstract = $wfsMatrix[$i]['featuretype_abstract'];
-				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->mdLink = "http://".$this->hostName."/mapbender/geoportal/showWFeatureTypeMetadata.php?id=".$wfsMatrix[$i]['featuretype_id'];
+				//TODO featuretype name
+				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->name = $otherInformation['featuretypeName'];
+				//TODO featuretype schema
+				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->schema = $otherInformation['describeFeaturetypeUrl'];
+				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->mdLink = "http://".$this->hostName."/mapbender/php/mod_showMetadata.php?resource=featuretype&id=".$wfsMatrix[$i]['featuretype_id'];
 				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->geomtype = $wfsMatrix[$i]['element_type'];
-				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->bbox = array(-180.0,-90.0,180.0,90.0);//TODO: $wfsMatrix[$i]['bbox'];
+				$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->bbox = $wfsMatrix[$i]['bbox'];//TODO: $wfsMatrix[$i]['bbox'];
+				//wfs capabilities url:
+				$this->wfsJSON->wfs->srv[$i-$j]->getCapabilitiesUrl = $otherInformation['getCapabilitiesUrl'];
 
-
 				//give info for inspire categories - not relevant for other services or instances of mapbender TODO: comment it if the mapbender installation is not used to generate inspire output
 				if (isset($wfsMatrix[$i]['md_inspire_cats']) & ($wfsMatrix[$i]['md_inspire_cats'] != '')){
 					$this->wfsJSON->wfs->srv[$i-$j]->ftype[$l-$m]->inspire = 1;
@@ -590,10 +599,15 @@
 		for($i=0; $i<count($datasetMatrix);$i++){
 			$this->datasetJSON->dataset->srv[$i]->id = $datasetMatrix[$i]['dataset_id'];
 			$this->datasetJSON->dataset->srv[$i]->title = $datasetMatrix[$i]['title'];
+			$this->datasetJSON->dataset->srv[$i]->uuid = $datasetMatrix[$i]['fileidentifier'];
 			$this->datasetJSON->dataset->srv[$i]->abstract = $datasetMatrix[$i]['dataset_abstract'];
 			$this->datasetJSON->dataset->srv[$i]->date = date("d.m.Y",$datasetMatrix[$i]['dataset_timestamp']);
 			$this->datasetJSON->dataset->srv[$i]->respOrg = $datasetMatrix[$i]['mb_group_name'];
 			$this->datasetJSON->dataset->srv[$i]->logoUrl = $datasetMatrix[$i]['mb_group_logo_path'];
+			list($hasConstraints, $symbolLink) = $this->hasConstraints("dataset", $datasetMatrix[$i]['dataset_id']);
+			$this->datasetJSON->dataset->srv[$i]->hasConstraints = $hasConstraints;
+			$this->datasetJSON->dataset->srv[$i]->isopen = $datasetMatrix[$i]['isopen'];
+			$this->datasetJSON->dataset->srv[$i]->symbolLink = $symbolLink;
 			//TODO: other url - to metadata uuid!
 			$this->datasetJSON->dataset->srv[$i]->mdLink = "http://".$this->hostName."/mapbender/php/mod_iso19139ToHtml.php?url=".urlencode("http://".$this->hostName."/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=").$datasetMatrix[$i]['fileidentifier'];
 			//TODO: preview?
@@ -834,6 +848,9 @@
 				$this->wmsJSON->wms->srv[$j]->layer[0]->getLegendGraphicUrl = $legendInfo['getLegendGraphicUrl'];
 				$this->wmsJSON->wms->srv[$j]->layer[0]->getLegendGraphicUrlFormat = $legendInfo['getLegendGraphicUrlFormat'];
 				$this->wmsJSON->wms->srv[$j]->layer[0]->legendUrl = $legendInfo['legendUrl'];
+				//get capabilities
+				$this->wmsJSON->wms->srv[$j]->layer[0]->getCapabilitiesUrl =  "http://".$this->hostName."/mapbender/php/wms.php?layer_id=".(integer)$subLayers[$rootIndex]['layer_id']."&INSPIRE=1&REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS";
+
 				$this->wmsJSON->wms->srv[$j]->layer[0]->minScale = $legendInfo['minScale'];
 				$this->wmsJSON->wms->srv[$j]->layer[0]->maxScale = $legendInfo['maxScale'];
 				//pull downloadOptions as json with function from other script: php/mod_getDownloadOptions.php
@@ -1189,7 +1206,7 @@
 		//check for postgis version
 		//sql for get version string
 		//get version number
-		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc" or strtolower($this->searchResources) === "dataset") & $this->searchBbox != NULL) {
+		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc" or strtolower($this->searchResources) === "dataset" or strtolower($this->searchResources) === "wfs" ) & $this->searchBbox != NULL) {
 			//decide which type of search should be done
 			//check for postgis version cause postgis versions < 1.4 have problems when doing disjoint and inside
 			//
@@ -1259,7 +1276,7 @@
 		}	
 		//search filter for isopen - open data classification of the managed termsofuse
 		//
-		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wfs") & $this->restrictToOpenData) {
+		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wfs" or strtolower($this->searchResources) === "dataset") & $this->restrictToOpenData) {
 			array_push($whereCondArray, '(isopen = 1)');
 		}
 		//search filter for md_topic_categories
@@ -1330,7 +1347,22 @@
 			array_push($whereCondArray, $time);
 		}
 
- 
+		//filter for data actuality (only for datasets)
+		if (strtolower($this->searchResources) === "dataset") {
+ 			if ($this->timeBegin != NULL && $this->timeEnd != NULL){
+				$time ="((to_timestamp('".$this->timeBegin."','YYYY-MM-DD'),to_timestamp('".$this->timeEnd."','YYYY-MM-DD')) OVERLAPS (timebegin,timeend))";
+				array_push($whereCondArray, $time);
+				//only begin is set		
+			}
+			if ($this->timeBegin != NULL && $this->timeEnd == NULL){
+				$time ="(timeend >= '".$this->timeBegin."')";
+				array_push($whereCondArray, $time);
+			}
+			if ($this->timeBegin == NULL && $this->timeEnd != NULL){
+				$time ="(timeend <= '".$this->timeEnd."')";
+				array_push($whereCondArray, $time);
+			}
+		}
 		//department condition
 		//TODO: generate filter for new sql check if at least some department is requested
 		//generate array
@@ -1373,7 +1405,7 @@
 		//defining range for paging
 		$sql .= " LIMIT ".$limit." OFFSET ".$offset."";
 		//Print out search SQL term
-		$e = new mb_notice("class_metadata.php: Search => SQL-Request of ".$this->searchResources." service metadata: ".$sql."");
+		$e = new mb_exception("class_metadata.php: Search => SQL-Request of ".$this->searchResources." service metadata: ".$sql."");
 		//parameter: searchId -> can be used global, searchResources -> is only one type per instance!!-> global,which categories -> can be defined global! $whereStr
 		$n = $this->writeCategories($whereStr, $v, $t); 
 		//write counts to filesystem to avoid to many database connections
@@ -1693,6 +1725,35 @@
 			return $returnArray; 
 	}
 
+	private function getInfofromFeaturetypeId($featuretypeId) {
+			$admin = new administration();
+			$sql = "SELECT wfs_id, wfs_version, wfs_getcapabilities, wfs_describefeaturetype, featuretype_name, wfs_owsproxy FROM wfs_featuretype INNER JOIN wfs ON wfs_featuretype.fkey_wfs_id = wfs.wfs_id WHERE wfs_featuretype.featuretype_id = $1";
+			$v = array($featuretypeId);
+			$t = array('i');
+			$res = db_prep_query($sql, $v, $t);
+			while($row = db_fetch_array($res)){
+				$getCapabilitiesUrl = $row['wfs_getcapabilities'];
+				$describeFeaturetypeUrl = $row['wfs_describefeaturetype'];
+				$featuretypeName = $row['featuretype_name'];
+				$owsProxy = $row['wfs_owsproxy'];
+				$wfsVersion = $row['wfs_version'];
+				$wfsId = $row['wfs_id'];
+			}
+			//if proxy is activated change request urls
+			if ($owsProxy != null && $owsProxy != '') {
+				$getCapabilitiesUrl = "http://".$this->hostName."/registry/wfs/".$wfsId."?SERVICE=WFS&VERSION=".$wfsVersion."&REQUEST=GetCapabilities";
+				$describeFeaturetypeUrl = "http://".$this->hostName."/registry/wfs/".$wfsId."?SERVICE=WFS&VERSION=".$wfsVersion."&REQUEST=DescribeFeaturetype&typename=".$featuretypeName;
+			} else {
+				$getCapabilitiesUrl = $admin->checkURL($getCapabilitiesUrl)."SERVICE=WFS&VERSION=".$wfsVersion."&REQUEST=GetCapabilities";
+				$describeFeaturetypeUrl = $admin->checkURL($describeFeaturetypeUrl)."SERVICE=WFS&VERSION=".$wfsVersion."&REQUEST=DescribeFeaturetype&typename=".$featuretypeName;
+			}
+			$returnArray['getCapabilitiesUrl'] = $getCapabilitiesUrl;
+			$returnArray['describeFeaturetypeUrl'] = $describeFeaturetypeUrl;
+			$returnArray['featuretypeName'] = $featuretypeName;
+			$returnArray['owsProxy'] = $owsProxy;
+			return $returnArray; 
+	}
+
 	private function getPermissionValueForLayer($layerId,$wmsId){
 		//TODO: Set Email of owner into view for ressource - so it don't have to be searched?
 		$return_permission="";
@@ -1911,6 +1972,12 @@
 			$sql .= "  wfs_termsofuse ON  (wfs.wfs_id = wfs_termsofuse.fkey_wfs_id) LEFT OUTER JOIN termsofuse ON";
 			$sql .= " (wfs_termsofuse.fkey_termsofuse_id=termsofuse.termsofuse_id) where wfs.wfs_id = $1";	
 }
+		if ($type == "dataset") {
+			$sql = "SELECT constraints as accessconstraints, fees, termsofuse.name,";
+			$sql .= " termsofuse.termsofuse_id ,termsofuse.symbollink, termsofuse.description,termsofuse.descriptionlink from mb_metadata LEFT OUTER JOIN";
+			$sql .= "  md_termsofuse ON  (mb_metadata.metadata_id = md_termsofuse.fkey_metadata_id) LEFT OUTER JOIN termsofuse ON";
+			$sql .= " (md_termsofuse.fkey_termsofuse_id=termsofuse.termsofuse_id) where mb_metadata.metadata_id = $1";	
+}
 		$v = array();
 		$t = array();
 		array_push($t, "i");

Modified: trunk/mapbender/http/php/mod_callMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_callMetadata.php	2016-05-06 10:44:38 UTC (rev 9443)
+++ trunk/mapbender/http/php/mod_callMetadata.php	2016-05-06 10:48:22 UTC (rev 9444)
@@ -39,9 +39,9 @@
 //$restrictToOpenData = "false";
 $languageCode = "de";
 $outputFormat = 'json';
-#$searchResources = "wms,wfs,wmc,georss,dataset";
+#$searchResources = "wms,wfs,wmc,dataset";
 #$searchResources = "wms";
-$searchPages = "1";
+//$searchPages = "1";
 $resourceIds = NULL; //resourceIds is used to get a comma separated list with ids of the resources - layer - featuretypes - wmc
 //it will be used to filter some results 
 $resultTarget = "web";
@@ -67,6 +67,7 @@
 }
 //read the whole query string:
 $searchURL = $_SERVER['QUERY_STRING'];
+//$e = new mb_exception("mod_callMetadata.php: searchURL".$searchURL);
 //decode it !
 $searchURL = urldecode($searchURL);
 //control if some request variables are not set and set them explicit to NULL
@@ -434,21 +435,28 @@
 
 if ($resultTarget == 'file' or $resultTarget == 'webclient') {
 	if (!isset($searchResources) OR ($searchResources == "")) {
-		$searchResources = "wms,wfs,wmc";
-		$searchPages = "1,1,1";
+		$searchResources = "dataset,wms,wfs,wmc";
+		$resolveCoupledResources = true;
+		$searchPages = "1,1,1,1";
 	}
 
 }
+if (!isset($searchPages) OR ($searchPages == "")) {
+	for($i=0;$i<count(explode(",",$searchResources));$i++) {
+		$searchPages[$i] = 1;
+	}
+	$searchPages = implode(",",$searchPages);
+	//$e = new mb_exception("mod_callMetadata.php: set searchPages to :".$searchPages);	
+}
 if ($resultTarget == 'web' or $resultTarget == 'debug') {
 	if (!isset($searchResources) OR ($searchResources == "")) {
 		$searchResources = "wms";
 		$searchPages = "1";
 	}
-
 }
 
 //convert the respources and the pagenumbers into arrays
-$searchResources = explode(",",$searchResources);
+$searchResourcesArray = explode(",",$searchResources);
 $searchPages = explode(",",$searchPages);
 
 //Generate search filter file. This file holds the defined search filter to allow the user to see how he searched 
@@ -583,6 +591,9 @@
 $classificationElements[6]['name'] = 'regTimeBegin';
 $classificationElements[7]['name'] = 'regTimeEnd';
 $classificationElements[8]['name'] = 'restrictToOpenData';
+$classificationElements[9]['name'] = 'searchResources';
+$classificationElements[10]['name'] = 'timeBegin';
+$classificationElements[11]['name'] = 'timeEnd';
 
 $classificationElements[0]['source'] = '';
 $classificationElements[1]['source'] = 'database';
@@ -593,6 +604,9 @@
 $classificationElements[6]['source'] = '';
 $classificationElements[7]['source'] = '';
 $classificationElements[8]['source'] = '';
+$classificationElements[9]['source'] = '';
+$classificationElements[10]['source'] = '';
+$classificationElements[11]['source'] = '';
 
 $classificationElements[0]['list'] = true;
 $classificationElements[1]['list'] = true;
@@ -603,6 +617,9 @@
 $classificationElements[6]['list'] = false;
 $classificationElements[7]['list'] = false;
 $classificationElements[8]['list'] = false;
+$classificationElements[9]['list'] = true;
+$classificationElements[10]['list'] = false;
+$classificationElements[11]['list'] = false;
 
 //Defining of the different result categories		
 		$resourceCategories = array();
@@ -623,6 +640,9 @@
 		$classificationElements[6]['name2show'] = 'Registrierung/Aktualisierung von:';
 		$classificationElements[7]['name2show'] = 'Registrierung/Aktualisierung bis:';
 		$classificationElements[8]['name2show'] = 'Nur OpenData Ressourcen:';
+		$classificationElements[9]['name2show'] = 'Art der Ressource:';
+		$classificationElements[10]['name2show'] = 'Datenaktualität von:';
+		$classificationElements[11]['name2show'] = 'Datenaktualität bis:';
 
 		$resourceCategories['wms'] = 'Darstellungsdienste';
 		$resourceCategories['wfs'] = 'Such- und Download- und Erfassungsmodule';
@@ -650,6 +670,9 @@
 		$classificationElements[6]['name2show'] = 'Registration/Update from:';
 		$classificationElements[7]['name2show'] = 'Registration/Update till:';		
 		$classificationElements[8]['name2show'] = 'Only OpenData resources:';
+		$classificationElements[9]['name2show'] = 'Kind of resource:';
+		$classificationElements[10]['name2show'] = 'Actuality of dataset from:';
+		$classificationElements[11]['name2show'] = 'Actuality of dataset to:';
 
 		$resourceCategories['wms'] = 'Viewingservices';
 		$resourceCategories['wfs'] = 'Search- and Downloadservices';
@@ -676,6 +699,9 @@
 		$classificationElements[6]['name2show'] = 'Enregistrement/Mise à jour du :';
 		$classificationElements[7]['name2show'] = 'Enregistrement/Mise à jour au:';
 		$classificationElements[8]['name2show'] = 'Pas plus de OpenData:';
+		$classificationElements[9]['name2show'] = 'Art der Ressource:';
+		$classificationElements[10]['name2show'] = 'Actuality of dataset from:';
+		$classificationElements[11]['name2show'] = 'Actuality of dataset to:';
 
 		$resourceCategories['wms'] = 'Services de visualisation';
 		$resourceCategories['wfs'] = 'Services de recherche et de téléchargement';
@@ -702,6 +728,9 @@
 		$classificationElements[6]['name2show'] = 'Registrierung/Aktualisierung von:';
 		$classificationElements[7]['name2show'] = 'Registrierung/Aktualisierung bis:';
 		$classificationElements[8]['name2show'] = 'Nur OpenData Ressourcen:';
+		$classificationElements[9]['name2show'] = 'Art der Ressource:';
+		$classificationElements[10]['name2show'] = 'Actuality of dataset from:';
+		$classificationElements[11]['name2show'] = 'Actuality of dataset to:';
 
 		$resourceCategories['wms'] = 'Darstellungsdienste';
 		$resourceCategories['wfs'] = 'Such- und Downloaddienste';
@@ -726,10 +755,10 @@
 $queryJSON->searchFilter = (object) array();
 $queryJSON->searchFilter->origURL = $searchURL;
 #$queryJSON->searchFilter->classes = (object) array();
-for($i=0; $i<count($searchResources);$i++){
+for($i=0; $i<count($searchResourcesArray);$i++){
 //fill in the different search classes into the filter - the client can generate the headers out of this information
-	$queryJSON->searchFilter->classes[$i]->title = $resourceCategories[$searchResources[$i]];
-	$queryJSON->searchFilter->classes[$i]->name = $searchResources[$i];
+	$queryJSON->searchFilter->classes[$i]->title = $resourceCategories[$searchResourcesArray[$i]];
+	$queryJSON->searchFilter->classes[$i]->name = $searchResourcesArray[$i];
 }
 //generate search filter file - if more categories are defined give 
 //echo "<br> number of filter elements: ".count($classificationElements)."<br>";
@@ -759,18 +788,22 @@
 		} else {
 
 
-
+			//$e = new mb_exception('mod_callMetadata.php: $classificationElements[$i][name]: '.$classificationElements[$i]['name']);
 			//TODO delete all entries of this main category (not for searchText)
-			if ($classificationElements[$i]['name'] != 'searchText') { 
+			if ($classificationElements[$i]['name'] != 'searchText' && $classificationElements[$i]['name'] != 'searchResources') { 
 				$queryJSON->searchFilter->{$classificationElements[$i]['name']}->delLink = delTotalFromQuery($classificationElements[$i]['name'],$searchURL);
 			} else {
 				//$queryJSON->searchFilter->{$classificationElements[$i]['name']}->delLink = NULL;
 				$queryJSON->searchFilter->{$classificationElements[$i]['name']}->delLink = delTotalFromQuery($classificationElements[$i]['name'],$searchURL);
+				//$e = new mb_exception('mod_callMetadata.php: dellink: '.$queryJSON->searchFilter->{$classificationElements[$i]['name']}->delLink);
 			}
 			$queryJSON->searchFilter->{$classificationElements[$i]['name']}->item = array();
-			$queryArray = explode(',',${$classificationElements[$i]['name']});
+
+			$queryArray = explode(',', ${$classificationElements[$i]['name']});
+		
 			//loop for the subcategories
 			for($j=0; $j < count($queryArray); $j++){
+				//$e = new mb_exception('mod_callMetadata.php: queryArrayi: '.$queryArray[$j]);
 				if ($classificationElements[$i]['source'] == 'database') {
 					$identArray = ${$classificationElements[$i]['name']."Array"};
 					$identArray = flipDiagonally($identArray);
@@ -782,10 +815,14 @@
 						$queryJSON->searchFilter->{$classificationElements[$i]['name']}->item[$j]->title = ${$classificationElements[$i]['name']."Array"}[$key]['name'];
 					}
 				} else {
-					$queryJSON->searchFilter->{$classificationElements[$i]['name']}->item[$j]->title = $queryArray[$j];
+					if ($classificationElements[$i]['name'] != 'searchResources') {
+						$queryJSON->searchFilter->{$classificationElements[$i]['name']}->item[$j]->title = $queryArray[$j];
+					} else {
+						$queryJSON->searchFilter->{$classificationElements[$i]['name']}->item[$j]->title = $resourceCategories[$queryArray[$j]];
+					}
 				}
 				//generate links to disable filters on a simple way
-				if ($classificationElements[$i]['name'] === 'searchText' & count(explode(',',${$classificationElements[$i]['name']})) === 1) { 
+				if (($classificationElements[$i]['name'] === 'searchText' || $classificationElements[$i]['name'] === 'searchResources') & count(explode(',',${$classificationElements[$i]['name']})) === 1) { 
 					//$queryJSON->searchFilter->{$classificationElements[$i]['name']}->item[$j]->delLink = NULL;
 					$newSearchLink = delFromQuery($classificationElements[$i]['name'], $searchURL,$queryArray[$j],$queryArray,${$classificationElements[$i]['name']});
 					$newSearchLink = delTotalFromQuery('searchId',$newSearchLink);
@@ -952,6 +989,11 @@
 		} else {
 			$str2exchange = "";
 		}
+		if ($paramName == "searchResources") {
+			$str2exchange = "searchResources=dataset,wms,wfs,wmc&";
+		} else {
+			$str2exchange = "";
+		}
 		$queryStringNew = str_replace($str2search, $str2exchange, $queryString);
 		$queryStringNew = str_replace("&&", "&", $queryStringNew);
 	} else {
@@ -982,6 +1024,9 @@
 		} else {
 			$str2exchange = "";
 	}
+	if ($paramName == "searchResources") {
+		$str2exchange = "searchResources=dataset,wms,wfs,wmc&";
+	} 
 	$queryStringNew = preg_replace('/\b'.$paramName.'\=[^&]*&?/',$str2exchange,$queryString); //TODO find empty get params
 	$queryStringNew = ltrim($queryStringNew,'&');
 	$queryStringNew = rtrim($queryStringNew,'&');
@@ -1000,7 +1045,7 @@
 
 //call class_metadata - in case of file for all requested resources, in case of web only for one resource - cause there are different result files
 if ($resultTarget == 'file') {
-	for($i=0; $i<count($searchResources);$i++){
+	for($i=0; $i<count($searchResourcesArray);$i++){
 		/*$str = "nohup php5 /data/mapbender/http/php/mod_metadataWrite.php ";
 		$str .= "'".$userId."' ";		
 		$str .= "'".$searchId."' ";		
@@ -1018,7 +1063,7 @@
 		$str .= "'".$accessRestrictions."' ";
 		$str .= "'".$languageCode."' ";
 		$str .= "'".$searchEPSG."' ";
-		$str .= "'".$searchResources[$i]."' ";
+		$str .= "'".$searchResourcesArray[$i]."' ";
 		$str .= "'".$searchPages[$i]."' ";
 		$str .= "'".$outputFormat."' ";
 		$str .= "'".$resultTarget."' ";
@@ -1032,13 +1077,14 @@
 		$str .= " & ";
 		$e = new mb_notice($str);
 		exec($str);*/
-		$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResources[$i], $searchPages[$i], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData, $originFromHeader, $resolveCoupledResources);
+		
+		$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResourcesArray[$i], $searchPages[$i], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData, $originFromHeader, $resolveCoupledResources);
 	}
 }
 if ($resultTarget == 'web' or $resultTarget == 'debug' or $resultTarget == 'webclient' or $resultTarget == 'categories') {
-	if (count($searchResources) == 1) {
+	if (count($searchResourcesArray) == 1) {
 		//$e = new mb_exception("originFromHeader: ".$originFromHeader);
-		$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, $resourceIds, $restrictToOpenData, $originFromHeader, $resolveCoupledResources);
+		$metadata = new searchMetadata($userId, $searchId, $searchText, $registratingDepartments, $isoCategories, $inspireThemes, $timeBegin, $timeEnd, $regTimeBegin, $regTimeEnd, $maxResults, $searchBbox, $searchTypeBbox, $accessRestrictions, $languageCode, $searchEPSG, $searchResourcesArray[0], $searchPages[0], $outputFormat, $resultTarget, $searchURL, $customCategories, $hostName, $orderBy, $resourceIds, $restrictToOpenData, $originFromHeader, $resolveCoupledResources);
 		#if ($outputFormat == 'xml') {
 		#	header("Content-type: application/xhtml+xml; charset=UTF-8");		
 		#}

Modified: trunk/mapbender/http/php/mod_inspireDownloadFeed.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2016-05-06 10:44:38 UTC (rev 9443)
+++ trunk/mapbender/http/php/mod_inspireDownloadFeed.php	2016-05-06 10:48:22 UTC (rev 9444)
@@ -1089,13 +1089,25 @@
 				//TODO: check if epsg, and bbox are filled correctly!
 				$sqlExtent = "SELECT X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->minx." ".$mapbenderMetadata[$m]->miny.")',4326),".$epsgId.")) as minx, Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->minx." ".$mapbenderMetadata[$m]->miny.")',4326),".$epsgId.")) as miny, X(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->maxx." ".$mapbenderMetadata[$m]->maxy.")',4326),".$epsgId.")) as maxx, Y(transform(GeometryFromText('POINT(".$mapbenderMetadata[$m]->maxx." ".$mapbenderMetadata[$m]->maxy.")',4326),".$epsgId.")) as maxy";
 				$resExtent =  db_query($sqlExtent);
+				//TODO calculate length on earth if coordinates are given in deegree
 				$minx = floatval(db_result($resExtent,0,"minx"));
 				$miny = floatval(db_result($resExtent,0,"miny"));
 				$maxx = floatval(db_result($resExtent,0,"maxx"));
 				$maxy = floatval(db_result($resExtent,0,"maxy"));
-	
-				$diffX = $maxx - $minx; //in m
-				$diffY = $maxy - $miny;	//in m
+				$lengthSql = "SELECT ST_Distance("; 
+				$lengthSql .= "ST_Transform(GeomFromText('POINT(".$minx." ".$miny.")',4326),"."25832"."),";
+				$lengthSql .= "ST_Transform(GeomFromText('POINT(".$minx." ".$maxy.")',4326),"."25832".")) as lengthX,";
+				$lengthSql .= "ST_Distance("; 
+				$lengthSql .= "ST_Transform(GeomFromText('POINT(".$maxx." ".$miny.")',4326),"."25832"."),";
+				$lengthSql .= "ST_Transform(GeomFromText('POINT(".$maxx." ".$maxy.")',4326),"."25832".")) as lengthY";
+				$resLength =  db_query($lengthSql);
+				
+				$diffX = floatval(db_result($resLength,0,"lengthX"));
+				$diffY = floatval(db_result($resLength,0,"lengthY"));
+				$e = new mb_exception($diffX."-".$diffX);
+				//TODO: calculate in deegree again or use other origin?
+				//$diffX = $maxx - $minx; //in m
+				//$diffY = $maxy - $miny;	//in m
 				//$e = new mb_exception($diffX);
 				//echo $diffX .":". $diffY;
 				//calculate target number of pixels for x and y



More information about the Mapbender_commits mailing list