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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Dec 2 10:46:06 EST 2010


Author: verenadiewald
Date: 2010-12-02 07:46:06 -0800 (Thu, 02 Dec 2010)
New Revision: 7180

Modified:
   trunk/mapbender/conf/digitize_default.conf
   trunk/mapbender/http/css/digitize.css
   trunk/mapbender/http/javascripts/mod_digitize_tab.php
Log:
optional distance measuring for digitizing lines or polygons

Modified: trunk/mapbender/conf/digitize_default.conf
===================================================================
--- trunk/mapbender/conf/digitize_default.conf	2010-12-02 12:53:44 UTC (rev 7179)
+++ trunk/mapbender/conf/digitize_default.conf	2010-12-02 15:46:06 UTC (rev 7180)
@@ -55,6 +55,8 @@
 }; 
 var measureNumberOfDigits = 3;
 
+var measureDistances = true;
+
 var showSaveButtonForExistingGeometries = false;
 
 var updatePointGeometriesInstantly = true;

Modified: trunk/mapbender/http/css/digitize.css
===================================================================
--- trunk/mapbender/http/css/digitize.css	2010-12-02 12:53:44 UTC (rev 7179)
+++ trunk/mapbender/http/css/digitize.css	2010-12-02 15:46:06 UTC (rev 7180)
@@ -18,4 +18,9 @@
 	width: 5px;
 	height: 5px;
 	background-color: #F00;
-}
\ No newline at end of file
+}
+
+.measure {
+	font-size: 8px;
+  	font-family: "Verdana","Arial","Tahoma",sans-serif;
+}

Modified: trunk/mapbender/http/javascripts/mod_digitize_tab.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_digitize_tab.php	2010-12-02 12:53:44 UTC (rev 7179)
+++ trunk/mapbender/http/javascripts/mod_digitize_tab.php	2010-12-02 15:46:06 UTC (rev 7180)
@@ -1643,28 +1643,50 @@
 
 				for(var k = 0, lenPoint = currentGeometry.count(); k < lenPoint; k++){
 					var currentPoint = currentGeometry.get(k);
+					var totalDistMeasureTag = "";
 					var currentPointMap = new Point(Math.round((currentPoint.x - minX)*cx), Math.round((maxY - currentPoint.y)*cy));
-					
 //					var isTooCloseToPrevious = lastPaintedPoint && (k > 0) && Math.abs(currentPointMap.x-lastPaintedPoint.x) <= minDist && Math.abs(currentPointMap.y-lastPaintedPoint.y) <= minDist;
 //					if (!isTooCloseToPrevious) {
 						var currentPointIsVisible = currentPointMap.x > 0 && currentPointMap.x < width && currentPointMap.y > 0 && currentPointMap.y < height;
 						if (currentPointIsVisible) {
 							if (!isComplete && ((k == 0 && isPolygon) || (k == lenPoint-1 && isLine))) {
-								smPArray[smPArray.length] = "<div class='bp' style='top:"+
+								smPArray[smPArray.length] = "<div class='bp test1' style='top:"+
 									(currentPointMap.y-2)+"px;left:"+(currentPointMap.x-2)+"px;z-index:"+
 									parseInt(digitizeTransactionalZIndex+10, 10)+";background-color:"+linepointColor+"'";
+								if(measureDistances) {
+									if(isLine && k != 0) {
+										totalDistMeasureTag = "<p class='measure'>"+currentGeometry.getAggregatedDist(k-1, 2)+"</p>";
+									}
+								}	
+								
 							}
 							else {
-								smPArray[smPArray.length] = "<div class='bp' style='top:"+(currentPointMap.y-2)+"px;left:"+(currentPointMap.x-2)+"px;z-index:"+parseInt(digitizeTransactionalZIndex+10, 10)+";'";
+								smPArray[smPArray.length] = "<div class='bp test2' style='top:"+(currentPointMap.y-2)+"px;left:"+(currentPointMap.x-2)+"px;z-index:"+parseInt(digitizeTransactionalZIndex+10, 10)+";'";
+								if(measureDistances) {
+									if(isLine && k == 0) {
+										//nothing
+										totalDistMeasureTag = "";
+									}
+									else {
+										totalDistMeasureTag = "<p class='measure'>"+currentGeometry.getAggregatedDist(k-1, 2)+"</p>";
+									}
+								}
+								
 							}
 							if(k==0 && isPolygon && !isComplete){
 								smPArray[smPArray.length] = " title='"+msgObj.closePolygon_title+"' ";
+								
 							}
 							if(isMoveOrInsertOrDelete) {
 								smPArray[smPArray.length] = " onmouseover='window.frames[\""+mod_digitize_elName+"\"].handleBasepoint(this,"+i+","+j+","+k+")' ;";
 							}
-							smPArray[smPArray.length] = "></div>";
+							smPArray[smPArray.length] = ">";
+							if (isPolygon || isLine) {
+								smPArray[smPArray.length] = totalDistMeasureTag;
+							}	
+							smPArray[smPArray.length] = "</div>";
 							lastPaintedPoint = currentPointMap;
+							
 						}
 						if (k > 0) {
 							points = parent.calculateVisibleDash(currentPointMap, previousPointMap, width, height);
@@ -1749,6 +1771,8 @@
 	if (n > 0) {
 		var step = delta.dividedBy(n);
 	}
+	var lineCenter = Math.round(n/2);
+	
 	for(var i=1; i < n; i++){
 		var x = Math.round(start.x + i * step.x) - 2;
 		var y = Math.round(start.y + i * step.y) - 2;
@@ -1762,7 +1786,13 @@
 			if(mod_digitizeEvent == button_insert) {
 				strArray[strArray.length] = "onmouseover='window.frames[\""+mod_digitize_elName+"\"].convertLinepointToBasepoint(this,"+memberIndex+","+geomIndex+","+ringIndex+","+pointIndex+")'";
 			}
-			strArray[strArray.length] = "></div>";
+			strArray[strArray.length] = ">";
+			if(measureDistances) {
+				if(i == lineCenter) {
+					strArray[strArray.length] = "<p class='measure'>"+d.getGeometry(memberIndex, geomIndex).getDist(pointIndex-1, 2)+"</p>";
+				}
+			}
+			strArray[strArray.length] = "</div>";
 		}
 	}
 	return strArray.join("");



More information about the Mapbender_commits mailing list