[Mapbender-commits] r1028 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jan 24 08:09:02 EST 2007


Author: christoph
Date: 2007-01-24 08:09:02 -0500 (Wed, 24 Jan 2007)
New Revision: 1028

Modified:
   trunk/mapbender/http/javascripts/wfs.js
Log:
add ajax style wfs handling

Modified: trunk/mapbender/http/javascripts/wfs.js
===================================================================
--- trunk/mapbender/http/javascripts/wfs.js	2007-01-24 13:08:39 UTC (rev 1027)
+++ trunk/mapbender/http/javascripts/wfs.js	2007-01-24 13:09:02 UTC (rev 1028)
@@ -1,14 +1,38 @@
-<?php 
-require_once("mod_geometryArray.js");
-require_once("mod_highlight.php");
+ <?php
+#$Id$
+#$Header: /cvsroot/mapbender/mapbender/http/javascripts/mod_wfs_spatialRequest.php,v 1.4 2006/03/08 15:26:26 c_baudson Exp $
+# 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();
+import_request_variables("PG");
+require_once("../php/mb_validateSession.php");
+require_once("../../conf/mapbender.conf");
+$con = db_connect(DBSERVER,OWNER,PW);
+db_select_db(DB,$con);
+
+$gui_id = $_REQUEST["gui_id"];
+$e_id_css = "wfs";
+include '../include/dyn_js.php';
 require_once("wfs_usemap.js");
 ?>
-var digiFrame = "digitize";
-var highlight_tag_id = "digitize";
+var highlight_tag_id = "wfs";
 var mb_wfs_fetched = new Array();
-var	mb_wfs_fetch = new GeometryArray();
-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;
@@ -16,13 +40,28 @@
 var mb_wfs_objwin_width = 200;
 var mb_wfs_objwin_height = 200;
 var mb_wfs_targets = new Array("mapframe1","overview");
-var mb_wfs_maxBasePoints = 200;
 var mb_wfs_fillColor = "#ff0000";
 var usemap = "";
 var mod_usemap_radius = 10;
 var mod_usemap_line_tolerance = 5;
-var highlight = new Highlight(mb_wfs_targets, highlight_tag_id);
+var useCheckboxForHighlighting = true;
 
+var mb_wfs_fetch = new GeometryArray();
+
+var highlight;
+
+mb_registerInitFunctions('initHighlight()');
+
+function initHighlight() {
+	highlight = new Highlight(mb_wfs_targets, highlight_tag_id);
+}
+try {if(displayWfsResultList){}}catch(e) {displayWfsResultList = 0;}
+
+if (displayWfsResultList == 1) {
+	//mb_registerWfsReadSubFunctions(function(geom){mb_wfs_listMember(geom)});
+}
+
+
 if (parseInt(useUsemap) == 1) {
 	mb_registerSubFunctions('mod_usemap("")');
 }
@@ -32,73 +71,6 @@
 	mb_registerInitFunctions('highlight.paint()');
 }
 
-	function calculateVisibleDash (p0, p1, width, height) {
-		if (p0.x > p1.x) {var p_temp = p0; p0 = p1; p1 = p_temp; p_temp = null;}
-		var p = p0; var q = p1; var m; 
-		if (p1.x != p0.x) {
-			m = -(p1.y-p0.y)/(p1.x-p0.x); 
-			if (p0.x < width && p1.x > 0 && !(p0.y < 0 && p1.y < 0) && !(p0.y > height && p1.y > height) ) {
-				if (p0.x < 0) {
-					var iy = p0.y - m*(0-p0.x);
-					if (iy > 0 && iy < height) p = new Point(0, iy);
-					else if (iy > height) {
-					    var ix = p0.x+((p0.y - height)/m);
-					    if (ix > 0 && ix < width) p = new Point(ix, height); else return false;
-					}
-					else if (iy < 0) {
-					    var ix = p0.x+(p0.y/m);
-					    if (ix > 0 && ix < width) p = new Point(ix, 0); else return false;
-					}
-					else return false;
-				}
-				else if (p0.y >= 0 && p0.y <= height) {p = p0;}
-				else if (p0.y < 0) {
-				    var ix = p0.x+(p0.y/m);
-				    if (ix > 0 && ix < width) p = new Point(ix, 0); else return false;
-				}
-				else if (p0.y > height && m > 0) {
-				    var ix = p0.x+((p0.y - height)/m);
-				    if (ix > 0 && ix < width) p = new Point(ix, height); else return false;
-				}
-				else return false;
-				if (p1.x > width) {
-					var iy = p1.y - m*(width-p1.x);
-					if (iy > 0 && iy < height) {q = new Point(width, iy);}
-					else if (iy < 0) {
-					    var ix = p0.x+(p0.y/m);
-					    if (ix > 0 && ix < width) q = new Point(ix, 0); else return false;
-					}
-					else if (iy > height) {
-					    var ix = p0.x+((p0.y - height)/m);
-					    if (ix > 0 && ix < width) q = new Point(ix, height); else return false;
-					}
-					else return false;
-				}
-				else if (p1.y >= 0 && p1.y <= height) {q = p1;}
-				else if (p1.y < 0) {
-				    var ix = p1.x+(p1.y/m);
-				    if (ix > 0 && ix < width) q = new Point(ix, 0); else return false;
-				}
-				else if (p1.y > height) {
-				    var ix = p1.x+((p1.y- height)/m);
-				    if (ix > 0 && ix < width) q = new Point(ix, height); else return false;
-				}
-			}
-			else return false;
-		}
-		else {
-			if (!(p0.y < 0 && p1.y < 0) && !(p0.y > height && p1.y > height)) {
-				if (p0.y < 0) {p = new Point(p0.x, 0);}
-				else if (p0.y > height) {p = new Point(p0.x, height);}
-				else p = p0;
-				if (p1.y < 0) {q = new Point(p0.x, 0);}
-				else if (p1.y > height) {q = new Point(p0.x, height);}
-				else q = p1;
-			}
-			else return false;
-		}
-		return new Array(new Point(Math.round(q.x), Math.round(q.y)), new Point(Math.round(p.x), Math.round(p.y)));
-	}
 /*
 if (useExtentIsSet()) {
 	mb_registerSubFunctions("mb_setwfsrequest_extent()");
@@ -121,167 +93,40 @@
 	}
 }
 */
- 
-function mb_setwfsrequest(target,geom){
-	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(geom.geomtype==geomTypePolygon){
-		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'];
-						}
+
+function mb_wfs_listMember(geomArray){
+	mb_wfs_fetch.union(geomArray);
+	var wfs_conf = get_complete_wfs_conf();
+	var str = "<table>";
+	for(var i=0; i<mb_wfs_fetch.count(); i++){
+		var t = wfs_conf[mb_wfs_fetch.get(i).wfs_conf];
+		for(var j=0; j<t['element'].length; j++){
+			if(t['element'][j]['f_show'] > 0){
+				var k = mb_wfs_fetch.get(i).e.getElementIndexByName(t['element'][j]['element_name']);
+				//alert(k);
+				if(k != -1){
+					str += "<tr><td>";
+					if (useCheckboxForHighlighting) {
+						str += "<input type=checkbox id=highlightCheckbox" + i + " onChange='highlightGeometry(" + i + ")'></td><td>";
 					}
-				filter += "</ogc:PropertyName>";
-				filter += '<gml:Polygon srsName="EPSG:4326">';
-					filter += '<gml:outerBoundaryIs>';
-						filter += '<gml:LinearRing>';
-							filter += '<gml:coordinates>';
-								for(var k=0; k<geom.count(); k++){
-									if(k>0){
-										filter += " ";
-									}
-									filter += geom.get(k).x+","+geom.get(k).y;								 
-								}
-							filter += '</gml:coordinates>';
-						filter += '</gml:LinearRing>';
-					filter += '</gml:outerBoundaryIs>';
-				filter += '</gml:Polygon>';
-			filter += '</Within>';
-			filter += '</ogc:Filter>';
-			path += filter;
-			mb_wfs_createwin(w_[i],path);
-			mb_wfsreq++;
-		}
-	}
-	else if(geom.geomtype==geomTypeLine || geom.geomtype == geomTypePoint){
-		var rectangle = new Array();
-		if(geom.geomtype == geomTypePoint){
-			var tmp = realToMap(mb_wfs_target,geom.get(0));
-			var buffer = new Point(mb_wfs_tolerance/2, mb_wfs_tolerance/2);
-			rectangle[0] = mapToReal(mb_wfs_target, tmp.plus(buffer));
-			rectangle[1] = mapToReal(mb_wfs_target, tmp.minus(buffer));
-		}
-		if(geom.geomtype == geomTypeLine){
-			var rectangle = geom.getBBox();
-		}
-		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'];
+					str += "<div";
+					if (!useCheckboxForHighlighting) {
+						str += " onmouseover='mb_wfs_perform(\"over\",mb_wfs_fetch.get("+i+"))' ";
+						str += " onmouseout='mb_wfs_perform(\"out\",mb_wfs_fetch.get("+i+"))' ";
+					}
+					str += " onclick='mb_wfs_perform(\"click\",mb_wfs_fetch.get("+i+"))' ";
+					str += ">" + mb_wfs_fetch.get(i).e.getValue(k)+ "</div></td></tr>";
 				}
 			}
-			filter += "</ogc:PropertyName>";
-			filter += '<gml:Box srsName="4326"><gml:coordinates>';	
-			filter += rectangle[0].x+","+rectangle[0].y;
-			filter += " ";
-			filter += rectangle[1].x+","+rectangle[1].y; 
-			filter += '</gml:coordinates></gml:Box></ogc:BBOX>';
-			filter += '</ogc:Filter>';
-			path += filter;
-			mb_wfs_createwin(w_[i],path);
-			mb_wfsreq++;
 		}
 	}
-	highlight = new Highlight(mb_wfs_targets, highlight_tag_id);
-	return true;
+	str += "</table>";
+	mb_wfs_objwin.innerHTML = str;
+//	if (parseInt(useUsemap) == 1) mod_usemap(wfs_name);
 }
 
-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';
-}
-
-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 != false && a.count()>0){
-		for(var i=0; i<a.count(); i++){
-			
-			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.appendMember(a.get(i));
-				mb_wfs_fetch.get(-1).wfs_conf = current_wfs_name;
-
-				if(tooManyBasepoints()){ //if a geometry has too many basepoints, its bbox will be displayed
-					var newGeom = mb_wfs_fetch.get(-1).getBBox();
-					mb_wfs_fetch.get(-1).emptyMember();
-					mb_wfs_fetch.get(-1).addGeometry();
-					mb_wfs_fetch.getGeometry(-1,-1).addPoint(newGeom[0]);
-					mb_wfs_fetch.getGeometry(-1,-1).addPoint(new Point(newGeom[0].x, newGeom[1].y));
-					mb_wfs_fetch.getGeometry(-1,-1).addPoint(newGeom[1]);
-					mb_wfs_fetch.getGeometry(-1,-1).addPoint(new Point(newGeom[1].x, newGeom[0].y));
-					mb_wfs_fetch.getGeometry(-1,-1).close();
-				}
-			}
-			else alert("EPSG mismatch. Invalid WFS result. Press OK to continue.");
-		}		
-		if (isSetWfsResultToDigitize() == false) {
-			mb_wfs_listMember(current_wfs_name);
-		}
-		else {
-			if (mb_wfs_fetch.count()>0) {
-				tab_open(digiFrame);
-
-				for (var i = 0 ; i < mb_wfs_fetch.count() ; i ++) {
-					parent.window.frames[digiFrame].appendGeometry(mb_wfs_fetch.get(i));
-				}
-			}
-		}
-	}
-//	alert(mb_wfs_fetch.count());
-}
-
 function mb_wfs_reset(){
-	mb_wfs_fetch = new GeometryArray();
+	mb_wfs_fetch = new parent.GeometryArray();
 	usemap = "";
 	
 	if(mb_wfs_objwin == null){
@@ -305,41 +150,6 @@
 	return true;
 }
 
-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.count(); i++){
-		var t = wfs_conf[mb_wfs_fetch.get(i).wfs_conf];
-		for(var j=0; j<t['element'].length; j++){
-			if(t['element'][j]['f_show'] > 0){
-				var k = mb_wfs_fetch.get(i).e.getElementIndexByName(t['element'][j]['element_name'])
-				if(k != -1){
-					str += "<tr><td><img src = '"+buttonWfs_toDigitize_src+"' title='"+buttonWfs_toDigitize_title+"' onClick = 'tab_open(digiFrame);parent.window.frames[digiFrame].appendGeometry(mb_wfs_fetch.get("+i+"))'></td><td>";
-					if (useCheckboxForHighlighting) {
-						str += "<input type=checkbox id=highlightCheckbox" + i + " onChange='highlightGeometry(" + i + ")'></td><td>";
-					}
-					str += "<div";
-					if (!useCheckboxForHighlighting) {
-						str += " onmouseover='mb_wfs_perform(\"over\",mb_wfs_fetch.get("+i+"))' ";
-						str += " onmouseout='mb_wfs_perform(\"out\",mb_wfs_fetch.get("+i+"))' ";
-					}
-					str += " onclick='mb_wfs_perform(\"click\",mb_wfs_fetch.get("+i+"))' ";
-					str += ">" + mb_wfs_fetch.get(i).e.getValue(k)+ "</div></td></tr>";
-				}
-			}
-		}
-	}
-	str += "</table>";
-	mb_wfs_objwin.innerHTML = str;
-	if (parseInt(useUsemap) == 1) mod_usemap(wfs_name);
-}
-
-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;
@@ -347,17 +157,16 @@
 
 function highlightGeometry(i) {
 	var id = "highlightCheckbox"+i;
-	if (document.getElementById(id).checked) highlight.add(mb_wfs_fetch.get(i));
-	else highlight.del(mb_wfs_fetch.get(i));
+	if (document.getElementById(id).checked) highlight.add(mb_wfs_fetch.get(i), '#00ff00');
+	else highlight.del(mb_wfs_fetch.get(i), '#00ff00');
 }
 
 function mb_wfs_perform(type,m){
 
 	var wfs_conf = window.frames["wfs_conf"].get_wfs_conf();
-	if(type=='over') highlight.add(m);
-	else if(type=='out') highlight.del(m);
+	if(type=='over') highlight.add(m, '#0000ff');
+	else if(type=='out') highlight.del(m, '#0000ff');
 	else if(type=='click') {
-		highlight.del(m);
 		var tmp = m.getBBox();
 		var b = 0;
 		if (m.wfs_conf != -1) {
@@ -371,9 +180,138 @@
 	}
 }
 
-function tooManyBasepoints() {
-	if (mb_wfs_fetch.get(-1).getTotalPointCount() > mb_wfs_maxBasePoints) {
-		return true;
+function get_wfs_str(myconf, d, m, type, fid) {
+	var str = '<wfs:Transaction version="1.0.0" service="WFS" xmlns="http://www.someserver.com/myns" ';
+
+	var ns_gml = false;	var ns_ogc = false;	var ns_xsi = false;	var ns_wfs = false;	var ns_topp = false;
+	
+	for (var q = 0 ; q < myconf['namespaces'].length ; q++) {
+		if (myconf['namespaces'][q]['name'] == "gml") ns_gml = true;
+		else if (myconf['namespaces'][q]['name'] == "ogc") ns_ogc = true;
+		else if (myconf['namespaces'][q]['name'] == "xsi") ns_xsi = true;
+		else if (myconf['namespaces'][q]['name'] == "wfs") ns_wfs = true;
+		else if (myconf['namespaces'][q]['name'] == "topp") ns_topp = true;
+		str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
 	}
-	return false;
-}
\ No newline at end of file
+	
+	if (ns_gml == false) str += 'xmlns:gml="http://www.opengis.net/gml" ';
+	if (ns_ogc == false) str += 'xmlns:ogc="http://www.opengis.net/ogc" ';
+	if (ns_xsi == false) str += 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';
+	if (ns_topp == false) str += 'xmlns:topp="http://www.someserver.com/topp" ';
+	if (ns_wfs == false) str += 'xmlns:wfs="http://www.opengis.net/wfs" ';
+	
+	str += 'xsi:schemaLocation="http://www.someserver.com/myns http://wms1.ccgis.de/geoserver-1.3-beta4/wfs/getCapabilities?request=describefeaturetype&amp;typename=mapbender_user http://www.opengis.net/wfs../wfs/1.0.0/WFS-transaction.xsd">';
+
+	
+	//
+	// ---------------------------------------- SAVE -------------------------------------------------
+	//
+	if (type == "save") {
+		str += '<wfs:Insert><'+ myconf['featuretype_name']+'>';
+		for(var i=0; i<d.get(m).e.count(); i++){
+			if(d.get(m).e.getValue(i) != ""){
+				var tmp = d.get(m).e.getName(i);
+				str += '<' + tmp  + '>' + d.get(m).e.getValue(i) + '</' + tmp  + '>';
+			}
+		}
+		for(var j=0; j<myconf['element'].length; j++){
+			if(myconf['element'][j]['f_geom'] == 1){
+				var el_geom = myconf['element'][j]['element_name'];	
+			}
+		}
+		str += '<' + el_geom + '>';	
+		if(d.get(m).geomtype == geomTypePoint){
+			str += '<gml:Point srsName="' + myconf['featuretype_srs'] + '">';
+			str += '<gml:coordinates>';
+			str += d.getPoint(m,0,0).x + "," + d.getPoint(m,0,0).y; 
+			str += '</gml:coordinates>';
+			str += '</gml:Point>';		
+		}
+		if(d.get(m).geomtype == geomTypeLine){
+			str += '<gml:MultiLineString srsName="' + myconf['featuretype_srs'] + '">';
+			str += '<gml:lineStringMember><gml:LineString><gml:coordinates>';
+			for(var k=0; k<d.getGeometry(m,0).count(); k++){
+				if(k>0)	str += " ";	
+				str += d.getPoint(m,0,k).x + "," + d.getPoint(m,0,k).y;
+			} 
+			str += '</gml:coordinates></gml:LineString></gml:lineStringMember>';
+			str += '</gml:MultiLineString>';
+		}
+		if(d.get(m).geomtype == geomTypePolygon){
+			str += '<gml:MultiPolygon srsName="' + myconf['featuretype_srs'] + '">';
+			str += '<gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>';
+
+			for(var k=0; k<d.getGeometry(m,0).count(); k++){
+				if(k>0)	str += " ";	
+				str += d.getPoint(m,0,k).x + "," + d.getPoint(m,0,k).y;
+			} 
+			str += '</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon>';
+		}
+		str += '</' + el_geom + '></'+ myconf['featuretype_name']+'></wfs:Insert>';		
+	}
+	//
+	// --------------------------------------- UPDATE ------------------------------------------------
+	//
+	else if (type == "update") {
+		str += '<wfs:Update typeName="'+ myconf['featuretype_name']+'">';
+		for(var i=0; i<d.get(m).e.count(); i++){
+			if(d.get(m).e.getValue(i) != ""){
+				str += '<wfs:Property>';
+				str += '<wfs:Name>'+d.get(m).e.getName(i)+'</wfs:Name>';
+				str += '<wfs:Value>'+d.get(m).e.getValue(i)+'</wfs:Value>';
+				str += '</wfs:Property>';
+			}
+		}
+		for(var j=0; j<myconf['element'].length; j++){
+			if(myconf['element'][j]['f_geom'] == 1){
+				var el_geom = myconf['element'][j]['element_name'];	
+			}
+		}
+		str += '<' + el_geom + '>';	
+		str += '<wfs:Property><wfs:Name>' + el_geom + '</wfs:Name><wfs:Value>';
+		if(d.get(m).geomtype == geomTypePoint){
+			str += '<gml:Point srsName="' + myconf['featuretype_srs'] + '"><gml:coordinates>';
+			str += d.getPoint(m,0,0).x + "," + d.getPoint(m,0,0).y; 
+			str += '</gml:coordinates></gml:Point>';		
+		}
+		if(d.get(m).geomtype == geomTypeLine){
+			str += '<gml:MultiLineString srsName="' + myconf['featuretype_srs'] + '">';
+			str += '<gml:lineStringMember><gml:LineString><gml:coordinates>';
+			for(var k=0; k<d.getGeometry(m,0).count(); k++){
+				if(k>0)	str += " ";	
+				str += d.getPoint(m,0,k).x + "," + d.getPoint(m,0,k).y;
+			} 
+			str += '</gml:coordinates></gml:LineString></gml:lineStringMember>';
+			str += '</gml:MultiLineString>';
+		}
+		if(d.get(m).geomtype == geomTypePolygon){
+			str += '<gml:MultiPolygon srsName="' + myconf['featuretype_srs'] + '">';
+			str += '<gml:polygonMember><gml:Polygon><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>';
+			for(var k=0; k<d.getGeometry(m,0).count(); k++){
+				if(k>0)	str += " ";	
+				str += d.getPoint(m,0,k).x + "," + d.getPoint(m,0,k).y;
+			} 
+			str += '</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></gml:polygonMember></gml:MultiPolygon>';
+		}
+		str += '</wfs:Value></wfs:Property>';
+		str += '</' + el_geom + '>';
+		str += '<ogc:Filter><ogc:FeatureId fid="'+fid+'"/></ogc:Filter>';
+		str += '</wfs:Update>';
+	}
+	//
+	// --------------------------------------- DELETE ------------------------------------------------
+	//
+	else if (type == "delete") {
+		str += '<wfs:Delete typeName="'+ myconf['featuretype_name']+'">';
+		for(var j=0; j<myconf['element'].length; j++){
+			if(myconf['element'][j]['f_geom'] == 1){
+				var el_geom = myconf['element'][j]['element_name'];	
+			}
+		}
+		str += '<ogc:Filter><ogc:FeatureId fid="'+fid+'"/></ogc:Filter>';
+		str += '</wfs:Delete>';
+	}
+	
+	str += '</wfs:Transaction>';
+	return str;
+}



More information about the Mapbender_commits mailing list