svn commit: r383 - trunk/mapbender/http/javascripts/mod_digitize_tab.php
christoph at osgeo.org
christoph at osgeo.org
Tue Jun 6 10:42:33 EDT 2006
Author: christoph
Date: 2006-06-06 14:42:33+0000
New Revision: 383
Modified:
trunk/mapbender/http/javascripts/mod_digitize_tab.php
Log:
fixed bug (namespaces). Save, update, delete works now.
Modified: trunk/mapbender/http/javascripts/mod_digitize_tab.php
Url: https://mapbender.osgeo.org/source/browse/mapbender/trunk/mapbender/http/javascripts/mod_digitize_tab.php?view=diff&rev=383&p1=trunk/mapbender/http/javascripts/mod_digitize_tab.php&p2=trunk/mapbender/http/javascripts/mod_digitize_tab.php&r1=382&r2=383
==============================================================================
--- trunk/mapbender/http/javascripts/mod_digitize_tab.php (original)
+++ trunk/mapbender/http/javascripts/mod_digitize_tab.php 2006-06-06 14:42:33+0000
@@ -713,16 +713,16 @@
var colspan = 0;
if (geom) {
- str += "\t\t\t<td><input type='button' name='saveButton' value='Save' onclick='window.opener.saveGeom("+selMember+")' /></td>\n";
+ str += "\t\t\t<td><input type='button' name='saveButton' value='Save' onclick=\"window.opener.dbGeom('save', "+selMember+")\" /></td>\n";
}
else colspan++;
if (parseInt(memberIndex) != -1 && gid) {
if (geom) {
- str += "\t\t\t<td><input type='button' name='updateButton' value='Update' onclick='window.opener.updateGeom("+selMember+")'/></td>\n";
+ str += "\t\t\t<td><input type='button' name='updateButton' value='Update' onclick=\"window.opener.dbGeom('update', "+selMember+")\"/></td>\n";
}
else colspan++;
- str += "\t\t\t<td><input type='button' name='deleteButton' value='Delete' onclick='window.opener.deleteGeom("+selMember+")'/></td>\n";
+ str += "\t\t\t<td><input type='button' name='deleteButton' value='Delete' onclick=\"window.opener.dbGeom('delete', "+selMember+")\"/></td>\n";
}
else colspan++;
@@ -783,246 +783,162 @@
dwin = window.open("../php/mod_wfs_save.php","dwin","width=300,height=200");
}
-function saveGeom(m){
- var myform = wfsWindow.document.forms[0];
- var ind = myform.wfs.selectedIndex;
- var wfs = myform.wfs.options[ind].value;
- myform = wfsWindow.document.forms[1];
- d.get(m).wfs_conf = wfs;
+function dbGeom(type,m) {
+ d.get(m).wfs_conf = wfsWindow.document.forms[0].wfs.options[wfsWindow.document.forms[0].wfs.selectedIndex].value;
d.get(m).e = new Wfs_element();
- var cnt = 0;
- for( var i=0; i<myform.length; i++){
- if(myform.elements[i].type == 'text'){
- d.get(m).e.setElement(myform.elements[i].name, myform.elements[i].value);
- }
- }
+
var myconf = wfs_conf[d.get(m).wfs_conf];
- document.sendForm.url.value = myconf['wfs_transaction'];
- var str = '<wfs:Transaction version="1.0.0" service="WFS" ';
-
- for (var q = 0 ; q < myconf['namespaces'].length ; q++) {
- //alert('xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ');
- str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
+ var mapObjInd = parent.getMapObjIndexByName(mod_digitize_target);
+
+ if (myconf['featuretype_srs'] != parent.mb_mapObj[mapObjInd].epsg) {
+ alert("fatal error: EPSG mismatch. "+ parent.mb_mapObj[mapObjInd].epsg + " / "+ myconf['featuretype_srs']);
}
+ else {
+ var myform = wfsWindow.document.forms[1];
- str += 'xsi:schemaLocation="http://www.someserver.com/myns http://wms1.ccgis.de/geoserver-1.3-beta4/wfs/getCapabilities?request=describefeaturetype&typename=mapbender_user http://www.opengis.net/wfs../wfs/1.0.0/WFS-transaction.xsd">';
- str += '<wfs:Insert>';
- str += '<'+ 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 + '>';
- str += d.get(m).e.getValue(i);
- str += '</' + 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'];
+ for (var i=0; i<myform.length; i++){
+ if(myform.elements[i].type == 'text'){
+ d.get(m).e.setElement(myform.elements[i].name, myform.elements[i].value);
+ }
}
- }
- str += '<' + el_geom + '>';
+ document.sendForm.url.value = myconf['wfs_transaction'];
+ var str = '<wfs:Transaction version="1.0.0" service="WFS" ';
-// if(dig.D[0].type == 'text'){
-// str += '<gml:Point srsName="epsg:4326">';
-// str += '<gml:coordinates>';
-// str += dig.D[0].x[0] + "," + dig.D[0].y[0];
-// str += '</gml:coordinates>';
-// str += '</gml:Point>';
-// }
-// if(dig.D[0].type == 'line'){
-// str += '<gml:MultiLineString srsName="epsg:4326">';
-// str += '<gml:lineStringMember>';
-// str += '<gml:LineString>';
-//
-// str += '<gml:coordinates>';
-// for(var k=0; k<dig.D[0].x.length; k++){
-// if(k>0){
-// str += " ";
-// }
-// str += dig.D[0].x[k] + "," + dig.D[0].y[k];
-// }
-// str += '</gml:coordinates>';
-// str += '</gml:LineString>';
-// str += '</gml:lineStringMember>';
-// str += '</gml:MultiLineString>';
-// }
- if(d.get(m).geomtype == geomTypePolygon){
- str += '<gml:MultiPolygon srsName="epsg:4326">';
- str += '<gml:polygonMember>';
- str += '<gml:Polygon>';
- str += '<gml:outerBoundaryIs>';
- str += '<gml:LinearRing>';
-
- str += '<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>';
- str += '</gml:LinearRing>';
- str += '</gml:outerBoundaryIs>';
- str += '</gml:Polygon>';
- str += '</gml:polygonMember>';
- str += '</gml:MultiPolygon>';
- }
- str += '</' + el_geom + '>';
- str += '</'+ myconf['featuretype_name']+'>';
- str += '</wfs:Insert>';
- str += '</wfs:Transaction>';
- document.sendForm.filter.value = str;
- document.sendForm.submit();
-// document.forms[1].filter.value = str;
-// document.forms[1].submit();
- return false;
-}
-function updateGeom(m){
- var myid_value;
- var myform = wfsWindow.document.forms[0];
- var ind = myform.wfs.selectedIndex;
- var wfs = myform.wfs.options[ind].value;
- myform = wfsWindow.document.forms[1];
- d.get(m).wfs_conf = wfs;
- d.get(m).e = new Wfs_element();
- var cnt = 0;
- for( var i=0; i<myform.length; i++){
- if(myform.elements[i].type == 'text'){
- d.get(m).e.setElement(myform.elements[i].name, myform.elements[i].value);
- if(d.get(m).e.getName(cnt) == 'gid'){
- myid_value = d.get(m).e.getValue(cnt);
+ str += 'xmlns="http://www.someserver.com/myns" ';
+// str += 'xmlns:gml="http://www.opengis.net/gml" ';
+ str += 'xmlns:ogc="http://www.opengis.net/ogc" ';
+ str += 'xmlns:wfs="http://www.opengis.net/wfs" ';
+ str += 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';
+// str += 'xmlns:topp="http://www.someserver.com/topp" ';
+
+
+ for (var q = 0 ; q < myconf['namespaces'].length ; q++) {
+ str += 'xmlns:' + myconf['namespaces'][q]['name'] + '="' + myconf['namespaces'][q]['location'] + '" ';
+ }
+ str += 'xsi:schemaLocation="http://www.someserver.com/myns http://wms1.ccgis.de/geoserver-1.3-beta4/wfs/getCapabilities?request=describefeaturetype&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 + '>';
+ }
}
- cnt++;
- }
- }
-// alert(wfs_conf[D[m]['wfs_conf']]['wfs_transaction']);
- var myconf = wfs_conf[d.get(m).wfs_conf];
- document.sendForm.url.value = myconf['wfs_transaction'];
- var str = '<wfs:Transaction version="1.0.0" service="WFS" xmlns="http://www.someserver.com/myns" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.someserver.com/myns http://wms1.ccgis.de/geoserver-1.3-beta4/wfs/getCapabilities?request=describefeaturetype&typename=mapbender_user http://www.opengis.net/wfs../wfs/1.0.0/WFS-transaction.xsd" xmlns:topp="http://www.someserver.com/topp">';
- 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 + '>';
-// if(dig.D[0].type == 'text'){
-// str += '<gml:Point srsName="epsg:4326">';
-// str += '<gml:coordinates>';
-// str += dig.D[0].x[0] + "," + dig.D[0].y[0];
-// str += '</gml:coordinates>';
-// str += '</gml:Point>';
-// }
-// if(dig.D[0].type == 'line'){
-// str += '<gml:MultiLineString srsName="epsg:4326">';
-// str += '<gml:lineStringMember>';
-// str += '<gml:LineString>';
-//
-// str += '<gml:coordinates>';
-// for(var k=0; k<dig.D[0].x.length; k++){
-// if(k>0){
-// str += " ";
-// }
-// str += dig.D[0].x[k] + "," + dig.D[0].y[k];
-// }
-// str += '</gml:coordinates>';
-// str += '</gml:LineString>';
-// str += '</gml:lineStringMember>';
-// str += '</gml:MultiLineString>';
-// }
- if(d.get(m).geomtype == geomTypePolygon){
- str += '<wfs:Property>';
- str += '<wfs:Name>' + el_geom + '</wfs:Name>';
- str += '<wfs:Value>';
- str += '<gml:MultiPolygon srsName="epsg:4326">';
- str += '<gml:polygonMember>';
- str += '<gml:Polygon>';
- str += '<gml:outerBoundaryIs>';
- str += '<gml:LinearRing>';
- str += '<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>';
- str += '</gml:LinearRing>';
- str += '</gml:outerBoundaryIs>';
- str += '</gml:Polygon>';
- str += '</gml:polygonMember>';
- str += '</gml:MultiPolygon>';
- str += '</wfs:Value>';
- str += '</wfs:Property>';
- }
-// str += '</' + el_geom + '>';
- str += '<ogc:Filter>';
- str += '<ogc:PropertyIsEqualTo>';
- str += '<ogc:PropertyName>gid</ogc:PropertyName>';
- str += '<ogc:Literal>'+myid_value+'</ogc:Literal>';
- str += '</ogc:PropertyIsEqualTo>';
- str += '</ogc:Filter>';
- str += '</wfs:Update>';
- str += '</wfs:Transaction>';
- document.sendForm.filter.value = str;
- document.sendForm.submit();
- //document.forms[1].filter.value = str;
- //prompt("",str);
- //document.forms[1].submit();
- return false;
-}
-function deleteGeom(m){
- var myid_value;
- var myform = wfsWindow.document.forms[0];
- var ind = myform.wfs.selectedIndex;
- var wfs = myform.wfs.options[ind].value;
- myform = wfsWindow.document.forms[1];
- d.get(m).wfs_conf = wfs;
- d.get(m).e = new Wfs_element();
- var cnt = 0;
- for( var i=0; i<myform.length; i++){
- if(myform.elements[i].type == 'text'){
- d.get(m).e.setElement(myform.elements[i].name, myform.elements[i].value);
- if(d.get(m).e.getName(cnt) == 'gid'){
- myid_value = d.get(m).e.getValue(cnt);
+ for(var j=0; j<myconf['element'].length; j++){
+ if(myconf['element'][j]['f_geom'] == 1){
+ var el_geom = myconf['element'][j]['element_name'];
+ }
}
- cnt++;
- }
- }
-// alert(wfs_conf[D[m]['wfs_conf']]['wfs_transaction']);
- var myconf = wfs_conf[d.get(m).wfs_conf];
- document.sendForm.url.value = myconf['wfs_transaction'];
- var str = '<wfs:Transaction version="1.0.0" service="WFS" xmlns="http://www.someserver.com/myns" xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc" xmlns:wfs="http://www.opengis.net/wfs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.someserver.com/myns http://wms1.ccgis.de/geoserver-1.3-beta4/wfs/getCapabilities?request=describefeaturetype&typename=mapbender_user http://www.opengis.net/wfs../wfs/1.0.0/WFS-transaction.xsd" xmlns:topp="http://www.someserver.com/topp">';
- 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 += '<' + 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 + '>';
+ if(d.get(m).geomtype == geomTypePolygon){
+ 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 += '<wfs:Property><wfs:Name>' + el_geom + '</wfs:Name><wfs:Value>';
+ 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:PropertyIsEqualTo>';
+ str += '<ogc:PropertyName>gid</ogc:PropertyName>';
+ str += '<ogc:Literal>'+d.get(m).e.getElementValueByName('gid')+'</ogc:Literal>';
+ str += '</ogc:PropertyIsEqualTo></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:PropertyIsEqualTo>';
+ str += '<ogc:PropertyName>gid</ogc:PropertyName>';
+ str += '<ogc:Literal>'+d.get(m).e.getElementValueByName('gid')+'</ogc:Literal>';
+ str += '</ogc:PropertyIsEqualTo></ogc:Filter>';
+ str += '</wfs:Delete>';
+ }
+
+ str += '</wfs:Transaction>';
+ document.sendForm.filter.value = str;
+ document.sendForm.submit();
}
- str += '<ogc:Filter>';
- str += '<ogc:PropertyIsEqualTo>';
- str += '<ogc:PropertyName>gid</ogc:PropertyName>';
- str += '<ogc:Literal>'+myid_value+'</ogc:Literal>';
- str += '</ogc:PropertyIsEqualTo>';
- str += '</ogc:Filter>';
- str += '</wfs:Delete>';
- str += '</wfs:Transaction>';
- document.sendForm.filter.value = str;
- document.sendForm.submit();
- //document.forms[1].filter.value = str;
- //prompt("",str);
- //document.forms[1].submit();
- return false;
}
+
</script>
</head>
<body onload="registerFunctions();displayButtons();">
More information about the Mapbender_commits
mailing list