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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Mar 2 06:23:07 EST 2007


Author: christoph
Date: 2007-03-02 06:23:03 -0500 (Fri, 02 Mar 2007)
New Revision: 1163

Modified:
   trunk/mapbender/http/classes/class_wms.php
Log:
added new function createJsLayerObjFromWMS

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2007-03-02 11:21:28 UTC (rev 1162)
+++ trunk/mapbender/http/classes/class_wms.php	2007-03-02 11:23:03 UTC (rev 1163)
@@ -644,13 +644,13 @@
 		$this->gui_wms_featureinfoformat ."','". 
 		$this->gui_wms_exceptionformat . "','". 
 		$this->gui_wms_epsg ."','". 
-		$this->gui_wms_visible ."');");
+		$this->gui_wms_visible ."');\n");
 		
 	for($i=0;$i<count($this->data_format);$i++){
 		if($parent){
 			echo "parent.";
 		}		
-		echo "wms_add_data_type_format('". $this->data_type[$i] ."','". $this->data_format[$i] ."');";		
+		echo "wms_add_data_type_format('". $this->data_type[$i] ."','". $this->data_format[$i] ."');\n";		
 	}
 	for($i=0; $i<count($this->objLayer); $i++){
 		if($parent){
@@ -660,7 +660,7 @@
 			$this->objLayer[$i]->layer_parent ."','". 
 			$this->objLayer[$i]->layer_uid ."','". 
 			$this->objLayer[$i]->layer_name . "','". 
-			$this->objLayer[$i]->layer_title ."','". 
+			addslashes($this->objLayer[$i]->layer_title) ."','". 
 			$this->objLayer[$i]->layer_dataurl_href ."','". 
 			$this->objLayer[$i]->layer_pos ."','". 
 			$this->objLayer[$i]->layer_queryable ."','". 
@@ -675,7 +675,7 @@
 			$this->objLayer[$i]->gui_layer_querylayer ."','". 
 			$this->objLayer[$i]->gui_layer_minscale ."','". 
 			$this->objLayer[$i]->gui_layer_maxscale ."','".
-			$this->objLayer[$i]->gui_layer_wfs_featuretype ."');");
+			$this->objLayer[$i]->gui_layer_wfs_featuretype ."');\n");
 		for($j=0; $j<count($this->objLayer[$i]->layer_epsg);$j++){
 			if($i==0){
 				if($parent){
@@ -686,7 +686,7 @@
 					$this->objLayer[$i]->layer_epsg[$j]["minx"] ."','". 
 					$this->objLayer[$i]->layer_epsg[$j]["miny"] ."','". 
 					$this->objLayer[$i]->layer_epsg[$j]["maxx"] ."','". 
-					$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');");
+					$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n");
 			}
 			if($parent){
 			echo "parent.";
@@ -696,16 +696,107 @@
 				$this->objLayer[$i]->layer_epsg[$j]["minx"] ."','". 
 				$this->objLayer[$i]->layer_epsg[$j]["miny"] ."','". 
 				$this->objLayer[$i]->layer_epsg[$j]["maxx"] ."','". 
-				$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');");
+				$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n");
 		}
 		for($j=0; $j<count($this->objLayer[$i]->layer_style);$j++){
 			if($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]["legendformat"]."');");
+			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]["legendformat"]."');\n");
 		}
 	}
   }
+  
+  function createJsLayerObjFromWMS($parent=0, $layer_name){
+  	if(!$this->wms_title || $this->wms_title == ""){
+		echo " alert('Error: no valid capabilities-document !!');";
+		die; exit;
+	}
+		if($parent){
+			echo "parent.";
+		}
+		// wms_title and abstract have previously been urlencoded
+		// this solution may not yet be the ultimate one
+		print("add_wms('". 
+		$this->wms_id ."','".
+		$this->wms_version ."','".
+		str_replace("'", "", $this->wms_title) ."','".
+		str_replace("'", "", $this->wms_abstract) ."','". 
+		$this->wms_getmap ."','" .
+		$this->wms_getfeatureinfo ."','".
+		$this->wms_getlegendurl ."','".
+		$this->wms_filter ."','".
+		$this->gui_wms_mapformat ."','". 
+		$this->gui_wms_featureinfoformat ."','". 
+		$this->gui_wms_exceptionformat . "','". 
+		$this->gui_wms_epsg ."','". 
+		$this->gui_wms_visible ."');\n");
+		
+	for($i=0;$i<count($this->data_format);$i++){
+		if($parent){
+			echo "parent.";
+		}		
+		echo "wms_add_data_type_format('". $this->data_type[$i] ."','". $this->data_format[$i] ."');\n";		
+	}
+	for($i=0; $i<count($this->objLayer); $i++){
+		if($parent){
+			echo "parent.";
+		}
+	if($this->objLayer[$i]->layer_name == $layer_name|| $this->objLayer[$i]->layer_pos == 0){
+		
+		 print ("wms_add_layer('". 
+			$this->objLayer[$i]->layer_parent ."','". 
+			$this->objLayer[$i]->layer_uid ."','". 
+			$this->objLayer[$i]->layer_name . "','". 
+			addslashes($this->objLayer[$i]->layer_title) ."','". 
+			$this->objLayer[$i]->layer_dataurl_href ."','". 
+			$this->objLayer[$i]->layer_pos ."','". 
+			$this->objLayer[$i]->layer_queryable ."','". 
+			$this->objLayer[$i]->layer_minscale . "','". 
+			$this->objLayer[$i]->layer_maxscale ."','". 
+			$this->objLayer[$i]->layer_metadataurl ."','". 
+			$this->objLayer[$i]->gui_layer_wms_id ."','". 
+			$this->objLayer[$i]->gui_layer_status ."','". 
+			$this->objLayer[$i]->gui_layer_selectable ."','". 
+			$this->objLayer[$i]->gui_layer_visible ."','". 
+			$this->objLayer[$i]->gui_layer_queryable ."','". 
+			$this->objLayer[$i]->gui_layer_querylayer ."','". 
+			$this->objLayer[$i]->gui_layer_minscale ."','". 
+			$this->objLayer[$i]->gui_layer_maxscale ."','".
+			$this->objLayer[$i]->gui_layer_wfs_featuretype ."');\n");
+		for($j=0; $j<count($this->objLayer[$i]->layer_epsg);$j++){
+			if($i==0){
+				if($parent){
+				echo "parent.";
+				}
+				print("wms_addSRS('". 
+					$this->objLayer[$i]->layer_epsg[$j]["epsg"] ."','". 
+					$this->objLayer[$i]->layer_epsg[$j]["minx"] ."','". 
+					$this->objLayer[$i]->layer_epsg[$j]["miny"] ."','". 
+					$this->objLayer[$i]->layer_epsg[$j]["maxx"] ."','". 
+					$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n");
+			}
+			if($parent){
+			echo "parent.";
+			}
+			print("layer_addEpsg('". 
+				$this->objLayer[$i]->layer_epsg[$j]["epsg"] ."','". 
+				$this->objLayer[$i]->layer_epsg[$j]["minx"] ."','". 
+				$this->objLayer[$i]->layer_epsg[$j]["miny"] ."','". 
+				$this->objLayer[$i]->layer_epsg[$j]["maxx"] ."','". 
+				$this->objLayer[$i]->layer_epsg[$j]["maxy"] ."');\n");
+		}
+		for($j=0; $j<count($this->objLayer[$i]->layer_style);$j++){
+			if($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]["legendformat"]."');\n");
+		}
+	   }	
+	}
+  }
+  
+  
 /**
 * writeObjInDB
 *



More information about the Mapbender_commits mailing list