svn commit: r94 - trunk/mapbender/http/javascripts/wfs.js

christoph at osgeo.org christoph at osgeo.org
Wed Apr 19 09:22:33 EDT 2006


Author: christoph
Date: 2006-04-19 13:22:33+0000
New Revision: 94

Modified:
   trunk/mapbender/http/javascripts/wfs.js

Log:
wfs featuretype namespace

Modified: trunk/mapbender/http/javascripts/wfs.js
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/wfs.js?view=diff&rev=94&p1=trunk/mapbender/http/javascripts/wfs.js&p2=trunk/mapbender/http/javascripts/wfs.js&r1=93&r2=94
==============================================================================
--- trunk/mapbender/http/javascripts/wfs.js	(original)
+++ trunk/mapbender/http/javascripts/wfs.js	2006-04-19 13:22:33+0000
@@ -1,866 +1,866 @@
-var digiFrame = "digitize";
-var mb_wfs_fetched = new Array();
-var	mb_wfs_fetch = new Array();
-var mb_wfsreq = 0;
-var mb_wfs_tolerance = 8;
-var mb_wfs_target = "mapframe1";
-var mb_wfs_objwin = null;
-var mb_wfs_objwin_left = 800;
-var mb_wfs_objwin_top = 200;
-var mb_wfs_objwin_width = 200;
-var mb_wfs_objwin_height = 200;
-var mb_wfs_targets = new Array("mapframe1","overview");
-var mb_wfs_minPix = 8;
-var mb_wfs_maxBasePoints = 100;
-var mb_wfs_lineColor = "#ff0000";
-var mb_wfs_fillColor = "#ff0000";
-var mb_wfs_diameter = 8;
-var usemap = "";
-var mod_usemap_radius = 10;
-var mod_usemap_line_tolerance = 5;
-var canvas = new Array();
-var canvasHasDrawing = new Array();
-var useCheckboxForHighlighting = true;
-var useUsemap = false;
-
-if (useCheckboxForHighlighting) { 
-	mb_registerSubFunctions('highlightGeometry()');
-}
-
-if (useUsemap) {
-	mb_registerSubFunctions('mod_usemap("")');
-}
- 
-if (useExtentIsSet()) {
-	mb_registerSubFunctions("mb_setwfsrequest_extent()");
-}
-
-function mb_setwfsrequest_extent() {
-
-	if (useExtentIsSet()) {
-		var ind = getMapObjIndexByName(mb_wfs_targets[0]);
-		var pos_a = makeClickPos2RealWorldPos(mb_wfs_targets[0],0,0);
-		var pos_b = makeClickPos2RealWorldPos(mb_wfs_targets[0],mb_mapObj[ind].width,mb_mapObj[ind].height);
-	
-		var x = new Array();
-		var y = new Array();
-		x[0] = pos_a[0];
-		x[1] = pos_b[0];
-		y[0] = pos_a[1];
-		y[1] = pos_b[1];
-		
-		mb_setwfsrequest(mb_wfs_targets[0],'rectangle',x,y);
-	}
-}
- 
-function mb_setwfsrequest(target,type,x,y){
-	mb_wfs_reset();
-	var ind = getMapObjIndexByName(target);
-	var w = new Array();
-	var w_ = new Array();
-	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
-	for(var i=0; i<mb_mapObj[ind].wms.length; i++){
-		for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
-			var o = mb_mapObj[ind].wms[i].objLayer[ii];
-			if(o.gui_layer_wfs_featuretype != '' && o.gui_layer_querylayer == '1'){
-				w[w.length] = o.gui_layer_wfs_featuretype;
-			}	
-		}
-	}
-	for(var i=0; i<w.length; i++){
-		for(var ii=0; ii<wfs_conf.length; ii++){			
-			if(wfs_conf[ii]['wfs_conf_id'] == w[i]){
-				w_[w_.length] = ii;
-			}
-		}
-	}
-	if(type=='point'){
-		type = 'rectangle';
-		var tmp = makeRealWorld2mapPos(mb_wfs_target,x[0], y[0]);
-		var n1 = makeClickPos2RealWorldPos(mb_wfs_target, (tmp[0] + mb_wfs_tolerance/2), (tmp[1] + mb_wfs_tolerance/2));
-		x[0] = n1[0];
-		y[0] = n1[1];
-		var n2 = makeClickPos2RealWorldPos(mb_wfs_target, (tmp[0] - mb_wfs_tolerance/2), (tmp[1] - mb_wfs_tolerance/2));
-		x[1] = n2[0];
-		y[1] = n2[1];
-	}
-	if(type=='polygon'){
-		for(var i=0; i<w_.length; i++){
-			var path = "../php/mod_wfs_result.php?url=";
-			var url = wfs_conf[w_[i]]['wfs_getfeature'];
-			url += "service=wfs&request=getFeature&version=1.0.0";
-			url += "&typename="+ wfs_conf[w_[i]]['featuretype_name'];
-			url += "&filter=";
-			path += escape(url);
-			path += "&filter=";
-			var filter = '<ogc:Filter xmlns:ogc="http://ogc.org" xmlns:gml="http://www.opengis.net/gml">';
-			filter += "<Within>";
-				filter += '<ogc:PropertyName>';
-					for(var j=0; j<wfs_conf[w_[i]]['element'].length; j++){
-						if(wfs_conf[w_[i]]['element'][j]['f_geom'] == 1){
-							filter += wfs_conf[w_[i]]['element'][j]['element_name'];
-						}
-					}
-				filter += "</ogc:PropertyName>";
-				filter += '<gml:Polygon srsName="EPSG:4326">';
-					filter += '<gml:outerBoundaryIs>';
-						filter += '<gml:LinearRing>';
-							filter += '<gml:coordinates>';
-								for(var k=0; k<x.length; k++){
-									if(k>0){
-										filter += " ";
-									}
-									filter += x[k]+","+y[k];								 
-								}
-							filter += '</gml:coordinates>';
-						filter += '</gml:LinearRing>';
-					filter += '</gml:outerBoundaryIs>';
-				filter += '</gml:Polygon>';
-			filter += '</Within>';
-			filter += '</ogc:Filter>';
-			path += filter;
-			mb_wfs_createwin(mb_wfsreq,path);
-			mb_wfsreq++;
-		}
-	}
-	if(type=='rectangle'){
-		for(var i=0; i<w_.length; i++){
-			var path = "../php/mod_wfs_result.php?url=";
-			var url = wfs_conf[w_[i]]['wfs_getfeature'];
-			url += "service=wfs&request=getFeature&version=1.0.0";
-			url += "&typename="+ wfs_conf[w_[i]]['featuretype_name'];
-			url += "&filter=";
-			path += escape(url);
-			path += "&filter=";
-			var filter = '<ogc:Filter xmlns:ogc="http://ogc.org" xmlns:gml="http://www.opengis.net/gml">';
-			filter += "<ogc:BBOX>";
-			filter += '<ogc:PropertyName>';
-				for(var j=0; j<wfs_conf[w_[i]]['element'].length; j++){
-					if(wfs_conf[w_[i]]['element'][j]['f_geom'] == 1){
-						filter += wfs_conf[w_[i]]['element'][j]['element_name'];
-					}
-				}
-			filter += "</ogc:PropertyName>";
-			filter += '<gml:Box srsName="4326"><gml:coordinates>';	
-				filter += x[0]+","+y[0];
-				filter += " ";
-				filter += x[1]+","+y[1]; 
-			filter += '</gml:coordinates></gml:Box></ogc:BBOX>';
-			filter += '</ogc:Filter>';
-			path += filter;
-			mb_wfs_createwin(mb_wfsreq,path);
-			mb_wfsreq++;
-		}
-	}
-}
-
-// ---------------------------------------------------------------------------------------------------------------
-// --- usemap (begin) --------------------------------------------------------------------------------------------
-
-function mod_usemap (wfs_name) {
-	if (wfs_name == "") {
-		usemap = "";
-	}
-	var ind = getMapObjIndexByName(mb_wfs_targets[0]);
-	var myImg = window.frames[mb_wfs_targets[0]].document.getElementById("um_img").style; 
-	myImg.width = mb_mapObj[ind].width;
-	myImg.height = mb_mapObj[ind].height;
-
-	for (var i = 0 ; i < mb_wfs_fetch.length ; i ++) {
-	
-		if (mb_wfs_fetch[i]['wfs_conf'] == wfs_name || wfs_name == "") {
-		
-			if (mb_wfs_fetch[i]['geomtype'] == "Polygon") {
-				usemap += mod_usemap_polygon(i);
-			}
-			else if (mb_wfs_fetch[i]['geomtype'] == "Point") {
-				usemap += mod_usemap_circle(i);
-			}
-			else if (mb_wfs_fetch[i]['geomtype'] == "Line") {
-				usemap += mod_usemap_line(i);
-			}
-		}
-	}
-	writeUsemap(usemap);
-}
-
-function mod_usemap_circle(ind){
-	var str = "";
-	var coord = "";
-	
-	for (var i = 0 ; i < mb_wfs_fetch[ind]['geometry'].length ; i ++) {
-		var xArray = mb_wfs_fetch[ind]['geometry'][i]['x'];
-		var yArray = mb_wfs_fetch[ind]['geometry'][i]['y'];
-		var title = getElementValueByName(mb_wfs_fetch, ind, "name") + " (Pt)";
-		var pos = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[0],yArray[0]);
-		coord += pos[0] + ", " + pos[1];
-		
-		str += "<AREA  onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch["+ind+"])' ";
-		str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch["+ind+"])' shape='circle'  coords='";
-		str += coord + ", " + mod_usemap_radius + "' href='#'>";
-	}
-	
-	return str;
-}
-
-function mod_usemap_line_calculate (xArray, yArray, j, orientation, cnt) {
-	var coord = "";
-
-	var p1 = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[j],yArray[j]);
-	var p2 = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[j+orientation],yArray[j+orientation]);
-
-	var vec = new Array();
-	vec[0] = p2[0] - p1[0];
-	vec[1] = p2[1] - p1[1];
-	
-	if (vec[0] != 0 || vec[1] != 0) {
-		n_vec = new Array();
-		if (vec[0] != 0) {
-			if (vec[0] > 0) {
-				n_vec[0] = (-vec[1])/vec[0];
-				n_vec[1] = -1;
-			}
-			else {
-				n_vec[0] = (vec[1])/vec[0];
-				n_vec[1] = 1;
-			}
-		}
-		else {
-			if (vec[1] > 0) {
-				n_vec[0] = 1;
-				n_vec[1] = 0;
-			}
-			else {
-				n_vec[0] = -1;
-				n_vec[1] = 0;
-			}
-		}
-
-		n_vec_length = Math.sqrt(Math.pow(n_vec[0], 2) + Math.pow(n_vec[1], 2));
-		n_vec[0] = (n_vec[0]*mod_usemap_line_tolerance)/n_vec_length;
-		n_vec[1] = (n_vec[1]*mod_usemap_line_tolerance)/n_vec_length;
-
-		lp = new Array();
-		lp[0] = p1[0] + n_vec[0];
-		lp[1] = p1[1] - n_vec[1];
-
-		if (cnt > 0) {
-			coord += ", ";
-		}
-		coord += parseInt(lp[0]) + ", " + parseInt(lp[1]);
-		coord += ", " + parseInt(lp[0]+vec[0]) + ", " + parseInt(lp[1]+vec[1]);
-		
-	}
-	return coord;
-}
-
-function mod_usemap_line(ind){
-	var str = "";
-	for (var i = 0 ; i < mb_wfs_fetch[ind]['geometry'].length ; i ++) {
-		var coord = "";
-		var cnt = 0;
-
-		xArray = new Array();
-		xArray = mb_wfs_fetch[ind]['geometry'][i]['x'];
-		yArray = new Array();
-		yArray = mb_wfs_fetch[ind]['geometry'][i]['y'];
-		
-	
-		for (var j = 0 ; j < xArray.length - 1  ; j ++) {
-			var result = mod_usemap_line_calculate(xArray, yArray, j, 1, cnt);
-			if (result != "") {
-				coord += result;
-				cnt++;
-			}
-		}
-		
-		for (var j = (xArray.length - 1) ; j > 0 ; j--) {
-			var result = mod_usemap_line_calculate(xArray, yArray, j, -1, cnt);
-			if (result != "") {
-				coord += result;
-				cnt++;
-			}
-		}
-		
-		if (coord != "") {
-			str += "<AREA ";
-			str += "onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch["+ind+"])' ";
-			str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch["+ind+"])' ";
-			str += "shape='poly'  coords='";
-			str += coord + "' href='#'>";
-		}
-		else {
-			//display circle
-			var pos = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[0],yArray[0]);
-			coord += pos[0] + ", " + pos[1];
-			
-			str += "<AREA  onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch["+ind+"])' ";
-			str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch["+ind+"])' shape='circle'  coords='";
-			str += coord + ", " + mod_usemap_radius + "' href='#'>";
-		}
-	}
-	
-	return str;
-}
-
-function mod_usemap_polygon(ind){
-	var str = "";
-	var coord = "";
-	
-	for (var i = 0 ; i < mb_wfs_fetch[ind]['geometry'].length ; i ++) {
-		var xArray = mb_wfs_fetch[ind]['geometry'][i]['x'];
-		var yArray = mb_wfs_fetch[ind]['geometry'][i]['y'];
-		var title = getElementValueByName(mb_wfs_fetch, ind, "name") + " (Py)";
-		var pos = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[0],yArray[0]);
-		coord += pos[0] + ", " + pos[1];
-		
-		for (var j = 1 ; j < xArray.length ; j ++) {
-			pos = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[j],yArray[j]);
-			coord += ", " + pos[0] + ", " + pos[1];
-		}
-		
-		str += "<AREA  onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch["+ind+"])' ";
-		str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch["+ind+"])' shape='poly'  coords='";
-		str += coord + "' href='#'>";
-	}
-	
-	return str;
-}
-
-function writeUsemap(str) {
-	writeTag(mb_wfs_targets[0], 'um', str);
-}
-// --- usemap (end) ----------------------------------------------------------------------------------------------
-// ---------------------------------------------------------------------------------------------------------------
-
-
-function mb_repaint() {
-	for (var i = 0 ; i < mb_wfs_targets.length ; i ++) {
-		mf = mb_wfs_targets[i];
-		if (canvas[mf]) {
-			canvas[mf].paint();
-		}
-	}
-}
-
-function mb_wfs_createwin(ind,url){
-	var nid = "mb_wfs_win_"+ind;
-	var iframe=document.createElement('iframe');
-	iframe.setAttribute("src",url + "&id=" + nid);
-	var tmp = document.body.appendChild(iframe);
-	tmp.style.width = '0px';
-	tmp.style.height='0px';
-	tmp.style.visibility = 'hidden';
-}
-
-//
-// x- and y- coordinates are put in different arrays, the old arrays are being deleted
-//
-function rearrangeXY (cnt) {
-	for(var j=0; j<mb_wfs_fetch[cnt]['geometry'].length; j++){
-		var g = mb_wfs_sortXY(mb_wfs_fetch[cnt]['geometry'][j]);
-		mb_wfs_fetch[cnt]['geometry'][j] = new Array();
-		mb_wfs_fetch[cnt]['geometry'][j]['x'] = g[0];
-		mb_wfs_fetch[cnt]['geometry'][j]['y'] = g[1];
-	}
-}
-
-function mb_wfs_register(n,a){
-	var tmp = n.split("_");
-	var current_wfs_name = tmp[3];
-	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
-//	alert("response from " + wfs_conf[tmp[3]]['wfs_conf_abstract']);	
-	if(a && a.length){
-		var str = n + ": \n";
-		for(var i=0; i<a.length; i++){
-			var cnt = mb_wfs_fetch.length;
-
-			var ind = getMapObjIndexByName(mb_wfs_targets[0]);
-			var wfs_tmp = wfs_conf[current_wfs_name]['featuretype_srs'] + " - " + mb_mapObj[ind].epsg;
-
-			if (wfs_conf[current_wfs_name]['featuretype_srs'] == mb_mapObj[ind].epsg) {
-				mb_wfs_fetch[cnt] = a[i];
-				mb_wfs_fetch[cnt]['wfs_conf'] = current_wfs_name;
-				rearrangeXY(cnt);
-
-				var check = mb_wfs_cntBasePoint(mb_wfs_fetch[cnt]['geometry']);
-				if(check == false){
-		
-					var newGeom = mb_wfs_getBBOX(mb_wfs_fetch[cnt]['geometry']);
-	
-					mb_wfs_fetch[cnt]['geometry'] = new Array();
-					mb_wfs_fetch[cnt]['geometry'][0] = new Array();
-					mb_wfs_fetch[cnt]['geometry'][0]['x'] = new Array();
-					mb_wfs_fetch[cnt]['geometry'][0]['y'] = new Array();
-					mb_wfs_fetch[cnt]['geometry'][0]['x'][0] = parseFloat(newGeom[0]);
-					mb_wfs_fetch[cnt]['geometry'][0]['y'][0] = parseFloat(newGeom[1]);
-					mb_wfs_fetch[cnt]['geometry'][0]['x'][1] = parseFloat(newGeom[0]);
-					mb_wfs_fetch[cnt]['geometry'][0]['y'][1] = parseFloat(newGeom[3]);
-					mb_wfs_fetch[cnt]['geometry'][0]['x'][2] = parseFloat(newGeom[2]);
-					mb_wfs_fetch[cnt]['geometry'][0]['y'][2] = parseFloat(newGeom[3]);
-					mb_wfs_fetch[cnt]['geometry'][0]['x'][3] = parseFloat(newGeom[2]);
-					mb_wfs_fetch[cnt]['geometry'][0]['y'][3] = parseFloat(newGeom[1]);
-					mb_wfs_fetch[cnt]['geometry'][0]['x'][4] = parseFloat(newGeom[0]);
-					mb_wfs_fetch[cnt]['geometry'][0]['y'][4] = parseFloat(newGeom[1]);
-				}
-			}
-			else {
-				alert("EPSG mismatch. Invalid WFS result. Press OK to continue.");
-			}
-		}		
-		checkMbWfsFetch();
-	}
-	mb_wfs_listMember(current_wfs_name);
-}
-
-//
-// checks if the mb_wfs_fetch array is valid. If not, a pop up window will display the error(s).
-//
-function checkMbWfsFetch() {
-	var error = "";
-	for (var i = 0 ; i < mb_wfs_fetch.length ; i++) {
-		error += checkWfsObj(i);
-	}
-	if (error) {
-		var wfsWindow = open("about:blank", "wfsattributes", "width=300, height=300, resizable, dependent=yes, scrollbars=yes");
-		wfsWindow.document.open("text/html");			
-		wfsWindow.document.write("An error occured:<br><hr>" + error);
-		wfsWindow.document.close();
-	}
-}
-//
-// checks if a wfs object at index index is valid. if not, alerts will be displayed
-//
-function checkWfsObj (index) {
-	var obj = mb_wfs_fetch[index];
-	var geometry = false;
-	var element = false;
-	var geomtype = false;
-	var wfs_conf = false;
-	var error = "";
-	
-	for (attr in obj) {
-		if (attr == "geometry") {
-			geometry = true;
-			var objGeom = obj['geometry'];
-			var objGeomLength = objGeom.length;
-			if (objGeomLength == 0) {
-				error += "object " + index + " doesn't contain any geometries.<br>";
-			}
-			else {
-				for (var i = 0 ; i < objGeomLength ; i ++) {
-					var objGeomAtIndex = objGeom[i];
-					var x = false;
-					var y = false;
-					for (attrib in objGeomAtIndex) {
-						if (attrib == "x") {
-							x = true;
-						}
-						else if (attrib == "y") {
-							y = true;
-						}
-						else {
-							error += "object " + index + ": unknown geometry attribute: " + attrib + ".<br>";
-						}
-					}					
-					if (x == true && y == true) {
-						if (objGeomAtIndex['x'].length != objGeomAtIndex['y'].length || objGeomAtIndex['x'].length == 0) {
-							error += "object " + index + " has an invalid geometry.<br>";
-						}
-					}
-					else {
-						error += "object " + index + " doesn't contain x- or y-values.<br>";
-					}
-				}
-			}
-		}
-		else if (attr == "element") {
-			elements = true;
-		
-			var objElem = obj['element'];
-			var objElemLength = objElem.length;
-			for (var i = 0 ; i < objElemLength ; i ++) {
-				var objElemAtIndex = objElem[i];
-				var elemName = false;
-				var elemVal = false;
-				for (attrib in objElemAtIndex) {
-					if (attrib == "name") {
-						elemName = true;
-					}
-					else if (attrib == "val") {
-						elemVal = true;
-					}
-					else {
-						error += "object " + index + ": unknown element attributes: " + attrib + ".<br>";
-					}
-				}
-				if (elemName != true || elemVal != true) {
-					error += "object " + index + ": missing object attributes.<br>";
-				}
-				else {
-					if (objElemAtIndex['name'] == "name") {
-						if (!objElemAtIndex['val']) {
-							error += "object " + index + " doesn't have a name.<br>";
-						}
-					}
-				}
-			}
-		}
-		else if (attr == "geomtype") {
-			geomtype = true;
-			if (obj['geomtype'] != "Point" && obj['geomtype'] != "Line" && obj['geomtype'] != "Polygon") {
-				error += "object " + index + ": wrong geometry type.<br>";
-			}
-		}
-		else if (attr == "wfs_conf") {
-			wfs_conf = true;
-			if (!obj['wfs_conf']) {
-				error += "object " + index + ": no wfs conf.<br>";
-			}
-		}
-		else {
-			error += "object " + index + ": unknown attribute: " + attr + ".<br>";
-		}
-		
-	}
-	if (geometry == false || geomtype == false || elements == false) {
-		error += "object " + index + " is corrupted.<br>";
-	}
-	
-	if (error) {
-		error += displayObject(mb_wfs_fetch[index]);
-		error += "<hr>";
-	}
-	return error;
-}
-
-function mb_wfs_reset(){
-	mb_wfs_fetch = new Array();
-	usemap = "";
-	
-	if(mb_wfs_objwin == null){
-		var iframe=document.createElement('div');
-		iframe.setAttribute("style","position:absolute;left:"+mb_wfs_objwin_left+"px;top:"+mb_wfs_objwin_top+"px;width:"+mb_wfs_objwin_width+"px;height:"+mb_wfs_objwin_height+"px");
-		mb_wfs_objwin = document.body.appendChild(iframe);
-		mb_wfs_objwin.id = "mb_wfs_objwin";
-		mb_wfs_objwin.name = "mb_wfs_objwin";
-		mb_wfs_objwin.style.position = 'absolute';
-		mb_wfs_objwin.style.left = mb_wfs_objwin_left+"px";
-		mb_wfs_objwin.style.top = mb_wfs_objwin_top+"px";
-		mb_wfs_objwin.style.width = mb_wfs_objwin_width+"px";
-		mb_wfs_objwin.style.height = mb_wfs_objwin_height+"px";
-	}
-	for(var i=0; i<mb_wfsreq; i++){
-		if(document.getElementById("mb_wfs_win_"+mb_wfsreq)){
-			document.removeChild("mb_wfs_win_"+mb_wfsreq);
-		}
-	}
-	mb_wfsreq = 0;
-	return true;
-}
-
-// 
-// displays an object
-// 
-
-function displayObject (someArray) {
-	var a = someArray;
-	var str = "";
-	
-	for (attr in a) {
-		b = a[attr];
-
-		if (typeof(b) == "object") {
-			str += "<br>[" + attr + "]<br>";
-			str += displayObject(b);
-		}
-		else {
-			str += "<br>[" + attr + "]: " + b + "<br>";
-		}
-	}	
-	return str;
-}
-
-//
-// returns an element value by name
-//
-function getElementValueByName(member, memberIndex, elementName) {
-	var arrayLength = member[memberIndex]['element'].length;
-	for (var j = 0 ; j < arrayLength ; j++) {
-		if (member[memberIndex]['element'][j]['name'] == elementName) {
-			return member[memberIndex]['element'][j]['val'];
-		}
-	}
-	return false;
-}
-
-function mb_wfs_listMember(wfs_name){
-	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
-	var usemap = "";
-	var str = "<table>";
-	for(var i=0; i<mb_wfs_fetch.length; i++){
-		var t = wfs_conf[mb_wfs_fetch[i]['wfs_conf']];
-//		str += t['g_label']+ ": <br>";
-		for(var j=0; j<t['element'].length; j++){
-			if(t['element'][j]['f_show'] > 0){
-				
-				for(var k=0; k<mb_wfs_fetch[i]['element'].length; k++){
-					if(t['element'][j]['element_name'] == mb_wfs_fetch[i]['element'][k]['name']){
-						//str += mb_wfs_fetch[i]['element'][k]['name'] + ": ";
-						str += "<tr><td><img src = '../img/wfs_digitize.png' onClick = 'tab_open(digiFrame);parent.window.frames[digiFrame].addMember(mb_wfs_fetch["+i+"])'></td>";
-						
-						str += "<td>";
-						if (useCheckboxForHighlighting) {
-							str += "<input type=checkbox id=highlightCheckbox" + i + " onClick='highlightGeometry()'></td><td>";
-						}
-				
-						str += "<div";
-						if (!useCheckboxForHighlighting) {
-							str += " onmouseover='mb_wfs_perform(\"over\",mb_wfs_fetch["+i+"])' ";
-							str += " onmouseout='mb_wfs_perform(\"out\",mb_wfs_fetch["+i+"])' ";
-						}
-						str += " onclick='mb_wfs_perform(\"click\",mb_wfs_fetch["+i+"])' ";
-						str += ">" + mb_wfs_fetch[i]['element'][k]['val']+"</div></td></tr>";
-					}
-				}
-			}
-		}
-	}
-	str += "</table>";
-	mb_wfs_objwin.innerHTML = str;
-	if (useUsemap) {
-		mod_usemap(wfs_name);
-	}
-}
-
-
-function highlightGeometry() {
-	var l = mb_wfs_fetch.length;
-//	if (l > 0) {
-		mb_wfs_wzClean();
-		mb_wfs_checkTag();
-//	}
-	for (var i = 0; i < l ; i++) {
-		var id = "highlightCheckbox"+i;
-		var cb = document.getElementById(id);
-		if (cb) {
-			if (cb.checked) {
-				mb_wfs_draw(mb_wfs_fetch[i]);
-			}
-		}
-	}
-	mb_repaint();
-}
-
-function get_wfs_conf(index) {
-	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
-	return wfs_conf[index];
-}
-
-function get_complete_wfs_conf() {
-	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
-	return wfs_conf;
-}
-
-function mb_wfs_perform(type,m){
-	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
-	if(type=='over'){
-		mb_wfs_checkTag();
-		mb_wfs_draw(m);
-		mb_repaint();
-	}
-	if(type=='out'){
-		if (useCheckboxForHighlighting) {
-			highlightGeometry();
-		}
-		else {
-			mb_wfs_wzClean();
-		}
-	}
-	if(type=='click'){
-		mb_wfs_checkTag();
-		var tmp = mb_wfs_getBBOX(m['geometry']);
-		var b = parseFloat(wfs_conf[m['wfs_conf']]['g_buffer']);
-		mb_calculateExtent(mb_wfs_targets[0],parseFloat(tmp[0])-b,parseFloat(tmp[1])-b,parseFloat(tmp[2])+b,parseFloat(tmp[3])+b);
-		zoom(mb_wfs_targets[0], 'true', 1.0);
-		if (!useCheckboxForHighlighting) {
-			mb_wfs_draw(m);
-		}
-	}
-}
-function mb_wfs_cntBasePoint(g){
-	var c = 0;
-	for(var i=0; i<g.length;i++){
-		c += (Math.round(g[i]['x'].length)/2);
-	}
-	if(c <= mb_wfs_maxBasePoints){
-		return true;
-	}
-	else{
-		return false;
-	}
-}
-function mb_wfs_getBBOX(g){
-	var tmp_x = new Array();
-	var tmp_y = new Array();
-
-	for(var i=0; i<g.length;i++){
-		tmp_x = tmp_x.concat(g[i]['x']);
-		tmp_y = tmp_y.concat(g[i]['y']);
-	}
-
-	var min_x = parseFloat(tmp_x[0]);
-	var min_y = parseFloat(tmp_y[0]);
-	var max_x = parseFloat(tmp_x[0]);
-	var max_y = parseFloat(tmp_y[0]);
-
-	var x,y;
-	
-	for(var i=1; i<tmp_x.length; i++){
-		x = parseFloat(tmp_x[i]);
-		y = parseFloat(tmp_y[i]);
-		if (x < min_x) {
-			min_x = x;
-		}
-		else if (x > max_x) {
-			max_x = x;
-		}
-		if (y < min_y) {
-			min_y = y;
-		}
-		else if (y > max_y) {
-			max_y = y;
-		}
-	}
-	var r = new Array(min_x, min_y, max_x, max_y);
-	return r;
-}
-
-function mb_wfs_checkPix(frame,g){
-	var tmp = mb_wfs_getBBOX(g);
-	var minpix = makeRealWorld2mapPos(frame,tmp[0],tmp[3]);
-	var maxpix = makeRealWorld2mapPos(frame,tmp[2],tmp[1]);
-	if((maxpix[0] - minpix[0] < mb_wfs_minPix) && (maxpix[1] - minpix[1] < mb_wfs_minPix)){
-		return false;
-	}
-	else{
-		return true;
-	}
-}
-function mb_wfs_center(frame,g){
-	var tmp = mb_wfs_getBBOX(g);
-	var x = parseFloat(tmp[0]) + parseFloat((tmp[2] - tmp[0])/2);
-	var y = parseFloat(tmp[1]) + parseFloat((tmp[3] - tmp[1])/2);
-	var r = new Array();
-	r[0] = new Array();
-	r[0]['x'] = new Array();
-	r[0]['y'] = new Array();
-	r[0]['x'][0] = x;
-	r[0]['y'][0] = y;
-	return r;
-}
-function mb_wfs_draw(m){
-	var t = m['geomtype'];
-	if(t.indexOf("Point")>-1){
-		for(var i=0; i<mb_wfs_targets.length; i++){
-			mb_wfs_wz(mb_wfs_targets[i],'Point',m['geometry']);
-		}
-	}
-	else if(t.indexOf("Line")>-1){
-		for(var i=0; i<mb_wfs_targets.length; i++){
-			var c = mb_wfs_checkPix(mb_wfs_targets[i],m['geometry']);
-			if(c == false){
-				var r = mb_wfs_center(mb_wfs_targets[i],m['geometry']);
-				mb_wfs_wz(mb_wfs_targets[i],'Point',r);
-			}
-			else{
-				mb_wfs_wz(mb_wfs_targets[i],'Line',m['geometry']);
-			}
-		}
-	}
-	else if(t.indexOf("Polygon")>-1){
-		for(var i=0; i<mb_wfs_targets.length; i++){
-			var c = mb_wfs_checkPix(mb_wfs_targets[i],m['geometry']);
-			if(c == false){
-				var r = mb_wfs_center(mb_wfs_targets[i],m['geometry']);
-				mb_wfs_wz(mb_wfs_targets[i],'Point',r);
-			}
-			else{
-				mb_wfs_wz(mb_wfs_targets[i],'Polygon',m['geometry']);
-			}
-		}
-	}
-	else{
-		alert("unknown geomtype");
-	}	
-}
-function mb_wfs_wz(mf,t,g){
-	if(t=='Point'){
-		for(var i=0; i<g.length; i++){
-			var apos = mb_wfs_toPix(mf,g[i]);
-			canvas[mf].setColor(mb_wfs_lineColor);
-			canvas[mf].drawEllipse((apos[0]-mb_wfs_diameter/2),(apos[1]-mb_wfs_diameter/2),mb_wfs_diameter,mb_wfs_diameter);
-		}
-	}
-	else if(t=='Line'){
-		for(var i=0; i<g.length; i++){
-			var apos = mb_wfs_toPix(mf,g[i]);	
-			canvas[mf].setColor(mb_wfs_lineColor);
-			canvas[mf].drawPolyline(apos[0],apos[1]);
-		}	
-	}
-	else if(t=='Polygon'){
-		for(var i=0; i<g.length; i++){
-			var apos = mb_wfs_toPix(mf,g[i]);	
-			mb_wfs_toPix(mf,g[i]);	
-			canvas[mf].setColor(mb_wfs_lineColor);
-			canvas[mf].drawPolygon(apos[0],apos[1]);
-		}
-	}
-}
-function mb_wfs_wzClean(){
-	for(var i=0; i<mb_wfs_targets.length; i++){
-		var el = window.frames[mb_wfs_targets[i]].document.getElementById('mod_gaz_draw');
-		if (el) el.innerHTML = "";
-		canvasHasDrawing[mb_wfs_targets[i]] = false;
-	}
-	return true;
-}
-function mb_wfs_checkTag(){
-	for(var i=0; i<mb_wfs_targets.length; i++){
-		var isTag = (window.frames[mb_wfs_targets[i]].document.getElementById('mod_gaz_draw'))?1:0;
-		if(isTag == 0){
-			var draw = window.frames[mb_wfs_targets[i]].document.createElement("div");
-			var tmp = window.frames[mb_wfs_targets[i]].document.getElementsByTagName("body")[0].appendChild(draw);
-			tmp.setAttribute("id","mod_gaz_draw");
-			tmp.setAttribute("style","position:absolute;top:0px;left:0px;width:0px;height:0px;z-index:100");
-		}
-		canvas[mb_wfs_targets[i]] = new jsGraphics('mod_gaz_draw', window.frames[mb_wfs_targets[i]]);
-		canvas[mb_wfs_targets[i]].setStroke(3);
-		canvasHasDrawing[mb_wfs_targets[i]] = false;
-	}
-	return true;
-}
-function mb_wfs_sortXY(g){
-	var r = new Array();
-	r[0] = new Array();
-	r[1] = new Array();
-	var cnt = 0;
-	for(var i=0; i<g.length -1 ; i+=2){
-		r[0][cnt] = g[i];
-		r[1][cnt] = g[i+1];
-		cnt++;
-	}
-	return r;
-}
-function mb_wfs_toPix(mf,g){
-	var r = new Array();
-	r[0] = new Array();
-	r[1] = new Array(); 
-	for(var i=0; i<g['x'].length; i++){
-		var pos = makeRealWorld2mapPos(mf,g['x'][i],g['y'][i]);
-		r[0][i] = pos[0];
-		r[1][i] = pos[1];
-	}
-	return r;
+var digiFrame = "digitize";
+var mb_wfs_fetched = new Array();
+var	mb_wfs_fetch = new Array();
+var mb_wfsreq = 0;
+var mb_wfs_tolerance = 8;
+var mb_wfs_target = "mapframe1";
+var mb_wfs_objwin = null;
+var mb_wfs_objwin_left = 800;
+var mb_wfs_objwin_top = 200;
+var mb_wfs_objwin_width = 200;
+var mb_wfs_objwin_height = 200;
+var mb_wfs_targets = new Array("mapframe1","overview");
+var mb_wfs_minPix = 8;
+var mb_wfs_maxBasePoints = 100;
+var mb_wfs_lineColor = "#ff0000";
+var mb_wfs_fillColor = "#ff0000";
+var mb_wfs_diameter = 8;
+var usemap = "";
+var mod_usemap_radius = 10;
+var mod_usemap_line_tolerance = 5;
+var canvas = new Array();
+var canvasHasDrawing = new Array();
+var useCheckboxForHighlighting = true;
+var useUsemap = false;
+
+if (useCheckboxForHighlighting) { 
+	mb_registerSubFunctions('highlightGeometry()');
+}
+
+if (useUsemap) {
+	mb_registerSubFunctions('mod_usemap("")');
+}
+ 
+if (useExtentIsSet()) {
+	mb_registerSubFunctions("mb_setwfsrequest_extent()");
+}
+
+function mb_setwfsrequest_extent() {
+
+	if (useExtentIsSet()) {
+		var ind = getMapObjIndexByName(mb_wfs_targets[0]);
+		var pos_a = makeClickPos2RealWorldPos(mb_wfs_targets[0],0,0);
+		var pos_b = makeClickPos2RealWorldPos(mb_wfs_targets[0],mb_mapObj[ind].width,mb_mapObj[ind].height);
+	
+		var x = new Array();
+		var y = new Array();
+		x[0] = pos_a[0];
+		x[1] = pos_b[0];
+		y[0] = pos_a[1];
+		y[1] = pos_b[1];
+		
+		mb_setwfsrequest(mb_wfs_targets[0],'rectangle',x,y);
+	}
+}
+ 
+function mb_setwfsrequest(target,type,x,y){
+	mb_wfs_reset();
+	var ind = getMapObjIndexByName(target);
+	var w = new Array();
+	var w_ = new Array();
+	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
+	for(var i=0; i<mb_mapObj[ind].wms.length; i++){
+		for(var ii=0; ii<mb_mapObj[ind].wms[i].objLayer.length; ii++){
+			var o = mb_mapObj[ind].wms[i].objLayer[ii];
+			if(o.gui_layer_wfs_featuretype != '' && o.gui_layer_querylayer == '1'){
+				w[w.length] = o.gui_layer_wfs_featuretype;
+			}	
+		}
+	}
+	for(var i=0; i<w.length; i++){
+		for(var ii=0; ii<wfs_conf.length; ii++){			
+			if(wfs_conf[ii]['wfs_conf_id'] == w[i]){
+				w_[w_.length] = ii;
+			}
+		}
+	}
+	if(type=='point'){
+		type = 'rectangle';
+		var tmp = makeRealWorld2mapPos(mb_wfs_target,x[0], y[0]);
+		var n1 = makeClickPos2RealWorldPos(mb_wfs_target, (tmp[0] + mb_wfs_tolerance/2), (tmp[1] + mb_wfs_tolerance/2));
+		x[0] = n1[0];
+		y[0] = n1[1];
+		var n2 = makeClickPos2RealWorldPos(mb_wfs_target, (tmp[0] - mb_wfs_tolerance/2), (tmp[1] - mb_wfs_tolerance/2));
+		x[1] = n2[0];
+		y[1] = n2[1];
+	}
+	if(type=='polygon'){
+		for(var i=0; i<w_.length; i++){
+			var path = "../php/mod_wfs_result.php?url=";
+			var url = wfs_conf[w_[i]]['wfs_getfeature'];
+			url += "service=wfs&request=getFeature&version=1.0.0";
+			url += "&typename="+ wfs_conf[w_[i]]['featuretype_name'];
+			url += "&filter=";
+			path += escape(url);
+			path += "&filter=";
+			var filter = '<ogc:Filter xmlns:ogc="http://ogc.org" xmlns:gml="http://www.opengis.net/gml">';
+			filter += "<Within>";
+				filter += '<ogc:PropertyName>';
+					for(var j=0; j<wfs_conf[w_[i]]['element'].length; j++){
+						if(wfs_conf[w_[i]]['element'][j]['f_geom'] == 1){
+							filter += wfs_conf[w_[i]]['element'][j]['element_name'];
+						}
+					}
+				filter += "</ogc:PropertyName>";
+				filter += '<gml:Polygon srsName="EPSG:4326">';
+					filter += '<gml:outerBoundaryIs>';
+						filter += '<gml:LinearRing>';
+							filter += '<gml:coordinates>';
+								for(var k=0; k<x.length; k++){
+									if(k>0){
+										filter += " ";
+									}
+									filter += x[k]+","+y[k];								 
+								}
+							filter += '</gml:coordinates>';
+						filter += '</gml:LinearRing>';
+					filter += '</gml:outerBoundaryIs>';
+				filter += '</gml:Polygon>';
+			filter += '</Within>';
+			filter += '</ogc:Filter>';
+			path += filter;
+			mb_wfs_createwin(mb_wfsreq,path);
+			mb_wfsreq++;
+		}
+	}
+	if(type=='rectangle'){
+		for(var i=0; i<w_.length; i++){
+			var path = "../php/mod_wfs_result.php?url=";
+			var url = wfs_conf[w_[i]]['wfs_getfeature'];
+			url += "service=wfs&request=getFeature&version=1.0.0";
+			url += "&typename="+ wfs_conf[w_[i]]['featuretype_name'];
+			url += "&filter=";
+			path += escape(url);
+			path += "&filter=";
+			var filter = '<ogc:Filter xmlns:ogc="http://ogc.org" xmlns:gml="http://www.opengis.net/gml">';
+			filter += "<ogc:BBOX>";
+			filter += '<ogc:PropertyName>';
+				for(var j=0; j<wfs_conf[w_[i]]['element'].length; j++){
+					if(wfs_conf[w_[i]]['element'][j]['f_geom'] == 1){
+						filter += wfs_conf[w_[i]]['element'][j]['element_name'];
+					}
+				}
+			filter += "</ogc:PropertyName>";
+			filter += '<gml:Box srsName="4326"><gml:coordinates>';	
+				filter += x[0]+","+y[0];
+				filter += " ";
+				filter += x[1]+","+y[1]; 
+			filter += '</gml:coordinates></gml:Box></ogc:BBOX>';
+			filter += '</ogc:Filter>';
+			path += filter;
+			mb_wfs_createwin(mb_wfsreq,path);
+			mb_wfsreq++;
+		}
+	}
+}
+
+// ---------------------------------------------------------------------------------------------------------------
+// --- usemap (begin) --------------------------------------------------------------------------------------------
+
+function mod_usemap (wfs_name) {
+	if (wfs_name == "") {
+		usemap = "";
+	}
+	var ind = getMapObjIndexByName(mb_wfs_targets[0]);
+	var myImg = window.frames[mb_wfs_targets[0]].document.getElementById("um_img").style; 
+	myImg.width = mb_mapObj[ind].width;
+	myImg.height = mb_mapObj[ind].height;
+
+	for (var i = 0 ; i < mb_wfs_fetch.length ; i ++) {
+	
+		if (mb_wfs_fetch[i]['wfs_conf'] == wfs_name || wfs_name == "") {
+		
+			if (mb_wfs_fetch[i]['geomtype'] == "Polygon") {
+				usemap += mod_usemap_polygon(i);
+			}
+			else if (mb_wfs_fetch[i]['geomtype'] == "Point") {
+				usemap += mod_usemap_circle(i);
+			}
+			else if (mb_wfs_fetch[i]['geomtype'] == "Line") {
+				usemap += mod_usemap_line(i);
+			}
+		}
+	}
+	writeUsemap(usemap);
+}
+
+function mod_usemap_circle(ind){
+	var str = "";
+	var coord = "";
+	
+	for (var i = 0 ; i < mb_wfs_fetch[ind]['geometry'].length ; i ++) {
+		var xArray = mb_wfs_fetch[ind]['geometry'][i]['x'];
+		var yArray = mb_wfs_fetch[ind]['geometry'][i]['y'];
+		var title = getElementValueByName(mb_wfs_fetch, ind, "name") + " (Pt)";
+		var pos = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[0],yArray[0]);
+		coord += pos[0] + ", " + pos[1];
+		
+		str += "<AREA  onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch["+ind+"])' ";
+		str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch["+ind+"])' shape='circle'  coords='";
+		str += coord + ", " + mod_usemap_radius + "' href='#'>";
+	}
+	
+	return str;
+}
+
+function mod_usemap_line_calculate (xArray, yArray, j, orientation, cnt) {
+	var coord = "";
+
+	var p1 = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[j],yArray[j]);
+	var p2 = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[j+orientation],yArray[j+orientation]);
+
+	var vec = new Array();
+	vec[0] = p2[0] - p1[0];
+	vec[1] = p2[1] - p1[1];
+	
+	if (vec[0] != 0 || vec[1] != 0) {
+		n_vec = new Array();
+		if (vec[0] != 0) {
+			if (vec[0] > 0) {
+				n_vec[0] = (-vec[1])/vec[0];
+				n_vec[1] = -1;
+			}
+			else {
+				n_vec[0] = (vec[1])/vec[0];
+				n_vec[1] = 1;
+			}
+		}
+		else {
+			if (vec[1] > 0) {
+				n_vec[0] = 1;
+				n_vec[1] = 0;
+			}
+			else {
+				n_vec[0] = -1;
+				n_vec[1] = 0;
+			}
+		}
+
+		n_vec_length = Math.sqrt(Math.pow(n_vec[0], 2) + Math.pow(n_vec[1], 2));
+		n_vec[0] = (n_vec[0]*mod_usemap_line_tolerance)/n_vec_length;
+		n_vec[1] = (n_vec[1]*mod_usemap_line_tolerance)/n_vec_length;
+
+		lp = new Array();
+		lp[0] = p1[0] + n_vec[0];
+		lp[1] = p1[1] - n_vec[1];
+
+		if (cnt > 0) {
+			coord += ", ";
+		}
+		coord += parseInt(lp[0]) + ", " + parseInt(lp[1]);
+		coord += ", " + parseInt(lp[0]+vec[0]) + ", " + parseInt(lp[1]+vec[1]);
+		
+	}
+	return coord;
+}
+
+function mod_usemap_line(ind){
+	var str = "";
+	for (var i = 0 ; i < mb_wfs_fetch[ind]['geometry'].length ; i ++) {
+		var coord = "";
+		var cnt = 0;
+
+		xArray = new Array();
+		xArray = mb_wfs_fetch[ind]['geometry'][i]['x'];
+		yArray = new Array();
+		yArray = mb_wfs_fetch[ind]['geometry'][i]['y'];
+		
+	
+		for (var j = 0 ; j < xArray.length - 1  ; j ++) {
+			var result = mod_usemap_line_calculate(xArray, yArray, j, 1, cnt);
+			if (result != "") {
+				coord += result;
+				cnt++;
+			}
+		}
+		
+		for (var j = (xArray.length - 1) ; j > 0 ; j--) {
+			var result = mod_usemap_line_calculate(xArray, yArray, j, -1, cnt);
+			if (result != "") {
+				coord += result;
+				cnt++;
+			}
+		}
+		
+		if (coord != "") {
+			str += "<AREA ";
+			str += "onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch["+ind+"])' ";
+			str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch["+ind+"])' ";
+			str += "shape='poly'  coords='";
+			str += coord + "' href='#'>";
+		}
+		else {
+			//display circle
+			var pos = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[0],yArray[0]);
+			coord += pos[0] + ", " + pos[1];
+			
+			str += "<AREA  onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch["+ind+"])' ";
+			str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch["+ind+"])' shape='circle'  coords='";
+			str += coord + ", " + mod_usemap_radius + "' href='#'>";
+		}
+	}
+	
+	return str;
+}
+
+function mod_usemap_polygon(ind){
+	var str = "";
+	var coord = "";
+	
+	for (var i = 0 ; i < mb_wfs_fetch[ind]['geometry'].length ; i ++) {
+		var xArray = mb_wfs_fetch[ind]['geometry'][i]['x'];
+		var yArray = mb_wfs_fetch[ind]['geometry'][i]['y'];
+		var title = getElementValueByName(mb_wfs_fetch, ind, "name") + " (Py)";
+		var pos = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[0],yArray[0]);
+		coord += pos[0] + ", " + pos[1];
+		
+		for (var j = 1 ; j < xArray.length ; j ++) {
+			pos = makeRealWorld2mapPos(mb_wfs_targets[0],xArray[j],yArray[j]);
+			coord += ", " + pos[0] + ", " + pos[1];
+		}
+		
+		str += "<AREA  onmouseover='parent.mb_wfs_perform(\"over\",parent.mb_wfs_fetch["+ind+"])' ";
+		str += "onmouseout='parent.mb_wfs_perform(\"out\",parent.mb_wfs_fetch["+ind+"])' shape='poly'  coords='";
+		str += coord + "' href='#'>";
+	}
+	
+	return str;
+}
+
+function writeUsemap(str) {
+	writeTag(mb_wfs_targets[0], 'um', str);
+}
+// --- usemap (end) ----------------------------------------------------------------------------------------------
+// ---------------------------------------------------------------------------------------------------------------
+
+
+function mb_repaint() {
+	for (var i = 0 ; i < mb_wfs_targets.length ; i ++) {
+		mf = mb_wfs_targets[i];
+		if (canvas[mf]) {
+			canvas[mf].paint();
+		}
+	}
+}
+
+function mb_wfs_createwin(ind,url){
+	var nid = "mb_wfs_win_"+ind;
+	var iframe=document.createElement('iframe');
+	iframe.setAttribute("src",url + "&id=" + nid);
+	var tmp = document.body.appendChild(iframe);
+	tmp.style.width = '0px';
+	tmp.style.height='0px';
+	tmp.style.visibility = 'hidden';
+}
+
+//
+// x- and y- coordinates are put in different arrays, the old arrays are being deleted
+//
+function rearrangeXY (cnt) {
+	for(var j=0; j<mb_wfs_fetch[cnt]['geometry'].length; j++){
+		var g = mb_wfs_sortXY(mb_wfs_fetch[cnt]['geometry'][j]);
+		mb_wfs_fetch[cnt]['geometry'][j] = new Array();
+		mb_wfs_fetch[cnt]['geometry'][j]['x'] = g[0];
+		mb_wfs_fetch[cnt]['geometry'][j]['y'] = g[1];
+	}
+}
+
+function mb_wfs_register(n,a){
+	var tmp = n.split("_");
+	var current_wfs_name = tmp[3];
+	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
+//	alert("response from " + wfs_conf[tmp[3]]['wfs_conf_abstract']);	
+	if(a && a.length){
+		var str = n + ": \n";
+		for(var i=0; i<a.length; i++){
+			var cnt = mb_wfs_fetch.length;
+
+			var ind = getMapObjIndexByName(mb_wfs_targets[0]);
+			var wfs_tmp = wfs_conf[current_wfs_name]['featuretype_srs'] + " - " + mb_mapObj[ind].epsg;
+
+			if (wfs_conf[current_wfs_name]['featuretype_srs'] == mb_mapObj[ind].epsg) {
+				mb_wfs_fetch[cnt] = a[i];
+				mb_wfs_fetch[cnt]['wfs_conf'] = current_wfs_name;
+				rearrangeXY(cnt);
+
+				var check = mb_wfs_cntBasePoint(mb_wfs_fetch[cnt]['geometry']);
+				if(check == false){
+		
+					var newGeom = mb_wfs_getBBOX(mb_wfs_fetch[cnt]['geometry']);
+	
+					mb_wfs_fetch[cnt]['geometry'] = new Array();
+					mb_wfs_fetch[cnt]['geometry'][0] = new Array();
+					mb_wfs_fetch[cnt]['geometry'][0]['x'] = new Array();
+					mb_wfs_fetch[cnt]['geometry'][0]['y'] = new Array();
+					mb_wfs_fetch[cnt]['geometry'][0]['x'][0] = parseFloat(newGeom[0]);
+					mb_wfs_fetch[cnt]['geometry'][0]['y'][0] = parseFloat(newGeom[1]);
+					mb_wfs_fetch[cnt]['geometry'][0]['x'][1] = parseFloat(newGeom[0]);
+					mb_wfs_fetch[cnt]['geometry'][0]['y'][1] = parseFloat(newGeom[3]);
+					mb_wfs_fetch[cnt]['geometry'][0]['x'][2] = parseFloat(newGeom[2]);
+					mb_wfs_fetch[cnt]['geometry'][0]['y'][2] = parseFloat(newGeom[3]);
+					mb_wfs_fetch[cnt]['geometry'][0]['x'][3] = parseFloat(newGeom[2]);
+					mb_wfs_fetch[cnt]['geometry'][0]['y'][3] = parseFloat(newGeom[1]);
+					mb_wfs_fetch[cnt]['geometry'][0]['x'][4] = parseFloat(newGeom[0]);
+					mb_wfs_fetch[cnt]['geometry'][0]['y'][4] = parseFloat(newGeom[1]);
+				}
+			}
+			else {
+				alert("EPSG mismatch. Invalid WFS result. Press OK to continue.");
+			}
+		}		
+		checkMbWfsFetch();
+	}
+	mb_wfs_listMember(current_wfs_name);
+}
+
+//
+// checks if the mb_wfs_fetch array is valid. If not, a pop up window will display the error(s).
+//
+function checkMbWfsFetch() {
+	var error = "";
+	for (var i = 0 ; i < mb_wfs_fetch.length ; i++) {
+		error += checkWfsObj(i);
+	}
+	if (error) {
+		var wfsWindow = open("about:blank", "wfsattributes", "width=300, height=300, resizable, dependent=yes, scrollbars=yes");
+		wfsWindow.document.open("text/html");			
+		wfsWindow.document.write("An error occured:<br><hr>" + error);
+		wfsWindow.document.close();
+	}
+}
+//
+// checks if a wfs object at index index is valid. if not, alerts will be displayed
+//
+function checkWfsObj (index) {
+	var obj = mb_wfs_fetch[index];
+	var geometry = false;
+	var element = false;
+	var geomtype = false;
+	var wfs_conf = false;
+	var error = "";
+	
+	for (attr in obj) {
+		if (attr == "geometry") {
+			geometry = true;
+			var objGeom = obj['geometry'];
+			var objGeomLength = objGeom.length;
+			if (objGeomLength == 0) {
+				error += "object " + index + " doesn't contain any geometries.<br>";
+			}
+			else {
+				for (var i = 0 ; i < objGeomLength ; i ++) {
+					var objGeomAtIndex = objGeom[i];
+					var x = false;
+					var y = false;
+					for (attrib in objGeomAtIndex) {
+						if (attrib == "x") {
+							x = true;
+						}
+						else if (attrib == "y") {
+							y = true;
+						}
+						else {
+							error += "object " + index + ": unknown geometry attribute: " + attrib + ".<br>";
+						}
+					}					
+					if (x == true && y == true) {
+						if (objGeomAtIndex['x'].length != objGeomAtIndex['y'].length || objGeomAtIndex['x'].length == 0) {
+							error += "object " + index + " has an invalid geometry.<br>";
+						}
+					}
+					else {
+						error += "object " + index + " doesn't contain x- or y-values.<br>";
+					}
+				}
+			}
+		}
+		else if (attr == "element") {
+			elements = true;
+		
+			var objElem = obj['element'];
+			var objElemLength = objElem.length;
+			for (var i = 0 ; i < objElemLength ; i ++) {
+				var objElemAtIndex = objElem[i];
+				var elemName = false;
+				var elemVal = false;
+				for (attrib in objElemAtIndex) {
+					if (attrib == "name") {
+						elemName = true;
+					}
+					else if (attrib == "val") {
+						elemVal = true;
+					}
+					else {
+						error += "object " + index + ": unknown element attributes: " + attrib + ".<br>";
+					}
+				}
+				if (elemName != true || elemVal != true) {
+					error += "object " + index + ": missing object attributes.<br>";
+				}
+				else {
+					if (objElemAtIndex['name'] == "name") {
+						if (!objElemAtIndex['val']) {
+							error += "object " + index + " doesn't have a name.<br>";
+						}
+					}
+				}
+			}
+		}
+		else if (attr == "geomtype") {
+			geomtype = true;
+			if (obj['geomtype'] != "Point" && obj['geomtype'] != "Line" && obj['geomtype'] != "Polygon") {
+				error += "object " + index + ": wrong geometry type.<br>";
+			}
+		}
+		else if (attr == "wfs_conf") {
+			wfs_conf = true;
+			if (!obj['wfs_conf']) {
+				error += "object " + index + ": no wfs conf.<br>";
+			}
+		}
+		else {
+			error += "object " + index + ": unknown attribute: " + attr + ".<br>";
+		}
+		
+	}
+	if (geometry == false || geomtype == false || elements == false) {
+		error += "object " + index + " is corrupted.<br>";
+	}
+	
+	if (error) {
+		error += displayObject(mb_wfs_fetch[index]);
+		error += "<hr>";
+	}
+	return error;
+}
+
+function mb_wfs_reset(){
+	mb_wfs_fetch = new Array();
+	usemap = "";
+	
+	if(mb_wfs_objwin == null){
+		var iframe=document.createElement('div');
+		iframe.setAttribute("style","position:absolute;left:"+mb_wfs_objwin_left+"px;top:"+mb_wfs_objwin_top+"px;width:"+mb_wfs_objwin_width+"px;height:"+mb_wfs_objwin_height+"px");
+		mb_wfs_objwin = document.body.appendChild(iframe);
+		mb_wfs_objwin.id = "mb_wfs_objwin";
+		mb_wfs_objwin.name = "mb_wfs_objwin";
+		mb_wfs_objwin.style.position = 'absolute';
+		mb_wfs_objwin.style.left = mb_wfs_objwin_left+"px";
+		mb_wfs_objwin.style.top = mb_wfs_objwin_top+"px";
+		mb_wfs_objwin.style.width = mb_wfs_objwin_width+"px";
+		mb_wfs_objwin.style.height = mb_wfs_objwin_height+"px";
+	}
+	for(var i=0; i<mb_wfsreq; i++){
+		if(document.getElementById("mb_wfs_win_"+mb_wfsreq)){
+			document.removeChild("mb_wfs_win_"+mb_wfsreq);
+		}
+	}
+	mb_wfsreq = 0;
+	return true;
+}
+
+// 
+// displays an object
+// 
+
+function displayObject (someArray) {
+	var a = someArray;
+	var str = "";
+	
+	for (attr in a) {
+		b = a[attr];
+
+		if (typeof(b) == "object") {
+			str += "<br>[" + attr + "]<br>";
+			str += displayObject(b);
+		}
+		else {
+			str += "<br>[" + attr + "]: " + b + "<br>";
+		}
+	}	
+	return str;
+}
+
+//
+// returns an element value by name
+//
+function getElementValueByName(member, memberIndex, elementName) {
+	var arrayLength = member[memberIndex]['element'].length;
+	for (var j = 0 ; j < arrayLength ; j++) {
+		if (member[memberIndex]['element'][j]['name'] == elementName) {
+			return member[memberIndex]['element'][j]['val'];
+		}
+	}
+	return false;
+}
+
+function mb_wfs_listMember(wfs_name){
+	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
+	var usemap = "";
+	var str = "<table>";
+	for(var i=0; i<mb_wfs_fetch.length; i++){
+		var t = wfs_conf[mb_wfs_fetch[i]['wfs_conf']];
+//		str += t['g_label']+ ": <br>";
+		for(var j=0; j<t['element'].length; j++){
+			if(t['element'][j]['f_show'] > 0){
+				
+				for(var k=0; k<mb_wfs_fetch[i]['element'].length; k++){
+					if(t['element'][j]['element_name'] == mb_wfs_fetch[i]['element'][k]['name']){
+						//str += mb_wfs_fetch[i]['element'][k]['name'] + ": ";
+						str += "<tr><td><img src = '../img/wfs_digitize.png' onClick = 'tab_open(digiFrame);parent.window.frames[digiFrame].addMember(mb_wfs_fetch["+i+"])'></td>";
+						
+						str += "<td>";
+						if (useCheckboxForHighlighting) {
+							str += "<input type=checkbox id=highlightCheckbox" + i + " onClick='highlightGeometry()'></td><td>";
+						}
+				
+						str += "<div";
+						if (!useCheckboxForHighlighting) {
+							str += " onmouseover='mb_wfs_perform(\"over\",mb_wfs_fetch["+i+"])' ";
+							str += " onmouseout='mb_wfs_perform(\"out\",mb_wfs_fetch["+i+"])' ";
+						}
+						str += " onclick='mb_wfs_perform(\"click\",mb_wfs_fetch["+i+"])' ";
+						str += ">" + mb_wfs_fetch[i]['element'][k]['val']+"</div></td></tr>";
+					}
+				}
+			}
+		}
+	}
+	str += "</table>";
+	mb_wfs_objwin.innerHTML = str;
+	if (useUsemap) {
+		mod_usemap(wfs_name);
+	}
+}
+
+
+function highlightGeometry() {
+	var l = mb_wfs_fetch.length;
+//	if (l > 0) {
+		mb_wfs_wzClean();
+		mb_wfs_checkTag();
+//	}
+	for (var i = 0; i < l ; i++) {
+		var id = "highlightCheckbox"+i;
+		var cb = document.getElementById(id);
+		if (cb) {
+			if (cb.checked) {
+				mb_wfs_draw(mb_wfs_fetch[i]);
+			}
+		}
+	}
+	mb_repaint();
+}
+
+function get_wfs_conf(index) {
+	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
+	return wfs_conf[index];
+}
+
+function get_complete_wfs_conf() {
+	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
+	return wfs_conf;
+}
+
+function mb_wfs_perform(type,m){
+	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
+	if(type=='over'){
+		mb_wfs_checkTag();
+		mb_wfs_draw(m);
+		mb_repaint();
+	}
+	if(type=='out'){
+		if (useCheckboxForHighlighting) {
+			highlightGeometry();
+		}
+		else {
+			mb_wfs_wzClean();
+		}
+	}
+	if(type=='click'){
+		mb_wfs_checkTag();
+		var tmp = mb_wfs_getBBOX(m['geometry']);
+		var b = parseFloat(wfs_conf[m['wfs_conf']]['g_buffer']);
+		mb_calculateExtent(mb_wfs_targets[0],parseFloat(tmp[0])-b,parseFloat(tmp[1])-b,parseFloat(tmp[2])+b,parseFloat(tmp[3])+b);
+		zoom(mb_wfs_targets[0], 'true', 1.0);
+		if (!useCheckboxForHighlighting) {
+			mb_wfs_draw(m);
+		}
+	}
+}
+function mb_wfs_cntBasePoint(g){
+	var c = 0;
+	for(var i=0; i<g.length;i++){
+		c += (Math.round(g[i]['x'].length)/2);
+	}
+	if(c <= mb_wfs_maxBasePoints){
+		return true;
+	}
+	else{
+		return false;
+	}
+}
+function mb_wfs_getBBOX(g){
+	var tmp_x = new Array();
+	var tmp_y = new Array();
+
+	for(var i=0; i<g.length;i++){
+		tmp_x = tmp_x.concat(g[i]['x']);
+		tmp_y = tmp_y.concat(g[i]['y']);
+	}
+
+	var min_x = parseFloat(tmp_x[0]);
+	var min_y = parseFloat(tmp_y[0]);
+	var max_x = parseFloat(tmp_x[0]);
+	var max_y = parseFloat(tmp_y[0]);
+
+	var x,y;
+	
+	for(var i=1; i<tmp_x.length; i++){
+		x = parseFloat(tmp_x[i]);
+		y = parseFloat(tmp_y[i]);
+		if (x < min_x) {
+			min_x = x;
+		}
+		else if (x > max_x) {
+			max_x = x;
+		}
+		if (y < min_y) {
+			min_y = y;
+		}
+		else if (y > max_y) {
+			max_y = y;
+		}
+	}
+	var r = new Array(min_x, min_y, max_x, max_y);
+	return r;
+}
+
+function mb_wfs_checkPix(frame,g){
+	var tmp = mb_wfs_getBBOX(g);
+	var minpix = makeRealWorld2mapPos(frame,tmp[0],tmp[3]);
+	var maxpix = makeRealWorld2mapPos(frame,tmp[2],tmp[1]);
+	if((maxpix[0] - minpix[0] < mb_wfs_minPix) && (maxpix[1] - minpix[1] < mb_wfs_minPix)){
+		return false;
+	}
+	else{
+		return true;
+	}
+}
+function mb_wfs_center(frame,g){
+	var tmp = mb_wfs_getBBOX(g);
+	var x = parseFloat(tmp[0]) + parseFloat((tmp[2] - tmp[0])/2);
+	var y = parseFloat(tmp[1]) + parseFloat((tmp[3] - tmp[1])/2);
+	var r = new Array();
+	r[0] = new Array();
+	r[0]['x'] = new Array();
+	r[0]['y'] = new Array();
+	r[0]['x'][0] = x;
+	r[0]['y'][0] = y;
+	return r;
+}
+function mb_wfs_draw(m){
+	var t = m['geomtype'];
+	if(t.indexOf("Point")>-1){
+		for(var i=0; i<mb_wfs_targets.length; i++){
+			mb_wfs_wz(mb_wfs_targets[i],'Point',m['geometry']);
+		}
+	}
+	else if(t.indexOf("Line")>-1){
+		for(var i=0; i<mb_wfs_targets.length; i++){
+			var c = mb_wfs_checkPix(mb_wfs_targets[i],m['geometry']);
+			if(c == false){
+				var r = mb_wfs_center(mb_wfs_targets[i],m['geometry']);
+				mb_wfs_wz(mb_wfs_targets[i],'Point',r);
+			}
+			else{
+				mb_wfs_wz(mb_wfs_targets[i],'Line',m['geometry']);
+			}
+		}
+	}
+	else if(t.indexOf("Polygon")>-1){
+		for(var i=0; i<mb_wfs_targets.length; i++){
+			var c = mb_wfs_checkPix(mb_wfs_targets[i],m['geometry']);
+			if(c == false){
+				var r = mb_wfs_center(mb_wfs_targets[i],m['geometry']);
+				mb_wfs_wz(mb_wfs_targets[i],'Point',r);
+			}
+			else{
+				mb_wfs_wz(mb_wfs_targets[i],'Polygon',m['geometry']);
+			}
+		}
+	}
+	else{
+		alert("unknown geomtype");
+	}	
+}
+function mb_wfs_wz(mf,t,g){
+	if(t=='Point'){
+		for(var i=0; i<g.length; i++){
+			var apos = mb_wfs_toPix(mf,g[i]);
+			canvas[mf].setColor(mb_wfs_lineColor);
+			canvas[mf].drawEllipse((apos[0]-mb_wfs_diameter/2),(apos[1]-mb_wfs_diameter/2),mb_wfs_diameter,mb_wfs_diameter);
+		}
+	}
+	else if(t=='Line'){
+		for(var i=0; i<g.length; i++){
+			var apos = mb_wfs_toPix(mf,g[i]);	
+			canvas[mf].setColor(mb_wfs_lineColor);
+			canvas[mf].drawPolyline(apos[0],apos[1]);
+		}	
+	}
+	else if(t=='Polygon'){
+		for(var i=0; i<g.length; i++){
+			var apos = mb_wfs_toPix(mf,g[i]);	
+			mb_wfs_toPix(mf,g[i]);	
+			canvas[mf].setColor(mb_wfs_lineColor);
+			canvas[mf].drawPolygon(apos[0],apos[1]);
+		}
+	}
+}
+function mb_wfs_wzClean(){
+	for(var i=0; i<mb_wfs_targets.length; i++){
+		var el = window.frames[mb_wfs_targets[i]].document.getElementById('mod_gaz_draw');
+		if (el) el.innerHTML = "";
+		canvasHasDrawing[mb_wfs_targets[i]] = false;
+	}
+	return true;
+}
+function mb_wfs_checkTag(){
+	for(var i=0; i<mb_wfs_targets.length; i++){
+		var isTag = (window.frames[mb_wfs_targets[i]].document.getElementById('mod_gaz_draw'))?1:0;
+		if(isTag == 0){
+			var draw = window.frames[mb_wfs_targets[i]].document.createElement("div");
+			var tmp = window.frames[mb_wfs_targets[i]].document.getElementsByTagName("body")[0].appendChild(draw);
+			tmp.setAttribute("id","mod_gaz_draw");
+			tmp.setAttribute("style","position:absolute;top:0px;left:0px;width:0px;height:0px;z-index:100");
+		}
+		canvas[mb_wfs_targets[i]] = new jsGraphics('mod_gaz_draw', window.frames[mb_wfs_targets[i]]);
+		canvas[mb_wfs_targets[i]].setStroke(3);
+		canvasHasDrawing[mb_wfs_targets[i]] = false;
+	}
+	return true;
+}
+function mb_wfs_sortXY(g){
+	var r = new Array();
+	r[0] = new Array();
+	r[1] = new Array();
+	var cnt = 0;
+	for(var i=0; i<g.length -1 ; i+=2){
+		r[0][cnt] = g[i];
+		r[1][cnt] = g[i+1];
+		cnt++;
+	}
+	return r;
+}
+function mb_wfs_toPix(mf,g){
+	var r = new Array();
+	r[0] = new Array();
+	r[1] = new Array(); 
+	for(var i=0; i<g['x'].length; i++){
+		var pos = makeRealWorld2mapPos(mf,g['x'][i],g['y'][i]);
+		r[0][i] = pos[0];
+		r[1][i] = pos[1];
+	}
+	return r;
 }
\ No newline at end of file




More information about the Mapbender_commits mailing list