[Mapbender-commits] r4786 - in trunk/mapbender: conf http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Oct 19 08:49:17 EDT 2009


Author: christoph
Date: 2009-10-19 08:49:17 -0400 (Mon, 19 Oct 2009)
New Revision: 4786

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

Modified: trunk/mapbender/conf/digitize_default.conf
===================================================================
--- trunk/mapbender/conf/digitize_default.conf	2009-10-19 12:46:29 UTC (rev 4785)
+++ trunk/mapbender/conf/digitize_default.conf	2009-10-19 12:49:17 UTC (rev 4786)
@@ -67,3 +67,5 @@
 
 // deprecated! check wfs_default.conf to configure this behaviour
 //var spatialRequestResultToDigitize = 1;
+
+var featuresMustHaveUniqueId = true;

Modified: trunk/mapbender/http/javascripts/geometry.js
===================================================================
--- trunk/mapbender/http/javascripts/geometry.js	2009-10-19 12:46:29 UTC (rev 4785)
+++ trunk/mapbender/http/javascripts/geometry.js	2009-10-19 12:49:17 UTC (rev 4786)
@@ -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: trunk/mapbender/http/javascripts/mod_digitize_tab.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_digitize_tab.php	2009-10-19 12:46:29 UTC (rev 4785)
+++ trunk/mapbender/http/javascripts/mod_digitize_tab.php	2009-10-19 12:49:17 UTC (rev 4786)
@@ -133,6 +133,10 @@
 try {if(updatePointGeometriesInstantly){}}catch(e) {updatePointGeometriesInstantly = false;}
 try {if(addCloneGeometryButton){}}catch(e) {addCloneGeometryButton = false;}
 
+if (typeof featuresMustHaveUniqueId === "undefined") {
+	var featuresMustHaveUniqueId = false;
+}
+
 function toggleTabs(tabId) {
 	if(!initialTab) {
 		return;
@@ -225,7 +229,7 @@
 
 function appendGeometryArray(obj) {
 	executeDigitizePreFunctions();
-	d.union(obj);
+	d.union(obj, featuresMustHaveUniqueId);
 	executeDigitizeSubFunctions();
 }
 



More information about the Mapbender_commits mailing list