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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Aug 10 08:11:04 PDT 2016


Author: armin11
Date: 2016-08-10 08:11:04 -0700 (Wed, 10 Aug 2016)
New Revision: 9554

Modified:
   trunk/mapbender/http/classes/class_wms.php
Log:
New possibility to handle dimension fields for wms layers - to be done - inheritance of dimensions from parent layers!

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2016-08-10 10:04:14 UTC (rev 9553)
+++ trunk/mapbender/http/classes/class_wms.php	2016-08-10 15:11:04 UTC (rev 9554)
@@ -842,6 +842,7 @@
 					//new for resolving metadataurls and dataurls
 					$cnt_metadataurl = -1;
 					$cnt_dataurl = -1;
+					$cnt_dimension = -1;
 					$cnt_layer++;
 					$parent[$element['level']+1] = $cnt_layer;
 					$myParent[$cnt_layer]= $parent[$element['level']];
@@ -1066,6 +1067,63 @@
 					$this->objLayer[$cnt_layer]->layer_minscale = sprintf("%u", $this->objLayer[$cnt_layer]->layer_minscale);
 					$this->objLayer[$cnt_layer]->layer_maxscale = sprintf("%u", $this->objLayer[$cnt_layer]->layer_maxscale);
 				}
+				// Parse dimension for each layer
+				if(mb_strtoupper($element['tag']) == "DIMENSION"){
+					$cnt_dimension++;
+					//extract dimension from capabilities
+					$this->objLayer[$cnt_layer]->layer_dimension[$cnt_dimension]->name = $element['attributes']['name'];
+					$this->objLayer[$cnt_layer]->layer_dimension[$cnt_dimension]->units = $element['attributes']['units'];
+					if (isset($element['attributes']['unitSymbol']) && $element['attributes']['unitSymbol'] !== "") {
+						$this->objLayer[$cnt_layer]->layer_dimension[$cnt_dimension]->unitSymbol = $element['attributes']['unitSymbol'];
+					}
+					/*if (isset($element['attributes']['unitSymbol']) && $element['attributes']['unitSymbol'] !== "") {
+						$this->objLayer[$cnt_layer]->layer_dimension[$cnt_dimension]->unitSymbol = $element['attributes']['unitSymbol'];
+					}*/
+					
+					switch ($this->wms_version) {
+						case "1.1.1":
+							//$this->objLayer[$cnt_layer]->layer_dimension[$cnt_dimension]->units = $element['attributes']['units'];
+							break;
+						case "1.3.0":
+							//mandatory
+							$this->objLayer[$cnt_layer]->layer_dimension[$cnt_dimension]->extent = $element['value'];
+							//optional
+							$optionalElements = array("default", "multipleValues", "nearestValue", "current");
+							foreach ($optionalElements as $optionalElement) {
+								if (isset($element['attributes'][$optionalElement]) && $element['attributes'][$optionalElement] !== "") {
+									$this->objLayer[$cnt_layer]->layer_dimension[$cnt_dimension]->{$optionalElement} = $element['attributes'][$optionalElement];
+								}
+							}
+							
+							//$this->objLayer[$cnt_layer]->layer_dimension[] =
+							break; 
+					}
+				}
+				//pull extent attributes for wms 1.1.1 into dimension object
+				if ($this->wms_version == '1.1.1') {
+					//$e = new mb_exception("version 1.1.1");
+					if(mb_strtoupper($element['tag']) == "EXTENT"){
+						//check for position of dimension element with same name
+						$posDimensionName = 0;
+						foreach ($this->objLayer[$cnt_layer]->layer_dimension as $layerDimension) {
+							$e = new mb_exception("test name: ".$layerDimension->name);
+							if ($layerDimension->name == $element['attributes']['name']) {
+								
+								break;
+							}
+							$posDimensionName++;
+						}
+						//extract 
+						$this->objLayer[$cnt_layer]->layer_dimension[$posDimensionName]->extent = $element['value'];
+						$mandatoryElements = array("default", "nearestValue");	
+						foreach ($mandatoryElements as $mandatoryElement) {
+							if (isset($element['attributes'][$mandatoryElement]) && $element['attributes'][$mandatoryElement] !== "") {
+								$this->objLayer[$cnt_layer]->layer_dimension[$posDimensionName]->{$mandatoryElement} = $element['attributes'][$mandatoryElement];
+							}
+						}
+					}
+				}
+				
 			} 
 			else {
 				continue;
@@ -1087,7 +1145,8 @@
 		if(count($doubleLayers) > 0) {
 			$e = new mb_exception("class_wms: createObjFromXML: WMS has " . count($doubleLayers) . " double layer name entries and could therefor not be loaded.");
 			$returnObject['success'] = false;
-			$returnObject['message'] = _mb("WMS has double layer names and could therefor not be loaded!");
+			$returnObject['message'] = _mb("WMS has following double layer names and could therefor not be loaded!");
+			$returnObject['message'] .= " "._mb("Double layer names").": ".implode(',', $doubleLayers);
 			return $returnObject;	
 		}
 		
@@ -1959,22 +2018,26 @@
 			db_rollback();	
 		}
 		else {
-			# save the id of each layer: set param2 true		
+			// save the id of each layer: set param2 true		
 			$this->objLayer[$i]->db_id = db_insert_id($con, 'layer','layer_id');
 			$this->insertLayerEPSG($i);
 			
-			# TABLE layer_style for each layer
+			//
+			$this->insertLayerDimension($i);
+
+			// TABLE layer_style for each layer
 			$this->insertLayerStyle($i);
 			
-			# insert Keywords
+			// insert Keywords
 			$this->insertLayerKeyword($i);
 
 			//insert categories - new for wms 1.3.0 as from october 2013
 			$this->insertLayerCategories($i);
 
-			# insert dataurls
+			// 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
+
+			// insert metadataurls
 			$this->insertLayerMetadataUrls($i);
 
 			//update messages for twitter and georss
@@ -2107,6 +2170,7 @@
 			//this things can only be updated, if the service is updated thru new capabilities documents
 			if (!$updateMetadataOnly) {
 				$this->insertLayerEPSG($i);
+				$this->insertLayerDimension($i);
 				$this->insertLayerDataUrls($i);
 				$this->insertLayerMetadataUrls($i);
 				$this->insertLayerStyle($i);
@@ -2369,6 +2433,24 @@
 		}
 		return $supportedSrsArray;
 	}
+	function insertLayerDimension($i) {
+		//first get array of all parent layers with their dimensions
+		//delete old dimension entries
+		$sql = "DELETE FROM layer_dimension WHERE fkey_layer_id = $1";
+		$v = array($this->objLayer[$i]->db_id);
+		$t = array('i');
+		$res = db_prep_query($sql,$v,$t);
+		for($j=0; $j<count($this->objLayer[$i]->layer_dimension);$j++){
+			$sql = "INSERT INTO layer_dimension (fkey_layer_id, name, units, unitSymbol,\"default\", multipleValues, nearestValue, current, extent) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9);";
+			$v = array($this->objLayer[$i]->db_id,
+			$this->objLayer[$i]->layer_dimension[$j]->name, $this->objLayer[$i]->layer_dimension[$j]->units, $this->objLayer[$i]->layer_dimension[$j]->unitSymbol, $this->objLayer[$i]->layer_dimension[$j]->default, $this->objLayer[$i]->layer_dimension[$j]->multipleValues, $this->objLayer[$i]->layer_dimension[$j]->nearestValue, $this->objLayer[$i]->layer_dimension[$j]->current, $this->objLayer[$i]->layer_dimension[$j]->extent);
+			$t = array('i','s','s','s','s','s','s','s','s');
+			$res = db_prep_query($sql,$v,$t);
+			if(!$res){
+				db_rollback();	
+			}
+		}
+	}
 	function insertLayerEPSG($i) {
 		//$currentSrsArray = array();
 		$sql = "DELETE FROM layer_epsg WHERE fkey_layer_id = $1";
@@ -3895,6 +3977,7 @@
 	var $layer_keyword_vocabulary = array();
 	var $layer_epsg = array();
 	var $layer_style = array();
+	var $layer_dimension = array();
 	var $layer_md_topic_category_id = array();
 	var $layer_inspire_category_id = array();
 	var $layer_custom_category_id = array();



More information about the Mapbender_commits mailing list