[Mapbender-commits] r2230 - branches/2.5/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Mar 13 06:13:00 EDT 2008


Author: verenadiewald
Date: 2008-03-13 06:13:00 -0400 (Thu, 13 Mar 2008)
New Revision: 2230

Modified:
   branches/2.5/http/javascripts/mod_wfs_gazetteer_client.php
Log:
added spatial request buttons, switch between results in tab or in popup..

Modified: branches/2.5/http/javascripts/mod_wfs_gazetteer_client.php
===================================================================
--- branches/2.5/http/javascripts/mod_wfs_gazetteer_client.php	2008-03-13 10:11:14 UTC (rev 2229)
+++ branches/2.5/http/javascripts/mod_wfs_gazetteer_client.php	2008-03-13 10:13:00 UTC (rev 2230)
@@ -1,462 +1,1120 @@
-<?php 
-# $Id$
-# maintained by http://www.mapbender.org/index.php/User:Verena Diewald
-# http://www.mapbender.org/index.php/WFS_gazetteer
-# Copyright (C) 2002 CCGIS 
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset='<?php echo CHARSET;?>'">	
-<title>mod_wfs_gazetteer</title>
-
-<?php
-include '../include/dyn_css.php';
-?>
-<script type="text/javascript">
-<?php 
-	echo "var targetString = '" . $e_target[0] . "';";
-	echo "var wfsConfIdString = '" . $wfsConfIdString . "';";
-?>
-
-// Element var maxHighlightedPoints
-try{
-	if (maxHighlightedPoints){
-		maxHighlightedPoints = Number(maxHighlightedPoints);
-
-		if (isNaN(maxHighlightedPoints)) {
-//			var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints must be a number.");
-		}
-	}
-}
-catch(e){
-	maxHighlightedPoints = 0;
-//	var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints is not set, see 'edit element vars'.");
-}
-
-var targetArray = targetString.split(",");
-var global_wfsConfObj;
-var global_selectedWfsConfId;
-var point_px = 10;
-var resultGeom = null;
-var cw_fillcolor = "#cc33cc";
-
-
-parent.mb_registerInitFunctions("window.frames['"+this.name+"'].initModWfsGazetteer()");
-
-function openwindow(Adresse) {
-	Fenster1 = window.open(Adresse, "Informationen", "width=500,height=500,left=100,top=100,scrollbars=yes,resizable=no");
-	Fenster1.focus();
-}
-//----------------------------------------------------------------------------------
-
-function appendWfsConf(newWfsConfIdString) {
-	// merge with existing wfs conf ids
-	if (wfsConfIdString !== "") {
-		if (newWfsConfIdString !== "") {
-			wfsConfIdString += "," + newWfsConfIdString;
-
-			// rebuild form
-			initModWfsGazetteer();
-		}
-	}
-	else {
-		wfsConfIdString = newWfsConfIdString;
-
-		// rebuild form
-		initModWfsGazetteer();
-	}
-	
-}
-
-function removeChildNodes(node) {
-	while (node.childNodes.length > 0) {
-	  var childNode = node.firstChild;
-		node.removeChild(childNode);
-	}
-}
-
-/**
- * removes whitespaces and endlines before and after a string
- *
- */ 
-function trimString (str) {
-	return str.replace(/^\s+|\s+|\n+$/g, '');
-}
-
-function appendStyles() {
-	var styleObj;
-	var rule = global_wfsConfObj[global_selectedWfsConfId].g_style + global_wfsConfObj[global_selectedWfsConfId].g_res_style;
-	if (parent.ie) {
-		var styleSheetObj=document.createStyleSheet();
-		styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
-		styleObj.setAttribute("type","text/css");
-		ruleArray = rule.split("}");
-		for (var i=0; i < ruleArray.length - 1; i++) {
-			var currentRule = trimString(ruleArray[i]);
-			var nameValueArray = currentRule.split("{");
-			var name = nameValueArray[0];
-			var value = nameValueArray[1];
-			styleSheetObj.addRule(name,value);
-		}
-	}
-	else {
-		styleObj=document.createElement("style");
-		styleObj.setAttribute("type","text/css");
-		document.getElementsByTagName("head")[0].appendChild(styleObj);
-		styleObj.appendChild(document.createTextNode(rule+"\n"));		
-	}
-}
-
-//----------------------------------------------------------------------------------
-
-
-function initModWfsGazetteer() {
-	// empty nodes
-	var nodesToEmpty = ["selectWfsConfForm", "wfsForm", "res", "wfsInfo"];
-	while (nodesToEmpty.length > 0) {
-		var currentId = nodesToEmpty.pop();
-		var currentNode = document.getElementById(currentId);
-		removeChildNodes(currentNode);
-	}
-	document.getElementById("wfsGeomType").style.visibility = "hidden";
-	document.getElementById("wfsRemove").style.visibility = "hidden";
-	
-	parent.mb_ajax_json("../php/mod_wfs_gazetteer_server.php", {command:"getWfsConf",wfsConfIdString:wfsConfIdString}, function(json, status) {
-		global_wfsConfObj = json;
-		var wfsCount = 0;
-		for (var wfsConfId in global_wfsConfObj) {
-			global_selectedWfsConfId = wfsConfId; 
-			if (typeof(global_wfsConfObj[wfsConfId] != 'function')) {
-				wfsCount++;
-			}
-		}
-		if (wfsCount === 0) {
-			var e = parent.Mb_exception("no wfs conf id available.");
-		}
-		else if (wfsCount === 1) {
-			appendStyles();
-			appendWfsForm();
-			setWfsInfo();	
-		}
-		else {
-			appendWfsConfSelectBox();
-			setWfsInfo();	
-		}
-		parent.mb_setWmcExtensionData({"wfsConfIdString":wfsConfIdString});
-	});
-}
-
-function setWfsInfo() {
-	var bulbNode = document.getElementById("wfsInfo"); 	
-
-	// append bulb image
-	removeChildNodes(bulbNode);
-	var imgNode = document.createElement("img");
-	imgNode.id = "wfsInfoImg";
-	imgNode.src = "../img/button_digitize/geomInfo.png";
-	imgNode.border = 0;
-	bulbNode.appendChild(imgNode);
-	bulbNode.href = "javascript:openwindow('../php/mod_featuretypeMetadata.php?wfs_conf_id=" + global_selectedWfsConfId.toString() + "');";
-	bulbNode.style.visibility = "visible";
-	
-	// set wfsGeomType image
-	var wfsGeomTypeNode = document.getElementById("wfsGeomType");
-	var wfsGeomType = "";
-	for (var i=0; i < global_wfsConfObj[global_selectedWfsConfId].element.length; i++) {
-		if (parseInt(global_wfsConfObj[global_selectedWfsConfId].element[i].f_geom)) {
-			wfsGeomType = global_wfsConfObj[global_selectedWfsConfId].element[i].element_type;
-		}
-	}
-	if (wfsGeomType.match(/Point/)) {
-		wfsGeomTypeNode.src = "../img/button_digitize/point_off.png";
-		wfsGeomTypeNode.style.visibility = 'visible';
-	}
-	else if (wfsGeomType.match(/Line/)) {
-		wfsGeomTypeNode.src = "../img/button_digitize/line_off.png";
-		wfsGeomTypeNode.style.visibility = 'visible';
-	}
-	else if (wfsGeomType.match(/Polygon/)) {
-		wfsGeomTypeNode.src = "../img/button_digitize/polygon_off.png";
-		wfsGeomTypeNode.style.visibility = 'visible';
-	}
-	else {
-		var e = new parent.Mb_exception("WFS gazetteer: geometry type unknown.");		
-	}
-	
-	// set image: remove this WFS
-	var wfsRemoveNode = document.getElementById("wfsRemove");
-	wfsRemoveNode.src = "../img/button_digitize/geomRemove.png";
-	wfsRemoveNode.style.visibility = 'visible';
-	// Internet explorer
-	if (parent.ie) {
-		wfsRemoveNode.onclick = function() {
-			var x = new Function ("", "delete global_wfsConfObj[global_selectedWfsConfId];setWfsConfIdString();initModWfsGazetteer();parent.mb_setWmcExtensionData({'wfsConfIdString':wfsConfIdString});"); 
-			x(); 
-		};
-	}
-	// Firefox
-	else {
-		wfsRemoveNode.onclick = function () {
-			delete global_wfsConfObj[global_selectedWfsConfId];
-			setWfsConfIdString();
-			initModWfsGazetteer();			
-			parent.mb_setWmcExtensionData({"wfsConfIdString":wfsConfIdString});
-		}
-	}
-}
-
-function setWfsConfIdString() {
-	var str = [];
-	for (var wfsConfId in global_wfsConfObj) {
-		global_selectedWfsConfId = wfsConfId; 
-		if (typeof(global_wfsConfObj[wfsConfId] != 'function')) {
-			str.push(wfsConfId);
-		}
-	}
-	wfsConfIdString = str.join(",");
-}
-
-function appendWfsConfSelectBox() {
-	var selectNode = document.createElement("select");
-	selectNode.name = "wfs_conf_sel";
-	var wfsFormNode = document.getElementById("selectWfsConfForm");
-	selectNode.onchange = function() {
-		global_selectedWfsConfId = this.value;
-		setWfsInfo();
-		appendStyles();
-		appendWfsForm();
-	};
-	var isSelected = false;
-	for (var wfsConfId in global_wfsConfObj) {
-		var optionNode = document.createElement("option");
-		
-		optionNode.value = wfsConfId;
-		optionNode.innerHTML = global_wfsConfObj[wfsConfId].g_label;
-
-		if (!isSelected) {
-			optionNode.selected = true;
-			isSelected = true;
-			global_selectedWfsConfId = wfsConfId;
-		}
-		selectNode.appendChild(optionNode);
-	}
-
-	var form = document.getElementById('selectWfsConfForm');
-	form.appendChild(selectNode);
-	
-	appendStyles();
-	appendWfsForm();
-}
-
-function appendWfsForm() {
-	var form = document.getElementById("wfsForm");
-	removeChildNodes(form);
-	var resultDiv = document.getElementById("res");
-	removeChildNodes(resultDiv);
-	
-	var divContainer = document.createElement("div");
-	divContainer.className = global_wfsConfObj[global_selectedWfsConfId].g_label_id;
-	
-	divContainer.innerHTML = global_wfsConfObj[global_selectedWfsConfId].g_label;
-	
-	form.appendChild(divContainer);
-
-	var wfsConfElementArray = global_wfsConfObj[global_selectedWfsConfId].element;
-
-	for (var i = 0; i < wfsConfElementArray.length; i++){
-		if (parseInt(wfsConfElementArray[i].f_search)) {
-			var spanNode = document.createElement("span");
-			spanNode.setAttribute("id", "ttttt");
-			spanNode.className = wfsConfElementArray[i].f_label_id;
-			spanNode.innerHTML = wfsConfElementArray[i].f_label;
-			var inputNode = document.createElement("input");
-			inputNode.type = "text";
-			inputNode.className = wfsConfElementArray[i].f_style_id;
-			inputNode.id = wfsConfElementArray[i].element_name;
-			
-			form.appendChild(spanNode);
-			form.appendChild(inputNode);
-			form.appendChild(document.createElement("br"));
-		}
-	}
-	var submitButton = document.createElement("input");
-	submitButton.type = "submit";
-	submitButton.className = global_wfsConfObj[global_selectedWfsConfId].g_button_id;
-	submitButton.value = global_wfsConfObj[global_selectedWfsConfId].g_button;
-	
-	form.appendChild(submitButton);
-}
-
-function validate(){
-	global_resultHighlight = new parent.Highlight(targetArray, "wfs_gazetteer_highlight", {"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 2);
-
-	var filterParameterCount = getNumberOfFilterParameters();
-	
-	if(filterParameterCount == 0){
-		return false;
-	}
-	else{
-		var andConditions = "";
-		
-		var el = global_wfsConfObj[global_selectedWfsConfId].element;
-
-		for (var i = 0; i < el.length; i++) {
-			if (el[i]['f_search'] == 1 && document.getElementById(el[i]['element_name']).value != '') {
-		
-				var a = new Array();
-				a = document.getElementById(el[i]['element_name']).value.split(",");
-				var orConditions = "";
-				for (var j=0; j < a.length; j++) {
-					
-					orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
-					orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
-					orConditions += "<ogc:Literal>*";
-					if(el[i]['f_toupper'] == 1){
-						orConditions += a[j].toUpperCase();
-					}
-					else{
-						orConditions += a[j];
-					}
-					orConditions += "*</ogc:Literal>";
-					orConditions += "</ogc:PropertyIsLike>";
-				}
-				if(a.length > 1){
-					andConditions += "<Or>" + orConditions + "</Or>";
-				}
-				else {
-					andConditions += orConditions;
-				}
-			}
-		}
-
-		var u = global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature + parent.mb_getConjunctionCharacter(global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature);
-		u += "REQUEST=getFeature&Typename="+global_wfsConfObj[global_selectedWfsConfId].featuretype_name+"&Version=1.0.0&service=WFS";
-		u += "&filter=";
-
-		if (filterParameterCount > 1) {
-			andConditions = "<And>" + andConditions + "</And>";
-		}
-
-		var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditions+"</ogc:Filter>";
-
-		document.getElementById("res").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
-		var parameters = {command:"getSearchResults", "wfs_conf_id":global_selectedWfsConfId, "frame":this.name, "url":u, "filter":filter, "backlink":""};
-		parent.mb_ajax_get("../php/mod_wfs_gazetteer_server.php", parameters, function (jsCode, status) {
-			document.getElementById("res").innerHTML = "<table><tr><td>Arranging search results...</td></tr></table>";
-			
-			eval(jsCode);
-			
-			for (var i=0; i < parent.wms.length; i++) {
-				for (var j=0; j < parent.wms[i].objLayer.length; j++) {
-	
-					var currentLayer = parent.wms[i].objLayer[j];
-					var wms_id = parent.wms[i].wms_id; 
-	
-					if (currentLayer.gui_layer_wfs_featuretype == global_selectedWfsConfId) {
-						var layer_name = currentLayer.layer_name; 
-						parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'querylayer',1); 
-						parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'visible',1);
-					}
-				}
-			}
-			
-			var body = "";
-			if (typeof(geom) == 'object') {
-				resultGeom = geom; // set the global variable
-				for (var i=0; i < geom.count(); i++) {
-					body += "<div id='geom"+i+"'style='cursor:pointer;' ";
-					if ((i % 2) === 0) {
-						body += "class='even'";
-					}
-					else {
-						body += "class='uneven'";
-					}
-					body += " onmouseover=\"setResult('over', this.id)\" ";
-					body += " onmouseout=\"setResult('out', this.id)\" ";
-					body += " onclick=\"setResult('click', this.id)\">";
-					for (var j=0; j < geom.get(i).e.count(); j++) {
-						body += geom.get(i).e.getValue(j) + " ";
-					}
-					body += "</div>";
-				}
-			}
-			else {
-				body = "Kein Ergebnis.";
-			}
-			document.getElementById('res').innerHTML = body;
-		});
-	}
-	return false;
-}
-
-function getNumberOfFilterParameters(){
-	var cnt = 0;
-	var el = global_wfsConfObj[global_selectedWfsConfId].element;
-
-	for (var i = 0; i < el.length; i++){
-		if( el[i]['f_search'] == 1){
-			if (document.getElementById(el[i]['element_name']).value != '') {
-				cnt++;
-			}
-		}
-	}
-	return cnt;
-}
-/*
-* event -> {over || out || click}
-* geom -> commaseparated coordinates x1,y1,x2,y2 ...
-*/
-function setResult(event, id){
-	var index = parseInt(id.slice(4));
-
-	var currentGeom = resultGeom.get(index);
-	if (maxHighlightedPoints > 0 && currentGeom.getTotalPointCount() > maxHighlightedPoints) {
-		currentGeom = currentGeom.getBBox4();
-	}
-	if (event == "over") {
-		global_resultHighlight.add(currentGeom, cw_fillcolor);
-	}
-	else if (event == "out"){
-		global_resultHighlight.del(currentGeom, cw_fillcolor);
-	}
-	else if (event == "click"){
-		global_resultHighlight.del(currentGeom, cw_fillcolor);
-		var bbox = currentGeom.getBBox();
-		var bufferFloat = parseFloat(global_wfsConfObj[global_selectedWfsConfId].g_buffer);
-		var buffer = new parent.Point(bufferFloat,bufferFloat);
-		bbox[0] = bbox[0].minus(buffer);
-		bbox[1] = bbox[1].plus(buffer);
-		parent.mb_calculateExtent(targetArray[0], bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y);
-		parent.zoom(targetArray[0], 'true', 1.0);
-		global_resultHighlight.add(currentGeom, cw_fillcolor);
-	}
-	return true;
-}
-</script>
-</head>
-<body leftmargin='0' topmargin='10'  bgcolor='#ffffff'>
-<form name='selectWfsConfForm' id='selectWfsConfForm'></form>
-<img src = "" name='wfsGeomType' id='wfsGeomType'>
-<img src = "" name='wfsRemove' id='wfsRemove'>
-<a name='wfsInfo' id='wfsInfo'></a>
-<form name='wfsForm' id='wfsForm' onsubmit='return validate()'></form>
-<div name='res' id='res' style='width:180px'></div>
-</body>
-</html>
\ No newline at end of file
+<?php 
+# $Id$
+# maintained by http://www.mapbender.org/index.php/User:Verena Diewald
+# http://www.mapbender.org/index.php/WFS_gazetteer
+# Copyright (C) 2002 CCGIS 
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+session_start();
+$gui_id = $_SESSION["mb_user_gui"];
+
+$target = $_REQUEST["e_target"];
+$e_id_css = $_REQUEST["e_id_css"];
+$e_id = $_REQUEST["e_id"];
+$isLoaded = $_REQUEST["isLoaded"];
+
+require_once(dirname(__FILE__) . "/../../conf/mapbender.conf");
+
+$con = db_connect($DBSERVER,$OWNER,$PW);
+db_select_db($DB,$con);
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset='<?php echo CHARSET;?>'">	
+<title>mod_wfs_gazetteer</title>
+
+<?php
+include '../include/dyn_css.php';
+?>
+<script type="text/javascript">
+<?php 
+	include '../include/dyn_js.php';
+	include '../include/dyn_php.php';
+	include("../../conf/" . $wfs_spatial_request_conf_filename);
+
+	echo "var targetString = '" . $target . "';";
+	echo "var wfsConfIdString = '" . $wfsConfIdString . "';";
+	echo "var e_id_css = '" . $e_id_css . "';";
+?>
+
+// Element var maxHighlightedPoints
+try{
+	if (maxHighlightedPoints){
+		maxHighlightedPoints = Number(maxHighlightedPoints);
+
+		if (isNaN(maxHighlightedPoints)) {
+//			var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints must be a number.");
+		}
+	}
+}
+catch(e){
+	maxHighlightedPoints = 0;
+//	var e = new parent.Mb_warning("mod_wfs_gazetteer_client.php: Element var maxHighlightedPoints is not set, see 'edit element vars'.");
+}
+// Element var showResultInPopup
+try {if(showResultInPopup){}}catch(e) {showResultInPopup = 1;}
+
+var targetArray = targetString.split(",");
+var global_wfsConfObj;
+var global_selectedWfsConfId;
+var point_px = 10;
+var resultGeom = null;
+var cw_fillcolor = "#cc33cc";
+var frameName = e_id_css;
+
+//start button management spatialRequest ////////
+var button_point = "point";
+var button_polygon = "polygon";
+var button_rectangle = "rectangle";
+var button_extent = "extent";
+var mb_wfs_tolerance = 8;
+
+var activeButton = null;
+var mod_wfs_spatialRequest_geometry = null;
+var mod_wfs_spatialRequest_frameName = "";
+var mod_wfs_spatialRequest_epsg;
+var mod_wfs_spatialRequest_width;
+var mod_wfs_spatialRequest_height;
+
+var spatialRequestGeom = null;
+var spatialRequestType = null;
+
+var geomArray;
+
+var buttonWfs_id = [];
+var buttonWfs_on = [];
+var buttonWfs_src = [];
+var buttonWfs_title_off = [];
+var buttonWfs_title_on = [];
+var buttonWfs_x = [];
+var buttonWfs_y = [];
+
+function addButtonWfs(id, isOn, src, title, x, y) {
+	buttonWfs_id.push(id);
+	buttonWfs_on.push(isOn);
+	buttonWfs_src.push(src);
+	buttonWfs_title_off.push(title);
+	buttonWfs_title_on.push(title);
+	buttonWfs_x.push(x);
+	buttonWfs_y.push(y);
+}
+// end of button management spatialRequest ///////////
+
+parent.mb_registerInitFunctions("window.frames['"+this.name+"'].initModWfsGazetteer()");
+parent.mb_registerInitFunctions("window.frames['"+this.name+"'].init_wfsSpatialRequest()");
+
+function init_wfsSpatialRequest() {
+	//parent.mb_ajax_json("../php/mod_wfsSpatialRequest_messages.php", function(obj, status) {
+	//	msgObj = obj;
+		buttonWfs_id = [];
+		buttonWfs_on = [];
+		buttonWfs_src = [];
+		buttonWfs_title_off = [];
+		buttonWfs_title_on = [];
+		buttonWfs_x = [];
+		buttonWfs_y = [];
+		addButtonWfs("rectangle", buttonRectangle.status, buttonRectangle.img, buttonRectangle.title, buttonRectangle.x, buttonRectangle.y);
+		addButtonWfs("polygon", buttonPolygon.status, buttonPolygon.img, buttonPolygon.title, buttonPolygon.x, buttonPolygon.y);
+		addButtonWfs("point", buttonPoint.status, buttonPoint.img, buttonPoint.title, buttonPoint.x, buttonPoint.y);
+		addButtonWfs("extent", buttonExtent.status, buttonExtent.img, buttonExtent.title, buttonExtent.x, buttonExtent.y);
+		displayButtons();
+	//});
+}
+
+function wfsInitFunction (j) {
+	var functionCall = "parent.mb_regButton_frame('initWfsButton', '"+frameName+"', "+j+")";
+	var x = new Function ("", functionCall); 
+	x();
+} 
+
+function initWfsButton(ind, pos) {
+	parent.mb_button[ind] = document.getElementById(buttonWfs_id[pos]);
+	parent.mb_button[ind].img_over = buttonWfs_imgdir + buttonWfs_src[pos].replace(/_off/,"_over");
+	parent.mb_button[ind].img_on = buttonWfs_imgdir + buttonWfs_src[pos].replace(/_off/,"_on");
+	parent.mb_button[ind].img_off = buttonWfs_imgdir + buttonWfs_src[pos];
+	parent.mb_button[ind].img_out = buttonWfs_imgdir + buttonWfs_src[pos];
+	parent.mb_button[ind].status = 0;
+	parent.mb_button[ind].elName = buttonWfs_id[pos];
+	parent.mb_button[ind].frameName = frameName;
+	parent.mb_button[ind].go = new Function ("wfsEnable(parent.mb_button["+ind+"], " + pos + ")");
+	parent.mb_button[ind].stop = new Function ("wfsDisable(parent.mb_button["+ind+"], " + pos + ")");
+	var ind = parent.getMapObjIndexByName("mapframe1");
+	mod_wfs_spatialRequest_width = parent.mb_mapObj[ind].width;
+	mod_wfs_spatialRequest_height = parent.mb_mapObj[ind].height;
+	mod_wfs_spatialRequest_epsg = parent.mb_mapObj[ind].epsg;
+	parent.mb_registerPanSubElement("measuring");
+}	
+
+function displayButtons() {
+	for (var i = 0 ; i < buttonWfs_id.length ; i ++) {
+		if (parseInt(buttonWfs_on[i])==1) {
+			var currentImg = document.createElement("img");
+			currentImg.id = buttonWfs_id[i];
+			currentImg.name = buttonWfs_id[i];
+			currentImg.title = buttonWfs_title_off[i];
+			currentImg.src = buttonWfs_imgdir+buttonWfs_src[i];
+			currentImg.style.marginRight = "5px;";
+			currentImg.onmouseover = new Function("wfsInitFunction("+i+")");
+			
+			document.getElementById("displaySpatialButtons").appendChild(currentImg);
+		}
+	}
+}
+
+function disableButtons() {
+	removeChildNodes(document.getElementById("displaySpatialButtons"));
+}
+
+function wfsEnable(obj) {
+   	var el = parent.window.frames["mapframe1"].document;
+   	el.onmouseover = null;
+   	el.onmousedown = null;
+   	el.onmouseup = null;
+   	el.onmousemove = null;
+   	
+	if (obj.id == button_point) {
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+	}
+	if (obj.id == button_polygon) {
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+	}
+	else if (obj.id == button_rectangle){
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+	}
+	else if (obj.id == button_extent){
+		if (activeButton == null) {
+			activeButton = obj;
+		}
+	}
+	callRequestGeometryConstructor(obj.id,"mapframe1");
+}
+
+function callRequestGeometryConstructor(selectedType,target){
+		if(document.getElementById("res")){
+			document.getElementById("res").innerHTML ="";
+			spatialRequestGeom = null;
+		}
+		spatialRequestType = selectedType;
+		var geometryConstructor = new parent.RequestGeometryConstructor(target);
+		geometryConstructor.getGeometry(selectedType,function(target,queryGeom){
+			if(queryGeom !=''){
+				var spatialRes = document.createElement("div");
+				spatialRes.id = "spatialResHint";
+				spatialRes.name = "spatialResHint";
+				document.getElementById("res").appendChild(spatialRes);
+				document.getElementById("spatialResHint").innerHTML = spatialRequestIsSetMessage;
+				spatialRequestGeom = queryGeom;
+			}
+		});
+}
+
+function wfsDisable(obj) {
+	var el = parent.window.frames["mapframe1"].document; 
+	el.onmousedown = null;
+	el.ondblclick = null;
+	el.onmousemove = null;
+	parent.writeTag("mapframe1","measure_display","");
+	parent.writeTag("mapframe1","measure_sub","");
+	activeButton = null;
+}
+
+function openwindow(url) {
+	window1 = window.open(url, "Information", "width=500,height=500,left=100,top=100,scrollbars=yes,resizable=no");
+	window1.focus();
+}
+//----------------------------------------------------------------------------------
+
+function appendWfsConf(newWfsConfIdString) {
+	// merge with existing wfs conf ids
+	if (wfsConfIdString !== "") {
+		if (newWfsConfIdString !== "") {
+			wfsConfIdString += "," + newWfsConfIdString;
+
+			// rebuild form
+			initModWfsGazetteer();
+		}
+	}
+	else {
+		wfsConfIdString = newWfsConfIdString;
+
+		// rebuild form
+		initModWfsGazetteer();
+	}
+	
+}
+
+function removeChildNodes(node) {
+	while (node.childNodes.length > 0) {
+	  var childNode = node.firstChild;
+		node.removeChild(childNode);
+	}
+}
+
+/**
+ * removes whitespaces and endlines before and after a string
+ *
+ */ 
+function trimString (str) {
+	return str.replace(/^\s+|\s+|\n+$/g, '');
+}
+
+function appendStyles() {
+	var styleObj;
+	var rule = global_wfsConfObj[global_selectedWfsConfId].g_style + global_wfsConfObj[global_selectedWfsConfId].g_res_style;
+	if (parent.ie) {
+		var styleSheetObj=document.createStyleSheet();
+		styleObj=styleSheetObj.owningElement || styleSheetObj.ownerNode;
+		styleObj.setAttribute("type","text/css");
+		ruleArray = rule.split("}");
+		for (var i=0; i < ruleArray.length - 1; i++) {
+			var currentRule = trimString(ruleArray[i]);
+			var nameValueArray = currentRule.split("{");
+			var name = nameValueArray[0];
+			var value = nameValueArray[1];
+			styleSheetObj.addRule(name,value);
+		}
+	}
+	else {
+		styleObj=document.createElement("style");
+		styleObj.setAttribute("type","text/css");
+		document.getElementsByTagName("head")[0].appendChild(styleObj);
+		styleObj.appendChild(document.createTextNode(rule+"\n"));		
+	}
+}
+
+//----------------------------------------------------------------------------------
+
+
+function initModWfsGazetteer() {
+	// empty nodes
+	var nodesToEmpty = ["selectWfsConfForm", "wfsForm", "res", "wfsInfo"];
+	while (nodesToEmpty.length > 0) {
+		var currentId = nodesToEmpty.pop();
+		var currentNode = document.getElementById(currentId);
+		removeChildNodes(currentNode);
+	}
+	document.getElementById("wfsGeomType").style.visibility = "hidden";
+	document.getElementById("wfsRemove").style.visibility = "hidden";
+		
+	geomArray = new parent.GeometryArray();
+
+	parent.mb_ajax_json("../php/mod_wfs_gazetteer_server.php", {command:"getWfsConf",wfsConfIdString:wfsConfIdString}, function(json, status) {
+		global_wfsConfObj = json;
+		var wfsCount = 0;
+		for (var wfsConfId in global_wfsConfObj) {
+			global_selectedWfsConfId = wfsConfId; 
+			if (typeof(global_wfsConfObj[wfsConfId] != 'function')) {
+				wfsCount++;
+			}
+		}
+		if (wfsCount === 0) {
+			var e = parent.Mb_exception("no wfs conf id available.");
+		}
+		else if (wfsCount === 1) {
+			appendStyles();
+			appendWfsForm();
+			setWfsInfo();	
+		}
+		else {
+			appendWfsConfSelectBox();
+			setWfsInfo();	
+		}
+		parent.mb_setWmcExtensionData({"wfsConfIdString":wfsConfIdString});
+	});
+}
+
+function setWfsInfo() {
+	var bulbNode = document.getElementById("wfsInfo"); 	
+
+	// append bulb image
+	removeChildNodes(bulbNode);
+	var imgNode = document.createElement("img");
+	imgNode.id = "wfsInfoImg";
+	//imgNode.src = "../img/button_digitize/geomInfo.png";
+	imgNode.src = "../img/tree_new/info.png";
+	imgNode.border = 0;
+	bulbNode.appendChild(imgNode);
+	bulbNode.href = "javascript:openwindow('../php/mod_featuretypeMetadata.php?wfs_conf_id=" + global_selectedWfsConfId.toString() + "');";
+	bulbNode.style.visibility = "visible";
+	
+	// set wfsGeomType image
+	var wfsGeomTypeNode = document.getElementById("wfsGeomType");
+	var wfsGeomType = "";
+	for (var i=0; i < global_wfsConfObj[global_selectedWfsConfId].element.length; i++) {
+		if (parseInt(global_wfsConfObj[global_selectedWfsConfId].element[i].f_geom)) {
+			wfsGeomType = global_wfsConfObj[global_selectedWfsConfId].element[i].element_type;
+		}
+	}
+	if (wfsGeomType.match(/Point/)) {
+		wfsGeomTypeNode.src = "../img/button_digitize/point.png";
+		wfsGeomTypeNode.style.visibility = 'visible';
+	}
+	else if (wfsGeomType.match(/Line/)) {
+		wfsGeomTypeNode.src = "../img/button_digitize/line.png";
+		wfsGeomTypeNode.style.visibility = 'visible';
+	}
+	else if (wfsGeomType.match(/Polygon/)) {
+		wfsGeomTypeNode.src = "../img/button_digitize/polygon.png";
+		wfsGeomTypeNode.style.visibility = 'visible';
+	}
+	else {
+		var e = new parent.Mb_exception("WFS gazetteer: geometry type unknown.");
+	}
+	
+	// set image: remove this WFS
+	var wfsRemoveNode = document.getElementById("wfsRemove");
+	//wfsRemoveNode.src = "../img/button_digitize/geomRemove.png";
+	wfsRemoveNode.src = "../img/tree_new/delete_wms.png";
+	wfsRemoveNode.style.visibility = 'visible';
+	// Internet explorer
+	if (parent.ie) {
+		wfsRemoveNode.onclick = function() {
+			var x = new Function ("", "delete global_wfsConfObj[global_selectedWfsConfId];setWfsConfIdString();initModWfsGazetteer();parent.mb_setWmcExtensionData({'wfsConfIdString':wfsConfIdString});"); 
+			x(); 
+		};
+	}
+	// Firefox
+	else {
+		wfsRemoveNode.onclick = function () {
+			delete global_wfsConfObj[global_selectedWfsConfId];
+			setWfsConfIdString();
+			initModWfsGazetteer();			
+			parent.mb_setWmcExtensionData({"wfsConfIdString":wfsConfIdString});
+		}
+	}  
+}
+
+function setWfsConfIdString() {
+	var str = [];
+	for (var wfsConfId in global_wfsConfObj) {
+		global_selectedWfsConfId = wfsConfId; 
+		if (typeof(global_wfsConfObj[wfsConfId] != 'function')) {
+			str.push(wfsConfId);
+		}
+	}
+	wfsConfIdString = str.join(",");
+}
+
+function appendWfsConfSelectBox() {
+	var selectNode = document.createElement("select");
+	selectNode.name = "wfs_conf_sel";
+	var wfsFormNode = document.getElementById("selectWfsConfForm");
+	if (parent.ie) {
+		selectNode.onchange = function() {
+		global_selectedWfsConfId = this.value;
+     	if(typeof(resultGeometryPopup)!="undefined"){
+	 		resultGeometryPopup.hide();
+	 	}
+	 	if(typeof(wfsPopup)!="undefined"){
+	 		wfsPopup.hide();
+	 	}
+    	setWfsInfo();
+		appendStyles();
+		appendWfsForm();
+		};
+	}
+	else{
+	   selectNode.setAttribute("onchange", "if(typeof(resultGeometryPopup)!='undefined'){resultGeometryPopup.hide();}if(typeof(wfsPopup)!='undefined'){wfsPopup.hide();};global_selectedWfsConfId = this.value;setWfsInfo();appendStyles();appendWfsForm();");
+	}
+	var isSelected = false;
+	for (var wfsConfId in global_wfsConfObj) {
+		var optionNode = document.createElement("option");
+		
+		optionNode.value = wfsConfId;
+		optionNode.innerHTML = global_wfsConfObj[wfsConfId].g_label;
+
+		if (!isSelected) {
+			optionNode.selected = true;
+			isSelected = true;
+			global_selectedWfsConfId = wfsConfId;
+		}
+		selectNode.appendChild(optionNode);
+	}
+
+	var form = document.getElementById('selectWfsConfForm');
+	form.appendChild(selectNode);
+	
+	appendStyles();
+	appendWfsForm();
+}
+
+function appendWfsForm() {
+	var form = document.getElementById("wfsForm");
+	removeChildNodes(form);
+	var resultDiv = document.getElementById("res");
+	removeChildNodes(resultDiv);
+	
+	var divContainer = document.createElement("div");
+	divContainer.className = global_wfsConfObj[global_selectedWfsConfId].g_label_id;
+	
+	divContainer.innerHTML = global_wfsConfObj[global_selectedWfsConfId].g_label;
+	
+	form.appendChild(divContainer);
+
+	var wfsConfElementArray = global_wfsConfObj[global_selectedWfsConfId].element;
+
+	for (var i = 0; i < wfsConfElementArray.length; i++){
+		if (parseInt(wfsConfElementArray[i].f_search)) {
+			var spanNode = document.createElement("span");
+			spanNode.setAttribute("id", "ttttt");
+			spanNode.className = wfsConfElementArray[i].f_label_id;
+			spanNode.innerHTML = wfsConfElementArray[i].f_label;
+			if(wfsConfElementArray[i].f_form_element_html.match(/\<select/)){
+				var inputNode = document.createElement("span");
+				inputNode.id = wfsConfElementArray[i].element_name+"Select";
+				inputNode.innerHTML = wfsConfElementArray[i].f_form_element_html;
+			}
+			else{ 
+				var inputNode = document.createElement("input");
+				inputNode.type = "text";
+				inputNode.className = wfsConfElementArray[i].f_style_id;
+				inputNode.id = wfsConfElementArray[i].element_name;
+			}
+			form.appendChild(spanNode);
+			form.appendChild(inputNode);
+			
+			//build imgNode for datepicker image
+			if(wfsConfElementArray[i].f_form_element_html.match(/datepicker/)){
+				var imgNode = document.createElement("span");
+				imgNode.id = wfsConfElementArray[i].element_name+"Img";
+				imgNode.innerHTML = wfsConfElementArray[i].f_form_element_html;
+				form.appendChild(imgNode);
+			}
+			form.appendChild(document.createElement("br"));
+		}
+	}
+	var submitButton = document.createElement("input");
+	submitButton.type = "submit";
+	submitButton.id = "submitButton";
+	submitButton.className = global_wfsConfObj[global_selectedWfsConfId].g_button_id;
+	submitButton.value = global_wfsConfObj[global_selectedWfsConfId].g_button;
+	
+	form.appendChild(submitButton);
+	
+	var delFilterButton = document.createElement("input");
+	delFilterButton.type = "button";
+	delFilterButton.style.marginLeft = "5px;";
+	delFilterButton.className = global_wfsConfObj[global_selectedWfsConfId].g_button_id;
+	delFilterButton.value = clearFilterButtonLabel;
+	// Internet explorer
+	if (parent.ie) {
+		delFilterButton.onclick = function() {
+			var x = new Function ("", "clearFilter();"); 
+			x(); 
+		};
+	}
+	// Firefox
+	else {
+		delFilterButton.onclick = function () {
+			clearFilter();
+		}
+	}  
+	form.appendChild(delFilterButton);
+	
+	checkSrs();
+}
+
+function checkSrs(){
+	//check SRS
+	var ind = parent.getMapObjIndexByName("mapframe1");
+	var submit = document.getElementById("submitButton");
+	if(global_wfsConfObj[global_selectedWfsConfId].featuretype_srs.toUpperCase()!=parent.mb_mapObj[ind].getSRS().toUpperCase()){
+		var msg = "Different EPSG of map and wfs featuretype, no spatial request possible!\n";
+		msg += parent.mb_mapObj[ind].getSRS()+" und "+global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
+		alert(msg);
+			
+		//disable Submit Button
+		if(submit)submit.disabled = true;
+	}
+	else{
+		//disable Submit Button
+		if(submit)submit.disabled = false;
+	}
+}
+
+function clearFilter(){
+	var wfsConfElementArray = global_wfsConfObj[global_selectedWfsConfId].element;
+	for (var i = 0; i < wfsConfElementArray.length; i++){
+		if (parseInt(wfsConfElementArray[i].f_search)) {
+			document.getElementById(wfsConfElementArray[i].element_name).value = "";	
+		}	
+	}
+	if(typeof(resultGeometryPopup)!="undefined"){
+ 		resultGeometryPopup.hide();
+ 	}
+ 	if(typeof(wfsPopup)!="undefined"){
+ 		wfsPopup.hide();
+ 	}
+ 	document.getElementById('res').value = "";	
+}
+
+function getNumberOfFilterParameters(){
+	var cnt = 0;
+	var el = global_wfsConfObj[global_selectedWfsConfId].element;
+
+	for (var i = 0; i < el.length; i++){
+	
+		if( el[i]['f_search'] == 1){
+			if(el[i]['f_form_element_html'].match(/\<select/)){
+				var elementValue = document.getElementById(el[i]['element_name']).options[document.getElementById(el[i]['element_name']).selectedIndex].value;
+    		}
+			else{
+				var elementValue = document.getElementById(el[i]['element_name']).value;
+			}
+	
+			if (elementValue != '') {
+				cnt++;
+			}
+		}
+	}
+	return cnt;
+}
+
+function validate(){
+	if(geomArray.count()>0){
+ 		geomArray.empty();
+ 	}
+	global_resultHighlight = new parent.Highlight(targetArray, "wfs_gazetteer_highlight", {"position":"absolute", "top":"0px", "left":"0px", "z-index":100}, 2);
+
+	var filterParameterCount = getNumberOfFilterParameters();
+	
+	if(filterParameterCount == 0 && spatialRequestGeom == null){
+		return false;
+	}
+	else{
+		var andConditions = "";
+		
+		var el = global_wfsConfObj[global_selectedWfsConfId].element;
+		var srs = global_wfsConfObj[global_selectedWfsConfId].featuretype_srs;
+	
+		for (var i = 0; i < el.length; i++) {
+			if (el[i]['f_search'] == 1){
+				if(el[i]['f_form_element_html'].match(/\<select/)){
+					var elementValue = document.getElementById(el[i]['element_name']).options[document.getElementById(el[i]['element_name']).selectedIndex].value;
+    			}
+				else{
+					var elementValue = document.getElementById(el[i]['element_name']).value;
+				}
+			}
+			
+			if (el[i]['f_search'] == 1 && elementValue != '') {
+				var a = new Array();
+				a = elementValue.split(",");
+				var orConditions = "";
+				for (var j=0; j < a.length; j++) {
+					if(el[i]['f_operator']=='bothside'){
+						orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+						orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+						orConditions += "<ogc:Literal>*";
+						if(el[i]['f_toupper'] == 1){
+							orConditions += a[j].toUpperCase();
+						}
+						else{
+							orConditions += a[j];
+						}
+						orConditions += "*</ogc:Literal>";
+						orConditions += "</ogc:PropertyIsLike>";
+				}
+					else if(el[i]['f_operator']=='rightside'){
+						orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+						orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+						orConditions += "<ogc:Literal>";
+						if(el[i]['f_toupper'] == 1){
+							orConditions += a[j].toUpperCase();
+						}
+						else{
+							orConditions += a[j];
+						}
+						orConditions += "*</ogc:Literal>";
+						orConditions += "</ogc:PropertyIsLike>";
+					}
+					else if(el[i]['f_operator']=='greater_than'){
+						orConditions += "<ogc:PropertyIsGreaterThan>";
+						orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+						orConditions += "<ogc:Literal>";
+						if(el[i]['f_toupper'] == 1){
+							orConditions += a[j].toUpperCase();
+						}
+						else{
+							orConditions += a[j];
+						}
+						orConditions += "</ogc:Literal>";
+						orConditions += "</ogc:PropertyIsGreaterThan>";
+					}
+					else if(el[i]['f_operator']=='less_than'){
+						orConditions += "<ogc:PropertyIsLessThan>";
+						orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+						orConditions += "<ogc:Literal>";
+						if(el[i]['f_toupper'] == 1){
+							orConditions += a[j].toUpperCase();
+						}
+						else{
+							orConditions += a[j];
+						}
+						orConditions += "</ogc:Literal>";
+						orConditions += "</ogc:PropertyIsLessThan>";
+					}
+					else if(el[i]['f_operator']=='less_equal_than'){
+						orConditions += "<ogc:PropertyIsLessThanOrEqualTo>";
+						orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+						orConditions += "<ogc:Literal>";
+						if(el[i]['f_toupper'] == 1){
+							orConditions += a[j].toUpperCase();
+						}
+						else{
+							orConditions += a[j];
+						}
+						orConditions += "</ogc:Literal>";
+						orConditions += "</ogc:PropertyIsLessThanOrEqualTo>";
+					}
+					else if(el[i]['f_operator']=='greater_equal_than'){
+						orConditions += "<ogc:PropertyIsGreaterThanOrEqualTo>";
+						orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+						orConditions += "<ogc:Literal>";
+						if(el[i]['f_toupper'] == 1){
+							orConditions += a[j].toUpperCase();
+						}
+						else{
+							orConditions += a[j];
+						}
+						orConditions += "</ogc:Literal>";
+						orConditions += "</ogc:PropertyIsGreaterThanOrEqualTo>";
+					}
+					else if(el[i]['f_operator']=='equal'){
+						orConditions += "<ogc:PropertyIsEqualTo>";
+						orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+						orConditions += "<ogc:Literal>";
+						if(el[i]['f_toupper'] == 1){
+							orConditions += a[j].toUpperCase();
+						}
+						else{
+							orConditions += a[j];
+						}
+						orConditions += "</ogc:Literal>";
+						orConditions += "</ogc:PropertyIsEqualTo>";
+					}
+					else{
+						orConditions += "<ogc:PropertyIsLike wildCard='*' singleChar='.' escape='!'>";
+						orConditions += "<ogc:PropertyName>" + el[i]['element_name'] + "</ogc:PropertyName>";
+						orConditions += "<ogc:Literal>*";
+						if(el[i]['f_toupper'] == 1){
+							orConditions += a[j].toUpperCase();
+						}
+						else{
+							orConditions += a[j];
+						}
+						orConditions += "*</ogc:Literal>";
+						orConditions += "</ogc:PropertyIsLike>";
+					}
+				}
+				if(a.length > 1){
+					andConditions += "<Or>" + orConditions + "</Or>";
+				}
+				else {
+					andConditions += orConditions;
+				}
+			}
+		}
+		
+		if(spatialRequestGeom!=null){
+			if(spatialRequestGeom.geomType == "polygon"){
+				if(buttonPolygon.filteroption=='within'){	
+					andConditions += "<Within><ogc:PropertyName>";
+					for (var j=0; j < el.length; j++) {
+						if(el[j]['f_geom']==1){
+							var elementName = el[j]['element_name'];
+							andConditions += el[j]['element_name'];
+						}
+					}
+					andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+					andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+					for(var k=0; k<spatialRequestGeom.count(); k++){
+						if(k>0)	andConditions += " ";
+						andConditions += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+					}
+					andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+					andConditions += "</gml:Polygon></Within>";
+				}
+				else if(buttonPolygon.filteroption=='intersects'){
+					andConditions += "<Intersects><ogc:PropertyName>";
+					for (var j=0; j < el.length; j++) {
+						if(el[j]['f_geom']==1){
+							var elementName = el[j]['element_name'];
+							andConditions += el[j]['element_name'];
+						}
+					}
+					andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+					andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";	
+					for(var k=0; k<spatialRequestGeom.count(); k++){
+						if(k>0)	andConditions += " ";
+						andConditions += spatialRequestGeom.get(k).x+","+spatialRequestGeom.get(k).y;
+					}
+					andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+					andConditions += "</gml:Polygon></Intersects>";
+				}
+			}	
+			else if(spatialRequestGeom.geomType == "line"){
+				var rectangle = [];
+				rectangle = spatialRequestGeom.getBBox();
+				
+				if(buttonRectangle.filteroption=='within'){	
+					andConditions += "<Within><ogc:PropertyName>";
+					for (var j=0; j < el.length; j++) {
+						if(el[j]['f_geom']==1){
+							var elementName = el[j]['element_name'];
+							andConditions += el[j]['element_name'];
+						}
+					}
+					andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+					andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";
+					andConditions += rectangle[0].x+","+rectangle[0].y;
+					andConditions += " ";
+					andConditions += rectangle[0].x+","+rectangle[1].y;
+					andConditions += " ";
+					andConditions += rectangle[1].x+","+rectangle[1].y;
+					andConditions += " ";
+					andConditions += rectangle[1].x+","+rectangle[0].y;
+					andConditions += " ";
+					andConditions += rectangle[0].x+","+rectangle[0].y;
+					andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+					andConditions += "</gml:Polygon></Within>";
+				}
+				else if(buttonRectangle.filteroption=='intersects'){
+					andConditions += "<Intersects><ogc:PropertyName>";
+					for (var j=0; j < el.length; j++) {
+						if(el[j]['f_geom']==1){
+							var elementName = el[j]['element_name'];
+							andConditions += el[j]['element_name'];
+						}
+					}
+					andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\">";
+					andConditions += "<gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";	
+					andConditions += rectangle[0].x+","+rectangle[0].y;
+					andConditions += " ";
+					andConditions += rectangle[0].x+","+rectangle[1].y;
+					andConditions += " ";
+					andConditions += rectangle[1].x+","+rectangle[1].y;
+					andConditions += " ";
+					andConditions += rectangle[1].x+","+rectangle[0].y;
+					andConditions += " ";
+					andConditions += rectangle[0].x+","+rectangle[0].y;
+					andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs>";
+					andConditions += "</gml:Polygon></Intersects>";
+				}			
+			}
+			else if(spatialRequestGeom.geomType == "point"){
+				var tmp = spatialRequestGeom.get(0);
+				var mapPos = parent.makeRealWorld2mapPos("mapframe1",tmp.x, tmp.y);
+				var buffer = mb_wfs_tolerance/2;
+				var mapPosXAddPix = mapPos[0] + buffer; 
+				var mapPosYAddPix = mapPos[1] +buffer;
+				var mapPosXRemovePix = mapPos[0] - buffer;
+				var mapPosYRemovePix = mapPos[1] - buffer;
+				var realWorld1 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYRemovePix);
+				var realWorld2 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+				var realWorld3 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXAddPix,mapPosYRemovePix);
+				var realWorld4 = parent.makeClickPos2RealWorldPos("mapframe1",mapPosXRemovePix,mapPosYAddPix);
+				andConditions += "<Intersects><ogc:PropertyName>";
+				for (var j=0; j < el.length; j++) {
+					if(el[j]['f_geom']==1){
+						var elementName = el[j]['element_name'];
+						andConditions += el[j]['element_name'];
+					}
+				}
+				andConditions += "</ogc:PropertyName><gml:Polygon srsName=\""+srs+"\"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>";	
+				andConditions += realWorld1[0] + "," + realWorld1[1] + " " + realWorld2[0] + "," + realWorld2[1] +  " ";
+				andConditions += realWorld3[0] + "," + realWorld3[1] + " " + realWorld4[0] + "," + realWorld4[1] + " " + realWorld1[0] + "," + realWorld1[1]; 
+				andConditions += "</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></Intersects>";
+			}
+			//andConditions += "<ogc:Not><ogc:PropertyIsNull>";
+            //andConditions += "<ogc:PropertyName>" + elementName + "</ogc:PropertyName>";
+       		//andConditions += "</ogc:PropertyIsNull></ogc:Not>";
+		}
+		
+		var u = global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature + parent.mb_getConjunctionCharacter(global_wfsConfObj[global_selectedWfsConfId].wfs_getfeature);
+		u += "REQUEST=getFeature&Typename="+global_wfsConfObj[global_selectedWfsConfId].featuretype_name+"&Version=1.0.0&service=WFS";
+		u += "&filter=";
+
+		if (filterParameterCount > 1 || spatialRequestGeom != null) {
+			andConditions = "<And>" + andConditions + "</And>";
+		}
+
+		var filter = "<ogc:Filter xmlns:ogc='http://ogc.org' xmlns:gml='http://www.opengis.net/gml'>"+andConditions+"</ogc:Filter>";
+
+		document.getElementById("res").innerHTML = "<table><tr><td><img src='../img/indicator_wheel.gif'></td><td>Searching...</td></tr></table>";
+		var parameters = {command:"getSearchResults", "wfs_conf_id":global_selectedWfsConfId, "frame":this.name, "url":u, "filter":filter, "backlink":""};
+		parent.mb_ajax_get("../php/mod_wfs_gazetteer_server.php", parameters, function (jsCode, status) {
+			document.getElementById("res").innerHTML = "<table><tr><td>Arranging search results...</td></tr></table>";
+			
+			if(status=='success'){
+				for (var i=0; i < parent.wms.length; i++) {
+					for (var j=0; j < parent.wms[i].objLayer.length; j++) {
+						var currentLayer = parent.wms[i].objLayer[j];
+						var wms_id = parent.wms[i].wms_id; 
+						if (currentLayer.gui_layer_wfs_featuretype == global_selectedWfsConfId) {
+							var layer_name = currentLayer.layer_name; 
+							parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'querylayer',1); 
+							parent.handleSelectedLayer_array(targetArray[0],[wms_id],[layer_name],'visible',1);					
+						}
+					}
+				}
+				var geoObj = eval('(' + jsCode + ')');	
+	       		if (jsCode) {
+		        	if (typeof(geoObj) == 'object') {
+		        		geomArray.importGeoJSON(geoObj);
+		        		document.getElementById("res").innerHTML = '';
+						displayResult(geomArray);
+					}
+					else {
+						document.getElementById("res").innerHTML = '';
+						displayResult();
+					}
+				}
+	       		else {
+					document.getElementById("res").innerHTML = '';
+					alert("No results.");
+				}
+	       	}
+		});
+	}
+	spatialRequestGeom = null;
+	return false;
+}
+
+function displayResult(geom){
+	geomArray = geom;
+	if(geomArray!=null && geomArray.count()>0){
+		var contentHtml = createListOfGeometries();
+	}
+	else{
+		var contentHtml = "No results.";
+	}
+	
+	if(showResultInPopup==1){
+		if (typeof(resultGeometryPopup) == "undefined") {
+			resultGeometryPopup = new parent.mb_popup(searchPopupTitle,contentHtml,searchPopupWidth,searchPopupHeight,searchPopupX,searchPopupY);
+		}
+		else {
+			resultGeometryPopup.hide();
+			resultGeometryPopup = new parent.mb_popup(searchPopupTitle,contentHtml,searchPopupWidth,searchPopupHeight,searchPopupX,searchPopupY);
+		}
+		resultGeometryPopup.show();
+	}
+	else{
+		document.getElementById("res").innerHTML = contentHtml;
+	}
+	
+} 
+
+function createListOfGeometries(){
+	var listOfGeom = "<table style='background-color:#EEEEEE;'>\n";
+	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+	var labelArray = [];
+	if (geomArray.count() > 0) {
+		listOfGeom += "<tr>";
+		var labelObj = getListTitle();
+		for (var k = 1 ; k < labelObj.length; k ++) {
+			listOfGeom += "<td>";
+			listOfGeom += labelObj[k];
+			listOfGeom += "</td>";
+		}
+		listOfGeom += "</tr>";
+		for (var i = 0 ; i < geomArray.count(); i ++) {
+			if (geomArray.get(i).get(-1).isComplete()) {
+				listOfGeom += "<tr>\n";
+				var resultElObj = getListValues(geomArray.get(i));
+				for (var l = 1 ; l < resultElObj.length; l ++) {
+					if(resultElObj[l]!=''){
+						listOfGeom += "<td style='cursor:pointer;\n";
+						if(showResultInPopup==1){
+							if ((i % 2) === 0) {
+								listOfGeom += "color:blue'";
+							}
+							else {
+								listOfGeom += "color:red'";
+							}
+						}
+						else{
+							if ((i % 2) === 0) {
+								listOfGeom += "' class='even'";
+							}
+							else {
+								listOfGeom += "' class='uneven'";
+							}
+						}
+						if(showResultInPopup==1){
+							var domPath = "window.frames['"+frameName+"'].";
+						}
+						else{
+							var domPath = "";
+						}
+						listOfGeom += " onmouseover=\""+domPath+"setResult('over',"+i+")\" ";
+						listOfGeom += " onmouseout=\""+domPath+"setResult('out',"+i+")\" ";
+						listOfGeom += " onclick=\""+domPath+"setResult('click',"+i+"); "+domPath+"showWfs("+i+");\" ";
+						listOfGeom += ">"+ resultElObj[l] +"</td>";
+					}
+				}	
+				listOfGeom += "\t</tr>\n"; 
+			}
+		}
+	}
+	listOfGeom += "</table>\n";
+	return listOfGeom; 
+}
+
+function getListTitle(){
+	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+	var labelArray = [];
+	for (var j = 0 ; j < wfsConf.element.length ; j++) {
+		if(wfsConf.element[j].f_show == 1 && wfsConf.element[j].f_label!=''){
+			var labelPos = wfsConf.element[j].f_respos;
+			labelArray[labelPos] = wfsConf.element[j].f_label;
+		}
+	}
+	return labelArray;
+}
+		
+function getListValues(geom){
+	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+	var resultArray = [];
+	for (var i = 0 ; i < wfsConf.element.length ; i++) {
+		if (wfsConf.element[i].f_show == 1 && geom.e.getElementValueByName(wfsConf.element[i].element_name) !=false) {
+			var pos = wfsConf.element[i].f_respos;
+			if(pos>0){
+				resultArray[pos] = geom.e.getElementValueByName(wfsConf.element[i].element_name);
+			}
+		}
+	}
+	return resultArray;
+}
+
+function showWfs(geometryIndex) {
+	var wfsConf = global_wfsConfObj[global_selectedWfsConfId];
+	var wfsElement = geomArray.get(geometryIndex).e;
+	var showDetailsObj = {};
+	var details = 0;
+	for (var i = 0 ; i <wfsConf.element.length; i ++) {
+		if(wfsConf.element[i].f_show_detail == 1 && wfsElement.getElementValueByName(wfsConf.element[i].element_name)!=''){
+			var elPos = wfsConf.element[i].f_respos;
+			if(elPos>0){
+				showDetailsObj[elPos] = {};
+				//var elementVal = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
+				//showDetailsObj[elPos][wfsConf.element[i].f_label] = elementVal;
+				if(wfsConf.element[i].f_form_element_html.indexOf("href")!=-1){
+					var setUrl = wfsConf.element[i].f_form_element_html.replace(/href\s*=\s*['|"]\s*['|"]/, "href='http://hnodc.hcmr.gr/hnodc_public_data/"+wfsElement.getElementValueByName(wfsConf.element[i].element_name)+"' target='_blank'");
+					if(setUrl.match(/><\/a>/)){
+						var newLink	=	setUrl.replace(/><\/a>/, ">"+wfsElement.getElementValueByName(wfsConf.element[i].element_name)+"</a>");
+					}
+					else{
+						var newLink = setUrl;
+					}
+					showDetailsObj[elPos][wfsConf.element[i].f_label] =  newLink;
+				}
+				else{
+					showDetailsObj[elPos][wfsConf.element[i].f_label] = wfsElement.getElementValueByName(wfsConf.element[i].element_name);
+				}
+			}
+			details = 1;
+		}
+	}
+	var resultHtml = "";
+	resultHtml += "<table style='background-color:#EEEEEE;'>\n";
+	for (var elPos in showDetailsObj) {
+		var currentDetail = showDetailsObj[elPos];
+		for(var key in currentDetail){
+			var currentDetailName = key;
+			var currentDetailValue = currentDetail[key];
+			resultHtml +="<tr><td>\n"; 
+			resultHtml += currentDetailName;
+			resultHtml +="</td>\n"; 
+			resultHtml += "<td>\n";
+			resultHtml += currentDetailValue;
+			resultHtml += "</td></tr>\n";
+		}
+	}
+	if(details != 1){
+		resultHtml +="<tr><td>No detail information</td></tr>\n";
+	}
+	resultHtml += "</table>\n";
+	
+	if (typeof(wfsPopup) == "undefined") {
+		wfsPopup = new parent.mb_popup(detailPopupTitle,resultHtml,detailPopupWidth,detailPopupHeight,detailPopupX,detailPopupY);
+	}
+	else {
+		wfsPopup.hide();
+		wfsPopup = new parent.mb_popup(detailPopupTitle,resultHtml,detailPopupWidth,detailPopupHeight,detailPopupX,detailPopupY);
+	}
+	wfsPopup.show();
+}
+
+/*
+* event -> {over || out || click}
+* geom -> commaseparated coordinates x1,y1,x2,y2 ...
+*/
+function setResult(event, index){
+	var currentGeom = geomArray.get(index);
+	if (maxHighlightedPoints > 0 && currentGeom.getTotalPointCount() > maxHighlightedPoints) {
+		currentGeom = currentGeom.getBBox4();
+	}
+	if (event == "over") {
+		global_resultHighlight.add(currentGeom, cw_fillcolor);
+		global_resultHighlight.paint();
+	}
+	else if (event == "out"){
+		global_resultHighlight.del(currentGeom, cw_fillcolor);
+		global_resultHighlight.paint();
+	}
+	else if (event == "click"){
+		global_resultHighlight.del(currentGeom, cw_fillcolor);
+		var bbox = currentGeom.getBBox();
+		var bufferFloat = parseFloat(global_wfsConfObj[global_selectedWfsConfId].g_buffer);
+		var buffer = new parent.Point(bufferFloat,bufferFloat);
+		bbox[0] = bbox[0].minus(buffer);
+		bbox[1] = bbox[1].plus(buffer);
+		parent.mb_calculateExtent(targetArray[0], bbox[0].x, bbox[0].y, bbox[1].x, bbox[1].y);
+		parent.zoom(targetArray[0], 'true', 1.0);
+		global_resultHighlight.add(currentGeom, cw_fillcolor);
+		global_resultHighlight.paint();
+	}
+	return true;
+}
+
+function callPick(obj){
+	dTarget = obj;
+	var dp = window.open('../tools/datepicker/datepicker.php?m=Jan_Feb_Mar_Apr_May_June_July_Aug_Sept_Oct_Nov_Dec&d=Mon_Tue_Wed_Thu_Fri_Sat_Sun&t=today','dp','left=200,top=200,width=230,height=210,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0');
+	dp.focus();
+	return false;
+}
+
+</script>
+</head>
+<body leftmargin='0' topmargin='10'  bgcolor='#ffffff'>
+<form name='selectWfsConfForm' id='selectWfsConfForm'></form>
+<div name='displaySpatialButtons' id='displaySpatialButtons' style='width:180px'></div>
+<a name='wfsInfo' id='wfsInfo'></a>
+<img src = "" name='wfsRemove' id='wfsRemove'>
+<img src = "" name='wfsGeomType' id='wfsGeomType'>
+<form name='wfsForm' id='wfsForm' onsubmit='return validate()'></form>
+<div name='res' id='res' style='width:180px'></div>
+</body>
+</html>



More information about the Mapbender_commits mailing list