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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Oct 23 07:21:04 PDT 2013


Author: armin11
Date: 2013-10-23 07:21:03 -0700 (Wed, 23 Oct 2013)
New Revision: 8729

Modified:
   trunk/mapbender/http/classes/class_wms.php
Log:
New possibility to parse categories from layer keywords of wms 1.3.0 into mapbenders categories tables. This is only done when registrating the resource, not when updating it. It should be managed thru the boolean wms->overwriteCategories which is default set to false now. TODO: Add steering possibility to updateWMS and update scheduler.

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2013-10-17 09:13:29 UTC (rev 8728)
+++ trunk/mapbender/http/classes/class_wms.php	2013-10-23 14:21:03 UTC (rev 8729)
@@ -68,7 +68,7 @@
 	  
 	var $default_epsg = 0;
 	var $overwrite = true;
-	
+	var $overwriteCategories = false;
 	var $twitterNews = false;
 	var $setGeoRss = false;
 	var $geoRss;
@@ -510,6 +510,31 @@
 		else {
 			$x = new connector($url);
 		}
+		//built hashes for category mapping
+		$topicCatHash = array();
+		$sql = "SELECT md_topic_category_id, md_topic_category_code_en FROM md_topic_category";
+		$res = db_query($sql);
+		while ($row = db_fetch_array($res)){
+			$topicCatHash[$row['md_topic_category_code_en']] = (integer)$row['md_topic_category_id'];
+					
+		}
+		//inspire
+		$inspireCatHash = array();
+		$sql = "SELECT inspire_category_id, inspire_category_code_en FROM inspire_category";
+		$res = db_query($sql);
+		while ($row = db_fetch_array($res)){
+			$inspireCatHash[$row['inspire_category_code_en']] = (integer)$row['inspire_category_id'];
+			//$e = new mb_exception("inspireCatHash: ".$row['inspire_category_code_en'] ." : ". $row['inspire_category_id'] );	
+			}
+		//custom
+		//keywords - as text i custom category - special keywords of geoportal instance defined as keys!
+		$customCatHash = array();
+		$sql = "SELECT custom_category_id, custom_category_key FROM custom_category";
+		$res = db_query($sql);
+		while ($row = db_fetch_array($res)){
+			$customCatHash[$row['custom_category_key']] = (integer)$row['custom_category_id'];
+			//$e = new mb_exception("customCatHash: ".$row['custom_category_key'] ." : ". $row['custom_category_id'] );	
+		}
 		$data = $x->file;
 		if ($data=='401') {
 			echo "<br>HTTP Error:<b>".$data." - Authorization required. This seems to be a service which needs HTTP Authentication!</b><br>";
@@ -876,7 +901,41 @@
 				}
 				if(mb_strtoupper($element['tag']	) == "KEYWORD"){
 					array_push($this->objLayer[$cnt_layer]->layer_keyword, trim($element['value']));
+					//add vocabulary attribut to keyword object
+					//read attribute
+					if (isset($element['attributes']['vocabulary'])) {
+						switch ($element['attributes']['vocabulary']) {
+							case "ISO 19115:2003":
+								array_push($this->objLayer[$cnt_layer]->layer_keyword_vocabulary, "ISO 19115:2003");
+								//add id for isoCategory
+								if (is_int($topicCatHash[trim($element['value'])])) {
+									$this->objLayer[$cnt_layer]->layer_md_topic_category_id[] = (integer)$topicCatHash[trim($element['value'])];
+									$e = new mb_exception("class_wms.php iso keyword added: ".(integer)$topicCatHash[trim($element['value'])]);
+								}
+							break;
+							case "GEMET - INSPIRE themes":
+								array_push($this->objLayer[$cnt_layer]->layer_keyword_vocabulary, "GEMET - INSPIRE themes, version 1.0");
+								//check if keyword is a key in mapbenders inspire keywords and add it to mapbenders inspire categories
+								if (is_int($inspireCatHash[trim($element['value'])])) {
+									$this->objLayer[$cnt_layer]->layer_inspire_category_id[] = (integer)$inspireCatHash[trim($element['value'])];
+								}
+							break;
+							case "http://www.mapbender.org":
+								array_push($this->objLayer[$cnt_layer]->layer_keyword_vocabulary, "http://www.mapbender.org");
+								//check if keyword is a key in mapbenders inspire keywords and add it to mapbenders inspire categories
+								if (is_int($customCatHash[trim($element['value'])])) {
+									$this->objLayer[$cnt_layer]->layer_custom_category_id[] = (integer)$customCatHash[trim($element['value'])];
+								}
+							break;
+							default:
+								array_push($this->objLayer[$cnt_layer]->layer_keyword_vocabulary, "none");
+							break;
+						}
+					} else {
+						array_push($this->objLayer[$cnt_layer]->layer_keyword_vocabulary, "none");
+					}
 				}
+				
 	      			if(mb_strtoupper($element['tag']	) == "DATAURL" && $element['type'] == "open"){
 					$dataurl = true;
 					$cnt_dataurl++;
@@ -1823,12 +1882,16 @@
 			$this->insertLayerStyle($i);
 			
 			# insert Keywords
-			$this->insertLayerKeyword($i);	
-	
+			$this->insertLayerKeyword($i);
+
+			//insert categories - new for wms 1.3.0 as from october 2013
+			$this->insertLayerCategories($i);
+
 			# insert dataurls
 			$this->insertLayerDataUrls($i); //TODO: in the spec 1.3.0 the schema defines a 1:n relation, but in the table there is only one link possible - maybe we need only this one link
 			# insert metadataurls
 			$this->insertLayerMetadataUrls($i);
+
 			//update messages for twitter and georss
 			$currentLayer = $this->objLayer[$i];
 			
@@ -1960,13 +2023,15 @@
 			$this->insertLayerStyle($i);
 			if($this->overwrite == true){
 				$this->insertLayerKeyword($i);
+				//$this->insertLayerCategories($i); //Don't overwrite layer categories by default any longer - it will make problems - maybe the wms 1.3.0 possibilities are a better way
+			}
+			if($this->overwriteCategories == true){
 				$this->insertLayerCategories($i);
 			}
 		}
 	}
 	function insertGuiLayer($i,$myWMS,$gui_id){
 		# table gui_layer
-		
 		$sql = "INSERT INTO gui_layer (fkey_gui_id, fkey_layer_id, gui_layer_wms_id, ";
 		$sql .= "gui_layer_status, gui_layer_selectable, gui_layer_visible, gui_layer_queryable, ";
 		$sql .= "gui_layer_querylayer,gui_layer_minscale,gui_layer_maxscale, gui_layer_priority, gui_layer_style, gui_layer_title) ";
@@ -2325,7 +2390,6 @@
 	
 	function insertLayerCategories($i){
 		global $con;
-
 		$types = array("md_topic", "inspire", "custom");
 		foreach ($types as $cat) {
 			$sql = "DELETE FROM layer_{$cat}_category WHERE fkey_layer_id = $1 AND fkey_metadata_id ISNULL";
@@ -3678,6 +3742,7 @@
 	var $layer_searchable;
 	var $inspire_download;
     	var $layer_keyword = array();
+	var $layer_keyword_vocabulary = array();
 	var $layer_epsg = array();
 	var $layer_style = array();
 	var $layer_md_topic_category_id = array();



More information about the Mapbender_commits mailing list