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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Aug 24 05:48:26 EDT 2010


Author: armin11
Date: 2010-08-24 09:48:26 +0000 (Tue, 24 Aug 2010)
New Revision: 6800

Modified:
   trunk/mapbender/http/classes/class_metadata_new.php
Log:
Update mapbender metadataserver component

Modified: trunk/mapbender/http/classes/class_metadata_new.php
===================================================================
--- trunk/mapbender/http/classes/class_metadata_new.php	2010-08-24 09:47:30 UTC (rev 6799)
+++ trunk/mapbender/http/classes/class_metadata_new.php	2010-08-24 09:48:26 UTC (rev 6800)
@@ -22,7 +22,7 @@
 #We need a parameter for internationalization - it should be send with the search request! Some of the Classes can be provided with different languages.
 #WMC and GeoRSS-Feeds have no or a to complex authorization info - maybe we need to test if wmc consists of info which is fully or only partually available to the anonymous user. 
 
-require_once(dirname(__FILE__)."/../../conf/mapbender.conf");
+require_once(dirname(__FILE__)."/../../core/globalSettings.php");
 require_once(dirname(__FILE__)."/class_administration.php");
 require_once(dirname(__FILE__)."/class_mb_exception.php");
 require_once(dirname(__FILE__)."/class_json.php");
@@ -88,7 +88,7 @@
 		$this->maxObjects = 15;
 		$this->maxFontSize = 30;
 		$this->maxWeight = 0;
-		$this->scale == 'linear';
+		$this->scale = 'linear';
 
 
 
@@ -138,34 +138,34 @@
 		$this->resourceCategories[0]['name'] = 'WMS';
 		$this->resourceCategories[1]['name'] = 'WFS';
 		$this->resourceCategories[2]['name'] = 'WMC';
-		$this->resourceCategories[3]['name'] = 'GeoRSS';
+		$this->resourceCategories[3]['name'] = 'DAD';
 		switch($this->languageCode){
         		case 'de':
                 	$this->resourceCategories[0]['name2show'] = 'Darstellungsdienste';
-			$this->resourceCategories[1]['name2show'] = 'Such- und Downloaddienste';
+			$this->resourceCategories[1]['name2show'] = 'Such- und Download- und Erfassungsmodule';
 			$this->resourceCategories[2]['name2show'] = 'Kartenzusammenstellungen';
-			$this->resourceCategories[3]['name2show'] = 'Geokodierte Newsfeeds';
+			$this->resourceCategories[3]['name2show'] = 'KML/Newsfeeds';
 			$this->keywordTitle = 'Schlagwortliste';
        			break;
         		case 'en':
                		$this->resourceCategories[0]['name2show'] = 'Viewingservices';
 			$this->resourceCategories[1]['name2show'] = 'Search- and Downloadservices';
 			$this->resourceCategories[2]['name2show'] = 'Combined Maps';
-			$this->resourceCategories[3]['name2show'] = 'Geocodet Newsfeeds';
+			$this->resourceCategories[3]['name2show'] = 'KML/Newsfeeds';
 			$this->keywordTitle = 'Keywordlist';
         		break;
         		case 'fr':
           	     	$this->resourceCategories[0]['name2show'] = 'Viewingservices';
 			$this->resourceCategories[1]['name2show'] = 'Search- and Downloadservices';
 			$this->resourceCategories[2]['name2show'] = 'Combined Maps';
-			$this->resourceCategories[3]['name2show'] = 'Geocodet Newsfeeds';
+			$this->resourceCategories[3]['name2show'] = 'KML/Newsfeeds';
 			$this->keywordTitle = 'Keywordlist';
        			break;
      			default:
                 	$this->resourceCategories[0]['name2show'] = 'Darstellungsdienste';
-			$this->resourceCategories[1]['name2show'] = 'Such- und Downloaddienste';
+			$this->resourceCategories[1]['name2show'] = 'Such- und Download- und Erfassungsmodule';
 			$this->resourceCategories[2]['name2show'] = 'Kartenzusammenstellungen';
-			$this->resourceCategories[3]['name2show'] = 'Geokodierte Newsfeeds';
+			$this->resourceCategories[3]['name2show'] = 'KML/Newsfeeds';
 			$this->keywordTitle = 'Schlagwortliste';
 		}	
 		//not needed til now - maybe usefull for georss output
@@ -242,7 +242,7 @@
 			if (isset($this->searchResources) & strtolower($this->searchResources) === "wmc") {
 				$this->searchView = 'search_wmc_view';
 				$this->databaseIdColumnName = 'wmc_id';
-				$this->databaseTableName = 'mb_user_wmc';
+				$this->databaseTableName = 'wmc';
 
 				switch ($this->orderBy) {
 					case "rank":
@@ -457,6 +457,7 @@
 			$this->wmcJSON->wmc->srv[$i]->date = date("d.m.Y",$wmcMatrix[$i]['wmc_timestamp']);
 			$this->wmcJSON->wmc->srv[$i]->respOrg = $wmcMatrix[$i]['mb_group_name'];
 			$this->wmcJSON->wmc->srv[$i]->mdLink = "http://".$this->hostName."/mapbender/x_geoportal/showWMCMetadata.php?id=".$wmcMatrix[$i]['wmc_id'];
+			$this->wmcJSON->wmc->srv[$i]->previewURL = "http://".$this->hostName."/mapbender/x_geoportal/mod_wmcPreview.php?id=".$wmcMatrix[$i]['wmc_id'];
 			$spatialSource = "";
 			$stateOrProvince = $wmcMatrix[$i]['mb_group_stateorprovince']; 
 			if ($stateOrProvince == "NULL" || $stateOrProvince == "") {
@@ -509,7 +510,6 @@
 		#echo "<br>user_id: ".$this->userId."<br><br>";
 		#var_dump($this->accessableLayers);
 		#echo "<br>";
-		
 		#$countWmsMatrix = count($wmsMatrix);
 		#echo $countWmsMatrix;
 		if ($n != 0) {
@@ -551,7 +551,6 @@
 				#echo "<br>".$rootLayerId."<br>";
 				//push root layer id in array
 				array_push($layerIdArray, $rootLayerId);
-				
 				#echo "<br>root Layer ID: ".$rootLayerId."<br>";
 				#array_multisort($subLayers['layer_pos'], SORT_ASC);
 				#print_r($subLayers);
@@ -565,7 +564,6 @@
 				#$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/x_geoportal/mod_layerMetadata.php?id=".(integer)$subLayers[$rootIndex]['layer_id'];
-				
 				$spatialSource = "";
 				$stateOrProvince = $subLayers[$rootIndex]['stateorprovince']; 
 				#echo $stateOrProvince."<br>";
@@ -584,10 +582,6 @@
 				//TODO check the field accessconstraints - which should be presented?
 				$this->wmsJSON->wms->srv[$j]->status = $subLayers[$rootIndex]['status']; //$wmsMatrix[$i][''];
 				$this->wmsJSON->wms->srv[$j]->avail = $subLayers[$rootIndex]['availability']; //$wmsMatrix[$i][''];
-
-
-
-				
 				//get info about defined price
 				if ($subLayers[$rootIndex]['wms_pricevolume'] == '' OR $subLayers[$rootIndex]['wms_pricevolume'] == 0){
 					$this->wmsJSON->wms->srv[$j]->price = NULL;
@@ -609,7 +603,6 @@
 				else {
 					 $this->wmsJSON->wms->srv[$j]->nwaccess = true;
 				}
-
 				#$this->wmsJSON->wms->srv[$j]->logged = NULL; //$wmsMatrix[$i][''];
 				#$this->wmsJSON->wms->srv[$j]->price = NULL; //$wmsMatrix[$i][''];
 				#$this->wmsJSON->wms->srv[$j]->nwaccess = NULL; //$wmsMatrix[$i][''];
@@ -818,84 +811,77 @@
 		}
 
 
-/* This is only for the later postgis versions. The within and disjoint is to slow, cause there is no usage of the geometrical index in the old versions!
-//check for postgis version
-//sql for get version string
-//get version number
-decide which type of search should be done
-
-
-		//spatial search filter - ist should be the first filter in the where clause, cause it is 
-		//
-		if (strtolower($this->searchResources) === "wms" & $this->searchBbox != NULL) {
-			#$spatialFilter = "(the_geom ";	
-			#echo "<br> spatial operator: ".$this->searchTypeBbox."<br>";
-			if ($this->searchTypeBbox == 'outside') {
-				$spatialFilter = ' disjoint(';
-			} elseif ($this->searchTypeBbox == 'inside') { 
-				$spatialFilter = ' within(';
-			} else {
-				$spatialFilter = ' intersects(';
-			}
-			//define spatial filter
-			if(count(explode(',',$this->searchBbox)) == 4){   //if searchBbox has 4 entries
-				
-				$spatialFilterCoords = explode(',',$this->searchBbox);//read out searchBbox
-				//definition of the spatial filter
-				$spatialFilter .= 'GeomFromText(\'POLYGON(('.$spatialFilterCoords[0];//minx
-				$spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
-				$spatialFilter .= $spatialFilterCoords[0];//minx
-				$spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
-				$spatialFilter .= $spatialFilterCoords[2];//maxx
-				$spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
-				$spatialFilter .= $spatialFilterCoords[2];//maxx
-				$spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
-				$spatialFilter .= $spatialFilterCoords[0];//minx
-				$spatialFilter .= ' '.$spatialFilterCoords[1].'))\',4326)';//miny
-				$spatialFilter .= ",the_geom)";
-				array_push($whereCondArray, $spatialFilter);
-			}
-			#array_push($whereCondArray, $spatialFilter);
-		}
-*/	
-		//spatial search filter - ist should be the first filter in the where clause, cause it is 
-		//
+		// This is only for the later postgis versions. The within and disjoint is to slow, cause there is no usage of the geometrical index in the old versions!
+		//check for postgis version
+		//sql for get version string
+		//get version number
 		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc") & $this->searchBbox != NULL) {
-			#$spatialFilter = "(the_geom ";	
-			#echo "<br> spatial operator: ".$this->searchTypeBbox."<br>";
-			#if ($this->searchTypeBbox == 'outside') {
-			#	$spatialFilter = ' disjoint(';
-			#} elseif ($this->searchTypeBbox == 'inside') { 
-			#	$spatialFilter = ' within(';
-			#} else {
-			#	$spatialFilter = ' intersects(';
-			#}
-			$spatialFilter = ' the_geom && ';
-			//define spatial filter
-			if(count(explode(',',$this->searchBbox)) == 4){   //if searchBbox has 4 entries
-				
-				$spatialFilterCoords = explode(',',$this->searchBbox);//read out searchBbox
-				//definition of the spatial filter
-				$spatialFilter .= 'GeomFromText(\'POLYGON(('.$spatialFilterCoords[0];//minx
-				$spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
-				$spatialFilter .= $spatialFilterCoords[0];//minx
-				$spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
-				$spatialFilter .= $spatialFilterCoords[2];//maxx
-				$spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
-				$spatialFilter .= $spatialFilterCoords[2];//maxx
-				$spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
-				$spatialFilter .= $spatialFilterCoords[0];//minx
-				$spatialFilter .= ' '.$spatialFilterCoords[1].'))\',4326)';//miny
-				#$spatialFilter .= ",the_geom)";
-				array_push($whereCondArray, $spatialFilter);
+			//decide which type of search should be done
+			//check for postgis version cause postgis versions < 1.4 have problems when doing disjoint and inside
+			//
+			$sqlPostgisVersion = "SELECT postgis_version();";
+			$vPostgisVersion = array();
+			$tPostgisVersion = array();
+			$resPostgisVersion = db_prep_query($sqlPostgisVersion, $vPostgisVersion, $tPostgisVersion);
+			// get version string
+			while($row = db_fetch_array($resPostgisVersion)){
+				$postgisVersion = $row['postgis_version'];
+				$postgisVersionArray = explode(" ",$postgisVersion);
+				$postgisVersionSmall = explode(".",$postgisVersionArray[0]);
+				$postgisSubNumber = $postgisVersionSmall[1];
+				$e = new mb_exception("class_metadata.php: postgis sub number = ".$postgisSubNumber);
 			}
-			#array_push($whereCondArray, $spatialFilter);
+			//
+			//
+			if ((integer)$postgisSubNumber >= 4){
+				#$spatialFilter = "(the_geom ";	
+				$e = new mb_exception("class_metadata.php: spatial operator: ".$this->searchTypeBbox);
+				if ($this->searchTypeBbox == 'outside') {
+					$spatialFilter = ' disjoint(';
+				} elseif ($this->searchTypeBbox == 'inside') { 
+					$spatialFilter = ' within(';
+				} else {
+					$spatialFilter = ' intersects(';
+				}
+				//define spatial filter
+				if(count(explode(',',$this->searchBbox)) == 4){   //if searchBbox has 4 entries
+					$spatialFilterCoords = explode(',',$this->searchBbox);//read out searchBbox
+					//definition of the spatial filter
+					$spatialFilter .= 'GeomFromText(\'POLYGON(('.$spatialFilterCoords[0];//minx
+					$spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
+					$spatialFilter .= $spatialFilterCoords[0];//minx
+					$spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
+					$spatialFilter .= $spatialFilterCoords[2];//maxx
+					$spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
+					$spatialFilter .= $spatialFilterCoords[2];//maxx
+					$spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
+					$spatialFilter .= $spatialFilterCoords[0];//minx
+					$spatialFilter .= ' '.$spatialFilterCoords[1].'))\',4326)';//miny
+					$spatialFilter .= ",the_geom)";
+					array_push($whereCondArray, $spatialFilter);
+				}
+			} else {
+		
+				$spatialFilter = ' the_geom && ';
+				//define spatial filter
+				if(count(explode(',',$this->searchBbox)) == 4){   //if searchBbox has 4 entries
+					$spatialFilterCoords = explode(',',$this->searchBbox);//read out searchBbox
+					//definition of the spatial filter
+					$spatialFilter .= 'GeomFromText(\'POLYGON(('.$spatialFilterCoords[0];//minx
+					$spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
+					$spatialFilter .= $spatialFilterCoords[0];//minx
+					$spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
+					$spatialFilter .= $spatialFilterCoords[2];//maxx
+					$spatialFilter .= ' '.$spatialFilterCoords[3].',';//maxy
+					$spatialFilter .= $spatialFilterCoords[2];//maxx
+					$spatialFilter .= ' '.$spatialFilterCoords[1].',';//miny
+					$spatialFilter .= $spatialFilterCoords[0];//minx
+					$spatialFilter .= ' '.$spatialFilterCoords[1].'))\',4326)';//miny
+					#$spatialFilter .= ",the_geom)";
+					array_push($whereCondArray, $spatialFilter);
+				}
+			}
 		}	
-
-
-
-
-
 		//search filter for md_topic_categories
 		//
 		if ((strtolower($this->searchResources) === "wms" or strtolower($this->searchResources) === "wmc") & $this->isoCategories != NULL) {
@@ -1074,15 +1060,26 @@
 				if (count($keywordCounts) > 0) {
 					$this->maxWeight = $keywordCounts[0]['count'];
 					for ($j = 0; $j < count($keywordCounts); $j++) {
-						$this->keyJSON->tagCloud->tags[$j]->title = $keywordCounts[$j]['keyword'];
-						//generate the weight:
 						if ($this->scale == 'linear'){
 							//order in a linear scale desc
-							 $this->keyJSON->tagCloud->tags[$j]->weight = $this->maxFontSize-($j*$this->inc);
+							 $keywordCounts[$j]['count'] = $this->maxFontSize-($j*$this->inc);
 						} else {
 							//set weight prop to count 
-							 $this->keyJSON->tagCloud->tags[$j]->weight = $keywordCounts[$j]['count']*$this->maxFontSize/$this->maxWeight;
+							 $keywordCounts[$j]['count'] = $keywordCounts[$j]['count']*$this->maxFontSize/$this->maxWeight;
 						}
+					}
+					//$this->maxWeight = $keywordCounts[0]['count'];
+					shuffle($keywordCounts);
+					for ($j = 0; $j < count($keywordCounts); $j++) {
+						$this->keyJSON->tagCloud->tags[$j]->title = $keywordCounts[$j]['keyword'];
+						//generate the weight:
+						//if ($this->scale == 'linear'){
+							//order in a linear scale desc
+							 $this->keyJSON->tagCloud->tags[$j]->weight = $keywordCounts[$j]['count'];
+						//} else {
+							//set weight prop to count 
+							// $this->keyJSON->tagCloud->tags[$j]->weight = $keywordCounts[$j]['count']*$this->maxFontSize/$this->maxWeight;
+						//}
 						//$this->keyJSON->tags[$j]->weight = $keywordCounts[$j]['count'];
 
 						$paramValue = $this->getValueForParam('searchText', $this->searchURL);	
@@ -1741,4 +1738,4 @@
 	}	
 		
 }
-?>
\ No newline at end of file
+?>



More information about the Mapbender_commits mailing list