[Mapbender-commits] r2452 - in branches/beck_dev/mapbender: http/javascripts http/php lib

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu May 15 05:03:10 EDT 2008


Author: christoph
Date: 2008-05-15 05:02:56 -0400 (Thu, 15 May 2008)
New Revision: 2452

Added:
   branches/beck_dev/mapbender/lib/ajax.js
   branches/beck_dev/mapbender/lib/div.js
   branches/beck_dev/mapbender/lib/exception.js
   branches/beck_dev/mapbender/lib/list.js
   branches/beck_dev/mapbender/lib/map_obj.js
   branches/beck_dev/mapbender/lib/wms.js
Removed:
   branches/beck_dev/mapbender/http/javascripts/map_obj.js
Modified:
   branches/beck_dev/mapbender/http/javascripts/map.js
   branches/beck_dev/mapbender/http/javascripts/map.php
   branches/beck_dev/mapbender/http/javascripts/mod_sandclock.php
   branches/beck_dev/mapbender/http/javascripts/mod_sandclock2.php
   branches/beck_dev/mapbender/http/javascripts/mod_switchLocale_noreload.php
   branches/beck_dev/mapbender/http/php/mod_addWmsFromFeatureInfo.php
   branches/beck_dev/mapbender/http/php/system.php
Log:
map.php et al refactoring

Modified: branches/beck_dev/mapbender/http/javascripts/map.js
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/map.js	2008-05-09 16:00:35 UTC (rev 2451)
+++ branches/beck_dev/mapbender/http/javascripts/map.js	2008-05-15 09:02:56 UTC (rev 2452)
@@ -17,29 +17,9 @@
 var mb_offset_left = 0;
 var mb_log = null;
 
-function mb_removeFunctionFromArray(arrayname,stringFunction){
-	var length = eval(arrayname+".length");
-	for(var i=0; i<length; i++){
-		if(eval(arrayname+"["+i+"]") == stringFunction){
-			var newArray1 = eval(arrayname+".slice(0, "+(i-1)+")");
-			var newArray2 = eval(arrayname+".slice("+(i+1)+", "+length+")");
-			eval(arrayname + " = newArray1.concat(newArray2)");
-			i--;
-			length--;
-		}
-	}
-}
-
 /**
  * @deprecated
  */
-function localize() {
-	eventLocalize.trigger();
-}
-
-/**
- * @deprecated
- */
 function mb_execloadWmsSubFunctions(){
 	eventAfterLoadWMS.trigger();
 }
@@ -74,11 +54,9 @@
 	return null;
 }
 
-var mb_security_proxy = "http://wms1.ccgis.de/mapbender/tools/security_proxy.php?mb_ows_security_proxy=";
-
+// transparent GIF
 var mb_trans = new Image(); 
 mb_trans.src = "../img/transparent.gif";
-/*END OF GLOBALS*/
 
 
 /**
@@ -97,371 +75,10 @@
 	}      	
 }
 
-function deleteWmsObject() {
-	wms = [];
-	wms_layer_count = 0;
-}
-
-function deleteMapObj() {
-	mb_mapObj = [];
-}
-
 function mb_registerMapObj(frameName, elementName,wms_index,width, height){
-	mb_mapObj[mb_mapObj.length] = new mb_mapObj_const(frameName, elementName, width, height, wms_index);    
+	mb_mapObj.push(new mb_mapObj_const(frameName, elementName, width, height, wms_index));    
 }
 
-function mb_mapObj_const(frameName, elementName, width, height, wms_index){
-	this.width = width;
-	this.height = height;
-	this.frameName = frameName;
-	this.elementName = elementName;
-	this.layers = [];
-	this.styles = [];
-	this.querylayers = [];
-	this.geom = "";
-	this.gml = ""; 
-	this.wms = [];
-
-	// 
-	// Add pointers to WMS objects which are in this map.
-	// If wms_index is set (=map is overview), only this 
-	// WMS is being pointed to.
-	//
-	var index = 0;
-	for(var i=0; i < wms.length; i++){
-		var isValidWms = (wms_index === null) || (wms_index == i);
-		if (isValidWms) {
-			this.wms[index] = wms[i];
-			this.wms[index].mapURL = false;
-			index++;
-		}
-	}
-
-	//
-	// set list of visible layers, active querylayers 
-	// and styles for each WMS in this map
-	//
-	var cnt_layers;
-	var cnt_querylayers;
-	var styles;
-	var layers;
-	var querylayers = "";
-	for(i=0; i< this.wms.length; i++){
-		cnt_layers = 0;
-		cnt_querylayers = 0;
-		styles = "";
-		layers = "";
-		querylayers = "";
-
-		for(var ii=0; ii<this.wms[i].objLayer.length; ii++){
-			// layer is visible and not root layer
-			if(this.wms[i].objLayer[ii].gui_layer_visible == 1 && ii>0){
-				if(cnt_layers > 0){
-					layers += ","; styles += ","; 
-				}
-				layers += wms[i].objLayer[ii].layer_name; 
-				styles += ""; 
-				cnt_layers++;
-			}            
-			// layer is queryable and not root layer
-			if(this.wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii>0){
-				if(cnt_querylayers > 0){
-					querylayers += ",";
-				}
-				querylayers += wms[i].objLayer[ii].layer_name; 
-				cnt_querylayers++;
-			}                          
-		}
-		this.layers[i] = layers;
-		this.styles[i] = styles;
-		this.querylayers[i] = querylayers;
-	}
-   
-	this.epsg = wms[0].gui_wms_epsg;
-	this.extent = setExtent(this.width,this.height,this.epsg);
-	this.mapURL = [];
-	var styleTag = window.frames[this.frameName].document.getElementById(this.elementName).style;
-	styleTag.width = this.width;
-	styleTag.height = this.height;   
-   
-	/**
-	 * get the width of the mapObj
-	 *
-	 * @member mb_mapObj_const
-	 * @return width of the mapObj  
-	 * @type integer  
-	 */
-	this.getWidth = function(){
-		return parseInt(this.width, 10);
-	};
-	
-	/**
-	 * set the width of the mapObj
-	 *
-	 * @param {integer} widht the width of the mapObj  
-	 */
-	this.setWidth = function(width){
-		this.width = parseInt(width, 10);
-	};
-	
-	/**
-	 * get the height of the mapObj
-	 *
-	 * @member mb_mapObj_const
-	 * @return width of the mapObj  
-	 * @type integer  
-	 */
-	this.getHeight = function(){
-		return parseInt(this.height, 10);
-	};
-	
-	/**
-	 * set the height of the mapObj
-	 *
-	 * @param {integer} height the height of the mapObj  
-	 */
-	this.setHeight = function(height){
-		this.height = parseInt(height, 10);
-	};
-	
-	/**
-	 * get the extent of the mapObj
-	 *
-	 * @member mb_mapObj_const
-	 * @return extent of the mapObj as commaseparated minx,minx,maxx,maxy  
-	 * @type string
-	 */
-	this.getExtent = function(){
-		return this.extent;
-	};
-	
-	/**
-	 * get the extent as minx, maxx, miny, maxy
-	 *
-	 * @return extent and additional informations of the mapObj  
-	 * @type Object
-	 */
-	this.getExtentInfos = function(){
-		var c = this.getExtent().split(",");
-		var ext = new Extent(c[0],c[1],c[2],c[3]);
-		return ext;
-	};
-	
-	/**
-	 * converts the extent of the mapobject so that the maximum	extent will be displayed
-	 *
-	 */
-	this.calculateExtent = function(ext){
-		var relation_px_x = this.getWidth() / this.getHeight();
-		var relation_px_y = this.getHeight() / this.getWidth();
-		var relation_bbox_x = ext.extentx / ext.extenty;     
-		if(relation_bbox_x <= relation_px_x){                
-			ext.minx = ext.centerx - relation_px_x * ext.extenty / 2;
-			ext.maxx = ext.centerx + relation_px_x * ext.extenty / 2;
-		}
-		if(relation_bbox_x > relation_px_x){                
-			ext.miny = ext.centery - relation_px_y * ext.extentx / 2;
-			ext.maxy = ext.centery + relation_px_y * ext.extentx / 2;
-		}
-		this.setExtent(ext.minx,ext.miny,ext.maxx,ext.maxy);
-	};
-	
-	
-	/**
-	 * zoom the map with a zoomfactor and optional to x,y coords
-	 * 
-	 * @param {boolean} in_ in = true, out = false
-	 * @param {float} factor the zoomfactor 1 equals 100%
-	 * @param {float} x center to x-position
-	 * @param {float} y center to y-position
-	 */
-	 this.zoom = function(in_, factor, x, y){
-		factor = parseFloat(factor);
-		if (!in_) {
-			factor = 1 / factor;
-		}
-		
-		var extent = this.getExtentInfos();
-		var distx = extent.maxx - extent.minx;
-		var disty =  extent.maxy - extent.miny;
-		
-		
-		if(x && y){
-			var centerx = parseFloat(x);
-			var centery = parseFloat(y);
-		}
-		else{
-			var centerx = extent.minx + distx/2;
-			var centery = extent.miny + disty/2;
-		}
-		
-		
-		var new_distx = distx / factor;
-		var new_disty = disty / factor;
-		var minx = centerx - new_distx / 2;
-		var miny = centery - new_disty / 2;
-		var maxx = centerx + new_distx / 2;
-		var maxy = centery + new_disty / 2;
-		this.setExtent(minx,miny,maxx,maxy);
-		//Todo:
-		//setMapRequest!
-	 };
-
-	/**
-	 * set the extent of the wms
-	 */
-	 this.setExtent = function(minx,miny,maxx,maxy){
-	 	this.extent = String(minx)+","+String(miny)+","+String(maxx)+","+String(maxy);
-	 };
-	
-	/**
-	 * get the srs of the mapObj
-	 *
-	 * @return srs as epsg:number  
-	 * @type string
-	 */
-	this.getSRS = function(){
-		return this.epsg;
-	};
-	
-	/**
-	 * get all mapRequests 
-	 *
-	 * @return array of mapRequests of this map object  
-	 * @type string[]  
-	 */
-	this.getMapRequests = function(){
-		var allRequests = [];
-		//loop through all wms to get the mapRequests
-		for(var i=0; i<this.wms.length; i++){
-			var currentRequest = this.wms[i].getMapRequest(this);
-			if(currentRequest){ 
-				allRequests.push(currentRequest);
-			}
-		}
-		if(allRequests.length > 0){
-			return allRequests;
-		}
-		return false;
-	};
-	
-	/**
-	 * get all MapRequests 
-	 *
-	 * @return array of all mapRequests of this map-object  
-	 * @type string[]  
-	 */
-	this.getMapRequests = function(){
-		var allRequests = [];
-		//loop through all wms to get the MapRequests
-		for(var i=0; i<this.wms.length; i++){
-			var currentRequest = this.wms[i].getMapRequest(this);
-			if(currentRequest){ 
-				allRequests.push(currentRequest);
-			}
-		}
-		if(allRequests.length > 0){
-			return allRequests;
-		}
-		return false;
-	};
-	
-	/**
-	 * get all featureInfoRequests 
-	 *
-	 * @member mb_mapObj_const
-	 * @param float x the x-value of the click position in pixel
-	 * @param float y the y-value of the click position in pixel
-	 * @return array of all featureInfoRequests of this map object  
-	 * @type string[]  
-	 */
-	this.getFeatureInfoRequests = function(clickPoint){
-		var allRequests = [];
-		//loop through all wms to get the FeatureInfoRequests
-		for(var i=0; i<this.wms.length; i++){
-			var currentRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
-			if(currentRequest){ 
-				allRequests.push(currentRequest);
-			}
-		}
-		if(allRequests.length > 0){
-			return allRequests;
-		}
-		return false;
-	};
-	
-	/**
-	 * calculation of the mapscale 
-	 *
-	 * @member mb_mapObj_const
-	 * @return scale  
-	 * @type integer  
-	 */
-	this.getScale = function(){
-		var scale;
-		var bbox = this.extent.split(",");
-		var xtenty;
-		if(this.epsg=="EPSG:4326"){
-			var pxLenx = (parseFloat(bbox[2])-parseFloat(bbox[0]))/this.width;
-			var pxLeny = (parseFloat(bbox[3])-parseFloat(bbox[1]))/this.height;
-			var lat_from = ((parseFloat(bbox[3])-parseFloat(bbox[1])/2)*Math.PI)/180;
-			var lat_to = ((parseFloat(bbox[3])-parseFloat(bbox[1])/2+pxLeny)*Math.PI)/180;
-			var lon_from = ((parseFloat(bbox[2])-parseFloat(bbox[0])/2)*Math.PI)/180;
-			var lon_to = ((parseFloat(bbox[2])-parseFloat(bbox[0])/2+pxLeny)*Math.PI)/180;
-			var dist=6371229*Math.acos(Math.sin(lat_from)*Math.sin(lat_to)+Math.cos(lat_from)*Math.cos(lat_to)*Math.cos(lon_from-lon_to));
-			scale = (dist/Math.SQRT2) * (mb_resolution * 100);
-		}else{
-			xtenty =  parseFloat(bbox[3]) - parseFloat(bbox[1]);
-			scale = (xtenty / this.height) * (mb_resolution * 100);
-		}
-		return Math.round(scale);
-	};
-	/**
-	 * move a wms or layer 
-	 *
-	 * @param int wms_id id of wms to move
-	 * @param int layer_id id of layer to move
-	 * @return true of successful
-	 * @type boolean
-	 */
-	this.move = function(wms_id, layer_id, moveUp){
-		var i,j;
-		for(i=0;i<this.wms.length;i++){
-			if (wms_id == this.wms[i].wms_id) {
-				break;
-			}
-		}
-		
-		//check if only one wms is affected?
-		if (layer_id && layer_id != this.wms[i].objLayer[0].layer_id) {
-			return this.wms[i].moveLayer(layer_id, moveUp);
-		}
-		
-		//else swap wms
-		j = i + (moveUp?-1:1);
-		if (!(i != j && i >= 0 && i < this.wms.length && j >= 0 && j < this.wms.length)) {
-			return false;
-		}
-		
-		upper = this.wms[i];
-		this.wms[i] = this.wms[j];
-		this.wms[j] = upper;
-		var upperLayers = this.layers[i];
-		var upperStyles = this.styles[i];
-		var upperQuerylayers = this.querylayers[i];
-		this.layers[i] = this.layers[j];
-		this.styles[i] = this.styles[j];
-		this.querylayers[i] = this.querylayers[j];
-		this.layers[j] = upperLayers;
-		this.styles[j] = upperStyles;
-		this.querylayers[j] = upperQuerylayers;
-		
-		return true;
-	};
-	
-	eventAfterMapObjectConstruction.trigger();
-}
-
 /*
  * get the conjunction character of an URL
  * @param {String} onlineresource
@@ -486,25 +103,22 @@
 }
 
 
-function mb_moveWmsById (mapObj_ind, wms_id, toIndex) {
-	return mb_wmsMoveByIndex(mapObj_ind, getWMSIndexById(mapObj_ind, wms_id), toIndex);
-}
-
 function mb_wmsMoveByIndex(mapObj_ind, fromIndex, toIndex) {
 	if (fromIndex != toIndex && fromIndex >= 0 && fromIndex < mb_mapObj[mapObj_ind].wms.length && toIndex >= 0 && toIndex < mb_mapObj[mapObj_ind].wms.length) {
 		var changed = false;
-
+		var i;
+		var result;
 		if (fromIndex > toIndex) {
-			for (var i = fromIndex; i > toIndex ; i--) {
-				var result = mb_swapWmsByIndex(mapObj_ind, i-1, i);
+			for (i = fromIndex; i > toIndex ; i--) {
+				result = mb_swapWmsByIndex(mapObj_ind, i-1, i);
 				if (result === true) {
 					changed = true;
 				}
 			}
 		}
 		else {
-			for (var i = fromIndex; i < toIndex ; i++) {
-				var result = mb_swapWmsByIndex(mapObj_ind, i, i+1);
+			for (i = fromIndex; i < toIndex ; i++) {
+				result = mb_swapWmsByIndex(mapObj_ind, i, i+1);
 				if (result === true) {
 					changed = true;
 				}
@@ -517,10 +131,6 @@
 	}
 }
 
-function mb_swapWmsById(mapObj_ind, wms1_id, wms2_id) {
-	return mb_swapWmsByIndex(mapObj_ind, getWMSIndexById(mapObj_ind, wms1_id), getWMSIndexById(mapObj_ind, wms2_id));
-}
-
 function mb_swapWmsByIndex(mapObj_ind, indexA, indexB) {
 	if (indexA != indexB && indexA >= 0 && indexA < mb_mapObj[mapObj_ind].wms.length && indexB >= 0 && indexB < mb_mapObj[mapObj_ind].wms.length) {
 		upper = mb_mapObj[mapObj_ind].wms[indexA];
@@ -542,24 +152,6 @@
 	}
 }
 
-function mb_moveUpWmsByIndex(mapObj_ind, index) {
-	if (index > 0 && index < wms.length) {
-		return mb_swapWmsByIndex(mapObj_ind, index-1, index);
-	}
-	else {
-		return false;
-	}
-}
-
-function mb_moveDownWmsByIndex(mapObj_ind, index) {
-	if (index >= 0 && index < wms.length-1) {
-		return mb_swapWmsByIndex(mapObj_ind, index, index+1);
-	}
-	else {
-		return false;
-	}
-}
-
 function mb_mapObjaddWMS(obj){
 	var cnt_layers = 0;
 	var cnt_querylayers = 0;
@@ -580,27 +172,16 @@
 	mb_execloadWmsSubFunctions();
 	return true; 
 }
-//CB
-function mb_mapObjaddWMSwithLayers(obj,layers,querylayers){
-	var cnt_layers = 0;
-	var cnt_querylayers = 0;
-	var styles = "";
-	var ind = getMapObjIndexByName(obj);
-	mb_mapObj[ind].wms[mb_mapObj[ind].wms.length] = wms[wms.length-1];
-	mb_mapObj[ind].layers[mb_mapObj[ind].layers.length] = layers;
-	mb_mapObj[ind].styles[mb_mapObj[ind].styles.length] = styles;
-	mb_mapObj[ind].querylayers[mb_mapObj[ind].querylayers.length] = querylayers;   
-}
 function mb_mapObjremoveWMS(objind,wmsind){
 	var wms_ID = null;
-	
+	var i;
 	var new_wmsarray = [];
 	var new_layerarray = [];
 	var new_querylayerarray = [];
 	var new_stylesarray = [];
 	var new_mapURLarray = [];
 	
-	for	(var i=0;i<mb_mapObj[objind].wms.length; i++){
+	for	(i=0;i<mb_mapObj[objind].wms.length; i++){
 		if(i != wmsind){
 			new_wmsarray[new_wmsarray.length] = mb_mapObj[objind].wms[i];
 			new_layerarray[new_layerarray.length] = mb_mapObj[objind].layers[i];
@@ -619,7 +200,7 @@
 	mb_mapObj[objind].mapURL = new_mapURLarray;
 
 	var another_new_wmsarray = [];
-	for	(var i=0;i<wms.length; i++){
+	for	(i=0;i<wms.length; i++){
 		if(wms[i].wms_id != wms_ID){
 			another_new_wmsarray[another_new_wmsarray.length] = wms[i]; 
 		}
@@ -657,246 +238,126 @@
 }
 function setMapRequest(frameName){
 	var functionName = 'setMapRequest';
-	var ts = mb_timestamp();
 
-
 	var ret = eventBeforeMapRequest.trigger({frameName:frameName}, "AND");
 	if (ret === false) {
 		return true;
 	}
-/*
-	for(var i=0; i<mb_MapRequestPreFunctions.length; i++){
-		var ret = eval(mb_MapRequestPreFunctions[i]);
-		if(ret == false){
-			return true;
+
+	var ts = mb_timestamp();
+	var myMapIds = [];
+	for (var i=0; i < mb_mapObj.length; i++){
+		var currentMapObject = mb_mapObj[i];
+		if (currentMapObject.frameName != frameName) {
+			continue;
 		}
-	}
-*/
-	for(var i=0; i<mb_mapObj.length; i++){
+		
 		var newMapRequest = "";
-		if(mb_mapObj[i].frameName == frameName){
-			for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){
-				if(mb_mapObj[i].wms[ii].gui_wms_visible > 0){
-					var myDivId = "div_" + ii;          
-					var myMapId = "map_" + ii;
-					//disable Layer which are out of scale
-					var validLayers = mb_checkScale(frameName,i,ii);
-					var layerNames = validLayers.toString();
-					if(mb_mapObj[i].layers[ii] !== "" && layerNames !== ''){
-						var newMapURL = "";
-
-						if (mb_mapObj[i].wms[ii].gui_wms_mapopacity != 1) {
- 							var cadenaOpacity = "opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity+"; Filter: Alpha(Opacity="+mb_mapObj[i].wms[ii].gui_wms_mapopacity*100+"); -moz-opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity+" ; -khtml-opacity:"+mb_mapObj[i].wms[ii].gui_wms_mapopacity;
-	 						newMapRequest += "<div id='"+myDivId+"' style=\"position:absolute; top:0px; left:0px; z-index:"+ii+";"+cadenaOpacity+"\">";
-						}
-						// IE problem: layers that are already transparent (defined in map file) 
-						// are sabotaged by the Mapbender opacity setting...
-						// this solution helps to display these layers correctly if no opacity
-						// manipulation is taking place in Mapbender
-						//
-						// solution needed for both WMS and Mapbender transparency in IE
-						// see: 
-						else {
-							newMapRequest += "<div id='"+myDivId+"' style='position:absolute; top:0px; left:0px; z-index:"+ii+"'>";
-						}
-
-						newMapRequest += "<img id='"+myMapId+"' name='mapimage' src='";
-						newMapURL += mb_mapObj[i].wms[ii].wms_getmap;   
-						
-						newMapURL += mb_getConjunctionCharacter(mb_mapObj[i].wms[ii].wms_getmap);
-						
-						if(mb_mapObj[i].wms[ii].wms_version == "1.0.0"){newMapURL += "WMTVER="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=map&";}
-						if(mb_mapObj[i].wms[ii].wms_version != "1.0.0"){newMapURL += "VERSION="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=GetMap&SERVICE=WMS&";} 
-						
-						newMapURL += "LAYERS="+layerNames+"&";
-						newMapURL += "STYLES=";
-						var layer = layerNames.split(",");
-						for(var j=0; j<layer.length; j++){
-							if(j>0){
-								newMapURL  += ",";
-							}
-							if(mb_mapObj[i].wms[ii].getCurrentStyleByLayerName(layer[j]) === false){
-								newMapURL  += "";
-							}
-							else{
-								newMapURL  += mb_mapObj[i].wms[ii].getCurrentStyleByLayerName(layer[j]);
-							}
-						}
-						newMapURL += "&";
-						newMapURL += "SRS="+mb_mapObj[i].epsg+"&";
-						newMapURL += "BBOX="+mb_mapObj[i].extent+"&";
-						newMapURL += "WIDTH="+mb_mapObj[i].width+"&";
-						newMapURL += "HEIGHT="+mb_mapObj[i].height+"&";
-						newMapURL += "FORMAT="+mb_mapObj[i].wms[ii].gui_wms_mapformat+"&";
-						newMapURL += "BGCOLOR=0xffffff&";
-						if(mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/gif/i)>-1 || mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/png/i)>-1){
-							newMapURL += "TRANSPARENT=TRUE&";
-						}
-						newMapURL += "EXCEPTIONS="+mb_mapObj[i].wms[ii].gui_wms_exceptionformat;
-						// add vendor-specifics
-						for(var v=0; v < mb_vendorSpecific.length; v++){
-							var vendorSpecificString = eval(mb_vendorSpecific[v]); 
-
-							// if eval doesn't evaluate a function, the result is undefined.
-							// Sometimes it is necessary not to evaluate a function, for
-							// example if you want to change a variable from the current
-							// scope (see mod_addSLD.php) 
-							if (typeof(vendorSpecificString) != "undefined") {
-								newMapURL += "&" + vendorSpecificString; 
-							}
-						}           
-						// add Filter
-						if(mb_mapObj[i].wms[ii].wms_filter !== ""){
-							var tmp = mb_mapObj[i].wms[ii].wms_filter +"?id="+ mb_styleID;
-
-							var temp = "&SLD=" + tmp+ "&";
-							newMapURL += temp;
-						}
-						// add sld
-						if(mb_mapObj[i].wms[ii].gui_wms_sldurl !== ""){
-							//alert(mb_mapObj[i].wms[ii].gui_wms_sldurl);
-							var temp = "&SLD=" + escape(mb_mapObj[i].wms[ii].gui_wms_sldurl) + "&";
-							newMapURL += temp;
-						}
-						if(mb_log){
-							var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
-						}
-						newMapRequest += newMapURL;
-						mb_mapObj[i].mapURL[ii] = newMapURL;	
-						mb_mapObj[i].wms[ii].mapURL = newMapURL;
-						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'></div>";   
-					}
-					else{
-						mb_mapObj[i].mapURL[ii] = false;
-						mb_mapObj[i].wms[ii].mapURL = false;
-						newMapRequest += "<div id='" + myDivId + "' style='position:absolute; top:0px; left:0px; z-index:" + ii + "'>";
-						newMapRequest += "<img id='"+myMapId+"' name='mapimage' src='" + mb_trans.src;
-						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'>";
-						newMapRequest +="</div>";
-					}
-				}
+		for (var ii = 0; ii < currentMapObject.wms.length; ii++){
+			var currentWms = currentMapObject.wms[ii];
+			if (!(currentWms.gui_wms_visible > 0)) {
+				continue;
 			}
-			//prompt("",newMapRequest);
-			writeTag(mb_mapObj[i].frameName,mb_mapObj[i].elementName,newMapRequest);
+			myMapIds.push("map_"+ii);
+			
+			newMapRequest += getLayerHtmlCode(frameName, i, ii);
+			
 		}
+		writeTag(mb_mapObj[i].frameName, mb_mapObj[i].elementName, newMapRequest);
 	}
-	eventAfterMapRequest.trigger({"frameName":frameName, "myMapId":myMapId});
+	eventAfterMapRequest.trigger({
+		"frameName": frameName,
+		"myMapIds": myMapIds.join(",")
+	});
 /*
 	for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
 		eval(mb_MapRequestSubFunctions[i]);
 	}
 */
 }
+
+function getLayerHtmlCode (frameName, i, ii) {
+	var currentMapObject = mb_mapObj[i];
+	var currentWms = currentMapObject.wms[ii];
+
+	var myDivId = "div_" + ii;          
+	var myMapId = "map_" + ii;
+	//disable Layer which are out of scale
+	var validLayers = mb_checkScale(frameName, i, ii);
+	var layerNames = validLayers.toString();
+
+	var newMapURL = false;
+	var opacityString = "";
+	if (currentMapObject.layers[ii] !== "" && layerNames !== ''){
+		// get map URL
+		newMapURL = currentMapObject.getMapUrl(i, ii);
+
+		var currentOpacity = currentWms.gui_wms_mapopacity;
+		if (currentOpacity != 1) {
+			opacityString += "opacity:" + currentOpacity + "; ";
+			opacityString += "Filter: Alpha(Opacity=" + currentOpacity*100 + "); ";
+			opacityString += "-moz-opacity:" + currentOpacity + " ; ";
+			opacityString += "-khtml-opacity:" + currentOpacity;
+		}
+	}
+
+	var imageString = "<img id='"+myMapId+"' name='mapimage' ";
+	imageString += "src='" + newMapURL + "' ";
+	imageString += "width='"+currentMapObject.width+"' ";
+	imageString += "height='"+currentMapObject.height+"' ";
+	imageString += "border='0'>";
+
+	var newMapRequest = "<div id='"+myDivId+"' ";
+	newMapRequest += "style=\"position:absolute; top:0px; left:0px; ";
+	newMapRequest += "z-index:" + ii + ";" + opacityString + "\">";
+	newMapRequest += imageString;
+	newMapRequest += "</div>";   
+
+	currentMapObject.mapURL[ii]= newMapURL;	
+	currentWms.mapURL = newMapURL;
+
+	if (mb_log && currentWms.mapURL) {
+		var tmp = eval(mb_log + "('" +newMapURL + "','" + ts + "')");
+	}
+
+	return newMapRequest;
+}
+
 function setSingleMapRequest(frameName,wms_id){
 	var functionName = 'setSingleMapRequest';
 	
+	eventBeforeMapRequest.trigger({frameName:frameName});
+
 	var ts = mb_timestamp();	
 
-	eventBeforeMapRequest.trigger({frameName:frameName});
-/*
-	for(var i=0; i<mb_MapRequestPreFunctions.length; i++){
-		eval(mb_MapRequestPreFunctions[i]);
-	}	
-*/
-	for(i=0; i<mb_mapObj.length; i++){
-		var newMapRequest = "";
-		if(mb_mapObj[i].frameName == frameName){
-			for(var ii=0; ii<mb_mapObj[i].wms.length; ii++){ 
-				var myDivId = "div_" + ii;
-				var myMapId = "map_" + ii;
-				//disable Layer which are out of scale
-				var validLayers = mb_checkScale(frameName,i,ii);
-				var layerNames = validLayers.toString();
-				
-				if(mb_mapObj[i].wms[ii].wms_id == wms_id){  
-					var newMapURL = "";
-					newMapRequest += "<img id='"+myMapId+"' name='mapimage' src='";
-					newMapURL += mb_mapObj[i].wms[ii].wms_getmap; 
+	for(i = 0; i < mb_mapObj.length; i++){
+		var currentMapObject = mb_mapObj[i];
+		if (currentMapObject.frameName != frameName) {
+			continue;
+		}
+		
+		for (var ii=0; ii < currentMapObject.wms.length; ii++){ 
+			var currentWms = currentMapObject.wms[ii];
+			if (currentWms.wms_id != wms_id) {
+				continue;
+			}
 
-					newMapURL += mb_getConjunctionCharacter(mb_mapObj[i].wms[ii].wms_getmap);
-						
-					if(mb_mapObj[i].wms[ii].wms_version == "1.0.0"){newMapURL += "WMTVER="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=map&";}
-					if(mb_mapObj[i].wms[ii].wms_version != "1.0.0"){newMapURL += "VERSION="+mb_mapObj[i].wms[ii].wms_version+"&REQUEST=GetMap&SERVICE=WMS&";}             
-					
-					newMapURL += "LAYERS="+layerNames+"&";
-					var layer = layerNames.split(",");
-					newMapURL += "STYLES=";
-					for(var j=0; j<layer.length; j++){
-						if(j>0){
-							newMapURL  += ",";
-						}
-						if(mb_mapObj[i].wms[ii].getCurrentStyleByLayerName(layer[j])===false){
-							newMapURL  += "";
-						}
-						else{
-							newMapURL  += mb_mapObj[i].wms[ii].getCurrentStyleByLayerName(layer[j]);
-						}
-					}
-					newMapURL += "&";
-					newMapURL += "SRS="+mb_mapObj[i].epsg+"&";
-					newMapURL += "BBOX="+mb_mapObj[i].extent+"&";
-					newMapURL += "WIDTH="+mb_mapObj[i].width+"&";
-					newMapURL += "HEIGHT="+mb_mapObj[i].height+"&";
-					newMapURL += "FORMAT="+mb_mapObj[i].wms[ii].gui_wms_mapformat+"&";
-					newMapURL += "BGCOLOR=0xffffff&";
-					if(mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/gif/i)>-1 || mb_mapObj[i].wms[ii].gui_wms_mapformat.search(/png/i)>-1){
-						newMapURL += "TRANSPARENT=TRUE&";
-					}
-					newMapURL += "EXCEPTIONS="+mb_mapObj[i].wms[ii].gui_wms_exceptionformat;
-					// add vendor-specific
-					for (var v = 0; v < mb_vendorSpecific.length; v++) {
-						var vendorSpecificString = eval(mb_vendorSpecific[v]); 
-						// if eval doesn't evaluate a function, the result is undefined.
-						// Sometimes it is necessary not to evaluate a function, for
-						// example if you want to change a variable from the current
-						// scope (see mod_addSLD.php) 
-						if (typeof(vendorSpecificString) != "undefined") {
-							newMapURL += "&" + vendorSpecificString;
-						} 
-					}
-					// add Filter
-					if(mb_mapObj[i].wms[ii].wms_filter !== ""){
-						var tmp = mb_mapObj[i].wms[ii].wms_filter +"?id="+ mb_styleID;
-						//prompt("",tmp);;
-						var temp = "&SLD=" + tmp+ "&";
-						newMapURL += temp;
-					}
-					// add sld
-					if(mb_mapObj[i].wms[ii].gui_wms_sldurl !== ""){
-						//alert(mb_mapObj[i].wms[ii].gui_wms_sldurl);
-						var temp = "&SLD=" + escape(mb_mapObj[i].wms[ii].gui_wms_sldurl) + "&";
-						newMapURL += temp;
-					}
+			var newMapRequest = getLayerHtmlCode(frameName, i, ii);
 
-					//prompt("",newMapURL);
-					if(mb_mapObj[i].layers[ii] !== "" && layerNames!==''){
-						newMapRequest += newMapURL;
-						mb_mapObj[i].mapURL[ii] = newMapURL;
-						mb_mapObj[i].wms[ii].mapURL = newMapURL;
-						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'>";
-					}
-					else{
-						mb_mapObj[i].mapURL[ii] = false;
-						mb_mapObj[i].wms[ii].mapURL = false;
-						newMapRequest = "<img id='"+myMapId+"' name='mapimage' src='" + mb_trans.src;
-						newMapRequest += "' width='"+mb_mapObj[i].width+"' height='"+mb_mapObj[i].height+"' border='0'>";
-					}        
-					//prompt("",newMapRequest);
-					if(mb_log){
-						var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
-					}
-					writeTag(mb_mapObj[i].frameName,myDivId,newMapRequest);
-				}                            
-			}           
+			if (mb_log) {
+				var tmp = eval(mb_log + "('" + newMapURL + "','" + ts + "')");
+			}
+			var myDivId = "div_" + ii;          
+			writeTag(currentMapObject.frameName, myDivId, newMapRequest);
+			var myMapId = "map_" + ii;
+			eventAfterMapRequest.trigger({"frameName":frameName, "myMapId":myMapId});
+			return true;
 		}      
-	}   
-	eventAfterMapRequest.trigger({"frameName":frameName, "myMapId":myMapId});
-/*
-	for(var i=0; i<mb_MapRequestSubFunctions.length; i++){
-		eval(mb_MapRequestSubFunctions[i]);
 	}  
-*/
+	return false; 
 }
+
+
 function mb_restateLayers(frameName,wms_id){
 	//alert(frameName + " / " + wms_id);
 	var ind = getMapObjIndexByName(frameName);	
@@ -1491,290 +952,8 @@
 		return false;
 	}
 }
-
 /*
  ***************************************************************************************
- *   div tag
- ***************************************************************************************
- */
-
-/**
- * @class Represents a div tag. May be located in any frame of Mapbender.
- * 
- * @constructor
- * @param aTagName {String} the name of the tag
- * @param aFrameName {String} the name of frame where the div tag is being created
- * @param aStyle {Object} an object containing a set of name value pairs, like
- *                        {position:absolute,top:30,z-Index:30}
- */
-function DivTag (aTagName, aFrameName, aStyle) {
-	/**
-	 * @ignore
-	 */
-	this.exists = function () { 
-		return (rootNode.getElementById(tagName)) ? true : false;
-	};
-	
-	/**
-	 * @ignore
-	 */
-	this.getTag = function() {
-		return rootNode.getElementById(tagName);
-	};
-	
-	/**
-	 * @private
-	 */
-	var determineRootNode = function () {
-		node = document;
-		if (frameName !== "") {
-			if (checkFrame()) {node = window.frames[frameName].document;}
-			else {var e = new Mb_exception("frame "+frameName+" doesn't exist.");}
-		}
-		return node;	
-	};
-	
-	/**
-	 * @private
-	 */
-	var toCamelCase = function(aString) {
-		var newString = "";
-		for (var i = 0; i < aString.length; i++) {
-			if (aString.substr(i,1) != "-") {
-				newString += aString.substr(i,1); 
-			}
-			else {
-				i++;
-				newString += aString.substr(i,1).toUpperCase();
-			}
-		}
-		return newString;
-	};
-	
-	/**
-	 * @private
-	 */
-	var setStyle = function () {
-		if (that.exists()) {
-			var node = rootNode.getElementById(tagName);
-			node.setAttribute("style", "");
-			
-			for (var attr in tagStyle) {
-				if (typeof(tagStyle[attr]) != "function" && typeof(tagStyle[attr]) != "object") {
-					var evalString = "node.style."+toCamelCase(attr)+" = \"" + tagStyle[attr] + "\";"; 
-					eval(evalString);				
-				}
-			}
-		}
-	};
-	
-	/**
-	 * @private
-	 */
-	var create = function () {
-		if (!that.exists()) {
-			var divTag = rootNode.createElement("div");
-			var divTagAppended = rootNode.getElementsByTagName("body")[0].appendChild(divTag);
-			divTagAppended.id = tagName;
-		}
-		else {
-			that.clean();
-		}
-		setStyle();
-	};
-
-	/**
-	 * @private
-	 */
-	var checkFrame = function () {
-		if (frameName !== "") {
-			return (typeof(window.frames[frameName]) != 'undefined');
-		}
-		return true;
-	};
-	
-	var that = this;
-	var tagName = aTagName;
-	var frameName = aFrameName;
-	var rootNode = determineRootNode();
-	var tagStyle = aStyle;
-
-	create();
-}
-/**
- * Writes a text into the div tag, while removing existing content.
- * 
- * @param {String} someText the text that is inserted into the tag.
- */
-DivTag.prototype.write = function (someText) {
-	if (this.exists()) {
-		this.getTag().innerHTML = someText;
-	}
-};
-
-/**
- * Deletes the div tag content.
- */
-DivTag.prototype.clean = function () {
-	this.write("");
-};
-
-
-/*
- ***************************************************************************************
- *   Javascript exception handling
- ***************************************************************************************
- */
-
-/**
- * @class An abstract class, logs JavaScript events like errors, warnings etc.
- *
- * @constructor
- */
-var Mb_log = function() {
-	var that = this;
-	
-	var levelArray = global_log_levels.split(",");
-	var log_level = global_mb_log_level;
-	var log_js = global_mb_log_js;
-	
-	var indexOfLevel = function(aLevel) {
-		for (var i = 0; i < levelArray.length; i++) {
-			if (aLevel == levelArray[i])  {
-				return i;
-			}
-		}
-		return false;
-	};
-	var isValidLevel = function(aLevel) {
-		var isNotOff = typeof(log_js) != 'undefined' && log_js != "off";
-		var levelIndex = indexOfLevel(aLevel);
-		var isAppropriate = (typeof(levelIndex)=='number' && levelIndex < indexOfLevel(log_level));
-		return (isNotOff && isAppropriate);
-	};
-	this.throwException = function (message, level) {
-		if (isValidLevel(level)) {
-			if (log_js == "on") {
-				try {
-					mb_ajax_post('../php/mb_js_exception.php', {level:level,text:message});
-				}
-				catch(e) {
-					alert(e + ": " + message);
-				}
-			}
-			else if (log_js == "alert") {
-				alert(message);
-			}
-			else if (log_js == "console") {
-				if (level == "warning") {
-					console.warn("%s", message);
-				}
-				else if (level == "error") {
-					console.error("%s", message);
-				}
-				else {
-					console.log("%s", message);
-				}
-			}
-		}
-	};
-};	
-
-/**
- *  class for exception logging
- *
- * @extends {@link Mb_log}
- * @param message the message that is being logged
- */	
-function Mb_exception(message) {
-	 var level = "error";
-	this.throwException(message, level);
-}
-Mb_exception.prototype = new Mb_log();
-
-/**
- *  class for warning logging
- *
- * @extends {@link Mb_log}
- * @param message the message that is being logged
- */
-function Mb_warning(message) {
-	var level = "warning";
-	this.throwException(message, level);
-}
-Mb_warning.prototype = new Mb_log();
- 
-/**
- *  class for notice logging
- *
- * @extends {@link Mb_log}
- * @param message the message that is being logged
- */	
- 
-function Mb_notice(message) {
-	var level = "notice";
-	this.throwException(message, level);
-}
-Mb_notice.prototype = new Mb_log();
-
-/*
- ***************************************************************************************
- *   AJAX wrapper functions
- ***************************************************************************************
- */
-/**
- * A wrapper for an AJAX request via GET 
- *
- * @param {String} url the URL of a (presumably a server side) script.
- * @param {Object} param An object containing parameters, f.e. {name1:value1, name2:value2}
- * @param {Function} callback A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (XML, HTML, whatever), status is a {String}, either "success" or "error". 
- */
-function mb_ajax_get(url, param, callback) {
-	try {
-//		$.ajaxSetup({async:false}); 
-		$.get(url, param, callback);
-	}
-	catch(e) {
-		var error = new Mb_exception('map.php: mb_ajax_get:'+e);
-	}
-}	
-
-/**
- * A wrapper for an AJAX request via POST 
- *
- * @param {String} url the URL of a (presumably a server side) script.
- * @param {Object} param An object containing parameters, f.e. {name1:value1, name2:value2}
- * @param {Function} callback A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (XML, HTML, whatever), status is a {String}, either "success" or "error". 
- */
-function mb_ajax_post(url, param, callback) {
-	try {
-//		$.ajaxSetup({async:false}); 
-		$.post(url, param, callback);
-	}
-	catch(e) {
-		var error = new Mb_exception('map.php: mb_ajax_post:'+e);
-	}
-}	
-	
-/**
- * A wrapper for an AJAX request via GET 
- *
- * @param {String} url the URL of a (presumably a server side) script.
- * @param {Object} param An object containing parameters, f.e. {name1:value1, name2:value2}
- * @param {Function} callback A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (a JavaScript Object, not a String!), status is a {String}, either "success" or "error". 
- */
-function mb_ajax_json(url, param, callback) {
-	try {
-//		window.frames['ajax'].$.ajaxSetup({async:false}); //TODO: find out why async doesn't work sometimes
-		$.getJSON(url, param, callback);
-	}
-	catch(e) {
-		var error = new Mb_exception('map.php: mb_ajax_json:'+e);
-	}
-}	
-
-/*
- ***************************************************************************************
  *   button handling
  ***************************************************************************************
  */
@@ -1977,118 +1156,6 @@
 }
 
 
-/**
- * @class A List object is an array of arbitrary objects with additional methods. 
- *
- * @constructor
- */
-var List = function() {
-	
-	/**
-	 * gets the number of elements in this {@link List}
-	 *
-	 * @returns number of elements in this {@link List}
-	 * @type Integer
-	 */
-	this.count = function() {
-		return this.list.length;
-	};
-
-	/**
-	 * deletes the object at index i; -1 refers to the last object in this {@link List}
-	 *
-	 * @param {Integer} i index
-	 */
-	this.del = function(i){
-		i = this.getIndex(i);
-		if (i !== false) {
-			for(var z = i; z < this.count() - 1; z++){
-				this.list[z] = this.list[z+1];
-			}
-			this.list.length -= 1;
-			return true;
-		}
-		return false;
-	};
-
-	/**
-	 * empties this {@link List}
-	 */
-	this.empty = function() {
-		while (this.list !== null && this.count() > 0) {
-			this.list.pop();
-		}
-	};
-	
-	/**
-	 * @param {Integer} i index
-	 * @returns the object at index i; -1 refers to the last object in this {@link List}
-	 * @type Integer or false
-	 */
-	this.get = function(i) {
-		i = this.getIndex(i);
-		if (i !== false) {return this.list[i];}
-		return false;		
-	};
-	/**
-	 * adds a reference to item to this {@link List}.
-	 *
-	 * @param {Object} item an object
-	 */
-	this.add = function(item) {
-		var i = this.list.length;
-		this.list[i] = item;
-	};
-	/**
-	 * adds a copy of item to this {@link List}.
-	 *
-	 * @param {Object} item an object
-	 */
-	this.addCopy = function(item) {
-		this.add(cloneObject(item));
-	};
-	/**
-	 * attaches the {@link List} aList to this {@link List}
-	 *
-	 * @param {List} aList another list
-	 */
-	this.union = function(aList) {
-		for (var i=0; i < aList.count(); i++) {this.addCopy(aList.get(i));}
-	};
-	/**
-	 * checks if the index is valid and returns it if it is; if i == -1, the correct index is retrieved.
-	 *
-	 * @private
-	 * @return Integer or false
-	 * @type Integer
-	 */
-	this.getIndex = function(i){ 
-		var len = this.list.length;
-		if (i<0 && len + i > -1) {
-			return len + i;			
-		}
-		else if (i > -1 && i < len){
-			return i;
-		}
-		var e = new Mb_exception("class List: function getIndex: member index " + i + " is not valid");
-		return false;
-	};
-	/**
-	 * @returns a {String} representation of this List
-	 * @type String
-	 */
-	this.toString = function(){
-		var str = "";
-		for (var i =0 ; i < this.count() ; i++){
-			str += this.get(i).toString();
-		}
-		return str;	
-	};	
-	
-	this.list = null;
-};
-
-
 /*
  ***************************************************************************************
  *   deprecated functions

Modified: branches/beck_dev/mapbender/http/javascripts/map.php
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/map.php	2008-05-09 16:00:35 UTC (rev 2451)
+++ branches/beck_dev/mapbender/http/javascripts/map.php	2008-05-15 09:02:56 UTC (rev 2452)
@@ -69,14 +69,20 @@
 echo "var global_log_levels = '".LOG_LEVEL_LIST."';";
 echo "var mb_feature_count = ".MB_FEATURE_COUNT.";";
 echo "var mb_resolution = ".MB_RESOLUTION.";";
+echo "var mb_security_proxy = '" . MB_SECURITY_PROXY . "';";
 
 //
 // Load JavaScript libraries
 //
 require_once(dirname(__FILE__) . "/../extensions/jquery.js");
+require_once(dirname(__FILE__) . "/../../lib/map_obj.js");
+require_once(dirname(__FILE__) . "/../../lib/exception.js");
+require_once(dirname(__FILE__) . "/../../lib/ajax.js");
+require_once(dirname(__FILE__) . "/../../lib/div.js");
+require_once(dirname(__FILE__) . "/../../lib/list.js");
 require_once(dirname(__FILE__) . "/../javascripts/map.js");
 require_once(dirname(__FILE__) . "/../javascripts/point.js");
-require_once(dirname(__FILE__) . "/../javascripts/map_obj.js");
+require_once(dirname(__FILE__) . "/../../lib/wms.js");
 require_once(dirname(__FILE__) . "/../javascripts/wfs_obj.js");
 require_once(dirname(__FILE__) . "/../extensions/jqjson.js");
 require_once(dirname(__FILE__) . "/../javascripts/style.js");

Deleted: branches/beck_dev/mapbender/http/javascripts/map_obj.js
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/map_obj.js	2008-05-09 16:00:35 UTC (rev 2451)
+++ branches/beck_dev/mapbender/http/javascripts/map_obj.js	2008-05-15 09:02:56 UTC (rev 2452)
@@ -1,777 +0,0 @@
-/* 
-* $Id$
-* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
-* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
-*/
-
-//global variables
-var wms = [];
-var wms_layer_count = 0;
-
-/*
- * global function to add wms to the wms-object
- * 
- * @param {String} wms_id the unique id of the wms 
- * @param {String} wms_version the version assumed from capabilities
- * @param {String} wms_title the title of the wms
- * @param {String} wms_abstract the abstract of the wms
- * @param {String} wms_getmap the url for map requests
- * @param {String} wms_getfeatureinfo the url for featureInof requests
- * @param {String} wms_getlegendurl the url for legend requests
- * @param {String} wms_filter a filter (deprecated)
- * @param {String} gui_wms_mapformat the image-format in the actual gui
- * @param {String} gui_wms_featureinfoformat the current format for featureInfos
- * @param {String} gui_wms_exceptionformat the exceptionformat for map requests
- * @param {String} gui_wms_epsg the current srs
- * @param {Integer} gui_wms_visible the visibility of this service
- * @param {Integer} gui_wms_opacity the initial display opacity in percent
- * @param {String} gui_wms_sldurl url to an actual sld
- */
-function add_wms(
-			wms_id,
-			wms_version,
-			wms_title,
-			wms_abstract,
-			wms_getmap,
-			wms_getfeatureinfo,
-			wms_getlegendurl,
-			wms_filter,
-			gui_wms_mapformat,
-			gui_wms_featureinfoformat,
-			gui_wms_exceptionformat,
-			gui_wms_epsg,
-			gui_wms_visible,
-			gui_wms_opacity,
-			gui_wms_sldurl){
-					wms[wms.length] = new wms_const( 
-					wms_id,
-					wms_version,
-					wms_title,
-					wms_abstract,
-					wms_getmap,
-					wms_getfeatureinfo,
-					wms_getlegendurl,
-					wms_filter,
-					gui_wms_mapformat,
-					gui_wms_featureinfoformat,
-					gui_wms_exceptionformat,
-					gui_wms_epsg,
-					parseInt(gui_wms_visible, 10),
-					parseInt(gui_wms_opacity),
-					parseInt(gui_wms_opacity),
-					gui_wms_sldurl);
-					wms_layer[wms.length - 1] = [];
-}
-/**
- * @class A class representing the wms
- *
- * @constructor
- * @param {String} wms_id the unique id of the wms 
- * @param {String} wms_version the version assumed from capabilities
- * @param {String} wms_title the title of the wms
- * @param {String} wms_abstract the abstract of the wms
- * @param {String} wms_getmap the url for map requests
- * @param {String} wms_getfeatureinfo the url for featureInof requests
- * @param {String} wms_getlegendurl the url for legend requests
- * @param {String} wms_filter a filter (deprecated)
- * @param {String} gui_wms_mapformat the image-format in the actual gui
- * @param {String} gui_wms_featureinfoformat the current format for featureInfos
- * @param {String} gui_wms_exceptionformat the exceptionformat for map requests
- * @param {String} gui_wms_epsg the current srs
- * @param {String} gui_wms_visible the visibility of this service
- * @param {Integer} gui_wms_opacity the initial display opacity in percent
- * @param {String} gui_wms_sldurl url to an actual sld
- * 
- */
-function wms_const(  
-			wms_id,
-			wms_version,
-			wms_title,
-			wms_abstract,
-			wms_getmap,
-			wms_getfeatureinfo,
-		    wms_getlegendurl,
-			wms_filter,
-			gui_wms_mapformat,
-			gui_wms_featureinfoformat,
-			gui_wms_exceptionformat,
-			gui_wms_epsg,
-			gui_wms_visible,
-			gui_wms_opacity,
-			gui_wms_sldurl){
-   
-	if (!wms_id) {
-		var id_ok = false;
-		while (id_ok === false) {
-			wms_id = "a"+Math.round(10000*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;
-	this.wms_abstract = wms_abstract;
-	this.wms_getmap = wms_getmap;
-	this.wms_getfeatureinfo = wms_getfeatureinfo;
-	this.wms_getlegendurl = wms_getlegendurl;
-	this.wms_filter = wms_filter;
-	this.data_type = [];
-	this.data_format = [];
-	this.objLayer = [];
-	this.gui_wms_mapformat = gui_wms_mapformat;
-	this.gui_wms_featureinfoformat = gui_wms_featureinfoformat;
-	this.gui_wms_exceptionformat = gui_wms_exceptionformat;
-	this.gui_wms_epsg = gui_wms_epsg;
-	this.gui_wms_visible = gui_wms_visible;
-	this.gui_epsg = [];
-	this.gui_minx = [];
-	this.gui_miny = [];
-	this.gui_maxx = [];
-	this.gui_maxy = [];
-
-	// opacity version 
-	this.gui_wms_mapopacity = gui_wms_opacity/100;
-	// sld version
-	this.gui_wms_sldurl = gui_wms_sldurl;      
-}
-
-/**
- * rephrases the mapRequest
- *
- * @param {Object} mapObj the mapbender mapObject of the wms  
- * @return mapRequest, i.e. onlineresource + params
- * @type String
- */
-wms_const.prototype.getMapRequest = function(mapObj){	
-	//check visible layers first
-	var layers = this.getLayers(mapObj);
-	if(!layers){
-		return false;
-	}
-	
-	var rq = this.wms_getmap;
-	rq += mb_getConjunctionCharacter(this.wms_getmap);
-	if(this.wms_version === "1.0.0"){
-		rq += "WMTVER=" + this.wms_version + "&REQUEST=map";
-	}
-	else{
-		rq += "VERSION=" + this.wms_version + "&REQUEST=getMap&SERVICE=WMS";
-	}
-	
-	rq += "&LAYERS=" + layers.join(",");
-	rq += "&WIDTH=" + mapObj.getWidth();
-	rq += "&HEIGHT=" + mapObj.getHeight();
-	rq += "&SRS=" + mapObj.getSRS();
-	rq += "&BBOX=" + mapObj.getExtent();
-	rq += "&STYLES=" + this.getLayerstyles(mapObj).join(",");
-	rq += "&FORMAT=" + this.gui_wms_mapformat;
-	rq += "&EXCEPTIONS=" + this.gui_wms_exceptionformat;
-	//Todo: error occurs:
-	//var throwNotice = new Mb_notice("getMapRequest: " + rq);
-	//window.console.log("getMapRequest: " + rq);
-	return rq;
-};
-
-
-/**
- * rephrases the featureInfoRequest
- *
- * @param {Object} mapObj the mapbender mapObject of the wms  
- * @param {Point} clickPoint map-click position {@link Point}
- * @return featureInfoRequest, onlineresource + params
- * @type string
- */
-wms_const.prototype.getFeatureInfoRequest = function(mapObj, clickPoint){	
-	
-	//check layers and querylayers first 
-	var layers = this.getLayers(mapObj);
-	var querylayers = this.getQuerylayers(mapObj);
-	
-	if(!layers || !querylayers){
-		return false;
-	}
-	
-	var rq = this.wms_getfeatureinfo;
-	rq += mb_getConjunctionCharacter(this.wms_getfeatureinfo);
-	if(this.wms_version === "1.0.0"){
-		rq += "WMTVER=" + this.wms_version + "&REQUEST=feature_info";
-	}
-	else{
-		rq += "VERSION=" + this.wms_version + "&REQUEST=GetFeatureInfo&SERVICE=WMS";
-	}
-	
-	rq += "&LAYERS=" + layers.join(",");
-	rq += "&QUERY_LAYERS=" + querylayers.join(",");
-	rq += "&WIDTH=" + mapObj.getWidth();
-	rq += "&HEIGHT=" + mapObj.getHeight();
-	rq += "&SRS=" + mapObj.getSRS();
-	rq += "&BBOX=" + mapObj.getExtent();
-	rq += "&STYLES=" + this.getLayerstyles(mapObj).join(",");
-	rq += "&FORMAT=" + this.gui_wms_mapformat;
-	rq += "&INFO_FORMAT=" + this.gui_wms_featureinfoformat;
-	rq += "&EXCEPTIONS=application/vnd.ogc.se_xml";
-	rq += "&X=" + clickPoint.x;
-	rq += "&Y=" + clickPoint.y;
-	//console.log(rq);
-	return rq;
-};
-
-/**
- * sets Opacity of WMS
- * 
- * @param {Integer} new opacity percentage value
- */
-wms_const.prototype.setOpacity = function(opacity){
-	//calc new opacity
-	this.gui_wms_mapopacity = parseInt(opacity)/100;
-	if(this.gui_wms_mapopacity>1||isNaN(this.gui_wms_mapopacity))
-		this.gui_wms_mapopacity=1;
-	if(this.gui_wms_mapopacity<0)
-		this.gui_wms_mapopacity=0;
-		
-	if (this.gui_wms_visible > 0) {
-
-		//get div id
-		var divId = null;
-		for (var i=0; i < wms.length; i++) {
-			if (this.wms_id == wms[i].wms_id) { 
-				var divId = 'div_'+i;
-				break;
-			}
-		}
-		if(!divId)
-			return;	
-		
-		//TODO: check if mapframe1 is the right mapframe
-		wmsImage = parent.mapframe1.document.getElementById(divId);
-		if (wmsImage != null) {
-			wmsImage.style.opacity = this.gui_wms_mapopacity;
-			wmsImage.style.MozOpacity = this.gui_wms_mapopacity;
-			wmsImage.style.KhtmlOpacity = this.gui_wms_mapopacity;
-			wmsImage.style.filter = "alpha(opacity=" + this.gui_wms_mapopacity*100 + ")";
-		}
-	}
-}
-
-/**
- * get all visible layers
- *
- * @return array of layernames 
- * @type string[]
- */
-wms_const.prototype.getLayers = function(mapObj){
-	
-	try {
-	//visibility of the wms
-	var wmsIsVisible = (this.gui_wms_visible > 0);
-	if(!wmsIsVisible){
-		return false;
-	}
-	visibleLayers = [];
-	for(var i=0; i< this.objLayer.length; i++){
-		var isVisible = (this.objLayer[i].gui_layer_visible === 1);
-		var hasNoChildren = (!this.objLayer[i].has_childs);
-		if (isVisible && hasNoChildren){
-			if(this.objLayer[i].checkScale(mapObj)){
-				//console.log("checkLayer: " + this.objLayer[i].layer_name);
-				visibleLayers.push(this.objLayer[i].layer_name);
-			}
-		}
-	}
-	if(visibleLayers.length === 0){
-		return false;
-	}
-	return visibleLayers;
-	}
-	catch (e) {
-		alert(e);
-	}
-};
-
-/**
- * get the actual style of all visible layers
- *
- * @return commaseparated list of actual layerstyles
- * @type string
- */
-wms_const.prototype.getLayerstyles = function(mapObj){
-	var layers = this.getLayers(mapObj);
-	var layerstyles = '';
-	var styles = [];
-	if(layers){
-		for(i = 0; i < layers.length; i++){
-			var style = this.getCurrentStyleByLayerName(layers[i]);
-			if(!style){
-				style = '';
-			}
-			styles.push(style);
-		}
-		return styles;
-	}
-	return false;
-};
-
-/**
- * check if layer is parentLayer
- *
- * @param layername
- * @return the parent value of the given layer
- * @type integer
- */
-wms_const.prototype.checkLayerParentByLayerName = function(layername){
-	for(var i=0; i< this.objLayer.length; i++){
-		if(this.objLayer[i].layer_name == layername){
-			return this.objLayer[i].layer_parent;
-		}
-	}
-};
-
-/**
- * get the title of the current layer
- *
- * @param layername
- * @return the title of the given layer
- * @type string
- */
-wms_const.prototype.getTitleByLayerName = function(layername){
-	for(var i=0; i< this.objLayer.length; i++){
-		if(this.objLayer[i].layer_name == layername){
-			return this.objLayer[i].layer_title;
-		}
-	}
-};
-
-/**
- * get the current style of the layer
- *
- * @param layername
- * @return the stylename of the given layer
- * @type string
- */
-wms_const.prototype.getCurrentStyleByLayerName = function(layername){
-	for(var i=0; i< this.objLayer.length; i++){
-		if(this.objLayer[i].layer_name == layername){
-			if(this.objLayer[i].gui_layer_style === '' || this.objLayer[i].gui_layer_style === null){
-				return false;
-			}
-			else{
-				return this.objLayer[i].gui_layer_style;	
-			}
-		}
-	}
-};
-
-/**
- * get the legendurl of the gui layer style
- *
- * @param stylename
- * @return the legendurl of the given style
- * @type string
- */
-wms_const.prototype.getLegendUrlByGuiLayerStyle = function(layername,guiLayerStyle){
-	for(var i=0; i< this.objLayer.length; i++){
-		if(this.objLayer[i].layer_name == layername){
-			if(this.objLayer[i].layer_style.length === 0){
-				return false;
-			}
-			for(var k=0; k< this.objLayer[i].layer_style.length; k++){
-				if(this.objLayer[i].layer_style[k].name == guiLayerStyle){
-					var legendUrl = this.objLayer[i].layer_style[k].legendurl;
-					if (this.gui_wms_sldurl !== "") {
-					 		legendUrl += "&SLD="+escape(this.gui_wms_sldurl);
-					}				
-					if(legendUrl !=='' && legendUrl !== null && typeof(legendUrl) != 'undefined'){
-						return legendUrl;
-					}
-					else {
-						return false;
-					}
-				}
-			}
-		}
-	}
-	return false;
-};
-
-/**
- * get all querylayers
- *
- * @return array of layernames
- * @type string[]
- */
-wms_const.prototype.getQuerylayers = function(){
-	queryLayers = [];
-	for(var i=0; i< this.objLayer.length; i++){
-		if(this.objLayer[i].gui_layer_querylayer === 1 && ! this.objLayer[i].has_childs ){
-			queryLayers.push(this.objLayer[i].layer_name);
-		}
-	}
-	if(queryLayers.length === 0){
-		return false;
-	}
-	return queryLayers;
-};
-
-/**
- * get a layer Object by layer_pos
- * 
- * @param int payer_pos layer_pos of layer you want to get
- * @return object layer
- */
-
-wms_const.prototype.getLayerByLayerPos = function(layer_pos){
-	for(var i=0;i<this.objLayer.length;i++){
-		if(this.objLayer[i].layer_pos == layer_pos) {
-			return this.objLayer[i];
-		}
-	}
-	return null;
-};
-/**
- * get the state of sublayers from a specified layer
- * 
- * @param int layer_id of the parent layer
- * @param String type "visible" or "querylayer"
- * @return int -1 if state differs else the state
- */
-
-wms_const.prototype.getSublayerState = function(layer_id, type){
-	var i;
-	var state=-1,value;
-	for(i = 0; i < this.objLayer.length; i++){
-		if(this.objLayer[i].layer_id==layer_id) {
-			break;
-		}
-	}
-	
-	//go throught sublayers
-	for(var j = i+1; j < this.objLayer.length; j++){
-		if(this.objLayer[i].parent_layer == this.objLayer[j].parent_layer) {
-			break;
-		}
-		if(type == "visible") {
-			value = this.objLayer[j].gui_layer_visible;
-		}
-		else if(type == "querylayer") {
-			value = this.objLayer[j].gui_layer_querylayer;
-		}
-		if(state == -1) {
-			state = value;
-		}
-		if(state != value) {
-			return -1;
-		}
-	}
-	
-	return state;
-};
-/**
- * handle change of visibility / quaryability of a layer
- * 
- * @param string layer_name of layer to handle
- * @param string type of change ("visible" or "querylayer")
- * @param int value of the change
- */
-wms_const.prototype.handleLayer = function(layer_name, type, value){
-	var i;
-	for(i = 0; i < this.objLayer.length; i++){
-		if(this.objLayer[i].layer_name==layer_name) {
-			break;
-		}
-	}
-	
-	//Set visibility/queryability of Layer and Sublayers
-	for(var j = i; j < this.objLayer.length; j++){
-		if (i != j && this.objLayer[i].layer_parent >= this.objLayer[j].layer_parent) {
-			break;
-		}
-		if(type == "visible") {
-			this.objLayer[j].gui_layer_visible = parseInt(value, 10);
-		}
-		else if(type=="querylayer") {
-			this.objLayer[j].gui_layer_querylayer = parseInt(value, 10);
-		}
-	}
-
-	//Update visibility/queryability of parent layer
-	var parentLayer = this.getLayerByLayerPos(this.objLayer[i].layer_parent);
-	if(parentLayer){
-		var state = this.getSublayerState(parentLayer.layer_id, type);
-		if(state!=-1){
-			if(type == "visible") {
-				this.objLayer[j].gui_layer_visible = state;
-			}
-			else if(type=="querylayer") {
-				this.objLayer[j].gui_layer_querylayer = state;
-			}
-		}
-	}
-};
-
-
-/**
- * move a layer (with his sublayers) up or down
- * 
- * @param int layerId layer_id of layer to move
- * @param boolean moveUp true to move up or false to move down
- * @return boolean success
- */
-
-wms_const.prototype.moveLayer = function(layerId, moveUp){
-	var iLayer=-1;
-	var i;
-	
-	//find layer to move
-	for(i=0;i<this.objLayer.length;i++){
-		if(this.objLayer[i].layer_id==layerId){
-			iLayer=i;
-			break;
-		}
-	}
-	if(iLayer==-1) {
-		return false;
-	}
-	
-	var upperLayer = -1;
-	var lowerLayer = -1;
-	
-	//find layer to swap position with
-	var parentLayer = this.objLayer[iLayer].layer_parent;	
-	if(moveUp){
-		lowerLayer = iLayer;
-		
-		//find previous layer on same level
-		for(i=iLayer-1;i>0;i--){
-			if(parentLayer == this.objLayer[i].layer_parent){
-				upperLayer = i;
-				break;
-			}
-		}
-		if(upperLayer == -1){
-			//alert("The Layer you selected is already on top of parent Layer/WMS");
-			return false;
-		}
-	}
-	else{
-		upperLayer = iLayer;
-		
-		//find next layer on same level
-		for(i=iLayer+1;i<this.objLayer.length;i++){
-			if(parentLayer == this.objLayer[i].layer_parent){
-				lowerLayer = i;
-				break;
-			}
-		}
-		if(lowerLayer == -1){
-			//alert("The Layer you selected is already on bottom of parent Layer/WMS");
-			return false;
-		}
-	}
-	
-	//calc number of layers to move down
-	var layersDown = lowerLayer - upperLayer;
-	
-	//get number of layers to move up
-	for(i=lowerLayer+1; i<this.objLayer.length; i++){
-		if(parentLayer == this.objLayer[i].layer_parent){
-			break;
-		}
-	}
-	var layersUp = i - lowerLayer;
-	
-	//do moving
-	var temp = [];
-	for(i=0;i<layersDown+layersUp;i++){
-		temp[temp.length]=this.objLayer[upperLayer+i];
-	}
-	for(i=0;i<layersUp;i++){
-		this.objLayer[upperLayer+i]=temp[i+layersDown];
-	}
-	for(i=0;i<layersDown;i++){
-		this.objLayer[upperLayer+layersUp+i]=temp[i];
-	}
-
-	return true;
-};
-
-function wms_add_data_type_format(datatype,dataformat){
-	var insertDataFormat = true;
-	for (var i = 0 ; i < wms[wms.length-1].data_type.length ; i ++) {
-		if (wms[wms.length-1].data_type[i] == datatype && wms[wms.length-1].data_format[i] == dataformat) {
-			insertDataFormat = false;
-		}
-	}
-	if (insertDataFormat === true) {
-		wms[wms.length-1].data_type[wms[wms.length-1].data_type.length] = datatype;
-		wms[wms.length-1].data_format[wms[wms.length-1].data_format.length] = dataformat;
-	}
-}
-function wms_addSRS(epsg,minx,miny,maxx,maxy){
-	wms[wms.length-1].gui_epsg[wms[wms.length-1].gui_epsg.length] = epsg;
-	wms[wms.length-1].gui_minx[wms[wms.length-1].gui_minx.length] = minx;
-	wms[wms.length-1].gui_miny[wms[wms.length-1].gui_miny.length] = miny;
-	wms[wms.length-1].gui_maxx[wms[wms.length-1].gui_maxx.length] = maxx;
-	wms[wms.length-1].gui_maxy[wms[wms.length-1].gui_maxy.length] = maxy;
-}
-function wms_addLayerStyle(styleName, styleTitle, count, layerCount, styleLegendUrl, styleLegendUrlFormat){
-	var currentLayer = wms[wms.length-1].objLayer[layerCount]; 
-	if (currentLayer) {
-		currentLayer.layer_style[count] = {};
-		currentLayer.layer_style[count].name = styleName;
-		currentLayer.layer_style[count].title = styleTitle;
-		currentLayer.layer_style[count].legendurl = styleLegendUrl;
-		currentLayer.layer_style[count].legendurlformat = styleLegendUrlFormat;
-	}
-}
-//TODO: add layerstyle handling....
-//layer
-function wms_add_layer(
-			layer_parent,
-			layer_uid,
-			layer_name,
-			layer_title,
-			layer_dataurl_href,
-			layer_pos,
-			layer_queryable,
-			layer_minscale,
-			layer_maxscale,
-			layer_metadataurl,
-			gui_layer_wms_id,
-			gui_layer_status,
-			gui_layer_style,
-			gui_layer_selectable,
-			gui_layer_visible,
-			gui_layer_queryable,
-			gui_layer_querylayer,
-			gui_layer_minscale,
-			gui_layer_maxscale,
-			gui_layer_wfs_featuretype){
-                      
-	wms[wms.length-1].objLayer[wms[wms.length-1].objLayer.length] = new wms_layer(
-											layer_parent,
-											layer_uid,
-											layer_name,
-											layer_title,
-											layer_dataurl_href,
-											layer_pos,
-											layer_queryable,
-											layer_minscale,
-											layer_maxscale,
-											layer_metadataurl,
-											gui_layer_wms_id,
-											gui_layer_status,
-											gui_layer_style,
-											parseInt(gui_layer_selectable, 10),
-											parseInt(gui_layer_visible, 10),
-											parseInt(gui_layer_queryable, 10),
-											parseInt(gui_layer_querylayer, 10),
-											parseInt(gui_layer_minscale, 10),
-											parseInt(gui_layer_maxscale, 10),
-											gui_layer_wfs_featuretype );
-	var parentLayer = wms[wms.length-1].getLayerByLayerPos(parseInt(layer_parent, 10));
-	if(parentLayer) {
-		parentLayer.has_childs = true;
-	}
-}
-function layer_addEpsg(epsg,minx,miny,maxx,maxy){
-	var j = wms[wms.length-1].objLayer.length-1;
-	var k = wms[wms.length-1].objLayer[j].layer_epsg.length;
-	var currentLayer = wms[wms.length-1].objLayer[j];
-	currentLayer.layer_epsg[k]={};
-	currentLayer.layer_epsg[k].epsg = epsg;
-	currentLayer.layer_epsg[k].minx = minx;
-	currentLayer.layer_epsg[k].miny = miny;
-	currentLayer.layer_epsg[k].maxx = maxx;
-	currentLayer.layer_epsg[k].maxy = maxy;
-}
-function wms_layer(
-			layer_parent,
-			wms_layer_uid,
-			layer_name,
-			layer_title,
-			layer_dataurl_href,
-			layer_pos,
-			layer_queryable,
-			layer_minscale,
-			layer_maxscale,
-			layer_metadataurl,
-			gui_layer_wms_id,
-			gui_layer_status,
-			gui_layer_style,
-			gui_layer_selectable,
-			gui_layer_visible,
-			gui_layer_queryable,
-			gui_layer_querylayer,
-			gui_layer_minscale,
-			gui_layer_maxscale,
-			gui_layer_wfs_featuretype){
-	this.layer_id = wms_layer_count;
-	this.layer_uid = wms_layer_uid;
-	this.layer_parent = layer_parent;
-	this.layer_name = layer_name;
-	this.layer_title = layer_title;
-	this.layer_dataurl_href = layer_dataurl_href;
-	this.layer_pos = layer_pos;
-	this.layer_queryable = layer_queryable;
-	this.layer_minscale = layer_minscale;
-	this.layer_maxscale = layer_maxscale;
-	this.layer_metadataurl = layer_metadataurl;
-	this.layer_epsg = [];
-	this.gui_layer_wms_id = gui_layer_wms_id;
-	this.gui_layer_status = gui_layer_status;
-	this.gui_layer_selectable = gui_layer_selectable;
-	this.gui_layer_visible = gui_layer_visible;
-	this.gui_layer_queryable = gui_layer_queryable;
-	this.gui_layer_querylayer = gui_layer_querylayer;
-	this.gui_layer_minscale = gui_layer_minscale;
-	this.gui_layer_maxscale = gui_layer_maxscale;
-	this.gui_layer_style = gui_layer_style;
-	this.gui_layer_wfs_featuretype = gui_layer_wfs_featuretype;
-	this.gui_layer_style = null;
-	this.has_childs = false;
-	this.layer_style = [];
-	wms_layer_count++;
-}
-/**
- * check the scale of the layer
- *
- * @param Object mapObj the mapbender mapObject of the layer
- * @return boolean if the layer is in scale or not
- * @type boolean
- */
-wms_layer.prototype.checkScale = function(mapObj){
-	var minScale = parseInt(this.gui_layer_minscale, 10);
-	var maxScale = parseInt(this.gui_layer_maxscale, 10);
-	var currentScale = parseInt(mapObj.getScale(), 10);
-	if(minScale === 0 && maxScale === 0){
-		return true;
-	}
-	if(minScale > currentScale || (maxScale !== 0 && maxScale < currentScale)) {
-		return false;
-	}	
-	return true;
-};
-/**
- * set visibility of the layer
- * @param boolean visible visibility on/off
- */
-wms_layer.prototype.setVisible = function(visible){
-	this.gui_layer_visible = parseInt(visible, 10);
-	//console.log("setVisible(%i) for Layer %s",visible, this.layer_name);
-};
-
-/**
- * set queryability of the layer
- * @param boolean queryable queryability on/off
- */
-
-wms_layer.prototype.setQueryable = function(queryable){
-	this.gui_layer_querylayer = parseInt(queryable, 10);
-	//console.log("setQueryable(%i) for Layer %s",queryable, this.layer_name);
-};
\ No newline at end of file

Modified: branches/beck_dev/mapbender/http/javascripts/mod_sandclock.php
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/mod_sandclock.php	2008-05-09 16:00:35 UTC (rev 2451)
+++ branches/beck_dev/mapbender/http/javascripts/mod_sandclock.php	2008-05-15 09:02:56 UTC (rev 2452)
@@ -31,17 +31,27 @@
 var mod_sandclock_img = new Image();
 mod_sandclock_img.src = mod_sandclock_image;
 
-mb_registerSubFunctions("mod_sandclock(true,myMapId)");
+mb_registerSubFunctions("mod_sandclock(true,myMapIds)");
 
-function mod_sandclock(start,myMapId){
+function mod_sandclock(start,myMapIds){
 	var ind = getMapObjIndexByName(mod_sandclock_target);
 	if(start){
 		var temp = "<img src='"+mod_sandclock_img.src+"'>";
 		writeTag(mod_sandclock_target, "sandclock", temp);
 		mb_arrangeElement(mod_sandclock_target, "sandclock", (mb_mapObj[ind].width/2 - 16), (mb_mapObj[ind].height/2 - 16));
 	}
-	aktiv = setTimeout("mod_sandclock('','"+myMapId+"')",100);
-	if(window.frames[mod_sandclock_target].document.getElementById(myMapId) && window.frames[mod_sandclock_target].document.getElementById(myMapId).complete){
+	aktiv = setTimeout("mod_sandclock('','"+myMapIds+"')",10);
+	var myMapIdArray = myMapIds.split(",");
+	var complete = true;
+	var myMapId;
+	for (var i = 0; i < myMapIdArray.length && complete; i++) {
+		myMapId = myMapIdArray[i];
+		if(window.frames[mod_sandclock_target].document.getElementById(myMapId) && 
+			!window.frames[mod_sandclock_target].document.getElementById(myMapId).complete) {
+			complete = false;
+		}
+	}
+	if (complete) {
 		clearTimeout(aktiv);
 		writeTag(mod_sandclock_target, "sandclock", "");
 	} 

Modified: branches/beck_dev/mapbender/http/javascripts/mod_sandclock2.php
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/mod_sandclock2.php	2008-05-09 16:00:35 UTC (rev 2451)
+++ branches/beck_dev/mapbender/http/javascripts/mod_sandclock2.php	2008-05-15 09:02:56 UTC (rev 2452)
@@ -29,7 +29,7 @@
 mb_registerSubFunctions("mod_sandclock(true,myMapId)");
 
 
-function mod_sandclock(start,myMapId){
+function mod_sandclock(start){
 	var ind = getMapObjIndexByName(mod_sandclock_target);
 	if(start){  
 		mod_sandclock_count = mod_sandclock_maxWait; 
@@ -44,7 +44,7 @@
 	}
 
 	// check images:
-	aktiv = setTimeout("mod_sandclock('','"+myMapId+"')",100);
+	aktiv = setTimeout("mod_sandclock(false)",100);
 	mod_sandclock_count -= 1000;
 
 	var allMaps = window.frames[mod_sandclock_target].document.getElementsByName("mapimage");

Modified: branches/beck_dev/mapbender/http/javascripts/mod_switchLocale_noreload.php
===================================================================
--- branches/beck_dev/mapbender/http/javascripts/mod_switchLocale_noreload.php	2008-05-09 16:00:35 UTC (rev 2451)
+++ branches/beck_dev/mapbender/http/javascripts/mod_switchLocale_noreload.php	2008-05-15 09:02:56 UTC (rev 2452)
@@ -32,7 +32,7 @@
 	var lang = document.getElementById("language").options[index].value;
 	mb_ajax_post("../php/mod_setLocale.php", {"lang":lang}, function(result, status) {
 		mapbender.locale = result;
-		localize();	
+		eventLocalize.trigger();
 	});
 }
 

Modified: branches/beck_dev/mapbender/http/php/mod_addWmsFromFeatureInfo.php
===================================================================
--- branches/beck_dev/mapbender/http/php/mod_addWmsFromFeatureInfo.php	2008-05-09 16:00:35 UTC (rev 2451)
+++ branches/beck_dev/mapbender/http/php/mod_addWmsFromFeatureInfo.php	2008-05-15 09:02:56 UTC (rev 2452)
@@ -55,5 +55,4 @@
 		mb_wmsMoveByIndex(getMapObjIndexByName(mod_target), mb_mapObj[getMapObjIndexByName(mod_target)].wms.length-1, mod_addWmsFromFeatureInfo_position-1);
 	}
 	eventAfterLoadWMS.unregister("addWmsFromInfo_pos()");
-//	mb_removeFunctionFromArray("mb_loadWmsSubFunctions", "addWmsFromInfo_pos()");	
 }
\ No newline at end of file

Modified: branches/beck_dev/mapbender/http/php/system.php
===================================================================
--- branches/beck_dev/mapbender/http/php/system.php	2008-05-09 16:00:35 UTC (rev 2451)
+++ branches/beck_dev/mapbender/http/php/system.php	2008-05-15 09:02:56 UTC (rev 2452)
@@ -28,7 +28,7 @@
 #
 define("MB_RESOLUTION", "28.35");
 define("MB_FEATURE_COUNT", "100");
-
+define("MB_SECURITY_PROXY", "http://wms1.ccgis.de/mapbender/tools/security_proxy.php?mb_ows_security_proxy=");
 #
 # available log levels 
 #

Added: branches/beck_dev/mapbender/lib/ajax.js
===================================================================
--- branches/beck_dev/mapbender/lib/ajax.js	                        (rev 0)
+++ branches/beck_dev/mapbender/lib/ajax.js	2008-05-15 09:02:56 UTC (rev 2452)
@@ -0,0 +1,63 @@
+/* 
+* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+
+
+/*
+ ***************************************************************************************
+ *   AJAX wrapper functions
+ ***************************************************************************************
+ */
+/**
+ * A wrapper for an AJAX request via GET 
+ *
+ * @param {String} url the URL of a (presumably a server side) script.
+ * @param {Object} param An object containing parameters, f.e. {name1:value1, name2:value2}
+ * @param {Function} callback A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (XML, HTML, whatever), status is a {String}, either "success" or "error". 
+ */
+function mb_ajax_get(url, param, callback) {
+	try {
+//		$.ajaxSetup({async:false}); 
+		$.get(url, param, callback);
+	}
+	catch(e) {
+		var error = new Mb_exception('map.php: mb_ajax_get:'+e);
+	}
+}	
+
+/**
+ * A wrapper for an AJAX request via POST 
+ *
+ * @param {String} url the URL of a (presumably a server side) script.
+ * @param {Object} param An object containing parameters, f.e. {name1:value1, name2:value2}
+ * @param {Function} callback A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (XML, HTML, whatever), status is a {String}, either "success" or "error". 
+ */
+function mb_ajax_post(url, param, callback) {
+	try {
+//		$.ajaxSetup({async:false}); 
+		$.post(url, param, callback);
+	}
+	catch(e) {
+		var error = new Mb_exception('map.php: mb_ajax_post:'+e);
+	}
+}	
+	
+/**
+ * A wrapper for an AJAX request via GET 
+ *
+ * @param {String} url the URL of a (presumably a server side) script.
+ * @param {Object} param An object containing parameters, f.e. {name1:value1, name2:value2}
+ * @param {Function} callback A function that is called when the server side script has been processed. The function is called with two parameters, result and status. Result is the output of the server side script (a JavaScript Object, not a String!), status is a {String}, either "success" or "error". 
+ */
+function mb_ajax_json(url, param, callback) {
+	try {
+//		window.frames['ajax'].$.ajaxSetup({async:false}); //TODO: find out why async doesn't work sometimes
+		$.getJSON(url, param, callback);
+	}
+	catch(e) {
+		var error = new Mb_exception('map.php: mb_ajax_json:'+e);
+	}
+}	
+

Added: branches/beck_dev/mapbender/lib/div.js
===================================================================
--- branches/beck_dev/mapbender/lib/div.js	                        (rev 0)
+++ branches/beck_dev/mapbender/lib/div.js	2008-05-15 09:02:56 UTC (rev 2452)
@@ -0,0 +1,133 @@
+/* 
+* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+
+
+/*
+ ***************************************************************************************
+ *   div tag
+ ***************************************************************************************
+ */
+
+/**
+ * @class Represents a div tag. May be located in any frame of Mapbender.
+ * 
+ * @constructor
+ * @param aTagName {String} the name of the tag
+ * @param aFrameName {String} the name of frame where the div tag is being created
+ * @param aStyle {Object} an object containing a set of name value pairs, like
+ *                        {position:absolute,top:30,z-Index:30}
+ */
+function DivTag (aTagName, aFrameName, aStyle) {
+	/**
+	 * @ignore
+	 */
+	this.exists = function () { 
+		return (rootNode.getElementById(tagName)) ? true : false;
+	};
+	
+	/**
+	 * @ignore
+	 */
+	this.getTag = function() {
+		return rootNode.getElementById(tagName);
+	};
+	
+	/**
+	 * @private
+	 */
+	var determineRootNode = function () {
+		node = document;
+		if (frameName !== "") {
+			if (checkFrame()) {node = window.frames[frameName].document;}
+			else {var e = new Mb_exception("frame "+frameName+" doesn't exist.");}
+		}
+		return node;	
+	};
+	
+	/**
+	 * @private
+	 */
+	var toCamelCase = function(aString) {
+		var newString = "";
+		for (var i = 0; i < aString.length; i++) {
+			if (aString.substr(i,1) != "-") {
+				newString += aString.substr(i,1); 
+			}
+			else {
+				i++;
+				newString += aString.substr(i,1).toUpperCase();
+			}
+		}
+		return newString;
+	};
+	
+	/**
+	 * @private
+	 */
+	var setStyle = function () {
+		if (that.exists()) {
+			var node = rootNode.getElementById(tagName);
+			node.setAttribute("style", "");
+			
+			for (var attr in tagStyle) {
+				if (typeof(tagStyle[attr]) != "function" && typeof(tagStyle[attr]) != "object") {
+					var evalString = "node.style."+toCamelCase(attr)+" = \"" + tagStyle[attr] + "\";"; 
+					eval(evalString);				
+				}
+			}
+		}
+	};
+	
+	/**
+	 * @private
+	 */
+	var create = function () {
+		if (!that.exists()) {
+			var divTag = rootNode.createElement("div");
+			var divTagAppended = rootNode.getElementsByTagName("body")[0].appendChild(divTag);
+			divTagAppended.id = tagName;
+		}
+		else {
+			that.clean();
+		}
+		setStyle();
+	};
+
+	/**
+	 * @private
+	 */
+	var checkFrame = function () {
+		if (frameName !== "") {
+			return (typeof(window.frames[frameName]) != 'undefined');
+		}
+		return true;
+	};
+	
+	var that = this;
+	var tagName = aTagName;
+	var frameName = aFrameName;
+	var rootNode = determineRootNode();
+	var tagStyle = aStyle;
+
+	create();
+}
+/**
+ * Writes a text into the div tag, while removing existing content.
+ * 
+ * @param {String} someText the text that is inserted into the tag.
+ */
+DivTag.prototype.write = function (someText) {
+	if (this.exists()) {
+		this.getTag().innerHTML = someText;
+	}
+};
+
+/**
+ * Deletes the div tag content.
+ */
+DivTag.prototype.clean = function () {
+	this.write("");
+};

Added: branches/beck_dev/mapbender/lib/exception.js
===================================================================
--- branches/beck_dev/mapbender/lib/exception.js	                        (rev 0)
+++ branches/beck_dev/mapbender/lib/exception.js	2008-05-15 09:02:56 UTC (rev 2452)
@@ -0,0 +1,103 @@
+/* 
+* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+
+
+/*
+ ***************************************************************************************
+ *   Javascript exception handling
+ ***************************************************************************************
+ */
+
+/**
+ * @class An abstract class, logs JavaScript events like errors, warnings etc.
+ *
+ * @constructor
+ */
+var Mb_log = function() {
+	var that = this;
+	
+	var levelArray = global_log_levels.split(",");
+	var log_level = global_mb_log_level;
+	var log_js = global_mb_log_js;
+	
+	var indexOfLevel = function(aLevel) {
+		for (var i = 0; i < levelArray.length; i++) {
+			if (aLevel == levelArray[i])  {
+				return i;
+			}
+		}
+		return false;
+	};
+	var isValidLevel = function(aLevel) {
+		var isNotOff = typeof(log_js) != 'undefined' && log_js != "off";
+		var levelIndex = indexOfLevel(aLevel);
+		var isAppropriate = (typeof(levelIndex)=='number' && levelIndex < indexOfLevel(log_level));
+		return (isNotOff && isAppropriate);
+	};
+	this.throwException = function (message, level) {
+		if (isValidLevel(level)) {
+			if (log_js == "on") {
+				try {
+					mb_ajax_post('../php/mb_js_exception.php', {level:level,text:message});
+				}
+				catch(e) {
+					alert(e + ": " + message);
+				}
+			}
+			else if (log_js == "alert") {
+				alert(message);
+			}
+			else if (log_js == "console") {
+				if (level == "warning") {
+					console.warn("%s", message);
+				}
+				else if (level == "error") {
+					console.error("%s", message);
+				}
+				else {
+					console.log("%s", message);
+				}
+			}
+		}
+	};
+};	
+
+/**
+ *  class for exception logging
+ *
+ * @extends {@link Mb_log}
+ * @param message the message that is being logged
+ */	
+function Mb_exception(message) {
+	 var level = "error";
+	this.throwException(message, level);
+}
+Mb_exception.prototype = new Mb_log();
+
+/**
+ *  class for warning logging
+ *
+ * @extends {@link Mb_log}
+ * @param message the message that is being logged
+ */
+function Mb_warning(message) {
+	var level = "warning";
+	this.throwException(message, level);
+}
+Mb_warning.prototype = new Mb_log();
+ 
+/**
+ *  class for notice logging
+ *
+ * @extends {@link Mb_log}
+ * @param message the message that is being logged
+ */	
+ 
+function Mb_notice(message) {
+	var level = "notice";
+	this.throwException(message, level);
+}
+Mb_notice.prototype = new Mb_log();
\ No newline at end of file

Added: branches/beck_dev/mapbender/lib/list.js
===================================================================
--- branches/beck_dev/mapbender/lib/list.js	                        (rev 0)
+++ branches/beck_dev/mapbender/lib/list.js	2008-05-15 09:02:56 UTC (rev 2452)
@@ -0,0 +1,117 @@
+/* 
+* $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+
+/**
+ * @class A List object is an array of arbitrary objects with additional methods. 
+ *
+ * @constructor
+ */
+var List = function() {
+	
+	/**
+	 * gets the number of elements in this {@link List}
+	 *
+	 * @returns number of elements in this {@link List}
+	 * @type Integer
+	 */
+	this.count = function() {
+		return this.list.length;
+	};
+
+	/**
+	 * deletes the object at index i; -1 refers to the last object in this {@link List}
+	 *
+	 * @param {Integer} i index
+	 */
+	this.del = function(i){
+		i = this.getIndex(i);
+		if (i !== false) {
+			for(var z = i; z < this.count() - 1; z++){
+				this.list[z] = this.list[z+1];
+			}
+			this.list.length -= 1;
+			return true;
+		}
+		return false;
+	};
+
+	/**
+	 * empties this {@link List}
+	 */
+	this.empty = function() {
+		while (this.list !== null && this.count() > 0) {
+			this.list.pop();
+		}
+	};
+	
+	/**
+	 * @param {Integer} i index
+	 * @returns the object at index i; -1 refers to the last object in this {@link List}
+	 * @type Integer or false
+	 */
+	this.get = function(i) {
+		i = this.getIndex(i);
+		if (i !== false) {return this.list[i];}
+		return false;		
+	};
+	/**
+	 * adds a reference to item to this {@link List}.
+	 *
+	 * @param {Object} item an object
+	 */
+	this.add = function(item) {
+		var i = this.list.length;
+		this.list[i] = item;
+	};
+	/**
+	 * adds a copy of item to this {@link List}.
+	 *
+	 * @param {Object} item an object
+	 */
+	this.addCopy = function(item) {
+		this.add(cloneObject(item));
+	};
+	/**
+	 * attaches the {@link List} aList to this {@link List}
+	 *
+	 * @param {List} aList another list
+	 */
+	this.union = function(aList) {
+		for (var i=0; i < aList.count(); i++) {this.addCopy(aList.get(i));}
+	};
+	/**
+	 * checks if the index is valid and returns it if it is; if i == -1, the correct index is retrieved.
+	 *
+	 * @private
+	 * @return Integer or false
+	 * @type Integer
+	 */
+	this.getIndex = function(i){ 
+		var len = this.list.length;
+		if (i<0 && len + i > -1) {
+			return len + i;			
+		}
+		else if (i > -1 && i < len){
+			return i;
+		}
+		var e = new Mb_exception("class List: function getIndex: member index " + i + " is not valid");
+		return false;
+	};
+	/**
+	 * @returns a {String} representation of this List
+	 * @type String
+	 */
+	this.toString = function(){
+		var str = "";
+		for (var i =0 ; i < this.count() ; i++){
+			str += this.get(i).toString();
+		}
+		return str;	
+	};	
+	
+	this.list = null;
+};
+

Copied: branches/beck_dev/mapbender/lib/map_obj.js (from rev 2450, branches/beck_dev/mapbender/http/javascripts/map_obj.js)
===================================================================
--- branches/beck_dev/mapbender/lib/map_obj.js	                        (rev 0)
+++ branches/beck_dev/mapbender/lib/map_obj.js	2008-05-15 09:02:56 UTC (rev 2452)
@@ -0,0 +1,402 @@
+/* 
+* $Id$
+* COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+* License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+*/
+function mb_mapObj_const(frameName, elementName, width, height, wms_index){
+	this.width = width;
+	this.height = height;
+	this.frameName = frameName;
+	this.elementName = elementName;
+	this.layers = [];
+	this.styles = [];
+	this.querylayers = [];
+	this.geom = "";
+	this.gml = ""; 
+	this.wms = [];
+
+	// 
+	// Add pointers to WMS objects which are in this map.
+	// If wms_index is set (=map is overview), only this 
+	// WMS is being pointed to.
+	//
+	var index = 0;
+	for(var i=0; i < wms.length; i++){
+		var isValidWms = (wms_index === null) || (wms_index == i);
+		if (isValidWms) {
+			this.wms[index] = wms[i];
+			this.wms[index].mapURL = false;
+			index++;
+		}
+	}
+
+	//
+	// set list of visible layers, active querylayers 
+	// and styles for each WMS in this map
+	//
+	var cnt_layers;
+	var cnt_querylayers;
+	var styles;
+	var layers;
+	var querylayers = "";
+	for(i=0; i< this.wms.length; i++){
+		cnt_layers = 0;
+		cnt_querylayers = 0;
+		styles = "";
+		layers = "";
+		querylayers = "";
+
+		for(var ii=0; ii<this.wms[i].objLayer.length; ii++){
+			// layer is visible and not root layer
+			if(this.wms[i].objLayer[ii].gui_layer_visible == 1 && ii>0){
+				if(cnt_layers > 0){
+					layers += ","; styles += ","; 
+				}
+				layers += wms[i].objLayer[ii].layer_name; 
+				styles += ""; 
+				cnt_layers++;
+			}            
+			// layer is queryable and not root layer
+			if(this.wms[i].objLayer[ii].gui_layer_querylayer == 1 && ii>0){
+				if(cnt_querylayers > 0){
+					querylayers += ",";
+				}
+				querylayers += wms[i].objLayer[ii].layer_name; 
+				cnt_querylayers++;
+			}                          
+		}
+		this.layers[i] = layers;
+		this.styles[i] = styles;
+		this.querylayers[i] = querylayers;
+	}
+   
+	this.epsg = wms[0].gui_wms_epsg;
+	this.extent = setExtent(this.width,this.height,this.epsg);
+	this.mapURL = [];
+	var styleTag = window.frames[this.frameName].document.getElementById(this.elementName).style;
+	styleTag.width = this.width;
+	styleTag.height = this.height;   
+   
+	/**
+	 * get the width of the mapObj
+	 *
+	 * @member mb_mapObj_const
+	 * @return width of the mapObj  
+	 * @type integer  
+	 */
+	this.getWidth = function(){
+		return parseInt(this.width, 10);
+	};
+	
+	/**
+	 * set the width of the mapObj
+	 *
+	 * @param {integer} widht the width of the mapObj  
+	 */
+	this.setWidth = function(width){
+		this.width = parseInt(width, 10);
+	};
+	
+	/**
+	 * get the height of the mapObj
+	 *
+	 * @member mb_mapObj_const
+	 * @return width of the mapObj  
+	 * @type integer  
+	 */
+	this.getHeight = function(){
+		return parseInt(this.height, 10);
+	};
+	
+	/**
+	 * set the height of the mapObj
+	 *
+	 * @param {integer} height the height of the mapObj  
+	 */
+	this.setHeight = function(height){
+		this.height = parseInt(height, 10);
+	};
+	
+	/**
+	 * get the extent of the mapObj
+	 *
+	 * @member mb_mapObj_const
+	 * @return extent of the mapObj as commaseparated minx,minx,maxx,maxy  
+	 * @type string
+	 */
+	this.getExtent = function(){
+		return this.extent;
+	};
+	
+	/**
+	 * get the extent as minx, maxx, miny, maxy
+	 *
+	 * @return extent and additional informations of the mapObj  
+	 * @type Object
+	 */
+	this.getExtentInfos = function(){
+		var c = this.getExtent().split(",");
+		var ext = new Extent(c[0],c[1],c[2],c[3]);
+		return ext;
+	};
+	
+	/**
+	 * converts the extent of the mapobject so that the maximum	extent will be displayed
+	 *
+	 */
+	this.calculateExtent = function(ext){
+		var relation_px_x = this.getWidth() / this.getHeight();
+		var relation_px_y = this.getHeight() / this.getWidth();
+		var relation_bbox_x = ext.extentx / ext.extenty;     
+		if(relation_bbox_x <= relation_px_x){                
+			ext.minx = ext.centerx - relation_px_x * ext.extenty / 2;
+			ext.maxx = ext.centerx + relation_px_x * ext.extenty / 2;
+		}
+		if(relation_bbox_x > relation_px_x){                
+			ext.miny = ext.centery - relation_px_y * ext.extentx / 2;
+			ext.maxy = ext.centery + relation_px_y * ext.extentx / 2;
+		}
+		this.setExtent(ext.minx,ext.miny,ext.maxx,ext.maxy);
+	};
+	
+	
+	/**
+	 * zoom the map with a zoomfactor and optional to x,y coords
+	 * 
+	 * @param {boolean} in_ in = true, out = false
+	 * @param {float} factor the zoomfactor 1 equals 100%
+	 * @param {float} x center to x-position
+	 * @param {float} y center to y-position
+	 */
+	 this.zoom = function(in_, factor, x, y){
+		factor = parseFloat(factor);
+		if (!in_) {
+			factor = 1 / factor;
+		}
+		
+		var extent = this.getExtentInfos();
+		var distx = extent.maxx - extent.minx;
+		var disty =  extent.maxy - extent.miny;
+		
+		
+		if(x && y){
+			var centerx = parseFloat(x);
+			var centery = parseFloat(y);
+		}
+		else{
+			var centerx = extent.minx + distx/2;
+			var centery = extent.miny + disty/2;
+		}
+		
+		
+		var new_distx = distx / factor;
+		var new_disty = disty / factor;
+		var minx = centerx - new_distx / 2;
+		var miny = centery - new_disty / 2;
+		var maxx = centerx + new_distx / 2;
+		var maxy = centery + new_disty / 2;
+		this.setExtent(minx,miny,maxx,maxy);
+		//Todo:
+		//setMapRequest!
+	 };
+
+	/**
+	 * set the extent of the wms
+	 */
+	 this.setExtent = function(minx,miny,maxx,maxy){
+	 	this.extent = String(minx)+","+String(miny)+","+String(maxx)+","+String(maxy);
+	 };
+	
+	/**
+	 * get the srs of the mapObj
+	 *
+	 * @return srs as epsg:number  
+	 * @type string
+	 */
+	this.getSRS = function(){
+		return this.epsg;
+	};
+	
+	/**
+	 * get all mapRequests 
+	 *
+	 * @return array of mapRequests of this map object  
+	 * @type string[]  
+	 */
+	this.getMapRequests = function(){
+		var allRequests = [];
+		//loop through all wms to get the mapRequests
+		for(var i=0; i<this.wms.length; i++){
+			var currentRequest = this.wms[i].getMapRequest(this);
+			if(currentRequest){ 
+				allRequests.push(currentRequest);
+			}
+		}
+		if(allRequests.length > 0){
+			return allRequests;
+		}
+		return false;
+	};
+
+	/**
+	 * Return the map URL of the WMS at index i
+	 * @param {Object} currentWmsIndex
+	 */
+	this.getMapUrl = function (i, ii) {
+		var currentWms = this.wms[ii];
+		var validLayers = currentWms.getLayers(this);
+		var layerNames = validLayers.join(",");
+		
+		url = currentWms.wms_getmap; 
+		url += mb_getConjunctionCharacter(currentWms.wms_getmap);
+			
+		if (currentWms.wms_version == "1.0.0") {
+			url += "WMTVER=" + currentWms.wms_version + "&REQUEST=map&";
+		}
+		else {
+			url += "VERSION=" + currentWms.wms_version + "&REQUEST=GetMap&SERVICE=WMS&";
+		}             
+		
+		url += "LAYERS=" + layerNames + "&";
+		url += "STYLES=";
+		var layer = layerNames.split(",");
+		for (var j = 0; j < layer.length; j++){
+			if (j > 0) {
+				url  += ",";
+			}
+			if (currentWms.getCurrentStyleByLayerName(layer[j]) !== false) {
+				url += currentWms.getCurrentStyleByLayerName(layer[j]);
+			}
+		}
+		url += "&";
+		url += "SRS=" + this.epsg + "&";
+		url += "BBOX=" + this.extent + "&";
+		url += "WIDTH=" + this.width + "&";
+		url += "HEIGHT=" + this.height + "&";
+		url += "FORMAT=" + currentWms.gui_wms_mapformat + "&";
+		url += "BGCOLOR=0xffffff&";
+	
+		if (currentWms.gui_wms_mapformat.search(/gif/i)>-1 || 
+			currentWms.gui_wms_mapformat.search(/png/i)>-1) {
+				url += "TRANSPARENT=TRUE&";
+		}
+	
+		url += "EXCEPTIONS=" + currentWms.gui_wms_exceptionformat + "&";
+	
+		// add vendor-specific
+		for (var v = 0; v < mb_vendorSpecific.length; v++) {
+			var vendorSpecificString = eval(mb_vendorSpecific[v]); 
+			// if eval doesn't evaluate a function, the result is undefined.
+			// Sometimes it is necessary not to evaluate a function, for
+			// example if you want to change a variable from the current
+			// scope (see mod_addSLD.php) 
+			if (typeof(vendorSpecificString) != "undefined") {
+				url += vendorSpecificString + "&";
+			} 
+		}
+		// add Filter
+		if (currentWms.wms_filter !== ""){
+			url += "&SLD=" + currentWms.wms_filter +"?id="+ mb_styleID + "&";
+		}
+		// add sld
+		if(currentWms.gui_wms_sldurl !== ""){
+			url += "&SLD=" + escape(currentWms.gui_wms_sldurl) + "&";
+		}
+		return url;
+	}
+
+	/**
+	 * get all featureInfoRequests 
+	 *
+	 * @member mb_mapObj_const
+	 * @param float x the x-value of the click position in pixel
+	 * @param float y the y-value of the click position in pixel
+	 * @return array of all featureInfoRequests of this map object  
+	 * @type string[]  
+	 */
+	this.getFeatureInfoRequests = function(clickPoint){
+		var allRequests = [];
+		//loop through all wms to get the FeatureInfoRequests
+		for(var i=0; i<this.wms.length; i++){
+			var currentRequest = this.wms[i].getFeatureInfoRequest(this, clickPoint);
+			if(currentRequest){ 
+				allRequests.push(currentRequest);
+			}
+		}
+		if(allRequests.length > 0){
+			return allRequests;
+		}
+		return false;
+	};
+	
+	/**
+	 * calculation of the mapscale 
+	 *
+	 * @member mb_mapObj_const
+	 * @return scale  
+	 * @type integer  
+	 */
+	this.getScale = function(){
+		var scale;
+		var bbox = this.extent.split(",");
+		var xtenty;
+		if(this.epsg=="EPSG:4326"){
+			var pxLenx = (parseFloat(bbox[2])-parseFloat(bbox[0]))/this.width;
+			var pxLeny = (parseFloat(bbox[3])-parseFloat(bbox[1]))/this.height;
+			var lat_from = ((parseFloat(bbox[3])-parseFloat(bbox[1])/2)*Math.PI)/180;
+			var lat_to = ((parseFloat(bbox[3])-parseFloat(bbox[1])/2+pxLeny)*Math.PI)/180;
+			var lon_from = ((parseFloat(bbox[2])-parseFloat(bbox[0])/2)*Math.PI)/180;
+			var lon_to = ((parseFloat(bbox[2])-parseFloat(bbox[0])/2+pxLeny)*Math.PI)/180;
+			var dist=6371229*Math.acos(Math.sin(lat_from)*Math.sin(lat_to)+Math.cos(lat_from)*Math.cos(lat_to)*Math.cos(lon_from-lon_to));
+			scale = (dist/Math.SQRT2) * (mb_resolution * 100);
+		}else{
+			xtenty =  parseFloat(bbox[3]) - parseFloat(bbox[1]);
+			scale = (xtenty / this.height) * (mb_resolution * 100);
+		}
+		return Math.round(scale);
+	};
+	/**
+	 * move a wms or layer 
+	 *
+	 * @param int wms_id id of wms to move
+	 * @param int layer_id id of layer to move
+	 * @return true of successful
+	 * @type boolean
+	 */
+	this.move = function(wms_id, layer_id, moveUp){
+		var i,j;
+		for(i=0;i<this.wms.length;i++){
+			if (wms_id == this.wms[i].wms_id) {
+				break;
+			}
+		}
+		
+		//check if only one wms is affected?
+		if (layer_id && layer_id != this.wms[i].objLayer[0].layer_id) {
+			return this.wms[i].moveLayer(layer_id, moveUp);
+		}
+		
+		//else swap wms
+		j = i + (moveUp?-1:1);
+		if (!(i != j && i >= 0 && i < this.wms.length && j >= 0 && j < this.wms.length)) {
+			return false;
+		}
+		
+		upper = this.wms[i];
+		this.wms[i] = this.wms[j];
+		this.wms[j] = upper;
+		var upperLayers = this.layers[i];
+		var upperStyles = this.styles[i];
+		var upperQuerylayers = this.querylayers[i];
+		this.layers[i] = this.layers[j];
+		this.styles[i] = this.styles[j];
+		this.querylayers[i] = this.querylayers[j];
+		this.layers[j] = upperLayers;
+		this.styles[j] = upperStyles;
+		this.querylayers[j] = upperQuerylayers;
+		
+		return true;
+	};
+	
+	eventAfterMapObjectConstruction.trigger();
+}
\ No newline at end of file

Added: branches/beck_dev/mapbender/lib/wms.js
===================================================================
--- branches/beck_dev/mapbender/lib/wms.js	                        (rev 0)
+++ branches/beck_dev/mapbender/lib/wms.js	2008-05-15 09:02:56 UTC (rev 2452)
@@ -0,0 +1,777 @@
+/* 
+ * $Id: map_obj.js 2413 2008-04-23 16:21:04Z christoph $
+ * COPYRIGHT: (C) 2001 by ccgis. This program is free software under the GNU General Public
+ * License (>=v2). Read the file gpl.txt that comes with Mapbender for details. 
+ */
+
+//global variables
+var wms = [];
+var wms_layer_count = 0;
+
+/**
+ * global function to add wms to the wms-object
+ * 
+ * @param {String} wms_id the unique id of the wms 
+ * @param {String} wms_version the version assumed from capabilities
+ * @param {String} wms_title the title of the wms
+ * @param {String} wms_abstract the abstract of the wms
+ * @param {String} wms_getmap the url for map requests
+ * @param {String} wms_getfeatureinfo the url for featureInof requests
+ * @param {String} wms_getlegendurl the url for legend requests
+ * @param {String} wms_filter a filter (deprecated)
+ * @param {String} gui_wms_mapformat the image-format in the actual gui
+ * @param {String} gui_wms_featureinfoformat the current format for featureInfos
+ * @param {String} gui_wms_exceptionformat the exceptionformat for map requests
+ * @param {String} gui_wms_epsg the current srs
+ * @param {Integer} gui_wms_visible the visibility of this service
+ * @param {Integer} gui_wms_opacity the initial display opacity in percent
+ * @param {String} gui_wms_sldurl url to an actual sld
+ */
+function add_wms(
+			wms_id,
+			wms_version,
+			wms_title,
+			wms_abstract,
+			wms_getmap,
+			wms_getfeatureinfo,
+			wms_getlegendurl,
+			wms_filter,
+			gui_wms_mapformat,
+			gui_wms_featureinfoformat,
+			gui_wms_exceptionformat,
+			gui_wms_epsg,
+			gui_wms_visible,
+			gui_wms_opacity,
+			gui_wms_sldurl){
+					wms[wms.length] = new wms_const( 
+					wms_id,
+					wms_version,
+					wms_title,
+					wms_abstract,
+					wms_getmap,
+					wms_getfeatureinfo,
+					wms_getlegendurl,
+					wms_filter,
+					gui_wms_mapformat,
+					gui_wms_featureinfoformat,
+					gui_wms_exceptionformat,
+					gui_wms_epsg,
+					parseInt(gui_wms_visible, 10),
+					parseInt(gui_wms_opacity),
+					parseInt(gui_wms_opacity),
+					gui_wms_sldurl);
+					wms_layer[wms.length - 1] = [];
+}
+/**
+ * @class A class representing the wms
+ *
+ * @constructor
+ * @param {String} wms_id the unique id of the wms 
+ * @param {String} wms_version the version assumed from capabilities
+ * @param {String} wms_title the title of the wms
+ * @param {String} wms_abstract the abstract of the wms
+ * @param {String} wms_getmap the url for map requests
+ * @param {String} wms_getfeatureinfo the url for featureInof requests
+ * @param {String} wms_getlegendurl the url for legend requests
+ * @param {String} wms_filter a filter (deprecated)
+ * @param {String} gui_wms_mapformat the image-format in the actual gui
+ * @param {String} gui_wms_featureinfoformat the current format for featureInfos
+ * @param {String} gui_wms_exceptionformat the exceptionformat for map requests
+ * @param {String} gui_wms_epsg the current srs
+ * @param {String} gui_wms_visible the visibility of this service
+ * @param {Integer} gui_wms_opacity the initial display opacity in percent
+ * @param {String} gui_wms_sldurl url to an actual sld
+ * 
+ */
+function wms_const(  
+			wms_id,
+			wms_version,
+			wms_title,
+			wms_abstract,
+			wms_getmap,
+			wms_getfeatureinfo,
+		    wms_getlegendurl,
+			wms_filter,
+			gui_wms_mapformat,
+			gui_wms_featureinfoformat,
+			gui_wms_exceptionformat,
+			gui_wms_epsg,
+			gui_wms_visible,
+			gui_wms_opacity,
+			gui_wms_sldurl){
+   
+	if (!wms_id) {
+		var id_ok = false;
+		while (id_ok === false) {
+			wms_id = "a"+Math.round(10000*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;
+	this.wms_abstract = wms_abstract;
+	this.wms_getmap = wms_getmap;
+	this.wms_getfeatureinfo = wms_getfeatureinfo;
+	this.wms_getlegendurl = wms_getlegendurl;
+	this.wms_filter = wms_filter;
+	this.data_type = [];
+	this.data_format = [];
+	this.objLayer = [];
+	this.gui_wms_mapformat = gui_wms_mapformat;
+	this.gui_wms_featureinfoformat = gui_wms_featureinfoformat;
+	this.gui_wms_exceptionformat = gui_wms_exceptionformat;
+	this.gui_wms_epsg = gui_wms_epsg;
+	this.gui_wms_visible = gui_wms_visible;
+	this.gui_epsg = [];
+	this.gui_minx = [];
+	this.gui_miny = [];
+	this.gui_maxx = [];
+	this.gui_maxy = [];
+
+	// opacity version 
+	this.gui_wms_mapopacity = gui_wms_opacity/100;
+	// sld version
+	this.gui_wms_sldurl = gui_wms_sldurl;      
+}
+
+/**
+ * rephrases the mapRequest
+ *
+ * @param {Object} mapObj the mapbender mapObject of the wms  
+ * @return mapRequest, i.e. onlineresource + params
+ * @type String
+ */
+wms_const.prototype.getMapRequest = function(mapObj){	
+	//check visible layers first
+	var layers = this.getLayers(mapObj);
+	if(!layers){
+		return false;
+	}
+	
+	var rq = this.wms_getmap;
+	rq += mb_getConjunctionCharacter(this.wms_getmap);
+	if(this.wms_version === "1.0.0"){
+		rq += "WMTVER=" + this.wms_version + "&REQUEST=map";
+	}
+	else{
+		rq += "VERSION=" + this.wms_version + "&REQUEST=getMap&SERVICE=WMS";
+	}
+	
+	rq += "&LAYERS=" + layers.join(",");
+	rq += "&WIDTH=" + mapObj.getWidth();
+	rq += "&HEIGHT=" + mapObj.getHeight();
+	rq += "&SRS=" + mapObj.getSRS();
+	rq += "&BBOX=" + mapObj.getExtent();
+	rq += "&STYLES=" + this.getLayerstyles(mapObj).join(",");
+	rq += "&FORMAT=" + this.gui_wms_mapformat;
+	rq += "&EXCEPTIONS=" + this.gui_wms_exceptionformat;
+	//Todo: error occurs:
+	//var throwNotice = new Mb_notice("getMapRequest: " + rq);
+	//window.console.log("getMapRequest: " + rq);
+	return rq;
+};
+
+
+/**
+ * rephrases the featureInfoRequest
+ *
+ * @param {Object} mapObj the mapbender mapObject of the wms  
+ * @param {Point} clickPoint map-click position {@link Point}
+ * @return featureInfoRequest, onlineresource + params
+ * @type string
+ */
+wms_const.prototype.getFeatureInfoRequest = function(mapObj, clickPoint){	
+	
+	//check layers and querylayers first 
+	var layers = this.getLayers(mapObj);
+	var querylayers = this.getQuerylayers(mapObj);
+	
+	if(!layers || !querylayers){
+		return false;
+	}
+	
+	var rq = this.wms_getfeatureinfo;
+	rq += mb_getConjunctionCharacter(this.wms_getfeatureinfo);
+	if(this.wms_version === "1.0.0"){
+		rq += "WMTVER=" + this.wms_version + "&REQUEST=feature_info";
+	}
+	else{
+		rq += "VERSION=" + this.wms_version + "&REQUEST=GetFeatureInfo&SERVICE=WMS";
+	}
+	
+	rq += "&LAYERS=" + layers.join(",");
+	rq += "&QUERY_LAYERS=" + querylayers.join(",");
+	rq += "&WIDTH=" + mapObj.getWidth();
+	rq += "&HEIGHT=" + mapObj.getHeight();
+	rq += "&SRS=" + mapObj.getSRS();
+	rq += "&BBOX=" + mapObj.getExtent();
+	rq += "&STYLES=" + this.getLayerstyles(mapObj).join(",");
+	rq += "&FORMAT=" + this.gui_wms_mapformat;
+	rq += "&INFO_FORMAT=" + this.gui_wms_featureinfoformat;
+	rq += "&EXCEPTIONS=application/vnd.ogc.se_xml";
+	rq += "&X=" + clickPoint.x;
+	rq += "&Y=" + clickPoint.y;
+	//console.log(rq);
+	return rq;
+};
+
+/**
+ * sets Opacity of WMS
+ * 
+ * @param {Integer} new opacity percentage value
+ */
+wms_const.prototype.setOpacity = function(opacity){
+	//calc new opacity
+	this.gui_wms_mapopacity = parseInt(opacity)/100;
+	if(this.gui_wms_mapopacity>1||isNaN(this.gui_wms_mapopacity))
+		this.gui_wms_mapopacity=1;
+	if(this.gui_wms_mapopacity<0)
+		this.gui_wms_mapopacity=0;
+		
+	if (this.gui_wms_visible > 0) {
+
+		//get div id
+		var divId = null;
+		for (var i=0; i < wms.length; i++) {
+			if (this.wms_id == wms[i].wms_id) { 
+				var divId = 'div_'+i;
+				break;
+			}
+		}
+		if(!divId)
+			return;	
+		
+		//TODO: check if mapframe1 is the right mapframe
+		wmsImage = parent.mapframe1.document.getElementById(divId);
+		if (wmsImage != null) {
+			wmsImage.style.opacity = this.gui_wms_mapopacity;
+			wmsImage.style.MozOpacity = this.gui_wms_mapopacity;
+			wmsImage.style.KhtmlOpacity = this.gui_wms_mapopacity;
+			wmsImage.style.filter = "alpha(opacity=" + this.gui_wms_mapopacity*100 + ")";
+		}
+	}
+}
+
+/**
+ * get all visible layers
+ *
+ * @return array of layernames 
+ * @type string[]
+ */
+wms_const.prototype.getLayers = function(mapObj){
+	
+	try {
+		//visibility of the wms
+		var wmsIsVisible = (this.gui_wms_visible > 0);
+		if(!wmsIsVisible){
+			return false;
+		}
+		visibleLayers = [];
+		for(var i=0; i< this.objLayer.length; i++){
+			var isVisible = (this.objLayer[i].gui_layer_visible === 1);
+			var hasNoChildren = (!this.objLayer[i].has_childs);
+			if (isVisible && hasNoChildren){
+				if(this.objLayer[i].checkScale(mapObj)){
+					//console.log("checkLayer: " + this.objLayer[i].layer_name);
+					visibleLayers.push(this.objLayer[i].layer_name);
+				}
+			}
+		}
+		if(visibleLayers.length === 0){
+			return false;
+		}
+		return visibleLayers;
+	}
+	catch (e) {
+		alert(e);
+	}
+};
+
+/**
+ * get the actual style of all visible layers
+ *
+ * @return commaseparated list of actual layerstyles
+ * @type string
+ */
+wms_const.prototype.getLayerstyles = function(mapObj){
+	var layers = this.getLayers(mapObj);
+	var layerstyles = '';
+	var styles = [];
+	if(layers){
+		for(i = 0; i < layers.length; i++){
+			var style = this.getCurrentStyleByLayerName(layers[i]);
+			if(!style){
+				style = '';
+			}
+			styles.push(style);
+		}
+		return styles;
+	}
+	return false;
+};
+
+/**
+ * check if layer is parentLayer
+ *
+ * @param layername
+ * @return the parent value of the given layer
+ * @type integer
+ */
+wms_const.prototype.checkLayerParentByLayerName = function(layername){
+	for(var i=0; i< this.objLayer.length; i++){
+		if(this.objLayer[i].layer_name == layername){
+			return this.objLayer[i].layer_parent;
+		}
+	}
+};
+
+/**
+ * get the title of the current layer
+ *
+ * @param layername
+ * @return the title of the given layer
+ * @type string
+ */
+wms_const.prototype.getTitleByLayerName = function(layername){
+	for(var i=0; i< this.objLayer.length; i++){
+		if(this.objLayer[i].layer_name == layername){
+			return this.objLayer[i].layer_title;
+		}
+	}
+};
+
+/**
+ * get the current style of the layer
+ *
+ * @param layername
+ * @return the stylename of the given layer
+ * @type string
+ */
+wms_const.prototype.getCurrentStyleByLayerName = function(layername){
+	for(var i=0; i< this.objLayer.length; i++){
+		if(this.objLayer[i].layer_name == layername){
+			if(this.objLayer[i].gui_layer_style === '' || this.objLayer[i].gui_layer_style === null){
+				return false;
+			}
+			else{
+				return this.objLayer[i].gui_layer_style;	
+			}
+		}
+	}
+};
+
+/**
+ * get the legendurl of the gui layer style
+ *
+ * @param stylename
+ * @return the legendurl of the given style
+ * @type string
+ */
+wms_const.prototype.getLegendUrlByGuiLayerStyle = function(layername,guiLayerStyle){
+	for(var i=0; i< this.objLayer.length; i++){
+		if(this.objLayer[i].layer_name == layername){
+			if(this.objLayer[i].layer_style.length === 0){
+				return false;
+			}
+			for(var k=0; k< this.objLayer[i].layer_style.length; k++){
+				if(this.objLayer[i].layer_style[k].name == guiLayerStyle){
+					var legendUrl = this.objLayer[i].layer_style[k].legendurl;
+					if (this.gui_wms_sldurl !== "") {
+					 		legendUrl += "&SLD="+escape(this.gui_wms_sldurl);
+					}				
+					if(legendUrl !=='' && legendUrl !== null && typeof(legendUrl) != 'undefined'){
+						return legendUrl;
+					}
+					else {
+						return false;
+					}
+				}
+			}
+		}
+	}
+	return false;
+};
+
+/**
+ * get all querylayers
+ *
+ * @return array of layernames
+ * @type string[]
+ */
+wms_const.prototype.getQuerylayers = function(){
+	queryLayers = [];
+	for(var i=0; i< this.objLayer.length; i++){
+		if(this.objLayer[i].gui_layer_querylayer === 1 && ! this.objLayer[i].has_childs ){
+			queryLayers.push(this.objLayer[i].layer_name);
+		}
+	}
+	if(queryLayers.length === 0){
+		return false;
+	}
+	return queryLayers;
+};
+
+/**
+ * get a layer Object by layer_pos
+ * 
+ * @param int payer_pos layer_pos of layer you want to get
+ * @return object layer
+ */
+
+wms_const.prototype.getLayerByLayerPos = function(layer_pos){
+	for(var i=0;i<this.objLayer.length;i++){
+		if(this.objLayer[i].layer_pos == layer_pos) {
+			return this.objLayer[i];
+		}
+	}
+	return null;
+};
+/**
+ * get the state of sublayers from a specified layer
+ * 
+ * @param int layer_id of the parent layer
+ * @param String type "visible" or "querylayer"
+ * @return int -1 if state differs else the state
+ */
+
+wms_const.prototype.getSublayerState = function(layer_id, type){
+	var i;
+	var state=-1,value;
+	for(i = 0; i < this.objLayer.length; i++){
+		if(this.objLayer[i].layer_id==layer_id) {
+			break;
+		}
+	}
+	
+	//go throught sublayers
+	for(var j = i+1; j < this.objLayer.length; j++){
+		if(this.objLayer[i].parent_layer == this.objLayer[j].parent_layer) {
+			break;
+		}
+		if(type == "visible") {
+			value = this.objLayer[j].gui_layer_visible;
+		}
+		else if(type == "querylayer") {
+			value = this.objLayer[j].gui_layer_querylayer;
+		}
+		if(state == -1) {
+			state = value;
+		}
+		if(state != value) {
+			return -1;
+		}
+	}
+	
+	return state;
+};
+/**
+ * handle change of visibility / quaryability of a layer
+ * 
+ * @param string layer_name of layer to handle
+ * @param string type of change ("visible" or "querylayer")
+ * @param int value of the change
+ */
+wms_const.prototype.handleLayer = function(layer_name, type, value){
+	var i;
+	for(i = 0; i < this.objLayer.length; i++){
+		if(this.objLayer[i].layer_name==layer_name) {
+			break;
+		}
+	}
+	
+	//Set visibility/queryability of Layer and Sublayers
+	for(var j = i; j < this.objLayer.length; j++){
+		if (i != j && this.objLayer[i].layer_parent >= this.objLayer[j].layer_parent) {
+			break;
+		}
+		if(type == "visible") {
+			this.objLayer[j].gui_layer_visible = parseInt(value, 10);
+		}
+		else if(type=="querylayer") {
+			this.objLayer[j].gui_layer_querylayer = parseInt(value, 10);
+		}
+	}
+
+	//Update visibility/queryability of parent layer
+	var parentLayer = this.getLayerByLayerPos(this.objLayer[i].layer_parent);
+	if(parentLayer){
+		var state = this.getSublayerState(parentLayer.layer_id, type);
+		if(state!=-1){
+			if(type == "visible") {
+				this.objLayer[j].gui_layer_visible = state;
+			}
+			else if(type=="querylayer") {
+				this.objLayer[j].gui_layer_querylayer = state;
+			}
+		}
+	}
+};
+
+
+/**
+ * move a layer (with his sublayers) up or down
+ * 
+ * @param int layerId layer_id of layer to move
+ * @param boolean moveUp true to move up or false to move down
+ * @return boolean success
+ */
+
+wms_const.prototype.moveLayer = function(layerId, moveUp){
+	var iLayer=-1;
+	var i;
+	
+	//find layer to move
+	for(i=0;i<this.objLayer.length;i++){
+		if(this.objLayer[i].layer_id==layerId){
+			iLayer=i;
+			break;
+		}
+	}
+	if(iLayer==-1) {
+		return false;
+	}
+	
+	var upperLayer = -1;
+	var lowerLayer = -1;
+	
+	//find layer to swap position with
+	var parentLayer = this.objLayer[iLayer].layer_parent;	
+	if(moveUp){
+		lowerLayer = iLayer;
+		
+		//find previous layer on same level
+		for(i=iLayer-1;i>0;i--){
+			if(parentLayer == this.objLayer[i].layer_parent){
+				upperLayer = i;
+				break;
+			}
+		}
+		if(upperLayer == -1){
+			//alert("The Layer you selected is already on top of parent Layer/WMS");
+			return false;
+		}
+	}
+	else{
+		upperLayer = iLayer;
+		
+		//find next layer on same level
+		for(i=iLayer+1;i<this.objLayer.length;i++){
+			if(parentLayer == this.objLayer[i].layer_parent){
+				lowerLayer = i;
+				break;
+			}
+		}
+		if(lowerLayer == -1){
+			//alert("The Layer you selected is already on bottom of parent Layer/WMS");
+			return false;
+		}
+	}
+	
+	//calc number of layers to move down
+	var layersDown = lowerLayer - upperLayer;
+	
+	//get number of layers to move up
+	for(i=lowerLayer+1; i<this.objLayer.length; i++){
+		if(parentLayer == this.objLayer[i].layer_parent){
+			break;
+		}
+	}
+	var layersUp = i - lowerLayer;
+	
+	//do moving
+	var temp = [];
+	for(i=0;i<layersDown+layersUp;i++){
+		temp[temp.length]=this.objLayer[upperLayer+i];
+	}
+	for(i=0;i<layersUp;i++){
+		this.objLayer[upperLayer+i]=temp[i+layersDown];
+	}
+	for(i=0;i<layersDown;i++){
+		this.objLayer[upperLayer+layersUp+i]=temp[i];
+	}
+
+	return true;
+};
+
+function wms_add_data_type_format(datatype,dataformat){
+	var insertDataFormat = true;
+	for (var i = 0 ; i < wms[wms.length-1].data_type.length ; i ++) {
+		if (wms[wms.length-1].data_type[i] == datatype && wms[wms.length-1].data_format[i] == dataformat) {
+			insertDataFormat = false;
+		}
+	}
+	if (insertDataFormat === true) {
+		wms[wms.length-1].data_type[wms[wms.length-1].data_type.length] = datatype;
+		wms[wms.length-1].data_format[wms[wms.length-1].data_format.length] = dataformat;
+	}
+}
+function wms_addSRS(epsg,minx,miny,maxx,maxy){
+	wms[wms.length-1].gui_epsg[wms[wms.length-1].gui_epsg.length] = epsg;
+	wms[wms.length-1].gui_minx[wms[wms.length-1].gui_minx.length] = minx;
+	wms[wms.length-1].gui_miny[wms[wms.length-1].gui_miny.length] = miny;
+	wms[wms.length-1].gui_maxx[wms[wms.length-1].gui_maxx.length] = maxx;
+	wms[wms.length-1].gui_maxy[wms[wms.length-1].gui_maxy.length] = maxy;
+}
+function wms_addLayerStyle(styleName, styleTitle, count, layerCount, styleLegendUrl, styleLegendUrlFormat){
+	var currentLayer = wms[wms.length-1].objLayer[layerCount]; 
+	if (currentLayer) {
+		currentLayer.layer_style[count] = {};
+		currentLayer.layer_style[count].name = styleName;
+		currentLayer.layer_style[count].title = styleTitle;
+		currentLayer.layer_style[count].legendurl = styleLegendUrl;
+		currentLayer.layer_style[count].legendurlformat = styleLegendUrlFormat;
+	}
+}
+//TODO: add layerstyle handling....
+//layer
+function wms_add_layer(
+			layer_parent,
+			layer_uid,
+			layer_name,
+			layer_title,
+			layer_dataurl_href,
+			layer_pos,
+			layer_queryable,
+			layer_minscale,
+			layer_maxscale,
+			layer_metadataurl,
+			gui_layer_wms_id,
+			gui_layer_status,
+			gui_layer_style,
+			gui_layer_selectable,
+			gui_layer_visible,
+			gui_layer_queryable,
+			gui_layer_querylayer,
+			gui_layer_minscale,
+			gui_layer_maxscale,
+			gui_layer_wfs_featuretype){
+                      
+	wms[wms.length-1].objLayer[wms[wms.length-1].objLayer.length] = new wms_layer(
+											layer_parent,
+											layer_uid,
+											layer_name,
+											layer_title,
+											layer_dataurl_href,
+											layer_pos,
+											layer_queryable,
+											layer_minscale,
+											layer_maxscale,
+											layer_metadataurl,
+											gui_layer_wms_id,
+											gui_layer_status,
+											gui_layer_style,
+											parseInt(gui_layer_selectable, 10),
+											parseInt(gui_layer_visible, 10),
+											parseInt(gui_layer_queryable, 10),
+											parseInt(gui_layer_querylayer, 10),
+											parseInt(gui_layer_minscale, 10),
+											parseInt(gui_layer_maxscale, 10),
+											gui_layer_wfs_featuretype );
+	var parentLayer = wms[wms.length-1].getLayerByLayerPos(parseInt(layer_parent, 10));
+	if(parentLayer) {
+		parentLayer.has_childs = true;
+	}
+}
+function layer_addEpsg(epsg,minx,miny,maxx,maxy){
+	var j = wms[wms.length-1].objLayer.length-1;
+	var k = wms[wms.length-1].objLayer[j].layer_epsg.length;
+	var currentLayer = wms[wms.length-1].objLayer[j];
+	currentLayer.layer_epsg[k]={};
+	currentLayer.layer_epsg[k].epsg = epsg;
+	currentLayer.layer_epsg[k].minx = minx;
+	currentLayer.layer_epsg[k].miny = miny;
+	currentLayer.layer_epsg[k].maxx = maxx;
+	currentLayer.layer_epsg[k].maxy = maxy;
+}
+function wms_layer(
+			layer_parent,
+			wms_layer_uid,
+			layer_name,
+			layer_title,
+			layer_dataurl_href,
+			layer_pos,
+			layer_queryable,
+			layer_minscale,
+			layer_maxscale,
+			layer_metadataurl,
+			gui_layer_wms_id,
+			gui_layer_status,
+			gui_layer_style,
+			gui_layer_selectable,
+			gui_layer_visible,
+			gui_layer_queryable,
+			gui_layer_querylayer,
+			gui_layer_minscale,
+			gui_layer_maxscale,
+			gui_layer_wfs_featuretype){
+	this.layer_id = wms_layer_count;
+	this.layer_uid = wms_layer_uid;
+	this.layer_parent = layer_parent;
+	this.layer_name = layer_name;
+	this.layer_title = layer_title;
+	this.layer_dataurl_href = layer_dataurl_href;
+	this.layer_pos = layer_pos;
+	this.layer_queryable = layer_queryable;
+	this.layer_minscale = layer_minscale;
+	this.layer_maxscale = layer_maxscale;
+	this.layer_metadataurl = layer_metadataurl;
+	this.layer_epsg = [];
+	this.gui_layer_wms_id = gui_layer_wms_id;
+	this.gui_layer_status = gui_layer_status;
+	this.gui_layer_selectable = gui_layer_selectable;
+	this.gui_layer_visible = gui_layer_visible;
+	this.gui_layer_queryable = gui_layer_queryable;
+	this.gui_layer_querylayer = gui_layer_querylayer;
+	this.gui_layer_minscale = gui_layer_minscale;
+	this.gui_layer_maxscale = gui_layer_maxscale;
+	this.gui_layer_style = gui_layer_style;
+	this.gui_layer_wfs_featuretype = gui_layer_wfs_featuretype;
+	this.gui_layer_style = null;
+	this.has_childs = false;
+	this.layer_style = [];
+	wms_layer_count++;
+}
+/**
+ * check the scale of the layer
+ *
+ * @param Object mapObj the mapbender mapObject of the layer
+ * @return boolean if the layer is in scale or not
+ * @type boolean
+ */
+wms_layer.prototype.checkScale = function(mapObj){
+	var minScale = parseInt(this.gui_layer_minscale, 10);
+	var maxScale = parseInt(this.gui_layer_maxscale, 10);
+	var currentScale = parseInt(mapObj.getScale(), 10);
+	if(minScale === 0 && maxScale === 0){
+		return true;
+	}
+	if(minScale > currentScale || (maxScale !== 0 && maxScale < currentScale)) {
+		return false;
+	}	
+	return true;
+};
+/**
+ * set visibility of the layer
+ * @param boolean visible visibility on/off
+ */
+wms_layer.prototype.setVisible = function(visible){
+	this.gui_layer_visible = parseInt(visible, 10);
+	//console.log("setVisible(%i) for Layer %s",visible, this.layer_name);
+};
+
+/**
+ * set queryability of the layer
+ * @param boolean queryable queryability on/off
+ */
+
+wms_layer.prototype.setQueryable = function(queryable){
+	this.gui_layer_querylayer = parseInt(queryable, 10);
+	//console.log("setQueryable(%i) for Layer %s",queryable, this.layer_name);
+};
\ No newline at end of file



More information about the Mapbender_commits mailing list