[Mapbender-commits] r4787 - in branches/2.6: conf http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Oct 19 09:00:48 EDT 2009


Author: christoph
Date: 2009-10-19 09:00:47 -0400 (Mon, 19 Oct 2009)
New Revision: 4787

Modified:
   branches/2.6/conf/digitize_default.conf
   branches/2.6/http/javascripts/geometry.js
   branches/2.6/http/javascripts/mod_digitize_tab.php
Log:
http://trac.osgeo.org/mapbender/ticket/546

Modified: branches/2.6/conf/digitize_default.conf
===================================================================
--- branches/2.6/conf/digitize_default.conf	2009-10-19 12:49:17 UTC (rev 4786)
+++ branches/2.6/conf/digitize_default.conf	2009-10-19 13:00:47 UTC (rev 4787)
@@ -61,4 +61,6 @@
 var wfsWindowHeight = 300;
 
 // deprecated! check wfs_default.conf to configure this behaviour
-//var spatialRequestResultToDigitize = 1;
\ No newline at end of file
+//var spatialRequestResultToDigitize = 1;
+
+var featuresMustHaveUniqueId = true;
\ No newline at end of file

Modified: branches/2.6/http/javascripts/geometry.js
===================================================================
--- branches/2.6/http/javascripts/geometry.js	2009-10-19 12:49:17 UTC (rev 4786)
+++ branches/2.6/http/javascripts/geometry.js	2009-10-19 13:00:47 UTC (rev 4787)
@@ -109,13 +109,36 @@
 	return this.get(i).get(j).innerRings.get(k).get(l);
 };
 
+GeometryArray.prototype.clone = function () {
+	var geomArray = new GeometryArray();
+	return geomArray.union(this, false);
+};
+
 /**
  * appends a geometry array to an existing geometryArray
  *
  * @param {GeometryArray} geom GeometryArray
  */
-GeometryArray.prototype.union = function(geom){
+GeometryArray.prototype.union = function(geom, uniqueFid){
 	var oldLen = this.count();
+	//
+	// only add geometries that are not already present
+	//
+	if (typeof uniqueFid === "boolean" && uniqueFid) {
+		var geom = geom.clone();
+		for (var i = 0; i < this.count(); i++) {
+			var existingFid = this.get(i).e.getElementValueByName("fid");
+			var len = geom.count() - 1;
+			for (var j = len; j >= 0; j--) {
+				var fid = geom.get(j).e.getElementValueByName("fid");
+				if (fid && fid === existingFid) {
+					geom.del(j);
+					continue;
+				}
+			}
+		}
+	}
+
 	this.importGeoJSON(geom.toString());
 	var j = 0;
 	for (var i = oldLen; i < this.count(); i++) {

Modified: branches/2.6/http/javascripts/mod_digitize_tab.php
===================================================================
--- branches/2.6/http/javascripts/mod_digitize_tab.php	2009-10-19 12:49:17 UTC (rev 4786)
+++ branches/2.6/http/javascripts/mod_digitize_tab.php	2009-10-19 13:00:47 UTC (rev 4787)
@@ -35,7 +35,7 @@
 $digitize_conf_filename = "digitize_default.conf";
 include '../include/dyn_css.php';
 ?>
-<script language='JavaScript'>
+<script type='text/javascript'>
 //
 // Buttons
 //
@@ -131,6 +131,10 @@
 try {if(nonTransactionalEditable){}}catch(e) {nonTransactionalEditable = false;}
 try {if(addCloneGeometryButton){}}catch(e) {addCloneGeometryButton = false;}
 
+if (typeof featuresMustHaveUniqueId === "undefined") {
+	var featuresMustHaveUniqueId = false;
+}
+
 function getMousePosition(e) {
 	var ind = parent.getMapObjIndexByName("<?php  echo $e_target;  ?>");
 	currentPos = parent.mb_mapObj[ind].getMousePosition(e);
@@ -170,7 +174,7 @@
 
 function appendGeometryArray(obj) {
 	executeDigitizePreFunctions();
-	d.union(obj);
+	d.union(obj, featuresMustHaveUniqueId);
 	executeDigitizeSubFunctions();
 }
 
@@ -1533,7 +1537,8 @@
 	wfsWindow = open("", "wfsattributes", "width="+wfsWindowWidth+", height="+wfsWindowHeight+", resizable, dependent=yes, scrollbars=yes");
 	wfsWindow.document.open("text/html");
 	wfsWindow.focus();
-	
+	wfsWindow.focus();
+
 	var str = "";
 	var strStyle = "";
 	var defaultIndex = -1;



More information about the Mapbender_commits mailing list