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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Fri Oct 30 07:31:46 EDT 2009


Author: christoph
Date: 2009-10-30 07:31:46 -0400 (Fri, 30 Oct 2009)
New Revision: 4885

Modified:
   trunk/mapbender/http/javascripts/geometry.js
Log:


Modified: trunk/mapbender/http/javascripts/geometry.js
===================================================================
--- trunk/mapbender/http/javascripts/geometry.js	2009-10-30 11:29:30 UTC (rev 4884)
+++ trunk/mapbender/http/javascripts/geometry.js	2009-10-30 11:31:46 UTC (rev 4885)
@@ -962,9 +962,15 @@
 			this.list.length -= 1;
 		
 			if (this.geomType == geomType.polygon){
-				if (i == tmpLength) {this.list[0] = this.list[tmpLength-1];}
-				else if (i === 0) {this.list[tmpLength-1] = this.list[0];}
-				if (this.list.length == 1){return false;}
+				if (i == tmpLength && this.complete) {
+					this.list[0] = this.list[tmpLength-1];
+				}
+				else if (i === 0) {
+					this.list[tmpLength-1] = this.list[0];
+				}
+				if (this.list.length == 1){
+					return false;
+				}
 			}
 			updateDist();
 			if(this.list.length === 0) {return false;}
@@ -1093,6 +1099,18 @@
 		}
 		return true;
 	};
+	
+	this.reopen = function () {
+		if (!complete) {
+			return false;
+		}
+		complete = false;
+		if (this.geomType == geomType.polygon){
+			this.del(-1);
+		}
+		return true;
+	};
+	
 	/**
 	 * checks if this {@link Geometry} has been closed. 
 	 *
@@ -1994,16 +2012,24 @@
 		return highlight.clean();
 	};
 	this.addPoint = function(aPoint) {
-		coord.push(aPoint);
+		coord.add(aPoint);
 	};
+	this.removePoint = function (aPoint) {
+		var len = coord.count() - 1;
+		for (var i = len; i >= 0; i--) {
+			if (coord.get(i).equals(aPoint)) {
+				coord.del(i);
+			}
+		}
+	};
 	this.getPointCount = function() {
-		return coord.length;
+		return coord.count();
 	};
 	this.getPoint = function(i) {
-		return coord[i];
+		return coord.get(i);
 	};
 	this.resetPoints = function() {
-		coord = [];
+		coord.empty();
 	};
 	this.getNearestNeighbour = function(){
 		if (min_i != -1) {return this.getPoint(min_i);}
@@ -2016,6 +2042,10 @@
 		min_i = -1;
 	};
 	
+	this.toString = function () {
+		return coord.list.join(",");
+	};
+	
 	/**
 	 * @private
 	 */
@@ -2029,7 +2059,8 @@
 	/**
 	 * @private
 	 */
-	var coord = []; 
+	var coord = new List(); 
+	coord.list = [];
 
 	/**
 	 * @private
@@ -2064,6 +2095,9 @@
 
 Snapping.prototype.check = function(currPoint){
 	var minDist = false;
+	if (this.getPointCount() === 0) {
+		return;
+	}
 	
 	for (var i = 0 ; i < this.getPointCount() ; i++) {
 



More information about the Mapbender_commits mailing list