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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Feb 22 11:57:20 EST 2007


Author: christoph
Date: 2007-02-22 11:57:20 -0500 (Thu, 22 Feb 2007)
New Revision: 1133

Modified:
   trunk/mapbender/http/javascripts/mod_digitize_tab.php
Log:
geometry remains editable after zoom
digitize tag use class DivTag

Modified: trunk/mapbender/http/javascripts/mod_digitize_tab.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_digitize_tab.php	2007-02-22 16:55:53 UTC (rev 1132)
+++ trunk/mapbender/http/javascripts/mod_digitize_tab.php	2007-02-22 16:57:20 UTC (rev 1133)
@@ -79,6 +79,8 @@
 var button_clear = "clear";
 var button_combine = "combine";
 
+var digitizeDivTag;
+
 var featureTypeElementFormId = "featureTypeElementForm";
 
 try {if(mod_digitize_elName){}}catch(e) {mod_digitize_elName = "digitize";}
@@ -89,7 +91,7 @@
 function appendGeometryArray(obj) {
 	executeDigitizePreFunctions();
 	for (i=0; i<obj.count(); i++) {
-		d.appendMember(obj.get(i));
+		d.addCopy(obj.get(i));
 	}
 	executeDigitizeSubFunctions();
 }
@@ -97,8 +99,6 @@
 function mod_digitize_go(e){
 	parent.mb_registerGML(mod_digitize_target,d);   
 
-	//executeDigitizePreFunctions();
-	
 	// ie workaround
 	if (e == undefined) {
 		e = parent.frames[mod_digitize_target].event;
@@ -110,7 +110,7 @@
 		s.check(currentPos);
 	}
 	else {
-		s.clean();
+//		s.clean();
 	}
 
 	var el = parent.frames[mod_digitize_target].document;
@@ -118,7 +118,6 @@
 }
 
 function mod_digitize_timeout(){
-	//parent.document.getElementById(mod_digitize_elName).style.visibility = 'hidden';
 	var el = parent.frames[mod_digitize_target].document;
 	el.onmousedown = null;
 	el.onmouseup = null;
@@ -127,7 +126,7 @@
 
 function mod_digitize_start(e){
 	// check if a proper geometry is selected	
-	if (d.getGeometry(-1,-1).complete || d.count() == 0){
+	if (d.getGeometry(-1,-1).isComplete() || d.count() == 0){
 		
 		if (mod_digitizeEvent != false) {
 			alert(errorMessageNoGeometrySelected[selectedLanguage]);
@@ -148,23 +147,29 @@
 	if (d.get(-1).geomType == parent.geomType.polygon && d.getGeometry(-1,-1).count() > 1 && d.getGeometry(-1,-1).get(0).equals(realWorldPos)) {
 				
 		// close the polygon
+		d.close();
 		parent.mb_disableThisButton(button_polygon);
+		return true;
 	}
 	else if (d.get(-1).geomType == parent.geomType.line && d.getGeometry(-1,-1).count() > 1 && d.getGeometry(-1,-1).get(-1).equals(realWorldPos)) {
 		// close the line
+		d.close();
 		parent.mb_disableThisButton(button_line);
+		return true;
 	}
 	else {
 		// set the calculated real world position as point of the geometry
 		d.getGeometry(-1,-1).addPoint(realWorldPos);
 		
 		if(d.get(-1).geomType == parent.geomType.point){
+			d.close();
 			parent.mb_disableThisButton(button_point);
+			return true;
 		}
 		
 		// add first point of polygon to snapping list (if three points have been inserted).
 		else if (d.get(-1).geomType == parent.geomType.polygon && d.getGeometry(-1,-1).count() == 3) {
-			s.add(d, 0, -1, -1);
+			s.add(d.getPoint(-1, -1, 0));
 		}
 
 		// add last point of line to snapping list (if at least two points have been inserted).
@@ -172,7 +177,7 @@
 			if (mod_digitizeEvent != button_move) {
 				s.store(d);
 			}
-			s.add(d, -1, -1, -1);
+			s.add(d.getPoint(-1, -1, -1));
 		}
 	}
 	executeDigitizeSubFunctions();
@@ -252,17 +257,6 @@
 	if(!basepointDragActive && mod_digitizeEvent == button_move){
 		basepointDragActive = true;
 		s.store(d, d.getPoint(basepointMemberIndex, basepointGeometryIndex, basepointPointIndex));
-		basepointObject.onmouseup = releaseBasepoint;
-		basepointObject.onmousemove = dragBasepoint;
-	}
-}
-
-function dragBasepoint(e){
-	if(basepointDragActive){
-		parent.mb_getMousePos(e, mod_digitize_target);
-		var currentPos = new parent.Point(parent.clickX, parent.clickY);
-		var res = s.check(currentPos);
-
 		// replace basepoint by transparent blob
 		basepointObject.style.width = mod_digitize_width;
 		basepointObject.style.height = mod_digitize_height;
@@ -276,8 +270,20 @@
 		else{
 			basepointObject.style.backgroundColor = 'transparent';
 		}
+
+		basepointObject.onmouseup = releaseBasepoint;
+		basepointObject.onmousemove = dragBasepoint;
 	}
 }
+
+function dragBasepoint(e){
+	if(basepointDragActive){
+		parent.mb_getMousePos(e, mod_digitize_target);
+		var currentPos = new parent.Point(parent.clickX, parent.clickY);
+		var res = s.check(currentPos);
+
+	}
+}
 	
 function updateAllPointsOfNonTransactionalLike(oldP, newP){ 
 	for (var i = 0; i < d.count(); i++) {
@@ -369,22 +375,20 @@
 	parent.mb_registerInitFunctions("window.frames['"+ mod_digitize_elName + "'].initialiseMeasure()");
 	parent.mb_registerSubFunctions("window.frames['" + mod_digitize_elName + "'].updateExtent()");
 	parent.mb_registerSubFunctions("window.frames['"+ mod_digitize_elName + "'].drawDashedLine()");
+	parent.mb_registerSubFunctions("window.frames['"+ mod_digitize_elName + "'].updateMeasureTag()");
 	parent.mb_registerWfsReadSubFunctions(function(geom){parent.tab_open(mod_digitize_elName);parent.window.frames[mod_digitize_elName].appendGeometryArray(geom);});
 	parent.mb_registerWfsWriteSubFunctions(function(){parent.zoom(mod_digitize_target, true, 0.999);});
 }
 
 function checkDigitizeTag(){
-	var attributes = [];
-	attributes[0] = [];
-	attributes[0][0] = "style";
-	attributes[0][1] = "position:absolute; top:0px; left:0px; z-index:"+digitizeTransactionalZIndex+"; font-size:10px"; 
-	node = parent.mb_checkTag(mod_digitize_target, "div", "digitize", "body", attributes);
-	if (!node) {
-		alert("Fatal error: Element id 'digitize' is already taken!");
-	}
-	parent.mb_registerPanSubElement("digitize");
+	var digitizeTagName = "digitize";
+	var digitizeTagStyle = {"position":"absolute", "top":"0px", "left":"0px", "z-index":digitizeTransactionalZIndex, "font-size":"10px"};
+	 
+	digitizeDivTag = new parent.DivTag(digitizeTagName, mod_digitize_target, digitizeTagStyle);
+	parent.mb_registerPanSubElement(digitizeTagName);
 }
 
+
 function setStyleForTargetFrame(){
 	var cssLink = parent.window.frames[mod_digitize_target].document.createElement("link");
 	cssLink.setAttribute("href", cssUrl); 
@@ -398,7 +402,7 @@
 	s = new parent.Snapping(mod_digitize_target, snappingTolerance, snappingColor, snappingHighlightZIndex);
 }
 function initialiseHighlight(){
-	nonTransactionalHighlight = new parent.Highlight(new Array(mod_digitize_target), "nonTransactional", "position:absolute; top:0px; left:0px; z-index:"+digitizeNonTransactionalZIndex, nonTransactionalLineWidth);
+	nonTransactionalHighlight = new parent.Highlight(new Array(mod_digitize_target), "nonTransactional", {"position":"absolute", "top":"0px", "left":"0px", "z-index":digitizeNonTransactionalZIndex}, nonTransactionalLineWidth);
 }
 function initialiseMeasure(){
 	measureDivTag = new parent.DivTag(measureTagName, measureTagTarget, measureTagStyle);
@@ -411,13 +415,17 @@
 	if (d.count() > 0 ) {
 		if (d.get(-1).count() > 0) {
 			if (d.getGeometry(-1, -1).count() > 0) {
-				measureDivTag.write(measureTagLabelCurrent[selectedLanguage] + d.getGeometry(-1, -1).getCurrentDist(measureNumberOfDigits) + "<br>" +measureTagLabelTotal[selectedLanguage] + d.getGeometry(-1, -1).getTotalDist(measureNumberOfDigits));
+				if (mod_digitizeEvent == button_line || mod_digitizeEvent == button_polygon) {
+					var measureString = "";
+					measureString += measureTagLabelCurrent[selectedLanguage] + d.getGeometry(-1, -1).getCurrentDist(measureNumberOfDigits) + "<br>";
+					measureString += measureTagLabelTotal[selectedLanguage] + d.getGeometry(-1, -1).getTotalDist(measureNumberOfDigits);
+					measureDivTag.write(measureString);
+					return true;
+				}
 			}
-			else {
-				measureDivTag.clean();
-			}
 		}
 	}
+	measureDivTag.clean();
 }
 
 
@@ -464,19 +472,64 @@
 		el.onmousemove = mod_digitize_go;
 
 		mod_digitizeEvent = obj.id;
+
+		if (mod_digitizeEvent == button_point || mod_digitizeEvent == button_line || mod_digitizeEvent == button_polygon || mod_digitizeEvent == button_insert ) {
+			s.store(d);
+		}
+
 		executeDigitizePreFunctions();
 		obj.title = obj.title_on;
 		if (obj.id == button_point) {
-			d.addMember(parent.geomType.point);
-			d.get(-1).addGeometry();
+			if (d.count() == 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
+				d.addMember(parent.geomType.point);
+				d.get(-1).addGeometry();
+			}
+			else {
+				d.del(-1);
+				d.addMember(parent.geomType.point);
+				d.get(-1).addGeometry();
+			}
 		}
 		else if (obj.id == button_polygon) {
-			d.addMember(parent.geomType.polygon);
-			d.get(-1).addGeometry();
+			if (d.count() == 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
+				// new geometry
+				d.addMember(parent.geomType.polygon);
+				d.get(-1).addGeometry();
+			}
+			else {
+				if (d.get(-1).geomType != parent.geomType.polygon) {
+					var geometryTemplate = parent.cloneObject(d.get(-1));
+					d.del(-1);
+					d.addMember(parent.geomType.polygon);
+					for (var i = 0; i < geometryTemplate.count(); i++) {
+						d.get(-1).addGeometry();
+						for (var j = 0; j < geometryTemplate.get(i).count(); j++) {
+							d.get(-1).get(-1).addPoint(geometryTemplate.get(i).get(j));
+						}
+					}
+				}
+				s.add(d.getPoint(-1, -1, 0));
+			}
 		}
 		else if (obj.id == button_line) {
-			d.addMember(parent.geomType.line);
-			d.get(-1).addGeometry();
+			if (d.count() == 0 || (d.count() > 0 && d.get(-1).count() > 0 && d.get(-1).get(-1).isComplete())) {
+				d.addMember(parent.geomType.line);
+				d.get(-1).addGeometry();
+			}
+			else {
+				if (d.get(-1).geomType != parent.geomType.line) {
+					var geometryTemplate = parent.cloneObject(d.get(-1));
+					d.del(-1);
+					d.addMember(parent.geomType.line);
+					for (var i = 0; i < geometryTemplate.count(); i++) {
+						d.get(-1).addGeometry();
+						for (var j = 0; j < geometryTemplate.get(i).count(); j++) {
+							d.get(-1).get(-1).addPoint(geometryTemplate.get(i).get(j));
+						}
+					}
+				}
+				s.add(d.getPoint(-1, -1, 0));
+			}
 		}
 		else if (obj.id == button_clear) {
 			var clear = confirm(messageConfirmDeleteAllGeomFromList[selectedLanguage]);
@@ -493,22 +546,23 @@
 //			});
 			parent.mb_disableThisButton(button_combine);
 		}
-		if (mod_digitizeEvent == button_point || mod_digitizeEvent == button_line || mod_digitizeEvent == button_polygon || mod_digitizeEvent == button_insert ) {s.store(d);}
 	}
 }
 
 function digitizeDisable(obj) {
 	if (obj.id == button_point || obj.id == button_line || obj.id == button_polygon){
 		obj.title = obj.title_off;
-		d.close();
+		if (d.get(-1).get(-1).count() == 0) {
+			d.delGeometry(-1,-1);
+		}
 		mod_digitize_timeout();
 		executeDigitizeSubFunctions();
 	}
 	else if (obj.id == button_clear) {
 		mod_digitize_timeout();
 		executeDigitizeSubFunctions();
-		var el = parent.frames[mod_digitize_target].document;
 	}
+	mod_digitizeEvent = false;
 }
 // --- button handling (end) ----------------------------------------------------------------------------------------------
 // ------------------------------------------------------------------------------------------------------------------------
@@ -518,9 +572,22 @@
 
 function updateExtent() {
 	var anInd = parent.getMapObjIndexByName(mod_digitize_target);
-	mod_digitize_width = parent.mb_mapObj[anInd].width;
-	mod_digitize_height = parent.mb_mapObj[anInd].height;
-	mod_digitize_epsg = parent.mb_mapObj[anInd].epsg;
+	var change = false;
+	if (typeof(mod_digitize_width) == 'undefined' || mod_digitize_width != parent.mb_mapObj[anInd].width) {
+		mod_digitize_width = parent.mb_mapObj[anInd].width;
+		change = true;
+	}
+	if (typeof(mod_digitize_height) == 'undefined' || mod_digitize_height != parent.mb_mapObj[anInd].height) {
+		mod_digitize_height = parent.mb_mapObj[anInd].height;
+		change = true;
+	}
+	if (typeof(mod_digitize_epsg) == 'undefined' || mod_digitize_epsg != parent.mb_mapObj[anInd].epsg) {
+		mod_digitize_epsg = parent.mb_mapObj[anInd].epsg;
+		change = true;
+	}
+//	if (change) {
+//		drawDashedLine();
+//	}
 }
 
 function drawDashedLine(){
@@ -549,7 +616,7 @@
 					else {
 						smP += "<div class='bp' style='top:"+(pos[1]-2)+"px;left:"+(pos[0]-2)+"px;z-index:"+digitizeTransactionalZIndex+";'";
 					}
-					if(j==0 && d.get(i).geomType == parent.geomType.polygon && !d.getGeometry(i,j).complete){
+					if(j==0 && d.get(i).geomType == parent.geomType.polygon && !d.getGeometry(i,j).isComplete()){
 						smP += " title='"+closePolygon_title+"' ";
 					}
 					if(mod_digitizeEvent == button_move || mod_digitizeEvent == button_insert || mod_digitizeEvent == button_delete) {
@@ -569,7 +636,7 @@
 			}
 		}
 	}
-	parent.writeTag(mod_digitize_target,"digitize",smP);
+	digitizeDivTag.write(smP);
 }
 
 function evaluateDashes(start, end, memberIndex, geomIndex, pointIndex){
@@ -646,7 +713,7 @@
 		wfsConf = parent.get_complete_wfs_conf();
 		for (var i = 0 ; i < d.count(); i ++) {
 
-			if (nonTransactionalEditable || isTransactional(d.get(i))) {
+			if (d.get(i).get(-1).isComplete() && (nonTransactionalEditable || isTransactional(d.get(i)))) {
 	
 				listOfGeom += "\t<tr>\n\t\t<td>\n";
 				if (wfsExistsForGeom(d.get(i), wfsConf)) {
@@ -997,7 +1064,7 @@
 		if (isTransactional) {
 			str += "\t\t<tr>\n";
 
-			var options = ["save", "update", "delete"];
+			var options = ["save", "update", "delete", "abort"];
 			for (var i = 0 ; i < options.length ; i++) {
 				var onClickText = "var result = window.opener.formCorrect(document, '"+featureTypeElementFormId+"');";
 				onClickText += 	"if (result.isCorrect) {";
@@ -1006,8 +1073,8 @@
 				onClickText += 	"else {";
 				onClickText += 		"alert(result.errorMessage);"
 				onClickText += 	"}";
-
-				if (options[i] == "save" && hasGeometryColumn) {
+				
+				if (options[i] == "save" && hasGeometryColumn && (!fid || showSaveButtonForExistingGeometries)) {
 					str += "\t\t\t<td><input type='button' name='saveButton' value='"+buttonLabelSaveGeometry[selectedLanguage]+"' onclick=\""+onClickText+"\" /></td>\n";
 				}
 				
@@ -1016,9 +1083,15 @@
 						str += "\t\t\t<td><input type='button' name='updateButton' value='"+buttonLabelUpdateGeometry[selectedLanguage]+"' onclick=\""+onClickText+"\"/></td>\n";
 					}
 					if (options[i] == "delete"){ 
-						str += "\t\t\t<td><input type='button' name='deleteButton' value='"+buttonLabelDeleteGeometry[selectedLanguage]+"' onclick=\""+onClickText+"\"/></td>\n";
+						var deleteOnClickText = "var deltrans = confirm('"+messageConfirmDeleteGeomFromDb[selectedLanguage]+"');";
+						deleteOnClickText += "if (deltrans){";
+						deleteOnClickText += onClickText + "}";
+						str += "\t\t\t<td><input type='button' name='deleteButton' value='"+buttonLabelDeleteGeometry[selectedLanguage]+"' onclick=\""+deleteOnClickText+"\"/></td>\n";
 					}
 				}
+				if (options[i] == "abort") {
+					str += "\t\t\t<td><input type='button' name='abortButton' value='"+buttonLabelAbort[selectedLanguage]+"' onclick=\"window.close();\" /></td>\n";
+				}
 			}
 			str += "\t\t</tr>\n";
 		}



More information about the Mapbender_commits mailing list