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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Mar 13 10:32:32 EDT 2012


Author: armin11
Date: 2012-03-13 07:32:32 -0700 (Tue, 13 Mar 2012)
New Revision: 8286

Modified:
   trunk/mapbender/http/classes/class_map.php
   trunk/mapbender/http/classes/class_wmc.php
   trunk/mapbender/http/html/mod_treefolderPlain.php
   trunk/mapbender/http/javascripts/mod_jsonAutocompleteGazetteer.php
   trunk/mapbender/http/javascripts/mod_loadwmc.js
   trunk/mapbender/http/javascripts/mod_savewmc.js
Log:
Bugfixes to prohibit the treetimes saving of the wmc after load a wmc from the database and some work to show the legend if the services are load from the wmc - some things have to be done.

Modified: trunk/mapbender/http/classes/class_map.php
===================================================================
--- trunk/mapbender/http/classes/class_map.php	2012-03-12 20:32:56 UTC (rev 8285)
+++ trunk/mapbender/http/classes/class_map.php	2012-03-13 14:32:32 UTC (rev 8286)
@@ -516,7 +516,12 @@
 			$wms->gui_wms_mapformat = $currentWms->gui_wms_mapformat;
 			$wms->gui_wms_featureinfoformat = $currentWms->gui_wms_featureinfoformat;
 			$wms->gui_wms_exceptionformat = $currentWms->gui_wms_exceptionformat;
-			$wms->gui_wms_opacity = ($currentWms->gui_wms_mapopacity)*100;//this definition is not easy to understand. TODO: find another, consistent behavior.
+			$e = new mb_notice('class_map: gui_wms_mapopacity: '.$currentWms->gui_wms_mapopacity);
+			if (!isset($currentWms->gui_wms_mapopacity) || $currentWms->gui_wms_mapopacity =='') {
+				$wms->gui_wms_opacity = 100;
+			} else {
+				$wms->gui_wms_opacity = ($currentWms->gui_wms_mapopacity)*100;//this definition is not easy to understand. TODO: find another, consistent behavior.
+			}
 			$wms->gui_wms_sldurl = $currentWms->gui_wms_sldurl;
 			$wms->gui_wms_visible = $currentWms->gui_wms_visible;
 			$wms->gui_wms_epsg = $currentWms->gui_wms_epsg;

Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php	2012-03-12 20:32:56 UTC (rev 8285)
+++ trunk/mapbender/http/classes/class_wmc.php	2012-03-13 14:32:32 UTC (rev 8286)
@@ -548,8 +548,8 @@
 
 					$LegendResources = $xpath->query("../../wmc:StyleList/wmc:Style/wmc:LegendURL/wmc:OnlineResource",$WMSId);
 					foreach ($LegendResources as $LegendResource) {
-							$e = new mb_notice("class_wmc.php: old getlegendurl (WMC): ".$LegendResource->getAttribute("xlink:href"));
-							$e = new mb_notice("class_wmc.php: new getlegendurl (OWSPROXY): ".$wmsGetLegendUrl);
+							$e = new mb_exception("class_wmc.php: old getlegendurl (WMC): ".$LegendResource->getAttribute("xlink:href"));
+							$e = new mb_exception("class_wmc.php: new getlegendurl (OWSPROXY): ".$wmsGetLegendUrl);
 							//get param part of getlegend url from xml
 							$arURL = parse_url($LegendResource->getAttribute("xlink:href"));
 							$query = $arURL["query"];
@@ -559,6 +559,7 @@
 				} else { //service is not secured - exchange urls only when they may have changed
 					$wmsGetMapUrl = $row["wms_getmap"];
 					$wmsGetLegendUrl = $row["wms_getlegendurl"];
+					
 					//in cases when no owsproxy is defined exchange only if timestamp are not in sync
 					$wms_timestamp = $row["wms_timestamp"];
 					//if ($this->timestamp < $wms_timestamp) {//TODO: check if such a distiction is really needful - the timestamp of a wmc changes if some metadata changes - therefor it is needed - exchange all urls by default! 
@@ -572,17 +573,26 @@
 						foreach($MapResources as $MapResource) {
 							$MapResource->setAttribute("xlink:href",$wmsGetMapUrl);
 						}
+						//Exchange the given styles for each layer
+						$query_mbLayerId = "/wmc:ViewContext/wmc:LayerList/wmc:Layer/wmc:Extension/mapbender:layer_id";
+						$LayerIdList = $xpath->query($query_mbLayerId);
+						//TODO: exchange the style urls on a right way!
+						/*foreach($LayerIdList as $LayerId) {
+							
+							$e = new mb_exception("layer_id: ".print_r($LayerId->nodeValue));
+						}*/
 
-						$LegendResources = $xpath->query("../../wmc:StyleList/wmc:Style/wmc:LegendURL/wmc:OnlineResource",$WMSId);
-						foreach ($LegendResources as $LegendResource) {
-							$e = new mb_notice("class_wmc.php: old getlegendurl (WMC): ".$LegendResource->getAttribute("xlink:href"));
-							$e = new mb_notice("class_wmc.php: new getlegendurl (DB): ".$wmsGetLegendUrl);
+						//$LegendResources = $xpath->query("../../wmc:StyleList/wmc:Style/wmc:LegendURL/wmc:OnlineResource",$WMSId);
+						
+						/*foreach ($LegendResources as $LegendResource) {
+							$e = new mb_exception("class_wmc.php: old getlegendurl (WMC): ".$LegendResource->getAttribute("xlink:href"));
+							$e = new mb_exception("class_wmc.php: new getlegendurl (DB): ".$wmsGetLegendUrl);
 							//get param part of getlegend url from xml
 							$arURL = parse_url($LegendResource->getAttribute("xlink:href"));
 							$query = $arURL["query"];
 							$url = $wmsGetLegendUrl . $query;
 							$LegendResource->setAttribute("xlink:href",$url);
-						}
+						}*/
 					}
 				}
 				
@@ -1211,14 +1221,18 @@
 		}
 
 		// .. request the map
+		
+		array_push($wmcJsArray, "lock_maprequest = true;");
+		array_push($wmcJsArray, "eventAfterLoadWMS.trigger();"); //TODO: Why? Reload tree? Other way to do this?
+		array_push($wmcJsArray, "lock_maprequest = false;");
 		array_push($wmcJsArray, "Mapbender.modules['".$this->mainMap->getFrameName().
 			"'].setMapRequest();");
 		if ($this->overviewMap !== null) {
 			array_push($wmcJsArray, "try {Mapbender.modules['".$this->overviewMap->getFrameName().
 				"'].setMapRequest()} catch (e) {};");
 		}
-
-		array_push($wmcJsArray, "eventAfterLoadWMS.trigger();");
+		//?initializeWms()
+		//eventAfterLoadWMS.register(reloadTree);
 		return $wmcJsArray;
 	}
 
@@ -1294,7 +1308,11 @@
 	protected function createObjFromWMC_xml($data) {
 	// store xml
 		$this->xml = $data;
-
+		//$wmcXml = simplexml_load_string(mb_utf8_encode($data));
+		//if ($wmcXml) {
+		//	$e = new mb_exception("class_wmc.php: parsing wmc successfully");
+		//}
+		
 		$values = administration::parseXml($data);
 		if (!$values) {
 			throw new Exception("WMC document could not be parsed.");
@@ -1317,7 +1335,33 @@
 		$layerlistArray = array();
 		$layerlistArray["main"] = array();
 		$layerlistArray["overview"] = array();
+		//parse WMC per simpleXML and use xpath instead of old bib
+		//$wmcXml = new SimpleXMLElement($data);
 
+		
+		//$wmcXml = simplexml_load_string(mb_utf8_encode($data));
+		//echo (";");
+		//print_r($wmcXml.";");
+		//if ($wmcXml) {
+		//	$e = new mb_exception("class_wmc.php: parsing wmc successfully");
+		//}
+		//print_r($ViewContext);
+		//$wmcXml->registerXPathNamespace('standard','http://www.opengis.net/context');
+		//$title = $wmcXml->xpath("/ViewContext/General/Title");
+		//$wmcXml->registerXPathNamespace('xsi', 'http://www.w3.org/2001/XMLSchema-instance');
+		//$wmcXml->registerXPathNamespace('mapbender', 'http://www.mapbender.org/context');
+		//$wmcXml->registerXPathNamespace('xlink', 'http://www.w3.org/1999/xlink');
+		//$wmcXml->registerXPathNamespace('wmc', 'http://opengis.net/context');
+		//$e = new mb_exception("class_wmc.php: data: ".mb_utf8_encode($data));
+		//$this->wmc_id = $wmcXml->xpath('/ViewContext/@id');
+		//$this->wmc_version = $wmcXml->xpath('/ViewContext/@version');
+		//$title = $wmcXml->xpath('/standard:ViewContext/standard:Title');
+		//var_dump($title);
+		
+		//$e = new mb_exception("class_wmc.php: parsing wmc by xpath: title: ".$title[0]);
+		//$e = new mb_exception("class_wmc.php: parsing wmc by xpath: wmc_version: ".$this->wmc_version);
+
+
 		foreach ($values as $element) {
 			$tag = strtoupper(administration::sepNameSpace($element[tag]));
 			$tagLowerCase = administration::sepNameSpace($element[tag]);
@@ -1585,6 +1629,7 @@
 									if ($tag == "ONLINERESOURCE") {
 										$currentLayer["style"][$index]["legendurl_type"] = $attributes["xlink:type"];
 										$currentLayer["style"][$index]["legendurl"] = $attributes["xlink:href"];
+										//$e = new mb_exception('class_wmc: legendurl onlineresource xlink:href: '.$attributes["xlink:href"]);
 									}
 								}
 								if ($tag == "LEGENDURL" && $type == "open") {

Modified: trunk/mapbender/http/html/mod_treefolderPlain.php
===================================================================
--- trunk/mapbender/http/html/mod_treefolderPlain.php	2012-03-12 20:32:56 UTC (rev 8285)
+++ trunk/mapbender/http/html/mod_treefolderPlain.php	2012-03-13 14:32:32 UTC (rev 8286)
@@ -108,6 +108,7 @@
 var lock=false;
 var lock_update=false;
 var lock_check=false;
+var lock_maprequest = false; //global var to prohibit multiple saving states as wmc to session when loading wmc 
 var selectedMap=-1;
 var selectedWMS=-1;
 var selectedLayer=-1;
@@ -670,7 +671,9 @@
 	if(confirm('<?php echo _mb("Are you sure you want to remove");?>' + ' "'+ mb_mapObj[j].wms[k].objLayer[l].layer_currentTitle+'"?')){
   		 mb_mapObjremoveWMS(j,k);
 		 mb_mapObj[j].zoom(true, 1.0);
+		 lock_maprequest = true; //done to prohibit save wmc for each wms
 		 mb_execloadWmsSubFunctions();
+		 lock_maprequest = false;
 	}
 }
 
@@ -714,7 +717,9 @@
 		l.gui_layer_querylayer = bChk ? 1 : 0;
 
 		mb_restateLayers(mod_treeGDE_map,wms_id);
-		setSingleMapRequest(mod_treeGDE_map,wms_id);
+		if (!lock_maprequest) {
+			setSingleMapRequest(mod_treeGDE_map,wms_id);
+		}		
 		return;
 	}
 	mb_mapObj[ind].wms[wms].handleLayer(layername,"visible",bChk?"1":"0");
@@ -730,8 +735,10 @@
 	}
 	if(reset_lock)
 	{
-		 mb_restateLayers(mod_treeGDE_map,wms_id);
-		 setSingleMapRequest(mod_treeGDE_map,wms_id);
+		mb_restateLayers(mod_treeGDE_map,wms_id);
+		if (!lock_maprequest) {
+			setSingleMapRequest(mod_treeGDE_map,wms_id);
+		}
 		lock_check=false;
 	}
 }

Modified: trunk/mapbender/http/javascripts/mod_jsonAutocompleteGazetteer.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_jsonAutocompleteGazetteer.php	2012-03-12 20:32:56 UTC (rev 8285)
+++ trunk/mapbender/http/javascripts/mod_jsonAutocompleteGazetteer.php	2012-03-13 14:32:32 UTC (rev 8286)
@@ -57,7 +57,7 @@
 $gui_id = array(Mapbender::session()->get("mb_user_gui"));
 
 //include all element vars from the given element
-//include '../include/dyn_js.php';
+include '../include/dyn_js.php';
 //include '../include/dyn_php.php';
 
 ?>
@@ -69,6 +69,7 @@
 });
 
 //initialize module
+alert(options.gazetteerUrl);
 if (options.gazetteerUrl === undefined) {
 	options.gazetteerUrl = 'http://www.geoportal.rlp.de/mapbender/geoportal/gaz_geom_mobile.php';
 	//options.gazetteerUrl = 'http://ws.geonames.org/searchJSON?lang=de&';
@@ -111,7 +112,7 @@
 	var targetName = options.target;
 	var ind = getMapObjIndexByName(targetName);
 	var my = mb_mapObj[ind];
-	
+	alert(options.gazetteerUrl);
 	/*this.zoomToExtent = function(minx,miny,maxx,maxy) {
 		var newExtent = new Mapbender.Extent(
                    	 parseFloat(minx),

Modified: trunk/mapbender/http/javascripts/mod_loadwmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.js	2012-03-12 20:32:56 UTC (rev 8285)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.js	2012-03-13 14:32:32 UTC (rev 8286)
@@ -371,8 +371,10 @@
 					}
 					if (obj.javascript && typeof(obj.javascript) == "object") {
 						for (var j = 0; j < obj.javascript.length; j++) {
-//							var e = new Mb_notice("Statement: " + obj.javascript[j]);
-//							console.log("Statement: " + obj.javascript[j]);
+							//TODO: prohibit multiple maprequests when load wmc, cause on maprequests the wmc maybe stored to session :-(   
+							//alert("Statement: " + obj.javascript[j]);
+							//eventAfterLoadWMS.trigger(); -- load the each wms again and saves the wmc to session for each wms - prohibit this behaviour!!!! - Done by global lock_maprequest in class_wmc.php line 1220+!!
+							//console.log("Statement: " + obj.javascript[j]);
 							eval(obj.javascript[j]);
 						}
 						if (args.method === "loadWmc") {

Modified: trunk/mapbender/http/javascripts/mod_savewmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.js	2012-03-12 20:32:56 UTC (rev 8285)
+++ trunk/mapbender/http/javascripts/mod_savewmc.js	2012-03-13 14:32:32 UTC (rev 8286)
@@ -413,9 +413,11 @@
 				options.$target.each(function () {
 					$(this).mapbender().events.afterMapRequest.register(function () {
 						if (!window.resetSession) {
-							that.save({
-								session : true
-							});
+							//if (!prohibitSaveWmc) {
+								that.save({
+									session : true
+								});
+							//}
 							//alert('afterMapRequest Saving!');
 						}
 					});



More information about the Mapbender_commits mailing list