svn commit: r717 - trunk/mapbender/http: classes javascripts

christoph at osgeo.org christoph at osgeo.org
Fri Jul 28 10:35:47 EDT 2006


Author: christoph
Date: 2006-07-28 14:35:46+0000
New Revision: 717

Modified:
   trunk/mapbender/http/classes/class_wmc.php
   trunk/mapbender/http/classes/class_wms.php
   trunk/mapbender/http/javascripts/map_obj.js

Log:
moved wms id generation

Modified: trunk/mapbender/http/classes/class_wmc.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/classes/class_wmc.php?view=diff&rev=717&p1=trunk/mapbender/http/classes/class_wmc.php&p2=trunk/mapbender/http/classes/class_wmc.php&r1=716&r2=717
==============================================================================
--- trunk/mapbender/http/classes/class_wmc.php	(original)
+++ trunk/mapbender/http/classes/class_wmc.php	2006-07-28 14:35:46+0000
@@ -536,7 +536,7 @@
 	}
 
 	function createJsObjFromWMC($target, $mapObj, $action){
-		
+		if ($action == "merge") $action = "append";
 		$wmc_string = "";
 		$validActions = array("load", "merge", "append");
 		if (!in_array($action, $validActions)) {
@@ -575,6 +575,7 @@
 						$wmc_string .= "\tif ('" . $this->wmc_wms_serviceURL[$i] . "' ==  " . $target . "mb_mapObj[ind].wms[m].wms_getmap) {\n";
 						$wmc_string .= "\t\twms_exists = true;\n";
 						$wmc_string .= "\t\tcurrent_wms_index = m;\n";
+						$wmc_string .= "\t\tchangedWmsIds[changedWmsIds.length] = wms[m].wms_id;\n";
 						$wmc_string .= "\t}\n";
 						$wmc_string .= "}\n";
 						$wmc_string .= "if (!wms_exists) {\n";
@@ -587,15 +588,7 @@
 						die; exit;
 					}
 		
-					// create temporary WMS id
-					$id = rand(1000, 9999); 
-					$this->wmc_wms_count ++;
-						
-					if ($action == "merge") {
-						$wmc_string .= "\tchangedWmsIds[changedWmsIds.length] = '" . $id . "';\n";
-					}
-					$wmc_string .= "\t" . $target . "add_wms('" .
-						$id ."','".
+					$wmc_string .= "\t" . $target . "add_wms('','".
 						$this->wmc_wms_version[$i] ."','".
 						$this->wmc_wms_title[$i] ."','".
 						$this->wmc_layer_abstract[$i] ."','".
@@ -603,7 +596,6 @@
 						$this->wmc_wms_serviceURL[$i] ."','" .
 						$this->wmc_layer_style_legendurl[$i][0] ."','','". 
 						$this->wmc_layer_format[$i][0] ."','text/html','application/vnd.ogc.se_xml','". 
-//						$this->wmc_layer_srs[$i][0] ."','1');\n";
 						$this->wmc_bBox_SRS ."','1');\n";
 		
 					$added_wms[count($added_wms)] = $current_wms;
@@ -691,9 +683,10 @@
 								// if yes, update the visibility and queryability..
 								$wmc_string .= "\t\t\t" . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[current_layer_index].gui_layer_visible = " . intval(!$this->wmc_layer_hidden[$ii]) . ";\n"; 
 								$wmc_string .= "\t\t\t" . $target . "mb_mapObj[ind].wms[current_wms_index].objLayer[current_layer_index].gui_layer_querylayer = " . $this->wmc_layer_queryable[$ii] . ";\n"; 
-		
 								// ... and check if current wms is in array of wmses that need restating...
 								$wmc_string .= "\t\t\twmsAlreadyInArray = false;\n";
+/*
+ 
 								$wmc_string .= "\t\t\tfor (var z=0; z<changedWmsIds.length; z++) {\n";
 								// FIXME: this 'if' may not work
 								$wmc_string .= "\t\t\t\tif (changedWmsIds[z] == " . $target . "mb_mapObj[ind].wms[current_wms_index].wms_id) {\n";
@@ -705,6 +698,7 @@
 								$wmc_string .= "\t\t\tif (wmsAlreadyInArray == false) {\n";
 								$wmc_string .= "\t\t\t\tchangedWmsIds[changedWmsIds.length] = " . $target . "mb_mapObj[ind].wms[current_wms_index].wms_id;\n";
 								$wmc_string .= "\t\t\t}\n";
+*/
 								$wmc_string .= "\t\t}\n";
 								$wmc_string .= "\t}\n"; 
 								$wmc_string .= "}\n"; 
@@ -715,20 +709,6 @@
 								if ($layerlist == "") {$layerlist = $this->wmc_layer_name[$ii];} else {$layerlist .= "," . $this->wmc_layer_name[$ii];}
 							}
 	
-#							for($j=0; $j<count($this->wmc_layer_srs[$ii]);$j++){
-#								if (!in_array($this->wmc_layer_srs[$ii][$j], $srs_array)) {
-#									$srs_array[count($srs_array)] = $this->wmc_layer_srs[$ii][$j]; 
-#									$wmc_string .= $target . "wms_addSRS('". 
-#										$this->wmc_bBox_SRS ."','". 
-#										$this->wmc_bBox_minx ."','". 
-#										$this->wmc_bBox_miny ."','". 
-#										$this->wmc_bBox_maxx ."','". 
-#										$this->wmc_bBox_maxy ."','". 
-#										"');\n";
-#								}
-#							}
-
-	
 							for($j=0; $j<count($this->wmc_layer_style_name[$ii]);$j++){
 								$wmc_string .= $target . "wms_addLayerStyle('".$this->wmc_layer_style_name[$ii][$j] ."','".$this->wmc_layer_style_title[$ii][$j] ."','".$j."','".$cnt_layers."', '" . $this->wmc_layer_style_legendurl[$ii][$j] . "', '" . $this->wmc_layer_style_legendurl_format[$ii][$j] . "');\n";
 							}

Modified: trunk/mapbender/http/classes/class_wms.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/classes/class_wms.php?view=diff&rev=717&p1=trunk/mapbender/http/classes/class_wms.php&p2=trunk/mapbender/http/classes/class_wms.php&r1=716&r2=717
==============================================================================
--- trunk/mapbender/http/classes/class_wms.php	(original)
+++ trunk/mapbender/http/classes/class_wms.php	2006-07-28 14:35:46+0000
@@ -50,7 +50,6 @@
 	
   } 
   
-  
 function createObjFromXML($url){
 
 	$x = new connector($url);
@@ -70,8 +69,9 @@
 		$this->wms_status = true;
 	}
 	
-	$time = explode(" ", microtime(1));
-	$this->wms_id = substr(md5(substr($time[0], 2)), 0, 5); 
+//	$time = explode(" ", microtime(1));
+//	$this->wms_id = substr(md5(substr($time[0], 2)), 0, 5);
+	$this->wms_id = ""; 
 	$parser = xml_parser_create(CHARSET);
 	xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0);
 	xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1);

Modified: trunk/mapbender/http/javascripts/map_obj.js
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/map_obj.js?view=diff&rev=717&p1=trunk/mapbender/http/javascripts/map_obj.js&p2=trunk/mapbender/http/javascripts/map_obj.js&r1=716&r2=717
==============================================================================
--- trunk/mapbender/http/javascripts/map_obj.js	(original)
+++ trunk/mapbender/http/javascripts/map_obj.js	2006-07-28 14:35:46+0000
@@ -54,6 +54,22 @@
 			gui_wms_epsg,
 			gui_wms_visible){
    
+	if (!wms_id) {
+		var id_ok = false;
+		while (id_ok == false) {
+			wms_id = "a";
+			for (var i=0; i < 4; i++) {
+				wms_id+=Math.round(10*Math.random());
+			}
+			id_ok = true;
+			for (var i=0; i < wms.length && id_ok == true; i++) {
+				if (wms_id == wms[i].wms_id) {
+					id_ok = false;
+				}
+			}
+		}
+	}
+	
 	this.wms_id = wms_id;
 	this.wms_version = wms_version;
 	this.wms_title = wms_title;




More information about the Mapbender_commits mailing list