[Mapbender-commits] r9559 - in trunk/mapbender/http: classes javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Aug 15 06:56:13 PDT 2016


Author: armin11
Date: 2016-08-15 06:56:13 -0700 (Mon, 15 Aug 2016)
New Revision: 9559

Modified:
   trunk/mapbender/http/classes/class_map.php
   trunk/mapbender/http/classes/class_wmc.php
   trunk/mapbender/http/classes/class_wmcToXml.php
   trunk/mapbender/http/classes/class_wms.php
   trunk/mapbender/http/javascripts/wms.js
Log:
Further implementation of simple support for wms dimension parameter

Modified: trunk/mapbender/http/classes/class_map.php
===================================================================
--- trunk/mapbender/http/classes/class_map.php	2016-08-11 10:09:47 UTC (rev 9558)
+++ trunk/mapbender/http/classes/class_map.php	2016-08-15 13:56:13 UTC (rev 9559)
@@ -620,7 +620,13 @@
 					$newLayer->layer_style[$z]["legendurl"] = $currentLayer->layer_style[$z]->legendurl;
 					$newLayer->layer_style[$z]["legendurlformat"] = $currentLayer->layer_style[$z]->legendurlformat;
 				}
-
+				//
+				$newLayer->layer_dimension = array();
+				foreach($currentLayer->layer_dimension as $dimension) {
+					foreach(get_object_vars($dimension) as $key=>$value) {
+  						$newLayer->layer_dimension[] = array($key => $value);
+					}	
+				}
 			}
 			array_push($this->wmsArray, $wms);
 		}
@@ -794,7 +800,7 @@
                 			}
 
                 			if($ovIndex > $count_wms) {
-                    				$e = new mb_exception("class_map.php: selectByApplication : OverviewIndex (set in overview element var 'overview_wms')does not exist!");
+                    				$e = new mb_exception("class_map.php: selectByApplication : OverviewIndex (set in overview element var 'overview_wms') does not exist!");
 						if ($cache->isActive) {
 							$cache->cachedVariableAdd($mapByAppKey,null);
 						}

Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php	2016-08-11 10:09:47 UTC (rev 9558)
+++ trunk/mapbender/http/classes/class_wmc.php	2016-08-15 13:56:13 UTC (rev 9559)
@@ -1546,7 +1546,7 @@
 		// is currently parsed.
 		//
 		$extension = false;		$general = false;		$layerlist = false;
-		$layer = false;  		$formatlist = false;	$layer_dataurl = false;
+		$layer = false;  		$layer_dimensionlist = false;         $formatlist = false;	$layer_dataurl = false;
 		$layer_metadataurl = false; 	$stylelist = false;
 
 		//
@@ -1793,6 +1793,16 @@
 						array_push($layerlistArray["main"], $modifiedLayer);
 						$layer = false;
 					}
+					if ($layer_dimensionlist) {
+						if ($tag == "DIMENSION") {
+							foreach (array_keys($attributes) as $attribute) {
+							 	array_push($currentLayer["dimension"], array($attribute => $attributes[$attribute]));	
+							}
+						}
+						if ($tag == "DIMENSIONLIST" && $type == "close") {
+							$layer_dimensionlist = false;
+						}
+					}
 					if ($formatlist) {
 						if ($tag == "FORMAT") {
 							array_push($currentLayer["format"], array("current" => $attributes["current"], "name" => $value));
@@ -1932,6 +1942,9 @@
 						if ($tag == "DATAURL" && $type == "open") {
 							$layer_dataurl = true;
 						}
+						if ($tag == "DIMENSIONLIST" && $type == "open") {
+							$layer_dimensionlist = true;
+						}
 						if ($tag == "FORMATLIST" && $type == "open") {
 							$formatlist = true;
 						}

Modified: trunk/mapbender/http/classes/class_wmcToXml.php
===================================================================
--- trunk/mapbender/http/classes/class_wmcToXml.php	2016-08-11 10:09:47 UTC (rev 9558)
+++ trunk/mapbender/http/classes/class_wmcToXml.php	2016-08-15 13:56:13 UTC (rev 9559)
@@ -340,6 +340,12 @@
 			$e_layer->appendChild($srsNode);
 		}
 
+		// Layer dimension
+		$dimensionListNode = $this->createLayerDimensionListNode($currentWms);
+		if ($dimensionNode !== null) {
+			$e_layer->appendChild($dimensionListNode);
+		}
+
 		// Layer format
 		$formatListNode = $this->createLayerFormatListNode($currentWms);
 		if ($formatListNode !== null) {
@@ -378,6 +384,22 @@
 		return $e_layer_srs;
 	}
 
+	private function createLayerDimensionListNode ($currentWms, $currentLayer) {
+		if (count($currentLayer->layer_dimension) >= 1) {
+			$e_layer_dimensionlist = $this->doc->createElement("DimensionList");
+			for ($k = 0; $k < count($currentLayer->layer_dimension); $k++){
+				$e_layer_dimension = $this->doc->createElement("Dimension");
+				foreach($currentLayer->layer_dimension as $dimension) {
+					foreach(get_object_vars($dimension) as $key=>$value) {
+  						$e_format->setAttribute($key, $value);
+					}	
+				}
+				$e_layer_dimensionlist->appendChild($e_layer_dimension);
+			}
+		}
+		return $e_layer_dimensionlist;
+	}
+
 	private function createLayerFormatListNode ($currentWms) {
 		$e_layer_format = $this->doc->createElement("FormatList");
 

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2016-08-11 10:09:47 UTC (rev 9558)
+++ trunk/mapbender/http/classes/class_wms.php	2016-08-15 13:56:13 UTC (rev 9559)
@@ -1765,10 +1765,18 @@
 			}
 			for($j=0; $j<count($this->objLayer[$i]->layer_style);$j++){
 				if($parent){
-				echo "parent.";
+				 echo "parent.";
 				}
 				print("wms_addLayerStyle('".$this->objLayer[$i]->layer_style[$j]["name"]."', '".$this->objLayer[$i]->layer_style[$j]["title"]."', ".$j.",".$i.",'".$this->objLayer[$i]->layer_style[$j]["legendurl"]."', '".$this->objLayer[$i]->layer_style[$j]["legendurlformat"]."');");
 			}
+			//2016 - new for dimension (time and elevation)
+			for($j=0; $j<count($this->objLayer[$i]->layer_dimension);$j++){
+				if($parent){
+				 echo "parent.";
+				}
+				//'name', 'units', 'unitSymbol', 'default', 'multipleValues', 'nearestValue', 'current', 'extent'
+				print("wms_addLayerDimension('".$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."');");
+			}
 		   }	
 		}
 	  }
@@ -2446,9 +2454,11 @@
 		//get parent layer
 		$admin = new administration();
 		$layerIdArray = $admin->getParentLayers($this->wms_id, $this->objLayer[$i]->db_id);
-		//insert dimensions from parent layers
-		$sql = "INSERT INTO layer_dimension (fkey_layer_id, name, units, unitSymbol,\"default\", multipleValues, nearestValue, current, extent, inherited) SELECT ".$this->objLayer[$i]->db_id." AS fkey_layer_id, name, units, unitSymbol,\"default\", multipleValues, nearestValue, current, extent, true as inherited FROM layer_dimension WHERE fkey_layer_id IN (".implode(",",$layerIdArray).") AND inherited IS FALSE";
-		$res = db_query($sql);
+		if ($layerIdArray !== false AND count($layerIdArray) > 0 AND is_array($layerIdArray)) {
+			//insert dimensions from parent layers
+			$sql = "INSERT INTO layer_dimension (fkey_layer_id, name, units, unitSymbol,\"default\", multipleValues, nearestValue, current, extent, inherited) SELECT ".$this->objLayer[$i]->db_id." AS fkey_layer_id, name, units, unitSymbol,\"default\", multipleValues, nearestValue, current, extent, true as inherited FROM layer_dimension WHERE fkey_layer_id IN (".implode(",",$layerIdArray).") AND inherited IS FALSE";
+			$res = db_query($sql);
+		}
 	}
 	function insertLayerEPSG($i) {
 		//$currentSrsArray = array();
@@ -3517,7 +3527,7 @@
 				$this->objLayer[$layer_cnt]->layer_searchable =$row2["layer_searchable"];
 				$this->objLayer[$layer_cnt]->inspire_download =$row2["inspire_download"];
 				$this->objLayer[$layer_cnt]->layer_pos =$row2["layer_pos"];						
-				$this->objLayer[$layer_cnt]->layer_queryable =$row2["layer_pos"];
+				//$this->objLayer[$layer_cnt]->layer_queryable =$row2["layer_pos"];
 				$this->objLayer[$layer_cnt]->layer_queryable =$row2["layer_queryable"];
 				$this->objLayer[$layer_cnt]->layer_minscale =$row2["layer_minscale"];
 				$this->objLayer[$layer_cnt]->layer_maxscale = $row2["layer_maxscale"];
@@ -3550,7 +3560,7 @@
 				$count_layer_epsg++;
 			}
 			
-			### handle styles
+			// handle styles
 			$sql = "SELECT * FROM layer_style WHERE fkey_layer_id = $1 ";
 			$v = array($layer_id);
 			$t = array('i');
@@ -3574,6 +3584,20 @@
 				$this->objLayer[$layer_cnt]->layer_style[$count_layer_style]["legendurlformat"]=$row2["legendurlformat"];
 				$count_layer_style++;
 			}
+			//handle layer dimensions (first only time and elevation!)
+			$sql = "SELECT * FROM layer_dimension WHERE fkey_layer_id = $1 AND ( name = 'time' OR name = 'elevation')";
+			$v = array($layer_id);
+			$t = array('i');
+			$res_dimension = db_prep_query($sql,$v,$t);
+			$count_layer_dimension = 0;
+			while($row_dim = db_fetch_array($res_dimension)) {
+				$attributeNames = array('name', 'units', 'unitSymbol', 'default', 'multipleValues', 'nearestValue', 'current', 'extent');
+				foreach($attributeNames as $attribute) {
+					//$e = new mb_exception("class_wms - pull dimension attribute: ".strtolower($attribute)." for layer: ".$layer_id);
+					$this->objLayer[$layer_cnt]->layer_dimension[$count_layer_dimension]->{$attribute} = $row_dim[strtolower($attribute)];
+				}
+				$count_layer_dimension++;
+			}
 			$count++;
 		}
 	   }
@@ -3763,7 +3787,21 @@
 				$this->objLayer[$layer_cnt]->layer_epsg[$count_layer_epsg]["maxy"]=$row2["maxy"];
 				$count_layer_epsg++;
 			}
-			### read out keywords
+			//handle layer dimensions (first only time and elevation!)
+			$sql = "SELECT * FROM layer_dimension WHERE fkey_layer_id = $1 AND ( name = 'time' OR name = 'elevation')";
+			$v = array($this->objLayer[$layer_cnt]->layer_uid);
+			$t = array('i');
+			$res_dimension = db_prep_query($sql,$v,$t);
+			$count_layer_dimension = 0;
+			while($row_dim = db_fetch_array($res_dimension)) {
+				$attributeNames = array('name', 'units', 'unitSymbol', 'default', 'multipleValues', 'nearestValue', 'current', 'extent');
+				foreach($attributeNames as $attribute) {
+					$this->objLayer[$layer_cnt]->layer_dimension[$count_layer_dimension]->{$attribute} = $row_dim[strtolower($attribute)];
+				}
+				$count_layer_dimension++;
+			}
+
+			// read out keywords
 			$sql = "SELECT keyword FROM keyword, layer_keyword 
 WHERE keyword_id = fkey_keyword_id AND fkey_layer_id = $1";
 			$v = array($this->objLayer[$layer_cnt]->layer_uid);

Modified: trunk/mapbender/http/javascripts/wms.js
===================================================================
--- trunk/mapbender/http/javascripts/wms.js	2016-08-11 10:09:47 UTC (rev 9558)
+++ trunk/mapbender/http/javascripts/wms.js	2016-08-15 13:56:13 UTC (rev 9559)
@@ -821,6 +821,21 @@
 	currentLayer.layer_epsg[k].maxx = maxx;
 	currentLayer.layer_epsg[k].maxy = maxy;
 }
+//'name', 'units', 'unitSymbol', 'default', 'multipleValues', 'nearestValue', 'current', 'extent'
+/*function layer_addDimension(name,units,unitSymbol,default1,multipleValues,nearestValue,current,extent){
+	var j = wms[wms.length-1].objLayer.length-1;
+	var k = wms[wms.length-1].objLayer[j].layer_dimension.length;
+	var currentLayer = wms[wms.length-1].objLayer[j];
+	currentLayer.layer_dimension[k]={};
+	currentLayer.layer_dimension[k].name = name;
+	currentLayer.layer_dimension[k].units = units;
+	currentLayer.layer_dimension[k].unitSymbol = unitSymbol;
+	currentLayer.layer_dimension[k].default = default1;
+	currentLayer.layer_dimension[k].multipleValues = multipleValues;
+	currentLayer.layer_dimension[k].nearestValue = nearestValue;
+	currentLayer.layer_dimension[k].current = current;
+	currentLayer.layer_dimension[k].extent = extent;
+}*/
 function wms_layer(
 	layer_parent,
 	wms_layer_uid,



More information about the Mapbender_commits mailing list