[Mapbender-commits] r7181 - trunk/mapbender/http/javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Dec 2 10:54:14 EST 2010
Author: verenadiewald
Date: 2010-12-02 07:54:14 -0800 (Thu, 02 Dec 2010)
New Revision: 7181
Modified:
trunk/mapbender/http/javascripts/geometry.js
Log:
new function getDist and getAggregatedDist for measuring in digitize
Modified: trunk/mapbender/http/javascripts/geometry.js
===================================================================
--- trunk/mapbender/http/javascripts/geometry.js 2010-12-02 15:46:06 UTC (rev 7180)
+++ trunk/mapbender/http/javascripts/geometry.js 2010-12-02 15:54:14 UTC (rev 7181)
@@ -1090,7 +1090,7 @@
this.addPointByCoordinates = function(x,y,z){
var newPoint = new Point(x,y,z);
this.add(newPoint);
-// updateDist();
+ updateDist();
};
/**
@@ -1143,17 +1143,34 @@
* @private
*/
var updateDist = function(){
-/*
- * DISABLED BECAUSE IT IS TOO SLOW
dist[0] = 0;
totaldist[0] = 0;
for (var i = 1 ; i < that.count(); i++){
dist[i] = that.get(i-1).dist(that.get(i));
totaldist[i] = totaldist[i-1] + dist[i];
}
-*/
};
/**
+ * gets the distance between two points i and i+1
+ *
+ * @param {Integer} i index
+ * @param {Integer} numberOfDigits round to numberOfDigits (optional)
+ * @return the distance
+ * @type Float
+ */
+ this.getDist = function(i, numberOfDigits) {
+ var indexA = this.getIndex(i);
+ var indexB = this.getIndex(i+1);
+ if (indexA === false || indexB === false) {
+ return 0;
+ }
+ if (typeof(numberOfDigits) == "number") {
+ return roundToDigits(dist[indexB], numberOfDigits);
+ }
+ return dist[indexB];
+
+ };
+ /**
* gets the distance between the last and last but one point of this {@link Geometry}.
*
* @param {Integer} numberOfDigitis round to numberOfDigits (optional)
@@ -1168,6 +1185,26 @@
};
/**
+ * gets the total distance between two points i and i+1
+ *
+ * @param {Integer} i index
+ * @param {Integer} numberOfDigits round to numberOfDigits (optional)
+ * @return the distance
+ * @type Float
+ */
+ this.getAggregatedDist = function(i, numberOfDigits) {
+ var indexA = this.getIndex(i);
+ var indexB = this.getIndex(i+1);
+ if (indexA === false || indexB === false) {
+ return 0;
+ }
+ if (typeof(numberOfDigits) == "number") {
+ return roundToDigits(totaldist[indexB], numberOfDigits);
+ }
+ return totaldist[indexB];
+
+ };
+ /**
* gets the length of the outer rim of this {@link Geometry}.
*
* @param {Integer} numberOfDigitis round to numberOfDigits (optional)
More information about the Mapbender_commits
mailing list